#ui/font
Xu 0.13.1 API
导入方式: #ui/font
公开 API: 15 函数, 31 方法, 19 类型, 3 常量, 0 方法集
标准库包 `#ui/font`。
struct AtlasEntry
pub struct AtlasEntry {
pub font_id int
pub glyph_id int
pub px_size_q int
pub x int
pub y int
pub w int
pub h int
pub offset_x int
pub offset_y int
pub advance_x f64
pub u0 f64
pub v0 f64
pub u1 f64
pub v1 f64
pub has_ink bool
}
用途
承载 font_id、glyph_id、px_size_q、x、y 等属性的结构体。
公开字段
font_id int- 字段(int)
glyph_id int- 字段(int)
px_size_q int- 字段(int)
x int- 值
y int- 值
w int- 写入侧 / 宽度
h int- 高度或句柄
offset_x int- 字段(int)
offset_y int- 字段(int)
advance_x f64- 字段(f64)
u0 f64- 字段(f64)
v0 f64- 字段(f64)
u1 f64- 字段(f64)
v1 f64- 字段(f64)
has_ink bool- 字段(bool)
struct GlyphAtlas
pub struct GlyphAtlas {
pub width int
pub height int
pub max_width int
pub max_height int
pub revision int
pub pixels []u8
pub entries []AtlasEntry
}
用途
承载 width、height、max_width、max_height、revision 等属性的结构体。
公开字段
width int- 字段(int)
height int- 字段(int)
max_width int- 字段(int)
max_height int- 字段(int)
revision int- 字段(int)
pixels []u8- 字段([]u8)
entries []AtlasEntry- 字段([]AtlasEntry)
quantize_px_size
pub fn quantize_px_size(px_size f64) int
用途
执行 quantize px size 操作。失败时抛出错误,调用方需处理或继续传播。
参数
px_size f64- px_size(f64)
返回值
int — 该类型的值
new_glyph_atlas
pub fn new_glyph_atlas(width int, height int, max_width int, max_height int) GlyphAtlas
用途
构造 glyph atlas。失败时抛出错误,调用方需处理或继续传播。
参数
width int- width(int)
height int- height(int)
max_width int- max_width(int)
max_height int- max_height(int)
返回值
GlyphAtlas — 该类型的值
default_glyph_atlas
pub fn default_glyph_atlas() GlyphAtlas
用途
执行 default glyph atlas 操作。失败时抛出错误,调用方需处理或继续传播。
参数
无需传入参数。
返回值
GlyphAtlas — 该类型的值
($&GlyphAtlas) clear
pub fn (atlas $&GlyphAtlas) clear()
用途
清空所有已缓冲或存储的数据项与内部状态。
参数
atlas $&GlyphAtlas- 本次调用使用的
GlyphAtlas 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
返回值
不返回值。
(&GlyphAtlas) entry_index
pub fn (atlas &GlyphAtlas) entry_index(font_id int, glyph_id int, px_size f64) int
用途
&GlyphAtlas 上的操作:执行 entry index 操作。未找到返回 -1。
参数
atlas &GlyphAtlas- 本次调用使用的
GlyphAtlas 实例;以只读借用传入,调用方仍持有实例。
font_id int- font_id(int)
glyph_id int- glyph_id(int)
px_size f64- px_size(f64)
返回值
int — 索引值;有效范围和特殊值见用途说明
($&GlyphAtlas) insert_bitmap
pub fn (atlas $&GlyphAtlas) insert_bitmap(glyph ResolvedGlyph, px_size f64, bmp &GlyphBitmap) AtlasEntry
用途
$&GlyphAtlas 上的操作:执行 insert bitmap 操作。失败时抛出错误,调用方需处理或继续传播。
参数
atlas $&GlyphAtlas- 本次调用使用的
GlyphAtlas 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
glyph ResolvedGlyph- glyph(ResolvedGlyph)
px_size f64- px_size(f64)
bmp &GlyphBitmap- bmp(只读借用,调用方仍持有原值;类型 &GlyphBitmap)
返回值
AtlasEntry — 该类型的值
($&GlyphAtlas) get_or_rasterize
pub fn (atlas $&GlyphAtlas) get_or_rasterize(stack &FontStack, glyph ResolvedGlyph, px_size f64) AtlasEntry
用途
$&GlyphAtlas 上的操作:读取 or rasterize。失败时抛出错误,调用方需处理或继续传播。
参数
atlas $&GlyphAtlas- 本次调用使用的
GlyphAtlas 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
stack &FontStack- stack(只读借用,调用方仍持有原值;类型 &FontStack)
glyph ResolvedGlyph- glyph(ResolvedGlyph)
px_size f64- px_size(f64)
返回值
AtlasEntry — 该类型的值
($&GlyphAtlas) get_codepoint
pub fn (atlas $&GlyphAtlas) get_codepoint(stack &FontStack, codepoint int, px_size f64) AtlasEntry
用途
$&GlyphAtlas 上的操作:读取 codepoint。失败时抛出错误,调用方需处理或继续传播。
参数
atlas $&GlyphAtlas- 本次调用使用的
GlyphAtlas 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
stack &FontStack- stack(只读借用,调用方仍持有原值;类型 &FontStack)
codepoint int- codepoint(int)
px_size f64- px_size(f64)
返回值
AtlasEntry — 该类型的值
(&GlyphAtlas) entry_count
pub fn (atlas &GlyphAtlas) entry_count() int
用途
&GlyphAtlas 上的操作:执行 entry count 操作。
参数
atlas &GlyphAtlas- 本次调用使用的
GlyphAtlas 实例;以只读借用传入,调用方仍持有实例。
返回值
int — 该类型的值
(&GlyphAtlas) sample_alpha
pub fn (atlas &GlyphAtlas) sample_alpha(px int, py int) int
用途
&GlyphAtlas 上的操作:执行 sample alpha 操作。
参数
atlas &GlyphAtlas- 本次调用使用的
GlyphAtlas 实例;以只读借用传入,调用方仍持有实例。
px int- px(int)
py int- py(int)
返回值
int — 该类型的值
(&GlyphAtlas) to_rgba8_white
pub fn (atlas &GlyphAtlas) to_rgba8_white() []u8
用途
&GlyphAtlas 上的操作:转换为 rgba8 white。
参数
atlas &GlyphAtlas- 本次调用使用的
GlyphAtlas 实例;以只读借用传入,调用方仍持有实例。
返回值
[]u8 — 切片结果
builtin_font
pub fn builtin_font(face_id int) FontFace
用途
执行 builtin font 操作。
参数
face_id int- face_id(int)
返回值
FontFace — 该类型的值
builtin_glyph_index
pub fn builtin_glyph_index(codepoint int) int
用途
执行 builtin glyph index 操作。
参数
codepoint int- codepoint(int)
返回值
int — 索引值;有效范围和特殊值见用途说明
builtin_glyph_metrics
pub fn builtin_glyph_metrics(glyph_id int) GlyphMetrics
用途
执行 builtin glyph metrics 操作。
参数
glyph_id int- glyph_id(int)
返回值
GlyphMetrics — 该类型的值
builtin_glyph_outline
pub fn builtin_glyph_outline(glyph_id int) GlyphOutline
用途
执行 builtin glyph outline 操作。
参数
glyph_id int- glyph_id(int)
返回值
GlyphOutline — 该类型的值
const TEXT_LEFT
用途
常量 TEXT_LEFT,定义了相关的协议或算法配置参数。
const TEXT_CENTER
pub const TEXT_CENTER = 1
用途
常量 TEXT_CENTER,定义了相关的协议或算法配置参数。
const TEXT_RIGHT
用途
常量 TEXT_RIGHT,定义了相关的协议或算法配置参数。
struct LayoutOptions
pub struct LayoutOptions {
pub size f64
pub width f64
pub align int
pub line_height f64
pub masked bool
pub disable_kerning bool
}
用途
Font 配置参数与选项集合。
公开字段
size f64- 字段(f64)
width f64- 字段(f64)
align int- 字段(int)
line_height f64- 字段(f64)
masked bool- 字段(bool)
disable_kerning bool- 字段(bool)
default_options
pub fn default_options(size f64) LayoutOptions
用途
执行 default options 操作。
参数
size f64- size(f64)
返回值
LayoutOptions — 该类型的值
wrapped_options
pub fn wrapped_options(size f64, width f64, align int) LayoutOptions
用途
执行 wrapped options 操作。
参数
size f64- size(f64)
width f64- width(f64)
align int- align(int)
返回值
LayoutOptions — 该类型的值
struct TextMetrics
pub struct TextMetrics {
pub width f64
pub height f64
pub baseline f64
pub lines int
pub ink_x f64
pub ink_y f64
pub ink_width f64
pub ink_height f64
}
用途
承载 width、height、baseline、lines、ink_x 等属性的结构体。
公开字段
width f64- 字段(f64)
height f64- 字段(f64)
baseline f64- 字段(f64)
lines int- 字段(int)
ink_x f64- 字段(f64)
ink_y f64- 字段(f64)
ink_width f64- 字段(f64)
ink_height f64- 字段(f64)
struct TextHit
pub struct TextHit {
pub index int
pub length int
pub trailing bool
pub inside bool
pub x f64
pub y f64
pub height f64
}
用途
承载 index、length、trailing、inside、x 等属性的结构体。
公开字段
index int- 字段(int)
length int- 字段(int)
trailing bool- 字段(bool)
inside bool- 字段(bool)
x f64- 值
y f64- 值
height f64- 字段(f64)
(&TextHit) byte_index
pub fn (hit &TextHit) byte_index() int
用途
&TextHit 上的操作:执行 byte index 操作。
参数
hit &TextHit- 本次调用使用的
TextHit 实例;以只读借用传入,调用方仍持有实例。
返回值
int — 索引值;有效范围和特殊值见用途说明
struct TextRect
pub struct TextRect {
pub x f64
pub y f64
pub width f64
pub height f64
}
用途
承载 x、y、width、height 等属性的结构体。
公开字段
x f64- 值
y f64- 值
width f64- 字段(f64)
height f64- 字段(f64)
struct PositionedGlyph
pub struct PositionedGlyph {
pub byte_index int
pub byte_length int
pub codepoint int
pub render_codepoint int
pub face_index int
pub font_id int
pub glyph_id int
pub x f64
pub y f64
pub baseline_y f64
pub advance f64
pub line_index int
pub is_newline bool
pub is_space bool
}
用途
承载 byte_index、byte_length、codepoint、render_codepoint、face_index 等属性的结构体。
公开字段
byte_index int- 字段(int)
byte_length int- 字段(int)
codepoint int- 字段(int)
render_codepoint int- 字段(int)
face_index int- 字段(int)
font_id int- 字段(int)
glyph_id int- 字段(int)
x f64- 值
y f64- 值
baseline_y f64- 字段(f64)
advance f64- 字段(f64)
line_index int- 字段(int)
is_newline bool- 字段(bool)
is_space bool- 字段(bool)
struct LineBox
pub struct LineBox {
pub line_index int
pub start_item int
pub end_item int
pub byte_start int
pub byte_end int
pub byte_end_with_newline int
pub x f64
pub y f64
pub baseline_y f64
pub width f64
pub height f64
}
用途
承载 line_index、start_item、end_item、byte_start、byte_end 等属性的结构体。
公开字段
line_index int- 字段(int)
start_item int- 字段(int)
end_item int- 字段(int)
byte_start int- 字段(int)
byte_end int- 字段(int)
byte_end_with_newline int- 字段(int)
x f64- 值
y f64- 值
baseline_y f64- 字段(f64)
width f64- 字段(f64)
height f64- 字段(f64)
struct TextLayout
pub struct TextLayout {
pub metrics TextMetrics
pub size f64
pub width f64
pub align int
pub line_height f64
pub text_len int
pub masked bool
pub glyphs []PositionedGlyph
pub lines []LineBox
}
用途
承载 metrics、size、width、align、line_height 等属性的结构体。
公开字段
metrics TextMetrics- 字段(TextMetrics)
size f64- 字段(f64)
width f64- 字段(f64)
align int- 字段(int)
line_height f64- 字段(f64)
text_len int- 字段(int)
masked bool- 字段(bool)
glyphs []PositionedGlyph- 字段([]PositionedGlyph)
lines []LineBox- 字段([]LineBox)
layout_text
pub fn layout_text(stack &FontStack, text &string, options &LayoutOptions) TextLayout
用途
执行 layout text 操作。失败时抛出错误,调用方需处理或继续传播。
参数
stack &FontStack- stack(只读借用,调用方仍持有原值;类型 &FontStack)
text &string- 文本(只读借用,调用方仍持有原值;类型 &string)
options &LayoutOptions- options(只读借用,调用方仍持有原值;类型 &LayoutOptions)
返回值
TextLayout — 该类型的值
(&TextLayout) glyph_count
pub fn (layout &TextLayout) glyph_count() int
用途
&TextLayout 上的操作:执行 glyph count 操作。
参数
layout &TextLayout- 本次调用使用的
TextLayout 实例;以只读借用传入,调用方仍持有实例。
返回值
int — 该类型的值
(&TextLayout) glyph_at
pub fn (layout &TextLayout) glyph_at(i int) PositionedGlyph
用途
&TextLayout 上的操作:执行 glyph at 操作。
参数
layout &TextLayout- 本次调用使用的
TextLayout 实例;以只读借用传入,调用方仍持有实例。
i int- 下标或整数(int)
返回值
PositionedGlyph — 该类型的值
(&TextLayout) line_count
pub fn (layout &TextLayout) line_count() int
用途
&TextLayout 上的操作:执行 line count 操作。
参数
layout &TextLayout- 本次调用使用的
TextLayout 实例;以只读借用传入,调用方仍持有实例。
返回值
int — 该类型的值
(&TextLayout) line_at
pub fn (layout &TextLayout) line_at(i int) LineBox
用途
&TextLayout 上的操作:执行 line at 操作。
参数
layout &TextLayout- 本次调用使用的
TextLayout 实例;以只读借用传入,调用方仍持有实例。
i int- 下标或整数(int)
返回值
LineBox — 该类型的值
(&TextLayout) populate_atlas
pub fn (layout &TextLayout) populate_atlas(atlas $&GlyphAtlas, stack &FontStack) int
用途
&TextLayout 上的操作:执行 populate atlas 操作。失败时抛出错误,调用方需处理或继续传播。
参数
layout &TextLayout- 本次调用使用的
TextLayout 实例;以只读借用传入,调用方仍持有实例。
atlas $&GlyphAtlas- atlas(独占借用,可修改原值;类型 $&GlyphAtlas)
stack &FontStack- stack(只读借用,调用方仍持有原值;类型 &FontStack)
返回值
int — 该类型的值
(&TextLayout) caret
pub fn (layout &TextLayout) caret(byte_index int, trailing bool) TextHit
用途
在 &TextLayout 上执行 caret 操作。失败时抛出错误,调用方需处理或继续传播。
参数
layout &TextLayout- 本次调用使用的
TextLayout 实例;以只读借用传入,调用方仍持有实例。
byte_index int- byte_index(int)
trailing bool- trailing(bool)
返回值
TextHit — 该类型的值
(&TextLayout) hit_test
pub fn (layout &TextLayout) hit_test(x f64, y f64) TextHit
用途
&TextLayout 上的操作:执行 hit test 操作。失败时抛出错误,调用方需处理或继续传播。
参数
layout &TextLayout- 本次调用使用的
TextLayout 实例;以只读借用传入,调用方仍持有实例。
x f64- 值(f64)
y f64- 值(f64)
返回值
TextHit — 该类型的值
(&TextLayout) selection_rects
pub fn (layout &TextLayout) selection_rects(start_byte int, end_byte int) []TextRect
用途
&TextLayout 上的操作:执行 selection rects 操作。失败时抛出错误,调用方需处理或继续传播。
参数
layout &TextLayout- 本次调用使用的
TextLayout 实例;以只读借用传入,调用方仍持有实例。
start_byte int- start_byte(int)
end_byte int- end_byte(int)
返回值
[]TextRect — 切片结果
struct GlyphBitmap
pub struct GlyphBitmap {
pub width int
pub height int
pub offset_x int
pub offset_y int
pub advance_x f64
pub pixels []u8
}
用途
承载 width、height、offset_x、offset_y、advance_x 等属性的结构体。
公开字段
width int- 字段(int)
height int- 字段(int)
offset_x int- 字段(int)
offset_y int- 字段(int)
advance_x f64- 字段(f64)
pixels []u8- 字段([]u8)
rasterize_outline
pub fn rasterize_outline(outline &GlyphOutline, px_size f64) GlyphBitmap
用途
执行 rasterize outline 操作。失败时抛出错误,调用方需处理或继续传播。
参数
outline &GlyphOutline- outline(只读借用,调用方仍持有原值;类型 &GlyphOutline)
px_size f64- px_size(f64)
返回值
GlyphBitmap — 该类型的值
struct ResolvedGlyph
pub struct ResolvedGlyph {
pub face_index int
pub font_id int
pub glyph_id int
}
用途
承载 face_index、font_id、glyph_id 等属性的结构体。
公开字段
face_index int- 字段(int)
font_id int- 字段(int)
glyph_id int- 字段(int)
struct LineMetrics
pub struct LineMetrics {
pub ascent f64
pub descent f64
pub line_gap f64
pub line_height f64
}
用途
承载 ascent、descent、line_gap、line_height 等属性的结构体。
公开字段
ascent f64- 字段(f64)
descent f64- 字段(f64)
line_gap f64- 字段(f64)
line_height f64- 字段(f64)
struct FontStack
pub struct FontStack {
pub faces []FontFace
}
用途
承载 faces 等属性的结构体。
公开字段
faces []FontFace- 字段([]FontFace)
new_font_stack
pub fn new_font_stack() FontStack
用途
构造 font stack。
参数
无需传入参数。
返回值
FontStack — 该类型的值
($&FontStack) add_face
pub fn (stack $&FontStack) add_face(face FontFace) int
用途
$&FontStack 上的操作:执行 add face 操作。
参数
stack $&FontStack- 本次调用使用的
FontStack 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
face FontFace- face(FontFace)
返回值
int — 该类型的值
($&FontStack) ensure_builtin_fallback
pub fn (stack $&FontStack) ensure_builtin_fallback(face_id int) int
用途
$&FontStack 上的操作:执行 ensure builtin fallback 操作。
参数
stack $&FontStack- 本次调用使用的
FontStack 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
face_id int- face_id(int)
返回值
int — 该类型的值
(&FontStack) face_count
pub fn (stack &FontStack) face_count() int
用途
&FontStack 上的操作:执行 face count 操作。
参数
stack &FontStack- 本次调用使用的
FontStack 实例;以只读借用传入,调用方仍持有实例。
返回值
int — 该类型的值
(&FontStack) clone
pub fn (stack &FontStack) clone() FontStack
用途
&FontStack 上的操作:拷贝一份独立的 string。
参数
stack &FontStack- 本次调用使用的
FontStack 实例;以只读借用传入,调用方仍持有实例。
返回值
FontStack — 该类型的值
(&FontStack) line_metrics
pub fn (stack &FontStack) line_metrics(px_size f64) LineMetrics
用途
&FontStack 上的操作:执行 line metrics 操作。失败时抛出错误,调用方需处理或继续传播。
参数
stack &FontStack- 本次调用使用的
FontStack 实例;以只读借用传入,调用方仍持有实例。
px_size f64- px_size(f64)
返回值
LineMetrics — 该类型的值
(&FontStack) resolve
pub fn (stack &FontStack) resolve(codepoint int) ResolvedGlyph
用途
&FontStack 上的操作:解析。失败时抛出错误,调用方需处理或继续传播。
参数
stack &FontStack- 本次调用使用的
FontStack 实例;以只读借用传入,调用方仍持有实例。
codepoint int- codepoint(int)
返回值
ResolvedGlyph — 该类型的值
(&FontStack) advance_px
pub fn (stack &FontStack) advance_px(glyph ResolvedGlyph, px_size f64) f64
用途
&FontStack 上的操作:执行 advance px 操作。失败时抛出错误,调用方需处理或继续传播。
参数
stack &FontStack- 本次调用使用的
FontStack 实例;以只读借用传入,调用方仍持有实例。
glyph ResolvedGlyph- glyph(ResolvedGlyph)
px_size f64- px_size(f64)
返回值
f64 — 该类型的值
(&FontStack) kerning_px
pub fn (stack &FontStack) kerning_px(left ResolvedGlyph, right ResolvedGlyph, px_size f64) f64
用途
&FontStack 上的操作:执行 kerning px 操作。
参数
stack &FontStack- 本次调用使用的
FontStack 实例;以只读借用传入,调用方仍持有实例。
left ResolvedGlyph- left(ResolvedGlyph)
right ResolvedGlyph- right(ResolvedGlyph)
px_size f64- px_size(f64)
返回值
f64 — 该类型的值
(&FontStack) rasterize
pub fn (stack &FontStack) rasterize(glyph ResolvedGlyph, px_size f64) GlyphBitmap
用途
在 &FontStack 上执行 rasterize 操作。失败时抛出错误,调用方需处理或继续传播。
参数
stack &FontStack- 本次调用使用的
FontStack 实例;以只读借用传入,调用方仍持有实例。
glyph ResolvedGlyph- glyph(ResolvedGlyph)
px_size f64- px_size(f64)
返回值
GlyphBitmap — 该类型的值
struct FontMetrics
pub struct FontMetrics {
pub units_per_em int
pub ascent int
pub descent int
pub line_gap int
pub x_min int
pub y_min int
pub x_max int
pub y_max int
pub num_glyphs int
}
用途
承载 units_per_em、ascent、descent、line_gap、x_min 等属性的结构体。
公开字段
units_per_em int- 字段(int)
ascent int- 字段(int)
descent int- 字段(int)
line_gap int- 字段(int)
x_min int- 字段(int)
y_min int- 字段(int)
x_max int- 字段(int)
y_max int- 字段(int)
num_glyphs int- 字段(int)
struct GlyphMetrics
pub struct GlyphMetrics {
pub glyph_id int
pub advance_width int
pub left_side_bearing int
}
用途
承载 glyph_id、advance_width、left_side_bearing 等属性的结构体。
公开字段
glyph_id int- 字段(int)
advance_width int- 字段(int)
left_side_bearing int- 字段(int)
struct ContourPoint
pub struct ContourPoint {
pub x f64
pub y f64
pub on_curve bool
}
用途
承载 x、y、on_curve 等属性的结构体。
公开字段
x f64- 值
y f64- 值
on_curve bool- 字段(bool)
struct GlyphOutline
pub struct GlyphOutline {
pub points []ContourPoint
pub contour_ends []int
pub units_per_em f64
pub advance_width f64
pub left_side_bearing f64
pub x_min f64
pub y_min f64
pub x_max f64
pub y_max f64
}
用途
承载 points、contour_ends、units_per_em、advance_width、left_side_bearing 等属性的结构体。
公开字段
points []ContourPoint- 字段([]ContourPoint)
contour_ends []int- 字段([]int)
units_per_em f64- 字段(f64)
advance_width f64- 字段(f64)
left_side_bearing f64- 字段(f64)
x_min f64- 字段(f64)
y_min f64- 字段(f64)
x_max f64- 字段(f64)
y_max f64- 字段(f64)
struct KernPair
pub struct KernPair {
pub key int
pub value int
}
用途
承载 key、value 等属性的结构体。
公开字段
key int- 键
value int- 字段(int)
struct FontFace
pub struct FontFace {
pub id int
pub metrics FontMetrics
pub is_builtin bool
}
用途
承载 id、metrics、is_builtin 等属性的结构体。
公开字段
id int- 字段(int)
metrics FontMetrics- 字段(FontMetrics)
is_builtin bool- 字段(bool)
(&FontFace) clone
pub fn (face &FontFace) clone() FontFace
用途
&FontFace 上的操作:拷贝一份独立的 string。
参数
face &FontFace- 本次调用使用的
FontFace 实例;以只读借用传入,调用方仍持有实例。
返回值
FontFace — 该类型的值
bytes_from_string
pub fn bytes_from_string(s &string) []u8
用途
字节从字符串。
参数
s &string- 源字符串(只读借用,调用方仍持有原值;类型 &string)
返回值
[]u8 — 切片结果
ttc_font_count
pub fn ttc_font_count(data &[]u8) int
用途
执行 ttc font count 操作。失败时抛出错误,调用方需处理或继续传播。
参数
data &[]u8- 数据(只读借用,调用方仍持有原值;类型 &[]u8)
返回值
int — 该类型的值
parse_ttf
pub fn parse_ttf(data &[]u8, font_index int, face_id int) FontFace
用途
解析为 ttf。失败时抛出错误,调用方需处理或继续传播。
参数
data &[]u8- 数据(只读借用,调用方仍持有原值;类型 &[]u8)
font_index int- font_index(int)
face_id int- face_id(int)
返回值
FontFace — 该类型的值
(&FontFace) glyph_index
pub fn (face &FontFace) glyph_index(codepoint int) int
用途
&FontFace 上的操作:执行 glyph index 操作。
参数
face &FontFace- 本次调用使用的
FontFace 实例;以只读借用传入,调用方仍持有实例。
codepoint int- codepoint(int)
返回值
int — 索引值;有效范围和特殊值见用途说明
(&FontFace) glyph_metrics
pub fn (face &FontFace) glyph_metrics(glyph_id int) GlyphMetrics
用途
&FontFace 上的操作:执行 glyph metrics 操作。失败时抛出错误,调用方需处理或继续传播。
参数
face &FontFace- 本次调用使用的
FontFace 实例;以只读借用传入,调用方仍持有实例。
glyph_id int- glyph_id(int)
返回值
GlyphMetrics — 该类型的值
(&FontFace) kerning
pub fn (face &FontFace) kerning(left_gid int, right_gid int) int
用途
在 &FontFace 上执行 kerning 操作。
参数
face &FontFace- 本次调用使用的
FontFace 实例;以只读借用传入,调用方仍持有实例。
left_gid int- left_gid(int)
right_gid int- right_gid(int)
返回值
int — 该类型的值
(&FontFace) glyph_outline
pub fn (face &FontFace) glyph_outline(glyph_id int) GlyphOutline
用途
&FontFace 上的操作:执行 glyph outline 操作。失败时抛出错误,调用方需处理或继续传播。
参数
face &FontFace- 本次调用使用的
FontFace 实例;以只读借用传入,调用方仍持有实例。
glyph_id int- glyph_id(int)
返回值
GlyphOutline — 该类型的值