Changeset 16357ec in mainline
- Timestamp:
- 2020-09-25T15:21:09Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- efca2e4
- Parents:
- 453f203b
- git-author:
- Jiri Svoboda <jiri@…> (2020-09-24 19:20:54)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-09-25 15:21:09)
- Location:
- uspace/app/fontedit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fontedit/fontedit.c
r453f203b r16357ec 148 148 printf("Save!\n"); 149 149 (void) gfx_glyph_bmp_save(fedit->gbmp); 150 rc = gfx_typeface_save(fedit->typeface, "/test.tpf");150 rc = gfx_typeface_save(fedit->typeface, fedit->fname); 151 151 if (rc != EOK) 152 152 printf("Error saving typeface.\n"); … … 426 426 * 427 427 * @param display_svc Display service 428 * @param fname Font file to open or @c NULL to create new font 428 429 * @param rfedit Place to store pointer to new font editor 429 430 * @return EOK on success or an error code 430 431 */ 431 static errno_t font_edit_create(const char *display_svc, font_edit_t **rfedit) 432 static errno_t font_edit_create(const char *display_svc, const char *fname, 433 font_edit_t **rfedit) 432 434 { 433 435 canvas_gc_t *cgc = NULL; … … 439 441 gfx_typeface_t *tface = NULL; 440 442 gfx_font_t *font = NULL; 443 gfx_font_info_t *finfo; 441 444 gfx_font_props_t props; 442 445 gfx_font_metrics_t metrics; … … 504 507 gc = canvas_gc_get_ctx(cgc); 505 508 506 rc = gfx_typeface_create(gc, &tface); 507 if (rc != EOK) { 508 printf("Error creating typeface.\n"); 509 goto error; 510 } 511 512 gfx_font_props_init(&props); 513 gfx_font_metrics_init(&metrics); 514 515 rc = gfx_font_create(tface, &props, &metrics, &font); 516 if (rc != EOK) { 517 printf("Error creating font.\n"); 518 goto error; 519 } 520 521 gfx_glyph_metrics_init(&gmetrics); 522 523 rc = gfx_glyph_create(font, &gmetrics, &glyph); 524 if (rc != EOK) { 525 printf("Error creating glyph.\n"); 526 goto error; 527 } 528 529 rc = gfx_glyph_set_pattern(glyph, "A"); 530 if (rc != EOK) { 531 printf("Error setting glyph pattern.\n"); 532 goto error; 509 if (fname == NULL) { 510 rc = gfx_typeface_create(gc, &tface); 511 if (rc != EOK) { 512 printf("Error creating typeface.\n"); 513 goto error; 514 } 515 516 gfx_font_props_init(&props); 517 gfx_font_metrics_init(&metrics); 518 519 rc = gfx_font_create(tface, &props, &metrics, &font); 520 if (rc != EOK) { 521 printf("Error creating font.\n"); 522 goto error; 523 } 524 525 gfx_glyph_metrics_init(&gmetrics); 526 527 rc = gfx_glyph_create(font, &gmetrics, &glyph); 528 if (rc != EOK) { 529 printf("Error creating glyph.\n"); 530 goto error; 531 } 532 533 rc = gfx_glyph_set_pattern(glyph, "A"); 534 if (rc != EOK) { 535 printf("Error setting glyph pattern.\n"); 536 goto error; 537 } 538 } else { 539 rc = gfx_typeface_open(gc, fname, &tface); 540 if (rc != EOK) { 541 printf("Error opening typeface '%s.\n", 542 fname); 543 goto error; 544 } 545 546 finfo = gfx_typeface_first_font(tface); 547 rc = gfx_font_open(finfo, &font); 548 if (rc != EOK) { 549 printf("Error opening font.\n"); 550 goto error; 551 } 552 553 glyph = gfx_font_first_glyph(font); 533 554 } 534 555 … … 543 564 sig_connect(&canvas->keyboard_event, &canvas->widget, 544 565 font_edit_kbd_event); 566 567 if (fname == NULL) 568 fname = "new.tpf"; 545 569 546 570 fedit->cgc = cgc; … … 549 573 fedit->height = vh; 550 574 fedit->pen_color = 1; 575 fedit->fname = fname; 551 576 fedit->typeface = tface; 552 577 fedit->font = font; … … 583 608 static void print_syntax(void) 584 609 { 585 printf("Syntax: fontedit [-d <display>] \n");610 printf("Syntax: fontedit [-d <display>] [<file.tpf>]\n"); 586 611 } 587 612 … … 590 615 errno_t rc; 591 616 const char *display_svc = DISPLAY_DEFAULT; 617 const char *fname = NULL; 592 618 font_edit_t *fedit; 593 619 int i; … … 611 637 } 612 638 613 rc = font_edit_create(display_svc, &fedit); 639 /* File name argument? */ 640 if (i < argc) { 641 fname = argv[i]; 642 ++i; 643 } 644 645 /* Extra arguments? */ 646 if (i < argc) { 647 printf("Unexpected argument '%s'.\n", argv[i]); 648 print_syntax(); 649 return 1; 650 } 651 652 rc = font_edit_create(display_svc, fname, &fedit); 614 653 if (rc != EOK) 615 654 return 1; -
uspace/app/fontedit/fontedit.h
r453f203b r16357ec 54 54 /** Pen color (1 = set, 0 = reset) */ 55 55 int pen_color; 56 /** File name */ 57 const char *fname; 56 58 /** Typeface */ 57 59 gfx_typeface_t *typeface;
Note:
See TracChangeset
for help on using the changeset viewer.