Changeset 5c27e77 in mainline
- Timestamp:
- 2022-03-06T22:37:06Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4583015
- Parents:
- af259da
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fontedit/fontedit.c
raf259da r5c27e77 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 167 167 } 168 168 169 /** Adjust font underline Y0. 170 * 171 * @param fedit Font editor 172 */ 173 static void font_edit_adjust_underline_y0(font_edit_t *fedit, 174 gfx_coord_t change) 175 { 176 gfx_font_metrics_t fmetrics; 177 178 gfx_font_get_metrics(fedit->font, &fmetrics); 179 fmetrics.underline_y0 += change; 180 (void) gfx_font_set_metrics(fedit->font, &fmetrics); 181 182 printf("New underline Y0: %d\n", fmetrics.underline_y0); 183 font_edit_paint(fedit); 184 } 185 186 /** Adjust font underline Y1. 187 * 188 * @param fedit Font editor 189 */ 190 static void font_edit_adjust_underline_y1(font_edit_t *fedit, 191 gfx_coord_t change) 192 { 193 gfx_font_metrics_t fmetrics; 194 195 gfx_font_get_metrics(fedit->font, &fmetrics); 196 fmetrics.underline_y1 += change; 197 (void) gfx_font_set_metrics(fedit->font, &fmetrics); 198 199 printf("New underline Y1: %d\n", fmetrics.underline_y1); 200 font_edit_paint(fedit); 201 } 202 169 203 /** Handle font editor close event. 170 204 * … … 314 348 font_edit_adjust_leading(fedit, +1); 315 349 break; 350 case KC_U: 351 font_edit_adjust_underline_y0(fedit, -1); 352 break; 353 case KC_I: 354 font_edit_adjust_underline_y0(fedit, +1); 355 break; 356 case KC_O: 357 font_edit_adjust_underline_y1(fedit, -1); 358 break; 359 case KC_P: 360 font_edit_adjust_underline_y1(fedit, +1); 361 break; 316 362 case KC_X: 317 363 (void) gfx_glyph_bmp_clear(fedit->gbmp); … … 521 567 gfx_color_t *color = NULL; 522 568 gfx_rect_t rect; 569 gfx_rect_t rect2; 523 570 gfx_rect_t grect; 524 571 gfx_font_metrics_t fmetrics; … … 564 611 fmetrics.leading, &rect); 565 612 rect.p1.x += 100; 613 614 rc = gfx_fill_rect(fedit->gc, &rect); 615 if (rc != EOK) 616 goto error; 617 618 gfx_color_delete(color); 619 620 /* Display underline */ 621 622 rc = gfx_color_new_rgb_i16(0x4000, 0x4000, 0, &color); 623 if (rc != EOK) 624 goto error; 625 626 rc = gfx_set_color(fedit->gc, color); 627 if (rc != EOK) 628 goto error; 629 630 font_edit_gpix_to_disp(fedit, 0, fmetrics.underline_y0, &rect); 631 font_edit_gpix_to_disp(fedit, 10, fmetrics.underline_y1, &rect2); 632 rect.p1 = rect2.p0; 566 633 567 634 rc = gfx_fill_rect(fedit->gc, &rect); -
uspace/app/gfxdemo/gfxdemo.c
raf259da r5c27e77 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 776 776 777 777 fmt.color = color; 778 fmt.underline = !fmt.underline; 778 779 779 780 pos.x = w / 20; -
uspace/lib/gfxfont/include/types/gfx/text.h
raf259da r5c27e77 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #define _TYPES_GFX_TEXT_H 38 38 39 #include <stdbool.h> 39 40 #include <types/gfx/coord.h> 40 41 #include <types/gfx/color.h> … … 74 75 /** Vertical alignment */ 75 76 gfx_valign_t valign; 77 /** Underline */ 78 bool underline; 76 79 } gfx_text_fmt_t; 77 80 -
uspace/lib/gfxfont/include/types/gfx/typeface.h
raf259da r5c27e77 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 50 50 /** Leading */ 51 51 gfx_coord_t leading; 52 /** Underline start Y coordinate (inclusive) */ 53 gfx_coord_t underline_y0; 54 /** Underline end Y coordinate (exclusive) */ 55 gfx_coord_t underline_y1; 52 56 } gfx_font_metrics_t; 53 57 -
uspace/lib/gfxfont/private/tpf_file.h
raf259da r5c27e77 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 76 76 uint16_t descent; 77 77 uint16_t leading; 78 int16_t underline_y0; 79 int16_t underline_y1; 78 80 } tpf_font_metrics_t; 79 81 -
uspace/lib/gfxfont/src/font.c
raf259da r5c27e77 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 546 546 metrics->descent = uint16_t_le2host(tmetrics.descent); 547 547 metrics->leading = uint16_t_le2host(tmetrics.leading); 548 metrics->underline_y0 = uint16_t_le2host(tmetrics.underline_y0); 549 metrics->underline_y1 = uint16_t_le2host(tmetrics.underline_y1); 548 550 return EOK; 549 551 } … … 565 567 tmetrics.descent = host2uint16_t_le(metrics->descent); 566 568 tmetrics.leading = host2uint16_t_le(metrics->leading); 569 tmetrics.underline_y0 = host2uint16_t_le(metrics->underline_y0); 570 tmetrics.underline_y1 = host2uint16_t_le(metrics->underline_y1); 567 571 568 572 rc = riff_wchunk_start(riffw, CKID_fmtr, &mtrck); -
uspace/lib/gfxfont/src/text.c
raf259da r5c27e77 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 229 229 { 230 230 gfx_glyph_metrics_t gmetrics; 231 gfx_font_metrics_t fmetrics; 231 232 size_t stradv; 232 233 const char *cp; 233 234 gfx_glyph_t *glyph; 234 235 gfx_coord2_t cpos; 236 gfx_coord2_t spos; 237 gfx_rect_t rect; 235 238 errno_t rc; 236 239 237 gfx_text_start_pos(font, pos, fmt, str, & cpos);240 gfx_text_start_pos(font, pos, fmt, str, &spos); 238 241 239 242 /* Text mode */ 240 243 if ((font->finfo->props.flags & gff_text_mode) != 0) 241 return gfx_puttext_textmode(font, & cpos, fmt->color, str);244 return gfx_puttext_textmode(font, &spos, fmt->color, str); 242 245 243 246 rc = gfx_set_color(font->typeface->gc, fmt->color); … … 245 248 return rc; 246 249 250 cpos = spos; 247 251 cp = str; 248 252 while (*cp != '\0') { … … 261 265 cp += stradv; 262 266 cpos.x += gmetrics.advance; 267 } 268 269 /* Text underlining */ 270 if (fmt->underline) { 271 gfx_font_get_metrics(font, &fmetrics); 272 273 rect.p0.x = spos.x; 274 rect.p0.y = spos.y + fmetrics.underline_y0; 275 rect.p1.x = cpos.x; 276 rect.p1.y = spos.y + fmetrics.underline_y1; 277 278 rc = gfx_fill_rect(font->typeface->gc, &rect); 279 if (rc != EOK) 280 return rc; 263 281 } 264 282
Note:
See TracChangeset
for help on using the changeset viewer.