• Top - The maximum distance above the baseline for the tallest glyph in the font at a given text size.
  • Ascent - The recommended distance above the baseline for singled spaced text.
  • Descent - The recommended distance below the baseline for singled spaced text.
  • Bottom - The maximum distance below the baseline for the lowest glyph in the font at a given text size.
  • Leading - The recommended additional space to add between lines of text. image
Unicode 字符串
  ↓
分段:段落 / script / bidi / font fallback / style run
  ↓
shaping:字符 → glyph,并计算 glyph advance / offset
  ↓
测量:ascent / descent / leading / baseline / line-height
  ↓
换行:word break / CJK break / hyphenation / maxLines / ellipsis
  ↓
布局:每一行的 line box、baseline、对齐、justify
  ↓
绘制:把 glyph rasterize 到屏幕
  ↓
命中测试:点击坐标 ↔ 字符 offset / selection range

Android

  • TextView 单行高度 ≈ font metrics + includeFontPadding + lineSpacing