modified declaration glyph in GlyphPart within MathTable.

This commit is contained in:
Peter Tang
2023-09-12 08:57:39 +08:00
parent d1c4ac77a6
commit 2d579c1192

View File

@@ -270,18 +270,17 @@ internal struct MathTable {
} }
var rv = [GlyphPart]() var rv = [GlyphPart]()
for part in parts { for part in parts {
let partInfo = part as? NSDictionary guard let partInfo = part as? NSDictionary, let glyph = font.get(glyphWithName: glyphName) else { continue }
var part = GlyphPart() var part = GlyphPart(glyph: glyph)
if let adv = partInfo?["advance"] as? NSNumber, if let adv = partInfo["advance"] as? NSNumber,
let end = partInfo?["endConnector"] as? NSNumber, let end = partInfo["endConnector"] as? NSNumber,
let start = partInfo?["startConnector"] as? NSNumber, let start = partInfo["startConnector"] as? NSNumber,
let ext = partInfo?["extender"] as? NSNumber, let ext = partInfo["extender"] as? NSNumber,
let glyphName = partInfo?["glyph"] as? String { let glyphName = partInfo["glyph"] as? String {
part.fullAdvance = fontUnitsToPt(adv.intValue) part.fullAdvance = fontUnitsToPt(adv.intValue)
part.endConnectorLength = fontUnitsToPt(end.intValue) part.endConnectorLength = fontUnitsToPt(end.intValue)
part.startConnectorLength = fontUnitsToPt(start.intValue) part.startConnectorLength = fontUnitsToPt(start.intValue)
part.isExtender = ext.boolValue part.isExtender = ext.boolValue
part.glyph = font.get(glyphWithName: glyphName)
rv.append(part) rv.append(part)
} }
} }
@@ -290,10 +289,9 @@ internal struct MathTable {
} }
extension MathTable { extension MathTable {
struct GlyphPart { struct GlyphPart {
/// The glyph that represents this part /// The glyph that represents this part
var glyph: CGGlyph! var glyph: CGGlyph
/// Full advance width/height for this part, in the direction of the extension in points. /// Full advance width/height for this part, in the direction of the extension in points.
var fullAdvance: CGFloat = 0 var fullAdvance: CGFloat = 0