Skip to content

Added possibility to set additional directories to search fonts - #1422

Merged
BobLd merged 10 commits into
UglyToad:masterfrom
adelobosko:feat/set-additional-font-search-dirs
Sep 1, 2026
Merged

Added possibility to set additional directories to search fonts#1422
BobLd merged 10 commits into
UglyToad:masterfrom
adelobosko:feat/set-additional-font-search-dirs

Conversation

@adelobosko

Copy link
Copy Markdown
Contributor

• fixed typo in WindowsSystemFontLister (PSFonts dir was not included, fonts dir was used twice instead)

• added possibility to set additional directories to search fonts

useful for strict environments without preinstalled fonts or without access to them
related to BobLd/PdfPig.Rendering.Skia#145

Comment thread src/UglyToad.PdfPig.Fonts/SystemFonts/AndroidSystemFontLister.cs Outdated
Comment thread src/UglyToad.PdfPig.Fonts/SystemFonts/AndroidSystemFontLister.cs Outdated
Comment thread src/UglyToad.PdfPig.Fonts/SystemFonts/ISystemFontLister.cs Outdated
Comment thread src/UglyToad.PdfPig.Fonts/SystemFonts/SystemFontFinder.cs Outdated
@BobLd

BobLd commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

@adelobosko thanks a lot for the PR, I think this is going to help many users.

I have added comments - let me know if any questions

The feedback in AndroidSystemFontLister.cs is applicable to all other ISystemFontLister implementations

@BobLd

BobLd commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

@adelobosko I did a 2nd pass on the code, have you successfully added other fonts in your use case?

AdditionalFontSearchDirectories is used inside Lazy<>, so once the lazy value is actually created, adding new font path won't do anything, and this happens silently.

We should aim at throw an exception if a path is added too late.

@adelobosko

Copy link
Copy Markdown
Contributor Author

@BobLd Yes, I was able to successfully add other fonts in my use case.

@adelobosko
adelobosko requested a review from BobLd August 27, 2026 07:27
@BobLd

BobLd commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

@adelobosko thanks for updating the PR.

Regarding my last comment, your FontSearchDirectoryLock does not do anything for the moment (and it's gating a concurrent bag).

Can you review your changes?

As a side note: I agree with the approach being static (even if not a huge fan, but I don't think there's an alternative), it just need to be robust.

@adelobosko

Copy link
Copy Markdown
Contributor Author

Regarding my last comment, your FontSearchDirectoryLock does not do anything for the moment (and it's gating a concurrent bag).

FontSearchDirectoryLock preventing duplicates, maybe better to use HashSet + lock instead of Concurrent bag

@BobLd

BobLd commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

@adelobosko agreed on the hashset, yes. My comment above was related to the use of AvailableFonts.IsValueCreated. It is not enough as a gate, FontSearchDirectoryLock should also be lock inside the lazy creation method.

Will merge as-is and push changes for the lock, and hashset.

@adelobosko

Copy link
Copy Markdown
Contributor Author

@BobLd done, changed to HashSet + locks

@BobLd

BobLd commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

@adelobosko thx for the updates. Can you let me know when you are done? I'll run the tests and merge

@adelobosko

Copy link
Copy Markdown
Contributor Author

@BobLd It's done

@BobLd
BobLd merged commit be7b034 into UglyToad:master Sep 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants