class Tessell::Kit::MultiFaceTextMetrics

Overview

多 face 度量(issue #29):包一层 FontStack,按整段文本覆盖选脸并 转发 face 的 font_id——单 face 假设不再泄漏到组件层。粗体宽度用 bold face 测量:组件传 font_id 给 measure_text(Context 缓存键含 font_id)。

Defined in:

tessell/kit/context.cr

Constructors

Instance Method Summary

Instance methods inherited from class Tessell::Kit::TextMetrics

font_metrics(size : Float32) : Tessell::Text::FontMetrics font_metrics, line_height(size : Float32) : Float32 line_height, measure(text : String, size : Float32, max_width : Float32, font_id : Int32) : Size
measure(text : String, size : Float32, max_width : Float32) : Size
measure(text : String, size : Float32, font_id : Int32) : Size
measure(text : String, size : Float32) : Size
measure

Constructor Detail

def self.new(stack : Tessell::Text::FontStack) #

[View source]

Instance Method Detail

def font_metrics(size : Float32) : Tessell::Text::FontMetrics #
Description copied from class Tessell::Kit::TextMetrics

字体度量(issue #6):设备像素单位。默认与 line_height(size)=1.25*size 口径一致(ascent+descent=line_height);CoreTextMetrics 委托给底层 Measurer#font_metrics(FT size metrics)。


[View source]
def line_height(size : Float32) : Float32 #

[View source]
def measure(text : String, size : Float32, max_width : Float32, font_id : Int32) : Size #

[View source]
def measure(text : String, size : Float32, max_width : Float32) : Size #
Description copied from class Tessell::Kit::TextMetrics

带可用宽度的测量;默认忽略 max_width,支持换行的实现应覆盖。


[View source]
def measure(text : String, size : Float32, font_id : Int32) : Size #
Description copied from class Tessell::Kit::TextMetrics

face 维度测量(issue #29):默认实现忽略 font_id(单 face 桩); 多 face 实现应按 font_id 选底层 measurer。


[View source]
def measure(text : String, size : Float32) : Size #
Description copied from class Tessell::Kit::TextMetrics

单位契约(issue #14):#measure / #line_height 的入参 size 与返回值 一律为设备像素单位(宿主渲染字形所用的实际字号)。逻辑单位的换算 由 Context#measure_text / Context#line_height 统一负责——组件层只 见逻辑单位,宿主不需要再包一层除法适配器。


[View source]

[View source]