summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-08-02 18:37:25 +0200
committerBoris Faure <billiob@gmail.com>2015-08-02 22:27:54 +0200
commit0265c9bd883b9402a27fb6d697ec56dc1b159b47 (patch)
treefd6a515e075523c5d44378185daa7f7bdbd9132c /src
parenteb25dabf09de07946b833c8f24b22939a3a94bff (diff)
cleanup --font handling. Closes T2433
Diffstat (limited to 'src')
-rw-r--r--src/bin/main.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index 2912d65..dbfe0c5 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -627,31 +627,27 @@ elm_main(int argc, char **argv)
627 627
628 if (font) 628 if (font)
629 { 629 {
630 if (strchr(font, '/')) 630 char *p = strchr(font, '/');
631 if (p)
631 { 632 {
632 char *fname = alloca(strlen(font) + 1); 633 int sz;
633 char *p; 634 char *fname = alloca(p - font + 1);
634 635
635 strcpy(fname, font); 636 strncpy(fname, font, p - font);
636 p = strrchr(fname, '/'); 637 fname[p - font] = '\0';
637 if (p) 638 sz = atoi(p+1);
638 { 639 if (sz > 0) config->font.size = sz;
639 int sz; 640 eina_stringshare_replace(&(config->font.name), fname);
640
641 *p = 0;
642 p++;
643 sz = atoi(p);
644 if (sz > 0) config->font.size = sz;
645 eina_stringshare_replace(&(config->font.name), fname);
646 }
647 config->font.bitmap = 0; 641 config->font.bitmap = 0;
642 config->font_set = 1;
648 } 643 }
649 else 644 else
650 { 645 {
651 char buf[4096], *file; 646 char buf[4096], *file;
652 Eina_List *files; 647 Eina_List *files;
653 int n = strlen(font); 648 int n = strlen(font);
654 649 Eina_Bool found = EINA_FALSE;
650
655 snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get()); 651 snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get());
656 files = ecore_file_ls(buf); 652 files = ecore_file_ls(buf);
657 EINA_LIST_FREE(files, file) 653 EINA_LIST_FREE(files, file)
@@ -663,10 +659,16 @@ elm_main(int argc, char **argv)
663 n = -1; 659 n = -1;
664 eina_stringshare_replace(&(config->font.name), file); 660 eina_stringshare_replace(&(config->font.name), file);
665 config->font.bitmap = 1; 661 config->font.bitmap = 1;
662 config->font_set = 1;
663 found = EINA_TRUE;
666 } 664 }
667 } 665 }
668 free(file); 666 free(file);
669 } 667 }
668 if (!found)
669 {
670 ERR("font '%s' not found in %s", font, buf);
671 }
670 } 672 }
671 config->temporary = EINA_TRUE; 673 config->temporary = EINA_TRUE;
672 } 674 }