diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-01-21 13:50:56 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-01-21 13:51:14 +0200 |
commit | abb060ba17024759a7cfcc7b9256742e1c1e418b (patch) | |
tree | 2529694d46ebcefa2f9751c1882982112797445f | |
parent | df37aaff1278b8f283af421a0c47cffcf0cbeb06 (diff) |
Fonts: Show abbreviated list of names on "about:fonts"
A big set can be viewed separately to see all the individual fonts.
-rw-r--r-- | src/fontpack.c | 19 | ||||
-rw-r--r-- | src/fontpack.h | 2 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 2 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/fontpack.c b/src/fontpack.c index 924d4781..96006226 100644 --- a/src/fontpack.c +++ b/src/fontpack.c | |||
@@ -749,7 +749,7 @@ const iPtrArray *listSpecsByPriority_Fonts(void) { | |||
749 | return &fonts_.specOrder; | 749 | return &fonts_.specOrder; |
750 | } | 750 | } |
751 | 751 | ||
752 | iString *infoText_FontPack(const iFontPack *d) { | 752 | iString *infoText_FontPack(const iFontPack *d, iBool isFull) { |
753 | const iFontPack *installed = pack_Fonts(cstr_String(&d->id)); | 753 | const iFontPack *installed = pack_Fonts(cstr_String(&d->id)); |
754 | const iBool isInstalled = (installed != NULL); | 754 | const iBool isInstalled = (installed != NULL); |
755 | const int installedVersion = installed ? installed->version : 0; | 755 | const int installedVersion = installed ? installed->version : 0; |
@@ -758,9 +758,17 @@ iString *infoText_FontPack(const iFontPack *d) { | |||
758 | size_t sizeInBytes = 0; | 758 | size_t sizeInBytes = 0; |
759 | iPtrSet *uniqueFiles = new_PtrSet(); | 759 | iPtrSet *uniqueFiles = new_PtrSet(); |
760 | iStringList *names = new_StringList(); | 760 | iStringList *names = new_StringList(); |
761 | size_t numNames = 0; | ||
762 | iBool isAbbreviated = iFalse; | ||
761 | iConstForEach(PtrArray, i, listSpecs_FontPack(d)) { | 763 | iConstForEach(PtrArray, i, listSpecs_FontPack(d)) { |
762 | const iFontSpec *spec = i.ptr; | 764 | const iFontSpec *spec = i.ptr; |
763 | pushBack_StringList(names, &spec->name); | 765 | numNames++; |
766 | if (isFull || size_StringList(names) < 20) { | ||
767 | pushBack_StringList(names, &spec->name); | ||
768 | } | ||
769 | else { | ||
770 | isAbbreviated = iTrue; | ||
771 | } | ||
764 | iForIndices(j, spec->styles) { | 772 | iForIndices(j, spec->styles) { |
765 | insert_PtrSet(uniqueFiles, spec->styles[j]->sourceData.i); | 773 | insert_PtrSet(uniqueFiles, spec->styles[j]->sourceData.i); |
766 | } | 774 | } |
@@ -778,11 +786,12 @@ iString *infoText_FontPack(const iFontPack *d) { | |||
778 | if (!endsWith_String(str, "(")) { | 786 | if (!endsWith_String(str, "(")) { |
779 | appendCStr_String(str, ", "); | 787 | appendCStr_String(str, ", "); |
780 | } | 788 | } |
781 | appendCStr_String(str, formatCStrs_Lang("num.fonts.n", size_StringList(names))); | 789 | appendCStr_String(str, formatCStrs_Lang("num.fonts.n", numNames)); |
782 | } | 790 | } |
783 | appendFormat_String(str, ")"); | 791 | appendFormat_String(str, ")"); |
784 | } | 792 | } |
785 | appendFormat_String(str, " \u2014 %s\n", cstrCollect_String(joinCStr_StringList(names, ", "))); | 793 | appendFormat_String(str, " \u2014 %s%s\n", cstrCollect_String(joinCStr_StringList(names, ", ")), |
794 | isAbbreviated ? ", ..." : ""); | ||
786 | if (isInstalled && installedVersion != d->version) { | 795 | if (isInstalled && installedVersion != d->version) { |
787 | appendCStr_String(str, format_Lang("${fontpack.meta.version}\n", d->version)); | 796 | appendCStr_String(str, format_Lang("${fontpack.meta.version}\n", d->version)); |
788 | } | 797 | } |
@@ -946,7 +955,7 @@ const iString *infoPage_Fonts(iRangecc query) { | |||
946 | appendFormat_String(str, "### %s\n", | 955 | appendFormat_String(str, "### %s\n", |
947 | isEmpty_String(packId) ? "fonts.ini" : | 956 | isEmpty_String(packId) ? "fonts.ini" : |
948 | cstr_String(packId)); | 957 | cstr_String(packId)); |
949 | append_String(str, collect_String(infoText_FontPack(pack))); | 958 | append_String(str, collect_String(infoText_FontPack(pack, iFalse))); |
950 | appendFormat_String(str, "=> %s ${fontpack.meta.viewfile}\n", | 959 | appendFormat_String(str, "=> %s ${fontpack.meta.viewfile}\n", |
951 | cstrCollect_String(makeFileUrl_String(&spec->sourcePath))); | 960 | cstrCollect_String(makeFileUrl_String(&spec->sourcePath))); |
952 | if (pack->isStandalone) { | 961 | if (pack->isStandalone) { |
diff --git a/src/fontpack.h b/src/fontpack.h index 27ecd087..f6d4d483 100644 --- a/src/fontpack.h +++ b/src/fontpack.h | |||
@@ -160,7 +160,7 @@ const iString * loadPath_FontPack (const iFontPack *); /* may return N | |||
160 | iBool isDisabled_FontPack (const iFontPack *); | 160 | iBool isDisabled_FontPack (const iFontPack *); |
161 | iBool isReadOnly_FontPack (const iFontPack *); | 161 | iBool isReadOnly_FontPack (const iFontPack *); |
162 | const iPtrArray * listSpecs_FontPack (const iFontPack *); | 162 | const iPtrArray * listSpecs_FontPack (const iFontPack *); |
163 | iString * infoText_FontPack (const iFontPack *); | 163 | iString * infoText_FontPack (const iFontPack *, iBool isFull); |
164 | const iArray * actions_FontPack (const iFontPack *, iBool showInstalled); | 164 | const iArray * actions_FontPack (const iFontPack *, iBool showInstalled); |
165 | 165 | ||
166 | const iString * idFromUrl_FontPack (const iString *url); | 166 | const iString * idFromUrl_FontPack (const iString *url); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index fdb55232..03119ca2 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -2659,7 +2659,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, | |||
2659 | if (loadArchive_FontPack(fp, zip)) { | 2659 | if (loadArchive_FontPack(fp, zip)) { |
2660 | appendFormat_String(&str, "# " fontpack_Icon "%s\n%s", | 2660 | appendFormat_String(&str, "# " fontpack_Icon "%s\n%s", |
2661 | cstr_String(id_FontPack(fp).id), | 2661 | cstr_String(id_FontPack(fp).id), |
2662 | cstrCollect_String(infoText_FontPack(fp))); | 2662 | cstrCollect_String(infoText_FontPack(fp, iTrue))); |
2663 | } | 2663 | } |
2664 | appendCStr_String(&str, "\n"); | 2664 | appendCStr_String(&str, "\n"); |
2665 | appendCStr_String(&str, cstr_Lang("fontpack.help")); | 2665 | appendCStr_String(&str, cstr_Lang("fontpack.help")); |