Skip to content

Commit df639ed

Browse files
authored
fix: incorrect font icon size conversion to device pixels. (#9910)
1 parent b3cb895 commit df639ed

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

packages/core/image-source/index.android.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,12 @@ export class ImageSource implements ImageSourceDefinition {
187187
paint.setColor(color.android);
188188
}
189189

190-
let fontSize = layout.toDevicePixels(font.fontSize);
191-
if (!fontSize) {
190+
let scaledFontSize = layout.toDevicePixels(font.fontSize);
191+
if (!scaledFontSize) {
192192
// TODO: Consider making 36 font size as default for optimal look on TabView and ActionBar
193-
fontSize = paint.getTextSize();
193+
scaledFontSize = layout.toDevicePixels(paint.getTextSize());
194194
}
195195

196-
const density = layout.getDisplayDensity();
197-
const scaledFontSize = fontSize * density;
198196
paint.setTextSize(scaledFontSize);
199197

200198
const textBounds = new android.graphics.Rect();

packages/core/image-source/index.ios.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,10 @@ export class ImageSource implements ImageSourceDefinition {
180180

181181
static fromFontIconCodeSync(source: string, font: Font, color: Color): ImageSource {
182182
font = font || Font.default;
183-
let fontSize = layout.toDevicePixels(font.fontSize);
184-
if (!fontSize) {
185-
// TODO: Consider making 36 font size as default for optimal look on TabView and ActionBar
186-
fontSize = UIFont.labelFontSize;
187-
}
188-
189-
const density = layout.getDisplayDensity();
190-
const scaledFontSize = fontSize * density;
191183

184+
// TODO: Consider making 36 font size as default for optimal look on TabView and ActionBar
192185
const attributes = {
193-
[NSFontAttributeName]: font.getUIFont(UIFont.systemFontOfSize(scaledFontSize)),
186+
[NSFontAttributeName]: font.getUIFont(UIFont.systemFontOfSize(UIFont.labelFontSize)),
194187
};
195188

196189
if (color) {

0 commit comments

Comments
 (0)