File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -429,14 +429,21 @@ class NoteObject final : public ObjectBase {
429429 if (typefaceName.isEmpty () || typefaceName == " Inter" ) {
430430 return Fonts::getVariableFont ().withStyle (style).withHeight (fontHeight);
431431 }
432+
433+ // Check if a system typeface exists, before we start searching for a font file
434+ // We do this because it's the most common case, and finding font files is slow
435+ if (Font::findAllTypefaceNames ().contains (typefaceName))
436+ {
437+ return { typefaceName, static_cast <float >(fontHeight), style };
438+ }
432439
433440 auto currentFile = cnv->patch .getCurrentFile ();
434441 if (currentFile.exists () && !currentFile.isRoot ()) {
435442 // Check if there is a patch font loaded via the patch loading
436443 if (auto const patchFont = Fonts::findFont (currentFile, typefaceName); patchFont.has_value ())
437444 return patchFont->withStyle (style).withHeight (fontHeight);
438445 }
439-
446+
440447 return { typefaceName, static_cast <float >(fontHeight), style };
441448 }
442449
Original file line number Diff line number Diff line change @@ -70,8 +70,7 @@ struct Fonts {
7070
7171 static std::optional<Font> findFont (File const & dirToSearch, String const & typefaceFileName)
7272 {
73- Array<File> fontFiles = dirToSearch.getParentDirectory ().findChildFiles (File::findFiles, true , " *.ttf;*.otf;" );
74-
73+ Array<File> fontFiles = dirToSearch.getParentDirectory ().findChildFiles (File::findFiles, false , " *.ttf;*.otf;" );
7574 for (auto font : fontFiles) {
7675 if (font.getFileNameWithoutExtension () == typefaceFileName) {
7776 auto it = fontTable.find (font.getFullPathName ());
You can’t perform that action at this time.
0 commit comments