From c17787e91a7642cdcccbb74ff28d7bfdb836707c Mon Sep 17 00:00:00 2001 From: Kevin Leung Date: Mon, 24 Sep 2018 02:01:05 -0700 Subject: [PATCH] Android subpixel text (#19043) Summary: Fixes inconsistency in custom font rendering in android. See explanation below. I tested the following on my physical device (Sony Z5C) and on Android emulator on Mac. The test app contains various fonts in the AvenirNext family, which are added to the app as `.ttf` format. Note that the character "thickness" is inconsistent. Some characters looks thicker than other. See the screenshots below as an example: - Looks thicker: right half of the `g` and `&` as in "Region & Language" (list-view screen) - Looks thicker: `w` as in `Change Password` (list-view screen) - Looks vertically compressed: `a` and `e` as in "Message" in the bottom bar (list-view screen) - Looks thicker: `A`, `N`, `V`, `v` (paragraph screen) - Looks thinner: `i` (paragraph screen), it leaves extra space on its right hand side ![screenshot_20180427-151129](https://user-images.githubusercontent.com/1103788/39350754-ae9fafe2-4a31-11e8-8835-97280783bb95.png) ![screenshot_20180427-151419](https://user-images.githubusercontent.com/1103788/39350755-aecc9bba-4a31-11e8-8128-2d230f003dfa.png) Every characters has consistent "weight" and looks nice: ![screenshot_20180427-150835](https://user-images.githubusercontent.com/1103788/39350753-ae698728-4a31-11e8-8a55-4e161c559b95.png) ![screenshot_20180427-151639](https://user-images.githubusercontent.com/1103788/39350756-aef95d44-4a31-11e8-820b-1a7dee77fabe.png) None [ANDROID] [ENHANCEMENT] [CustomStyleSpan] - Enable subpixel text rendering Pull Request resolved: https://github.com/facebook/react-native/pull/19043 Differential Revision: D10008155 Pulled By: hramos fbshipit-source-id: 7fe9bb0f9be80380947ff80eac522e3cfd6b22cf --- .../main/java/com/facebook/react/views/text/CustomStyleSpan.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/CustomStyleSpan.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/CustomStyleSpan.java index 127e3ab82d4d4f..8997ba57869de8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/CustomStyleSpan.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/CustomStyleSpan.java @@ -114,6 +114,7 @@ private static void apply( } else { paint.setTypeface(Typeface.defaultFromStyle(want)); } + paint.setSubpixelText(true); } }