diff options
Diffstat (limited to 'src/fontpack.c')
-rw-r--r-- | src/fontpack.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/fontpack.c b/src/fontpack.c index 215469b3..79f35526 100644 --- a/src/fontpack.c +++ b/src/fontpack.c | |||
@@ -559,6 +559,21 @@ static void sortSpecs_Fonts_(iFonts *d) { | |||
559 | sort_Array(&d->specOrder, cmpPriority_FontSpecPtr_); | 559 | sort_Array(&d->specOrder, cmpPriority_FontSpecPtr_); |
560 | } | 560 | } |
561 | 561 | ||
562 | static void disambiguateSpecs_Fonts_(iFonts *d) { | ||
563 | /* Names of specs with the same human-readable label are augmented with the font ID. */ | ||
564 | const size_t numSpecs = size_PtrArray(&d->specOrder); | ||
565 | for (size_t i = 0; i < numSpecs; i++) { | ||
566 | iFontSpec *spec1 = at_PtrArray(&d->specOrder, i); | ||
567 | for (size_t j = i + 1; j < numSpecs; j++) { | ||
568 | iFontSpec *spec2 = at_PtrArray(&d->specOrder, j); | ||
569 | if (equalCase_String(&spec1->name, &spec2->name)) { | ||
570 | appendFormat_String(&spec1->name, " [%s]", cstr_String(&spec1->id)); | ||
571 | appendFormat_String(&spec2->name, " [%s]", cstr_String(&spec2->id)); | ||
572 | } | ||
573 | } | ||
574 | } | ||
575 | } | ||
576 | |||
562 | static const iString *userFontsDirectory_Fonts_(const iFonts *d) { | 577 | static const iString *userFontsDirectory_Fonts_(const iFonts *d) { |
563 | return collect_String(concatCStr_Path(&d->userDir, "fonts")); | 578 | return collect_String(concatCStr_Path(&d->userDir, "fonts")); |
564 | } | 579 | } |
@@ -683,8 +698,12 @@ void init_Fonts(const char *userDir) { | |||
683 | pushBack_PtrArray(&d->packs, pack); | 698 | pushBack_PtrArray(&d->packs, pack); |
684 | } | 699 | } |
685 | } | 700 | } |
686 | } | 701 | } |
687 | sortSpecs_Fonts_(d); | 702 | sortSpecs_Fonts_(d); |
703 | disambiguateSpecs_Fonts_(d); | ||
704 | #if !defined (NDEBUG) | ||
705 | printf("[FontPack] %zu fonts available\n", size_Array(&d->specOrder)); | ||
706 | #endif | ||
688 | } | 707 | } |
689 | 708 | ||
690 | void deinit_Fonts(void) { | 709 | void deinit_Fonts(void) { |