Changeset 8fa65af0 in mainline for uspace/app/fontedit/fontedit.c


Ignore:
Timestamp:
2020-10-06T08:59:57Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74f59b7
Parents:
25f2983b
git-author:
Jiri Svoboda <jiri@…> (2020-10-05 18:59:36)
git-committer:
Jiri Svoboda <jiri@…> (2020-10-06 08:59:57)
Message:

Add text rendering routine and demo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/fontedit/fontedit.c

    r25f2983b r8fa65af0  
    4141#include <gfx/glyph.h>
    4242#include <gfx/render.h>
     43#include <gfx/text.h>
    4344#include <gfx/typeface.h>
    4445#include <stdbool.h>
     
    422423    gfx_coord_t x, gfx_coord_t y, const char *str)
    423424{
    424         gfx_glyph_metrics_t gmetrics;
    425         size_t stradv;
    426         const char *cp;
     425        gfx_text_fmt_t fmt;
    427426        gfx_coord2_t pos;
    428         gfx_glyph_t *glyph;
    429         errno_t rc;
     427
     428        gfx_text_fmt_init(&fmt);
    430429
    431430        pos.x = x;
    432431        pos.y = y;
    433         cp = str;
    434 
    435         while (*cp != '\0') {
    436                 rc = gfx_font_search_glyph(fedit->font, cp, &glyph, &stradv);
    437                 if (rc != EOK) {
    438                         ++cp;
    439                         continue;
    440                 }
    441 
    442                 gfx_glyph_get_metrics(glyph, &gmetrics);
    443 
    444                 rc = gfx_glyph_render(glyph, &pos);
    445                 if (rc != EOK)
    446                         return rc;
    447 
    448                 cp += stradv;
    449                 pos.x += gmetrics.advance;
    450         }
    451 
    452         return EOK;
     432
     433        return gfx_puttext(fedit->font, &pos, &fmt, str);
    453434}
    454435
Note: See TracChangeset for help on using the changeset viewer.