Changeset b433f68 in mainline for uspace/lib/gfxfont/src/text.c


Ignore:
Timestamp:
2021-02-26T16:23:36Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
77ffa01
Parents:
fe40b67
Message:

Puttext needs to know the color of the text being printed

So far we were using the GC's current drawing color. But unless there
was a way to read it, we could not render text-mode text in the correct
color.

File:
1 edited

Legend:

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

    rfe40b67 rb433f68  
    3636#include <errno.h>
    3737#include <gfx/bitmap.h>
     38#include <gfx/color.h>
    3839#include <gfx/font.h>
    3940#include <gfx/glyph.h>
     41#include <gfx/render.h>
    4042#include <gfx/text.h>
    4143#include <io/pixelmap.h>
     
    9799 * @param font Font
    98100 * @param pos Position of top-left corner of text
     101 * @param color Text color
    99102 * @param str String
    100103 * @return EOK on success or an error code
    101104 */
    102105static errno_t gfx_puttext_textmode(gfx_font_t *font, gfx_coord2_t *pos,
    103     const char *str)
     106    gfx_color_t *color, const char *str)
    104107{
    105108        gfx_context_t *gc = font->typeface->gc;
     
    107110        gfx_bitmap_t *bitmap;
    108111        gfx_bitmap_alloc_t alloc;
     112        uint16_t r, g, b;
    109113        pixelmap_t pmap;
    110114        gfx_coord_t x;
     
    116120         * the most efficient way.
    117121         */
     122
     123        gfx_color_get_rgb_i16(color, &r, &g, &b);
     124
     125        /*
     126         * We are setting the *background* color, the foreground color
     127         * will be set to its complement.
     128         */
     129        r = 0xff ^ (r >> 8);
     130        g = 0xff ^ (g >> 8);
     131        b = 0xff ^ (b >> 8);
    118132
    119133        gfx_bitmap_params_init(&params);
     
    138152
    139153        for (x = 0; x < params.rect.p1.x; x++) {
    140                 pixel = PIXEL(str[x], 0xff, 0xff, 0xff);
     154                pixel = PIXEL(str[x], r, g, b);
    141155                pixelmap_put_pixel(&pmap, x, 0, pixel);
    142156        }
     
    206220        /* Text mode */
    207221        if ((font->finfo->props.flags & gff_text_mode) != 0)
    208                 return gfx_puttext_textmode(font, &cpos, str);
     222                return gfx_puttext_textmode(font, &cpos, fmt->color, str);
     223
     224        rc = gfx_set_color(font->typeface->gc, fmt->color);
     225        if (rc != EOK)
     226                return rc;
    209227
    210228        cp = str;
Note: See TracChangeset for help on using the changeset viewer.