Skip to content

Commit 2b109a0

Browse files
committed
fix(shapers): Properly calculate metrics of single characters composed of many glyphs
1 parent e0b5cd8 commit 2b109a0

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

shapers/base.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,18 @@ function shaper:measureChar (char)
6767
local options = SILE.font.loadDefaults({})
6868
options.tracking = SILE.settings:get("shaper.tracking")
6969
local items = self:shapeToken(char, options)
70-
if items and items[1] then
71-
local item = items[1]
72-
return item, item.gid ~= 0
70+
if items and #items > 0 then
71+
local measurements = {
72+
width = 0,
73+
height = 0,
74+
depth = 0,
75+
}
76+
for _, item in ipairs(items) do
77+
measurements.width = measurements.width + item.width
78+
measurements.height = math.max(measurements.height, item.height)
79+
measurements.depth = math.max(measurements.depth, item.depth)
80+
end
81+
return measurements, items[1].gid ~= 0
7382
else
7483
SU.error("Unable to measure character", char)
7584
end

0 commit comments

Comments
 (0)