diff --git a/packages/math/base-elements.lua b/packages/math/base-elements.lua index 0aa9bb17c..0bc84fdc9 100644 --- a/packages/math/base-elements.lua +++ b/packages/math/base-elements.lua @@ -1625,7 +1625,10 @@ function elements.sqrt:shape () -- Note: In TeX, the radical sign extends a lot below the baseline, -- and MathML Core also has a lot of layout text about it. -- Not only it doesn't look good, but it's not very clear vs. OpenType. - local radicalGlyph = SILE.shaper:measureChar("√") + local radicalGlyph, found = SILE.shaper:measureChar("√") + if not found then + SU.error("Math font does not contain a square root glyph") + end local ratio = (self.radicand.height:tonumber() + self.radicand.depth:tonumber()) / (radicalGlyph.height + radicalGlyph.depth) local vertAdHocOffset = (ratio > 1 and math.log(ratio) or 0) * self.radicalVerticalGap diff --git a/shapers/base.lua b/shapers/base.lua index 9a0a08063..2cad46c42 100644 --- a/shapers/base.lua +++ b/shapers/base.lua @@ -67,8 +67,9 @@ function shaper:measureChar (char) local options = SILE.font.loadDefaults({}) options.tracking = SILE.settings:get("shaper.tracking") local items = self:shapeToken(char, options) - if #items > 0 then - return { height = items[1].height, width = items[1].width, depth = items[1].depth } + if items and items[1] then + local item = items[1] + return item, item.gid ~= 0 else SU.error("Unable to measure character", char) end diff --git a/types/unit.lua b/types/unit.lua index 169de78a9..93d66c988 100644 --- a/types/unit.lua +++ b/types/unit.lua @@ -223,8 +223,8 @@ unittypes["zw"] = { relative = true, definition = function (v) local zenkakuchar = SILE.settings:get("document.zenkakuchar") - local measurable, zenkaku = pcall(SILE.shaper.measureChar, SILE.shaper, zenkakuchar) - if not measurable then + local measurable, zenkaku, found = pcall(SILE.shaper.measureChar, SILE.shaper, zenkakuchar) + if not found or not measurable then SU.warn(([[ Zenkaku width (全角幅) unit zw is falling back to 1em == 1zw as we cannot measure %s @@ -232,7 +232,7 @@ unittypes["zw"] = { has it. ]]):format(zenkakuchar)) end - local width = measurable and zenkaku.width or SILE.settings:get("font.size") + local width = found and measurable and zenkaku.width or SILE.settings:get("font.size") return v * width end, }