FreeTypeAbstraction.jl icon indicating copy to clipboard operation
FreeTypeAbstraction.jl copied to clipboard

Use BaseDirs for locating font directories

Open tecosaur opened this issue 1 year ago • 2 comments

Identifying the correct platform-specific font directories can be done mostly correctly most of the time just with a hardcoded list of places to look (particularly on Apple systems). However, on Windows and XDG-following (i.e. Linux and friends) systems the user and system font directories can end up in other places, and accommodating these edge cases takes some effort.

This effort has already been put in with the BaseDirs package, which is a small zero-dependency package whose entire purpose is to find the correct directories for different types of content on various platforms. So, we can remove the current font-folder-finding code entirely and just call BaseDirs.fonts() for a reduction in code here and an improvement in compatibility.

tecosaur avatar Dec 30 '23 03:12 tecosaur

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (077003e) 95.26% compared to head (166378c) 96.07%.

Files Patch % Lines
src/FreeTypeAbstraction.jl 90.90% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #82      +/-   ##
==========================================
+ Coverage   95.26%   96.07%   +0.81%     
==========================================
  Files           6        6              
  Lines         317      306      -11     
==========================================
- Hits          302      294       -8     
+ Misses         15       12       -3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 30 '23 03:12 codecov[bot]

It seems like codecov is complaining about the line @static if Sys.isunix() && !Sys.isapple() not being tested (I don't think it can be hit at runtime while @static applies).

tecosaur avatar Dec 30 '23 03:12 tecosaur

Just rebased and benchmarked latency (with Julia 1.10):

julia> @time using FreeTypeAbstraction # current release
  0.459916 seconds (858.54 k allocations: 87.634 MiB, 6.14% gc time, 1.33% compilation time)
  
julia> @time using FreeTypeAbstraction # this PR
  0.463937 seconds (878.13 k allocations: 90.774 MiB, 3.77% gc time, 1.26% compilation time)

Seems like this makes a negligible difference to loading time :slightly_smiling_face:

tecosaur avatar Oct 04 '24 14:10 tecosaur