Changeset c78a03d in mainline for uspace/lib/gfxfont/src/font.c


Ignore:
Timestamp:
2020-07-21T22:48:59Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5592c56
Parents:
703c743
Message:

Flesh out most of font, glyph and glyph bitmap implementation and tests

File:
1 edited

Legend:

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

    r703c743 rc78a03d  
    3434 */
    3535
     36#include <adt/list.h>
    3637#include <assert.h>
    3738#include <errno.h>
    3839#include <gfx/font.h>
     40#include <gfx/glyph.h>
    3941#include <mem.h>
    4042#include <stdlib.h>
    4143#include "../private/font.h"
     44#include "../private/glyph.h"
    4245
    4346/** Initialize font metrics structure.
     
    8386
    8487        font->metrics = *metrics;
     88        list_initialize(&font->glyphs);
    8589        *rfont = font;
    8690        return EOK;
     
    9397void gfx_font_destroy(gfx_font_t *font)
    9498{
     99        gfx_glyph_t *glyph;
     100
     101        glyph = gfx_font_first_glyph(font);
     102        while (glyph != NULL) {
     103                gfx_glyph_destroy(glyph);
     104                glyph = gfx_font_first_glyph(font);
     105        }
     106
    95107        free(font);
    96108}
     
    125137gfx_glyph_t *gfx_font_first_glyph(gfx_font_t *font)
    126138{
    127         return NULL;
     139        link_t *link;
     140
     141        link = list_first(&font->glyphs);
     142        if (link == NULL)
     143                return NULL;
     144
     145        return list_get_instance(link, gfx_glyph_t, lglyphs);
    128146}
    129147
     
    135153gfx_glyph_t *gfx_font_next_glyph(gfx_glyph_t *cur)
    136154{
    137         return NULL;
     155        link_t *link;
     156
     157        link = list_next(&cur->lglyphs, &cur->font->glyphs);
     158        if (link == NULL)
     159                return NULL;
     160
     161        return list_get_instance(link, gfx_glyph_t, lglyphs);
    138162}
    139163
     
    149173    gfx_glyph_t **rglyph, size_t *rsize)
    150174{
    151         return EOK;
     175        gfx_glyph_t *glyph;
     176        size_t msize;
     177
     178        glyph = gfx_font_first_glyph(font);
     179        while (glyph != NULL) {
     180                if (gfx_glyph_matches(glyph, str, &msize)) {
     181                        *rglyph = glyph;
     182                        *rsize = msize;
     183                        return EOK;
     184                }
     185
     186                glyph = gfx_font_next_glyph(glyph);
     187        }
     188
     189        return ENOENT;
    152190}
    153191
Note: See TracChangeset for help on using the changeset viewer.