class
Tessell::Text::FtMeasurer
- Tessell::Text::FtMeasurer
- Tessell::Text::Measurer
- Reference
- Object
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.crtessell/text/rasterizer.cr
Constructors
Class Method Summary
- .available? : Bool
-
.face_family(path : String, index : Int32) : String | Nil
path[index] 的 family(issue #55):临时 FT face 读 sfnt name 表, 用完即释放(done_face → done_free_type),不产生持有资源的构造。
-
.num_faces_of(path : String) : Int32
path 的 face 集合数(issue #55);文件不存在或打开失败返回 0。
-
.sfnt_family_of(face : FT::Lib::Face) : String | Nil
sfnt name 表读 family:nameID 16 优先、退 nameID 1;记录按 (3,1,0x409) > (0,) > (3,) > (1,0) 打分取最高,未命中返回 nil。
- .unavailable_reason : String | Nil
Instance Method Summary
- #close : Nil
- #closed? : Bool
-
#covers?(text : String) : Bool
cmap 覆盖检测(issue #7):text 的每个码点在当前 face 的 cmap 中 都有非零 glyph id 才返回 true。FontStack 按它选脸,零 FFI 新声明。
-
#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)。
- #finalize
-
#font_metrics(font_id : Int32, size : Float32) : FontMetrics
字体度量(issue #6):读 FT size metrics(26.6 定点 → px)。
- #ft_face_handle : FT::Lib::Face
- #hb_buffer_handle : HB::Lib::Buffer
- #hb_font_handle : HB::Lib::Font
- #last_error : String | Nil
-
#measure(text : String, font_id : Int32, size : Float32, max_width : Float32) : Size
实现 Measurer 接口:font_id 被忽略(本实例绑定单一 face) 断行口径唯一来源 Text.reflow_run(issue #56:与 CachingMeasurer L2 reflow 共用,两条路径几何一致)。
- #measure_calls : Int32
-
#num_faces : Int32
face 集合数(issue #55):.ttc/.otc 是容器不是单 face;单 face 文件为 1。
-
#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 验证
-
#shape_run(text : String, font_id : Int32, size : Float32) : ShapeRun | Nil
宽度无关 shaping(issue #56 L2):advance 序列(px,含与 measure 相同的零 advance 回退口径)+ 行高(px)。不支持/失败返回 nil。
- #upem_value : Int32
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) : Sizemeasure(key : MeasureKey) : Size measure, shape_run(text : String, font_id : Int32, size : Float32) : ShapeRun | Nil shape_run
Constructor Detail
Class Method Detail
path[index] 的 family(issue #55):临时 FT face 读 sfnt name 表, 用完即释放(done_face → done_free_type),不产生持有资源的构造。
sfnt name 表读 family:nameID 16 优先、退 nameID 1;记录按 (3,1,0x409) > (0,) > (3,) > (1,0) 打分取最高,未命中返回 nil。
Instance Method Detail
cmap 覆盖检测(issue #7):text 的每个码点在当前 face 的 cmap 中 都有非零 glyph id 才返回 true。FontStack 按它选脸,零 FFI 新声明。
集合内第 index 张 face 的 family(issue #55):读 sfnt name 表, nameID 16(typographic family)优先、退 nameID 1;无 name 表或 打开失败返回 nil(调用方退回 index 0 并 warning)。
字体度量(issue #6):读 FT size metrics(26.6 定点 → px)。
实现 Measurer 接口:font_id 被忽略(本实例绑定单一 face) 断行口径唯一来源 Text.reflow_run(issue #56:与 CachingMeasurer L2 reflow 共用,两条路径几何一致)。
测量辅助:返回 HB shaping 的 glyph ids 与 x_advances(px) 供 spec 验证
宽度无关 shaping(issue #56 L2):advance 序列(px,含与 measure 相同的零 advance 回退口径)+ 行高(px)。不支持/失败返回 nil。