The font size of the android system is set to "font size" in "display" in "Settings". A total of four levels are provided: small, normal, large, and super large.
Select the corresponding configuration code location for the four levels
Packages/apps/setttings/res/values/arrays. xml
- <string-array name="entries_font_size">
- <item msgid="6490061470416867723">Small</item>
- <item msgid="3579015730662088893">Normal</item>
- <item msgid="1678068858001018666">Large</item>
- <item msgid="490158884605093126">Huge</item>
- </string-array>
- <string-array name="entryvalues_font_size" translatable="false">
- <item>0.85</item>
- <item>1.0</item>
- <item>1.15</item>
- <item>1.30</item>
- </string-array>
The above configuration is provided to the end user after being loaded using the following code
Packages/app/settings/DisplaySettings. java
- public void readFontSizePreference(ListPreference pref) {
- try {
- mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
- } catch (RemoteException e) {
- Log.w(TAG, "Unable to retrieve font size");
- }
- // mark the appropriate item in the preferences list
- int index = floatToIndex(mCurConfig.fontScale);
- pref.setValueIndex(index);
- // report the current size in the summary text
- final Resources res = getResources();
- String[] fontSizeNames = res.getStringArray(R.array.entries_font_size);
- pref.setSummary(String.format(res.getString(R.string.summary_font_size),
- fontSizeNames[index]));
- }
At the frameworks layer, a default font size is set for the system. The font scale-down ratio is 1, which is the "normal" font in the corresponding display settings.
Frameworks/base/core/java/android/content/res/Configuration. java
- /**
- * Set this object to the system defaults.
- */
- Public void setToDefaults (){
- FontScale = 1; // The default font scale is assigned here.
- Mcc = mnc = 0;
- Locale = null;
- UserSetLocale = false;
- Touchscreen = TOUCHSCREEN_UNDEFINED;
- Keyboard = KEYBOARD_UNDEFINED;
- KeyboardHidden = KEYBOARDHIDDEN_UNDEFINED;
- HardKeyboardHidden = HARDKEYBOARDHIDDEN_UNDEFINED;
- Navigation = NAVIGATION_UNDEFINED;
- NavigationHidden = NAVIGATIONHIDDEN_UNDEFINED;
- Orientation = ORIENTATION_UNDEFINED;
- ScreenLayout = SCREENLAYOUT_UNDEFINED;
- UiMode = UI_MODE_TYPE_UNDEFINED;
- ScreenWidthDp = compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
- ScreenHeightDp = compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
- SmallestScreenWidthDp = compatSmallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
- DensityDpi = DENSITY_DPI_UNDEFINED;
- Seq = 0;
- }