Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cache mechanism #76

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

add cache mechanism #76

wants to merge 6 commits into from

Conversation

t-bltg
Copy link
Member

@t-bltg t-bltg commented Dec 23, 2022

Fix #67.

@codecov
Copy link

codecov bot commented Dec 23, 2022

Codecov Report

Base: 94.62% // Head: 95.31% // Increases project coverage by +0.69% 🎉

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%) ⬇️
src/types.jl 94.28% <100.00%> (+0.05%) ⬆️
src/precompile.jl 100.00% <0.00%> (+100.00%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jkrumbiegel
Copy link
Collaborator

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.

@t-bltg
Copy link
Member Author

t-bltg commented Dec 24, 2022

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 MakieOrg/Makie.jl#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 #67 (comment) 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.

@jkrumbiegel
Copy link
Collaborator

I did mean caching the path, yes. Just in some relocatable way.

@t-bltg
Copy link
Member Author

t-bltg commented Dec 24, 2022

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.

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.

findfont scans all fonts every time
2 participants