1

Is there a way to prevent android system scaling of font size? Found one typescript solution, but can't make it work. Probably because i don't understand typescript good enough.

1 Answers1

2

Try this override in [app|main].[js|ts],

import { layout } from "tns-core-modules/utils/utils";
import { fontSizeProperty, TextBase } from "tns-core-modules/ui/text-base";

TextBase.prototype[fontSizeProperty.setNative] = function (value) {
    if (!this.formattedText || (typeof value !== "number")) {
        if (typeof value === "number") {
            this.nativeTextViewProtected.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, layout.toDevicePixels(value));
        } else {
            this.nativeTextViewProtected.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, value.nativeSize);
        }
    }
};

Note: You may have to do the same on TabView, HtmlView etc., if you are using them in your project and want to disable scaling. The above one takes care of Label, Button etc.,

Playground Sample

Manoj
  • 21,753
  • 3
  • 20
  • 41