Skip to content

Commit 0ac5a92

Browse files
authored
fix(canvas): iOS fix for StaticLayout using paint fontSize if not defined
inside createNativeAttributedString
1 parent d122c8b commit 0ac5a92

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/ui-canvas/canvas.ios.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2418,7 +2418,15 @@ export class StaticLayout {
24182418
const fullRange = { location: 0, length: nsAttributedString.length };
24192419
this.mToDraw = nsAttributedString;
24202420
this.nsAttributedString.enumerateAttributesInRangeOptionsUsingBlock(fullRange, 0 as any, (attributes: NSDictionary<string, any>, range: NSRange, p3: any) => {
2421-
nsAttributedString.addAttributesRange(attributes, range);
2421+
// if we find fontSizeNotSet we apply the font size of the paint
2422+
if (attributes.objectForKey('fontSizeNotSet') && attributes.objectForKey('NSFont')) {
2423+
const realAttributes = NSMutableDictionary.dictionaryWithDictionary(attributes);
2424+
const font = realAttributes.objectForKey('NSFont');
2425+
realAttributes.setObjectForKey(font.fontWithSize(this.paint.textSize), 'NSFont')
2426+
nsAttributedString.addAttributesRange(realAttributes, range);
2427+
} else {
2428+
nsAttributedString.addAttributesRange(attributes, range);
2429+
}
24222430
});
24232431
nsAttributedString.addAttributeValueRange(NSParagraphStyleAttributeName, paragraphStyle, fullRange);
24242432
}

0 commit comments

Comments
 (0)