Changeset f2d4a46 in mainline for uspace/lib/gfxfont/src/text.c
- Timestamp:
- 2022-11-18T20:00:57Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d19d15b
- Parents:
- 901b302
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/src/text.c
r901b302 rf2d4a46 97 97 /** Print string using text characters in text mode. 98 98 * 99 * @param font Font100 99 * @param pos Position of top-left corner of text 101 * @param color Text color100 * @param fmt Formatting 102 101 * @param str String 103 102 * @return EOK on success or an error code 104 103 */ 105 static errno_t gfx_puttext_textmode(gfx_ font_t *font, gfx_coord2_t *pos,106 gfx_color_t *color,const char *str)107 { 108 gfx_context_t *gc = f ont->typeface->gc;104 static errno_t gfx_puttext_textmode(gfx_coord2_t *pos, gfx_text_fmt_t *fmt, 105 const char *str) 106 { 107 gfx_context_t *gc = fmt->font->typeface->gc; 109 108 gfx_bitmap_params_t params; 110 109 gfx_bitmap_t *bitmap; 111 110 gfx_bitmap_alloc_t alloc; 111 gfx_coord_t width; 112 112 uint8_t attr; 113 113 pixelmap_t pmap; 114 114 gfx_coord_t x; 115 gfx_coord_t rmargin; 115 116 pixel_t pixel; 116 117 char32_t c; 117 118 size_t off; 119 bool ellipsis; 118 120 errno_t rc; 121 122 width = str_width(str); 123 if (fmt->abbreviate && width > fmt->width) { 124 ellipsis = true; 125 width = fmt->width; 126 if (width > 3) 127 rmargin = width - 3; 128 else 129 rmargin = width; 130 } else { 131 ellipsis = false; 132 rmargin = width; 133 } 119 134 120 135 /* … … 123 138 */ 124 139 125 gfx_color_get_ega( color, &attr);140 gfx_color_get_ega(fmt->color, &attr); 126 141 127 142 gfx_bitmap_params_init(¶ms); 128 143 params.rect.p0.x = 0; 129 144 params.rect.p0.y = 0; 130 params.rect.p1.x = str_width(str);145 params.rect.p1.x = width; 131 146 params.rect.p1.y = 1; 132 147 … … 151 166 152 167 off = 0; 153 for (x = 0; x < params.rect.p1.x; x++) {168 for (x = 0; x < rmargin; x++) { 154 169 c = str_decode(str, &off, STR_NO_LIMIT); 155 170 pixel = PIXEL(attr, … … 158 173 c & 0xff); 159 174 pixelmap_put_pixel(&pmap, x, 0, pixel); 175 } 176 177 if (ellipsis) { 178 for (x = rmargin; x < params.rect.p1.x; x++) { 179 c = '.'; 180 pixel = PIXEL(attr, 181 (c >> 16) & 0xff, 182 (c >> 8) & 0xff, 183 c & 0xff); 184 pixelmap_put_pixel(&pmap, x, 0, pixel); 185 } 160 186 } 161 187 … … 246 272 /* Text mode */ 247 273 if ((fmt->font->finfo->props.flags & gff_text_mode) != 0) 248 return gfx_puttext_textmode( fmt->font, &spos, fmt->color, str);274 return gfx_puttext_textmode(&spos, fmt, str); 249 275 250 276 rc = gfx_set_color(fmt->font->typeface->gc, fmt->color);
Note:
See TracChangeset
for help on using the changeset viewer.