FreeTypeAbstraction.jl
FreeTypeAbstraction.jl copied to clipboard
add cache mechanism
Fix https://github.com/JuliaGraphics/FreeTypeAbstraction.jl/issues/67.
Codecov Report
Base: 94.62% // Head: 95.31% // Increases project coverage by +0.69%
:tada:
Coverage data is based on head (
0864e78
) compared to base (b7d6d65
). Patch coverage: 100.00% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## master #76 +/- ##
==========================================
+ Coverage 94.62% 95.31% +0.69%
==========================================
Files 6 6
Lines 316 320 +4
==========================================
+ Hits 299 305 +6
+ Misses 17 15 -2
Impacted Files | Coverage Δ | |
---|---|---|
src/FreeTypeAbstraction.jl | 100.00% <100.00%> (ø) |
|
src/findfonts.jl | 89.06% <100.00%> (-4.59%) |
:arrow_down: |
src/types.jl | 94.28% <100.00%> (+0.05%) |
:arrow_up: |
src/precompile.jl | 100.00% <0.00%> (+100.00%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
How would saving these path strings during compilation play with relocation? Seems to me that it would break if you'd move a sysimage with baked in paths somewhere else. I guess fonts are difficult in that way as they could be in different places on different systems.
For Makie, we really only care about not triggering font search in the default case, correct? In that case, we should look into caching Makie's default fonts in a relocatable way. That's only a couple fonts, mostly the four Makie TeX Gyre Heros fonts and a few fallbacks. If those fonts are already known at load, we wouldn't get latencies until the user specifies a new font for the first time.
How would saving these path strings during compilation play with relocation
In this PR in FTA, the cache is invalidated on __init__
so there is no impact on relocation.
However, this could be a problem in Makie
in https://github.com/MakieOrg/Makie.jl/pull/2518 yes.
For Makie, we really only care about not triggering font search in the default case
There are a few options here, but fully caching the font might not be feasible (because of the FT handles opened). What I aim at least for https://github.com/JuliaGraphics/FreeTypeAbstraction.jl/issues/67#issuecomment-1364043802 is trying to cache a few font paths for defaults as done here avoiding re-running the costly search and trial + best score approach of findfont
at load time.
I did mean caching the path, yes. Just in some relocatable way.
I've added a failsafe in Makie.
For now, if the path is non-existent, just fallback to using FTA.findfont
for finding & loading the font.
Trying to truly relocate the path seems a bit excessive and error prone.