Changeset 2cc1ec0 in mainline for uspace/lib/gui/button.c


Ignore:
Timestamp:
2014-08-27T21:23:01Z (10 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a9763c6
Parents:
613d644
Message:

Refactor drawing of fonts into multiple layers.

This will need further work to split glyph resolution
process to separate functions in order to support ligatures,
addition of kerning support, separate text layout functions,
etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gui/button.c

    r613d644 r2cc1ec0  
    3838#include <drawctx.h>
    3939#include <surface.h>
     40#include <font/embedded.h>
     41#include <errno.h>
    4042#include "common.h"
    4143#include "window.h"
     
    7678        sysarg_t cpt_width;
    7779        sysarg_t cpt_height;
    78         font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
     80        font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
    7981       
    8082        if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
     
    8385               
    8486                drawctx_set_source(&drawctx, &btn->text);
    85                 drawctx_set_font(&drawctx, &btn->font);
     87                drawctx_set_font(&drawctx, btn->font);
    8688               
    8789                if (btn->caption)
     
    9698        widget_deinit(&btn->widget);
    9799        free(btn->caption);
    98         font_release(&btn->font);
     100        font_release(btn->font);
    99101}
    100102
     
    171173                btn->caption = str_dup(caption);
    172174       
    173         font_init(&btn->font, FONT_DECODER_EMBEDDED, NULL, points);
     175        int rc = embedded_font_create(&btn->font, points);
     176        if (rc != EOK) {
     177                free(btn->caption);
     178                btn->caption = NULL;
     179                return false;
     180        }
    174181       
    175182        sysarg_t cpt_width;
    176183        sysarg_t cpt_height;
    177         font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
     184        font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
    178185        btn->widget.width_min = cpt_width + 10;
    179186        btn->widget.height_min = cpt_height + 10;
Note: See TracChangeset for help on using the changeset viewer.