Android S version changes the font size and font to bold

1. Font size is very simple:

vendor/mediatek/proprietary/packages/apps/SettingsProvider/res/values/freeme_defaults.xml

<!-- freeme.biantao, 20170307. Default font scale. [1.0:default 0.85:small 1.15:large 1.3:largest] -->
    <string name="def_font_scale" translatable="false">1.45</string>

The default here is the maximum

2. The font is bold, which makes it look very simple!

At the beginning, many people were crazy about it, scratching their heads and wondering (sister);

In the end, luckily I persevered and understood the truth.

Take it in two steps:

(1) Modify /frameworks/base/core/java/android/provider$Settings.java under framework

       private static final float DEFAULT_FONT_SCALE = 1.0f;
        private static final int DEFAULT_FONT_WEIGHT = 0; // Mainly modify this, change it to 300 , why? You'll find out later, haha!

(2) Modify vendor/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/accessibility$ FontWeightAdjustmentPreferenceController.java

public class FontWeightAdjustmentPreferenceController extends TogglePreferenceController {
     //*/tyd,lxd,20221030, add bold font
    static final int BOLD_TEXT_ADJUSTMENT =  //700-400=300
           FontStyle.FONT_WEIGHT_BOLD - FontStyle.FONT_WEIGHT_NORMAL;

    public FontWeightAdjustmentPreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
    }

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
    }

    @Override
    public boolean isChecked() {
        return Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.FONT_WEIGHT_ADJUSTMENT, 300) == BOLD_TEXT_ADJUSTMENT
;

//why? Because the values ​​on both sides must be equal to make the font bold, if they are not equal, the font cannot be made bold.

I have to say that the design is ingenious, no, wonderful and weird.
    }

    @Override
    public boolean setChecked(boolean isChecked) {
        return Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.FONT_WEIGHT_ADJUSTMENT, (isChecked ? BOLD_TEXT_ADJUSTMENT : 0));
    }
}

It’s over here. I believe that after you modify these two files, you will be able to solve the current needs as you wish!

Guess you like

Origin blog.csdn.net/qq_46687516/article/details/131902236