Changeset b433f68 in mainline for uspace/lib/gfxfont
- Timestamp:
- 2021-02-26T16:23:36Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77ffa01
- Parents:
- fe40b67
- Location:
- uspace/lib/gfxfont
- Files:
-
- 3 edited
-
include/types/gfx/text.h (modified) (2 diffs)
-
src/text.c (modified) (6 diffs)
-
test/text.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/include/types/gfx/text.h
rfe40b67 rb433f68 38 38 39 39 #include <types/gfx/coord.h> 40 #include <types/gfx/color.h> 40 41 41 42 /** Text horizontal alignment */ … … 65 66 /** Text formatting */ 66 67 typedef struct { 68 /** Text color */ 69 gfx_color_t *color; 67 70 /** Horizontal alignment */ 68 71 gfx_halign_t halign; -
uspace/lib/gfxfont/src/text.c
rfe40b67 rb433f68 36 36 #include <errno.h> 37 37 #include <gfx/bitmap.h> 38 #include <gfx/color.h> 38 39 #include <gfx/font.h> 39 40 #include <gfx/glyph.h> 41 #include <gfx/render.h> 40 42 #include <gfx/text.h> 41 43 #include <io/pixelmap.h> … … 97 99 * @param font Font 98 100 * @param pos Position of top-left corner of text 101 * @param color Text color 99 102 * @param str String 100 103 * @return EOK on success or an error code 101 104 */ 102 105 static 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) 104 107 { 105 108 gfx_context_t *gc = font->typeface->gc; … … 107 110 gfx_bitmap_t *bitmap; 108 111 gfx_bitmap_alloc_t alloc; 112 uint16_t r, g, b; 109 113 pixelmap_t pmap; 110 114 gfx_coord_t x; … … 116 120 * the most efficient way. 117 121 */ 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); 118 132 119 133 gfx_bitmap_params_init(¶ms); … … 138 152 139 153 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); 141 155 pixelmap_put_pixel(&pmap, x, 0, pixel); 142 156 } … … 206 220 /* Text mode */ 207 221 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; 209 227 210 228 cp = str; -
uspace/lib/gfxfont/test/text.c
rfe40b67 rb433f68 27 27 */ 28 28 29 #include <gfx/color.h> 29 30 #include <gfx/context.h> 30 31 #include <gfx/font.h> … … 110 111 gfx_font_t *font; 111 112 gfx_context_t *gc; 113 gfx_color_t *color; 112 114 gfx_text_fmt_t fmt; 113 115 gfx_coord2_t pos; … … 118 120 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 119 121 122 rc = gfx_color_new_rgb_i16(0, 0, 0, &color); 123 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 124 120 125 rc = gfx_typeface_create(gc, &tface); 121 126 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 127 132 128 133 gfx_text_fmt_init(&fmt); 134 fmt.color = color; 129 135 pos.x = 0; 130 136 pos.y = 0; … … 135 141 gfx_font_close(font); 136 142 gfx_typeface_destroy(tface); 143 gfx_color_delete(color); 137 144 138 145 rc = gfx_context_delete(gc);
Note:
See TracChangeset
for help on using the changeset viewer.
