class Tessell::Text::FtMeasurer

Overview

Expose internals needed by Rasterizer without modifying ft_measurer.cr source file. (Allowed: same module, no FFI added.)

Defined in:

tessell/text/ft_measurer.cr
tessell/text/rasterizer.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Tessell::Text::Measurer

font_metrics(font_id : Int32, size : Float32) : FontMetrics font_metrics, measure(text : String, font_id : Int32, size : Float32, max_width : Float32) : Size
measure(key : MeasureKey) : Size
measure
, shape_run(text : String, font_id : Int32, size : Float32) : ShapeRun | Nil shape_run

Constructor Detail

def self.open(path : String, ttc_index : Int32 = 0) : FtMeasurer #

[View source]

Class Method Detail

def self.available? : Bool #

[View source]
def self.face_family(path : String, index : Int32) : String | Nil #

path[index] 的 family(issue #55):临时 FT face 读 sfnt name 表, 用完即释放(done_face → done_free_type),不产生持有资源的构造。


[View source]
def self.num_faces_of(path : String) : Int32 #

path 的 face 集合数(issue #55);文件不存在或打开失败返回 0。


[View source]
def self.sfnt_family_of(face : FT::Lib::Face) : String | Nil #

sfnt name 表读 family:nameID 16 优先、退 nameID 1;记录按 (3,1,0x409) > (0,) > (3,) > (1,0) 打分取最高,未命中返回 nil。


[View source]
def self.unavailable_reason : String | Nil #

[View source]

Instance Method Detail

def close : Nil #

[View source]
def closed? : Bool #

[View source]
def covers?(text : String) : Bool #

cmap 覆盖检测(issue #7):text 的每个码点在当前 face 的 cmap 中 都有非零 glyph id 才返回 true。FontStack 按它选脸,零 FFI 新声明。


[View source]
def face_family(index : Int32 = @ttc_index) : String | Nil #

集合内第 index 张 face 的 family(issue #55):读 sfnt name 表, nameID 16(typographic family)优先、退 nameID 1;无 name 表或 打开失败返回 nil(调用方退回 index 0 并 warning)。


[View source]
def finalize #

[View source]
def font_metrics(font_id : Int32, size : Float32) : FontMetrics #

字体度量(issue #6):读 FT size metrics(26.6 定点 → px)。


[View source]
def ft_face_handle : FT::Lib::Face #

[View source]
def hb_buffer_handle : HB::Lib::Buffer #

[View source]
def hb_font_handle : HB::Lib::Font #

[View source]
def last_error : String | Nil #

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

实现 Measurer 接口:font_id 被忽略(本实例绑定单一 face) 断行口径唯一来源 Text.reflow_run(issue #56:与 CachingMeasurer L2 reflow 共用,两条路径几何一致)。


[View source]
def measure_calls : Int32 #

[View source]
def num_faces : Int32 #

face 集合数(issue #55):.ttc/.otc 是容器不是单 face;单 face 文件为 1。


[View source]
def shape_info(text : String, size : Float32) : NamedTuple(glyph_ids: Array(UInt32), advances_px: Array(Float32), ft_char_index: Hash(UInt32, UInt32)) #

测量辅助:返回 HB shaping 的 glyph ids 与 x_advances(px) 供 spec 验证


[View source]
def shape_run(text : String, font_id : Int32, size : Float32) : ShapeRun | Nil #

宽度无关 shaping(issue #56 L2):advance 序列(px,含与 measure 相同的零 advance 回退口径)+ 行高(px)。不支持/失败返回 nil。


[View source]
def upem_value : Int32 #

[View source]