Changeset d884672 in mainline for uspace/lib/gfxfont/src


Ignore:
Timestamp:
2020-09-30T20:26:24Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c9748a4
Parents:
38a4b6d
Message:

Need to set rectangle/origin for new glyph

Otherwise, having unsaved glyphs would lead to corruption once another
glyph is created, edited and saved.

Location:
uspace/lib/gfxfont/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfxfont/src/font.c

    r38a4b6d rd884672  
    274274}
    275275
     276/** Get last glyph in font.
     277 *
     278 * @param font Font
     279 * @return Last glyph or @c NULL if there are none
     280 */
     281gfx_glyph_t *gfx_font_last_glyph(gfx_font_t *font)
     282{
     283        link_t *link;
     284
     285        link = list_last(&font->glyphs);
     286        if (link == NULL)
     287                return NULL;
     288
     289        return list_get_instance(link, gfx_glyph_t, lglyphs);
     290}
     291
     292/** Get previous glyph in font.
     293 *
     294 * @param cur Current glyph
     295 * @return Previous glyph in font or @c NULL if @a cur was the last one
     296 */
     297gfx_glyph_t *gfx_font_prev_glyph(gfx_glyph_t *cur)
     298{
     299        link_t *link;
     300
     301        link = list_prev(&cur->lglyphs, &cur->font->glyphs);
     302        if (link == NULL)
     303                return NULL;
     304
     305        return list_get_instance(link, gfx_glyph_t, lglyphs);
     306}
     307
    276308/** Search for glyph that should be set for the beginning of a string.
    277309 *
  • uspace/lib/gfxfont/src/glyph.c

    r38a4b6d rd884672  
    3838#include <errno.h>
    3939#include <gfx/bitmap.h>
     40#include <gfx/font.h>
    4041#include <gfx/glyph.h>
    4142#include <io/pixelmap.h>
     
    7374{
    7475        gfx_glyph_t *glyph;
     76        gfx_glyph_t *last;
    7577        errno_t rc;
    7678
     
    8890        }
    8991
     92        last = gfx_font_last_glyph(font);
     93
    9094        glyph->metrics = *metrics;
    9195        list_append(&glyph->lglyphs, &glyph->font->glyphs);
    9296        list_initialize(&glyph->patterns);
     97
     98        if (last != NULL)
     99                glyph->rect.p0.x = last->rect.p1.x;
     100        else
     101                glyph->rect.p0.x = 0;
     102
     103        glyph->rect.p0.y = 0;
     104        glyph->rect.p1.x = glyph->rect.p0.x;
     105        glyph->rect.p1.y = glyph->rect.p1.y;
     106
     107        glyph->origin.x = glyph->rect.p0.x;
     108        glyph->origin.y = glyph->rect.p0.y;
     109
    93110        *rglyph = glyph;
    94111        return EOK;
Note: See TracChangeset for help on using the changeset viewer.