fix: incorrect font icon size conversion to device pixels. (#9910)

This commit is contained in:
Dimitris-Rafail Katsampas
2022-05-18 23:28:58 +03:00
committed by Nathan Walker
parent a85a72d961
commit d3718e5e5f
2 changed files with 5 additions and 14 deletions

View File

@ -187,14 +187,12 @@ export class ImageSource implements ImageSourceDefinition {
paint.setColor(color.android); paint.setColor(color.android);
} }
let fontSize = layout.toDevicePixels(font.fontSize); let scaledFontSize = layout.toDevicePixels(font.fontSize);
if (!fontSize) { if (!scaledFontSize) {
// TODO: Consider making 36 font size as default for optimal look on TabView and ActionBar // TODO: Consider making 36 font size as default for optimal look on TabView and ActionBar
fontSize = paint.getTextSize(); scaledFontSize = layout.toDevicePixels(paint.getTextSize());
} }
const density = layout.getDisplayDensity();
const scaledFontSize = fontSize * density;
paint.setTextSize(scaledFontSize); paint.setTextSize(scaledFontSize);
const textBounds = new android.graphics.Rect(); const textBounds = new android.graphics.Rect();

View File

@ -180,17 +180,10 @@ export class ImageSource implements ImageSourceDefinition {
static fromFontIconCodeSync(source: string, font: Font, color: Color): ImageSource { static fromFontIconCodeSync(source: string, font: Font, color: Color): ImageSource {
font = font || Font.default; font = font || Font.default;
let fontSize = layout.toDevicePixels(font.fontSize);
if (!fontSize) {
// TODO: Consider making 36 font size as default for optimal look on TabView and ActionBar
fontSize = UIFont.labelFontSize;
}
const density = layout.getDisplayDensity();
const scaledFontSize = fontSize * density;
// TODO: Consider making 36 font size as default for optimal look on TabView and ActionBar
const attributes = { const attributes = {
[NSFontAttributeName]: font.getUIFont(UIFont.systemFontOfSize(scaledFontSize)), [NSFontAttributeName]: font.getUIFont(UIFont.systemFontOfSize(UIFont.labelFontSize)),
}; };
if (color) { if (color) {