mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
fix: incorrect font icon size conversion to device pixels. (#9910)
This commit is contained in:

committed by
Nathan Walker

parent
a85a72d961
commit
d3718e5e5f
@ -187,14 +187,12 @@ export class ImageSource implements ImageSourceDefinition {
|
||||
paint.setColor(color.android);
|
||||
}
|
||||
|
||||
let fontSize = layout.toDevicePixels(font.fontSize);
|
||||
if (!fontSize) {
|
||||
let scaledFontSize = layout.toDevicePixels(font.fontSize);
|
||||
if (!scaledFontSize) {
|
||||
// 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);
|
||||
|
||||
const textBounds = new android.graphics.Rect();
|
||||
|
@ -180,17 +180,10 @@ export class ImageSource implements ImageSourceDefinition {
|
||||
|
||||
static fromFontIconCodeSync(source: string, font: Font, color: Color): ImageSource {
|
||||
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 = {
|
||||
[NSFontAttributeName]: font.getUIFont(UIFont.systemFontOfSize(scaledFontSize)),
|
||||
[NSFontAttributeName]: font.getUIFont(UIFont.systemFontOfSize(UIFont.labelFontSize)),
|
||||
};
|
||||
|
||||
if (color) {
|
||||
|
Reference in New Issue
Block a user