Skip to content

Commit 4e381e7

Browse files
committed
revert bearing change
1 parent ab35f9e commit 4e381e7

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/rendering.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ function renderstring!(
186186

187187
# draw glyph bounding box
188188
if bbox_glyph !== nothing
189-
rect = boundingbox(metric)
190-
(mc, mr), (Mc, Mr) = extrema(rect)
191-
r1, r2 = clamp(py + mr, 1, imgh), clamp(py + Mr, 1, imgh)
192-
c1, c2 = clamp(px + mc, 1, imgw), clamp(px + Mc, 1, imgw)
193-
# ^^^ should be equivalent to vvv
194-
# r1, r2 = clamp(oy + row_lo, 1, imgh), clamp(oy + row_hi, 1, imgh)
195-
# c1, c2 = clamp(ox + col_lo, 1, imgw), clamp(ox + col_hi, 1, imgw)
189+
# rect = boundingbox(metric)
190+
# (mc, mr), (Mc, Mr) = extrema(rect)
191+
# r1, r2 = clamp(py + mr, 1, imgh), clamp(py + Mr, 1, imgh)
192+
# c1, c2 = clamp(px + mc, 1, imgw), clamp(px + Mc, 1, imgw)
193+
# ^^^ should be equivalent to vvv: see JuliaGraphics/FreeTypeAbstraction.jl/pull/71
194+
r1, r2 = clamp(oy + row_lo, 1, imgh), clamp(oy + row_hi, 1, imgh)
195+
c1, c2 = clamp(ox + col_lo, 1, imgw), clamp(ox + col_hi, 1, imgw)
196196
if r2 > r1 && c2 > c1
197197
img[r1, c1:c2] .= bbox_glyph
198198
img[r2, c1:c2] .= bbox_glyph

src/types.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ function FontExtent(fontmetric::FreeType.FT_Glyph_Metrics, scale::Integer)
104104
end
105105

106106
function bearing(extent::FontExtent{T}) where T
107+
# origin to SW corner of the horizontal metric
108+
# with the conventions of freetype.org/freetype2/docs/glyphs/glyphs-3.html
107109
return Vec2{T}(
108-
+extent.horizontal_bearing[1],
109-
-extent.horizontal_bearing[2],
110+
hbearing_ori_to_left(extent),
111+
hbearing_ori_to_top(extent) - inkheight(extent),
110112
)
111113
end
112114

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ face = FA.findfont("hack")
1616
@test FA.descender(face) isa Real
1717

1818
bb = FA.boundingbox("asdasd", face, 64)
19-
@test round.(Int, minimum(bb)) == Vec(4, -49)
19+
@test round.(Int, minimum(bb)) == Vec(4, -1)
2020
@test round.(Int, widths(bb)) == Vec2(221, 50)
2121

2222
FA.set_pixelsize(face, 64) # should be the default

0 commit comments

Comments
 (0)