Skip to content

Commit dd9f5c9

Browse files
authored
optimize fontname (#96)
1 parent f52c6bf commit dd9f5c9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/findfonts.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function try_load(fpath)
7575
end
7676
end
7777

78-
fontname(ft::FTFont) = "$(family_name(ft)) $(style_name(ft))"
78+
fontname(ft::FTFont) = ft.fontname
7979

8080
function findfont(
8181
searchstring::String;

src/types.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ mutable struct FTFont
146146
extent_cache::Dict{UInt64, FontExtent{Float32}}
147147
lock::ReentrantLock # lock this for the duration of any FT operation on ft_ptr
148148
mmapped::Union{Nothing,Vector{UInt8}}
149+
fontname::String
149150
function FTFont(ft_ptr::FreeType.FT_Face, use_cache::Bool=true, mmapped = nothing)
150151
extent_cache = Dict{UInt64, FontExtent{Float32}}()
151-
face = new(ft_ptr, use_cache, extent_cache, ReentrantLock(), mmapped)
152+
face = new(ft_ptr, use_cache, extent_cache, ReentrantLock(), mmapped, "")
153+
face.fontname = "$(family_name(face)) $(style_name(face))"
152154
finalizer(safe_free, face)
153155
return face
154156
end

0 commit comments

Comments
 (0)