https://developer.android.com/reference/android/text/BoringLayout.html StaticLayout.Builder.build() Returns null if not boring; the width, ascent, and descent if boring. BoringLayout.isBoring()
(Text Shaping Library) FreeType (Text Drawing Library) Skia (Graphics Library) Paint Canvas Java Native from Google I/O 2018 Best practices for text on Android (Google I/O '18) Trace point
is an 120px example text. 120px Returns null if not boring; the width, ascent, and descent if boring. BoringLayout.isBoring() doLayout("This is an ", "serif"); doLayout("example text", "Corsiva");
problem. Go with BoringLayout! Text is too long. Need word wrapping!!! Returns null if not boring; the width, ascent, and descent if boring. BoringLayout.isBoring()
text. ␣ ␣ ␣ ␣ StaticLayout.Builder.build() This is an ex- text. ample example exam- This␣ is␣ an␣ text. example␣ For words: 5 times For Hyphenation: 3 times example
␣ ␣ ␣ ␣ StaticLayout.Builder.build() This is an ex- text. ample example exam- This␣ is␣ an␣ example␣ text. example␣ For words: 5 times For Hyphenation: 3 times What happens if we disable hyphenation? example
API 28+ • Keeps copy of layout result. PrecomputedTextCompat - the backported version in AndroidX • Effective on API 21+ • Just warms up the layout cache before API 28. • The cache may be purged when needed. (by default, LRU 5000 words limit)
framework impl and always use AndroidX impl. (Crash happens on some environment.) Between API 21 to 28, warm up layout cache. val computedText = PrecomputedTextCompat.create(text, tv.textMetricsParamsCompat)
null /* You can pass custom Executor */) // AppcompatTextView will call Future.get() to resolve the measurement when needed. tv.setTextFuture(textFuture)
a giant mutex lock during doing text layout. ◦ Removed from API 28 • Hyphenation depends on the language. ◦ No hyphenation for Japanese, i.e. no performance gain by turning off