文本行(TextLine)
文本(Text) 换行后的一行。对其进行迭代会按视觉顺序(从左到右)访问字形,与书写方向无关。
for _, line in text:lines() do
for _, glyph in line do
renderer:save()
renderer:transform(glyph.transform)
renderer:drawPath(glyph.font:glyphPath(glyph.id), paint)
renderer:restore()
end
end
字段(Fields)
index
该行在文本中的索引,从 1 开始。
x
对齐后的左边缘。
top
行的顶部。
baseline
行的基线。
bottom
行的底部。
width
行宽。
direction
该行所属段落的基础方向。
firstIndex
该行上第一个码点的索引,从 1 开始。
lastIndex
该行上最后一个码点的索引,从 1 开始。
glyphCount
该行的字形数量。
方法(Methods)
glyph
glyph(index: number) -> Glyph
按从 1 开始的视觉位置返回该字形。
glyphs
glyphs() -> {Glyph}
全部字形,按视觉顺序。
__iter
__iter() -> ((TextLine, number) ->(number?, Glyph), TextLine, number)
按视觉顺序迭代字形:for _, glyph in line do。