From 53b0bf1d5afefb9ea02ff4f5fcfb2bd9937cb65a Mon Sep 17 00:00:00 2001 From: Michael Griebling Date: Wed, 22 Feb 2023 10:37:59 -0500 Subject: [PATCH] Fix issue when there are no variants. --- Sources/SwiftMath/MathRender/MTFontMathTable.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftMath/MathRender/MTFontMathTable.swift b/Sources/SwiftMath/MathRender/MTFontMathTable.swift index 545e731..83b73f4 100644 --- a/Sources/SwiftMath/MathRender/MTFontMathTable.swift +++ b/Sources/SwiftMath/MathRender/MTFontMathTable.swift @@ -203,15 +203,15 @@ class MTFontMathTable { func getVariantsForGlyph(_ glyph: CGGlyph, inDictionary variants:NSDictionary?) -> [NSNumber] { let glyphName = self.font!.get(nameForGlyph: glyph) - let variantGlyphs = variants![glyphName] as! NSArray? + let variantGlyphs = variants![glyphName] as! NSArray var glyphArray = [NSNumber]() - if variantGlyphs == nil { + if variantGlyphs.count == 0 { // There are no extra variants, so just add the current glyph to it. let glyph = self.font!.get(glyphWithName: glyphName) glyphArray.append(NSNumber(value:glyph)) return glyphArray } - for gvn in variantGlyphs! { + for gvn in variantGlyphs { let glyphVariantName = gvn as! String? let variantGlyph = self.font?.get(glyphWithName: glyphVariantName!) glyphArray.append(NSNumber(value:variantGlyph!)) @@ -225,13 +225,13 @@ class MTFontMathTable { func getLargerGlyph(_ glyph:CGGlyph) -> CGGlyph { let variants = _mathTable[kVertVariants] as! NSDictionary? let glyphName = self.font?.get(nameForGlyph: glyph) - let variantGlyphs = variants![glyphName!] as! NSArray? - if variantGlyphs == nil { + let variantGlyphs = variants![glyphName!] as! NSArray + if variantGlyphs.count == 0 { // There are no extra variants, so just returnt the current glyph. return glyph } // Find the first variant with a different name. - for gvn in variantGlyphs! { + for gvn in variantGlyphs { let glyphVariantName = gvn as! String? if glyphVariantName != glyphName { let variantGlyph = self.font?.get(glyphWithName: glyphVariantName!)