Skip to content

Commit ed173cb

Browse files
authored
Merge pull request #62 from jkrumbiegel/usability-improvements
usability improvements
2 parents 4e8feac + 43dba56 commit ed173cb

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/findfonts.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ if Sys.isapple()
77
]
88
end
99
elseif Sys.iswindows()
10-
_font_paths() = [joinpath(get(ENV, "SYSTEMROOT", "C:\\Windows"), "Fonts")]
10+
_font_paths() = [
11+
joinpath(get(ENV, "SYSTEMROOT", "C:\\Windows"), "Fonts"),
12+
joinpath(homedir(), "AppData", "Local", "Microsoft", "Windows", "Fonts"),
13+
]
1114
else
1215
function add_recursive(result, path)
1316
for p in readdir(path)
@@ -130,8 +133,6 @@ function findfont(
130133
# \W splits at all groups of non-word characters (like space, -, ., etc)
131134
searchparts = unique(split(lowercase(searchstring), r"\W+", keepempty=false))
132135

133-
candidates = Pair{FTFont, Tuple{Int, Int}}[]
134-
135136
best_score_so_far = (0, 0, false, typemin(Int))
136137
best_font = nothing
137138

src/types.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ function Base.getproperty(font::FTFont, fieldname::Symbol)
161161
end
162162
end
163163

164+
function Base.show(io::IO, font::FTFont)
165+
print(io, "FTFont (family = $(font.family_name), style = $(font.style_name))")
166+
end
167+
164168
# Allow broadcasting over fonts
165169
Base.Broadcast.broadcastable(ft::FTFont) = Ref(ft)
166170

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ using FreeType
55

66
face = FreeTypeAbstraction.findfont("hack"; additional_fonts=@__DIR__)
77

8+
@test repr(face) == "FTFont (family = Hack, style = Regular)"
9+
810
bb = boundingbox("asdasd", face, 64)
911
@test round.(Int, minimum(bb)) == Vec(4, -1)
1012
@test round.(Int, widths(bb)) == Vec2(221, 50)

0 commit comments

Comments
 (0)