class Tessell::Text::FontStack

Defined in:

tessell/text/font_stack.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(faces : Array(Tessell::Text::FontStack::Face)) #

[View source]
def self.open(entries : Array(NamedTuple(path: String, ttc_index: Int32, weight: Weight, label: String))) : FontStack #

打开多张 face;font_id 按数组顺序分配(= atlas 的 font 维度)。


[View source]
def self.open(entries : Array(NamedTuple(path: String, ttc_index: Int32, weight: Weight, label: String, family: String | Nil))) : FontStack #

family 通道(issue #55):entry 带 family 时在该文件的 face 集合内 按 sfnt family 解析 ttc_index(nameID 16 优先);解析失败保留显式 ttc_index 并一次性 warning。显式 ttc_index 通道不变。


[View source]

Instance Method Detail

def close : Nil #

[View source]
def face_count : Int32 #

[View source]
def faces : Array(Face) #

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

选脸并测量:优先级第一的覆盖脸的度量(逻辑入口)。


[View source]
def pick(text : String, weight : Weight) : Face | Nil #

按字重选脸(issue #29):先找覆盖文本且字重匹配的 face;没有匹配 字重的覆盖脸时退回第一个覆盖脸(缺 bold 时不至于拿到错宽度的脸)。


[View source]
def pick(text : String) : Face | Nil #

覆盖整段文本的第一张脸(按优先级);无覆盖返回 nil。


[View source]