PDF-Font

本文详细介绍了MuPDF库中的字体系统,包括字体编码表、Unicode映射、FreeType接口、字体形状处理以及系统字体加载等功能。通过fz_font结构体展示了字体的各种属性和操作,如获取字体名称、 bbox、风格信息等。此外,还涵盖了自定义字体加载钩子和内置字体的加载方法。
摘要由CSDN通过智能技术生成

#ifndef MUPDF_FITZ_FONT_H
#define MUPDF_FITZ_FONT_H

#include “mupdf/fitz/system.h”
#include “mupdf/fitz/context.h”
#include “mupdf/fitz/geometry.h”
#include “mupdf/fitz/buffer.h”

/* forward declaration for circular dependency */
struct fz_device;

/* Various font encoding tables and lookup functions */

extern const char *fz_glyph_name_from_adobe_standard[256];
extern const char *fz_glyph_name_from_iso8859_7[256];
extern const char *fz_glyph_name_from_koi8u[256];
extern const char *fz_glyph_name_from_mac_expert[256];
extern const char *fz_glyph_name_from_mac_roman[256];
extern const char *fz_glyph_name_from_win_ansi[256];
extern const char *fz_glyph_name_from_windows_1252[256];

extern const unsigned short fz_unicode_from_iso8859_1[256];
extern const unsigned short fz_unicode_from_iso8859_7[256];
extern const unsigned short fz_unicode_from_koi8u[256];
extern const unsigned short fz_unicode_from_pdf_doc_encoding[256];
extern const unsigned short fz_unicode_from_windows_1250[256];
extern const unsigned short fz_unicode_from_windows_1251[256];
extern const unsigned short fz_unicode_from_windows_1252[256];

int fz_iso8859_1_from_unicode(int u);
int fz_iso8859_7_from_unicode(int u);
int fz_koi8u_from_unicode(int u);
int fz_windows_1250_from_unicode(int u);
int fz_windows_1251_from_unicode(int u);
int fz_windows_1252_from_unicode(int u);

int fz_unicode_from_glyph_name(const char *name);
int fz_unicode_from_glyph_name_strict(const char *name);
const char **fz_duplicate_glyph_names_from_unicode(int unicode);
const char *fz_glyph_name_from_unicode_sc(int unicode);

/**
An abstract font handle.
*/
typedef struct fz_font fz_font;

/**
Fonts come in two variants:
Regular fonts are handled by FreeType.
Type 3 fonts have callbacks to the interpreter.
字体有两种变体:
常规字体由 FreeType 处理。
Type 3 字体具有对解释器的回调。
*/

/**
Retrieve the FT_Face handle
for the font.

font: The font to query

Returns the FT_Face handle for the font, or NULL
if not a freetype handled font. (Cast to void *
to avoid nasty header exposure).

检索 FT_Face 句柄
对于字体。

字体:要查询的字体

返回字体的 FT_Face 句柄,或 NULL
如果不是freetype处理字体。 (强制转换为无效 *
以避免令人讨厌的标题暴露)。

*/
void *fz_font_ft_face(fz_context *ctx, fz_font *font);

/**
Retrieve the Type3 procs
for a font.

font: The font to query

Returns the t3_procs pointer. Will be NULL for a
non type-3 font.
检索 Type3 过程
对于字体。

字体:要查询的字体

返回 t3_procs 指针。 将为 NULL
非 type-3 字体。

*/
fz_buffer **fz_font_t3_procs(fz_context *ctx, fz_font *font);

/* common CJK font collections */
enum { FZ_ADOBE_CNS, FZ_ADOBE_GB, FZ_ADOBE_JAPAN, FZ_ADOBE_KOREA };

/**
Every fz_font carries a set of flags
within it, in a fz_font_flags_t structure.
每个 fz_font 带有一组标志在其中,在 fz_font_flags_t 结构中。
/
typedef struct
{
unsigned int is_mono : 1;
unsigned int is_serif : 1;
unsigned int is_bold : 1;
unsigned int is_italic : 1;
unsigned int ft_substitute : 1; /
use substitute metrics /
unsigned int ft_stretch : 1; /
stretch to match PDF metrics */

unsigned int fake_bold : 1; /* synthesize bold */
unsigned int fake_italic : 1; /* synthesize italic */
unsigned int has_opentype : 1; /* has opentype shaping tables */
unsigned int invalid_bbox : 1;

} fz_font_flags_t;

/**
Retrieve a pointer to the font flags
for a given font. These can then be updated as required.

font: The font to query

Returns a pointer to the flags structure (or NULL, if
the font is NULL).
检索指向字体标志的指针
对于给定的字体。 然后可以根据需要更新这些。

字体:要查询的字体

返回一个指向标志结构的指针(或 NULL,如果
字体为 NULL)。

*/
fz_font_flags_t *fz_font_flags(fz_font *font);

/**
In order to shape a given font, we need to
declare it to a shaper library (harfbuzz, by default, but others
are possible). To avoid redeclaring it every time we need to
shape, we hold a shaper handle and the destructor for it within
the font itself. The handle is initialised by the caller when
first required and the destructor is called when the fz_font is
destroyed.
为了塑造给定的字体,我们需要
将其声明为 shaper 库(默认情况下为 harfbuzz,但其他人
是可能的)。 为了避免每次我们需要重新声明它
shape,我们持有一个 shaper 句柄和它的析构函数
字体本身。 句柄由调用者初始化,当
首先需要,当 fz_font 是析构函数时调用
摧毁了。
*/
typedef struct
{
void *shaper_handle;
void (*destroy)(fz_context *ctx, void ); / Destructor for shape_handle */
} fz_shaper_data_t;

/**
Retrieve a pointer to the shaper data
structure for the given font.

font: The font to query.

Returns a pointer to the shaper data structure (or NULL if
font is NULL).

检索指向 shaper 数据的指针
给定字体的结构。

字体:要查询的字体。

返回指向 shaper 数据结构的指针(或 NULL,如果
字体为空)

*/
fz_shaper_data_t *fz_font_shaper_data(fz_context *ctx, fz_font *font);

/**
Retrieve a pointer to the name of the font.

font: The font to query.

Returns a pointer to an internal copy of the font name.
Will never be NULL, but may be the empty string.

*/
const char *fz_font_name(fz_context *ctx, fz_font *font);

/**
Query whether the font flags say that this font is bold.
查询字体标志是否表示该字体为粗体。
*/
int fz_font_is_bold(fz_context *ctx, fz_font *font);

/**
Query whether the font flags say that this font is italic.
查询字体标志是否表示该字体为斜体。
*/
int fz_font_is_italic(fz_context *ctx, fz_font *font);

/**
Query whether the font flags say that this font is serif.
查询字体标志是否表示此字体为 serif。
*/
int fz_font_is_serif(fz_context *ctx, fz_font *font);

/**
Query whether the font flags say that this font is monospaced.
查询字体标志是否表示该字体是等宽的。
*/
int fz_font_is_monospaced(fz_context *ctx, fz_font *font);

/**
Retrieve a pointer to the font bbox.

font: The font to query.

Returns a pointer to the font bbox (or NULL if the
font is NULL).
检索指向字体 bbox 的指针。

字体:要查询的字体。

返回指向字体 bbox 的指针(如果
字体为空)。

*/
fz_rect fz_font_bbox(fz_context *ctx, fz_font *font);

/**
Type for user supplied system font loading hook.

name: The name of the font to load.

bold: 1 if a bold font desired, 0 otherwise.

italic: 1 if an italic font desired, 0 otherwise.
needs_exact_metrics: 1 if an exact metric match is required for
the font requested.

Returns a new font handle, or NULL if no font found (or on error).
用户提供的系统字体加载钩子的类型。

name:要加载的字体的名称。

粗体:如果需要粗体,则为 1,否则为 0。

斜体:如果需要斜体字体,则为 1,否则为 0。
Needs_exact_metrics: 1 如果需要精确的度量匹配
要求的字体。

返回一个新的字体句柄,如果没有找到字体(或出错),则返回 NULL。

*/
typedef fz_font *(fz_load_system_font_fn)(fz_context *ctx, const char *name, int bold, int italic, int needs_exact_metrics);

/**
Type for user supplied cjk font loading hook.

name: The name of the font to load.

ordering: The ordering for which to load the font (e.g.
FZ_ADOBE_KOREA)

serif: 1 if a serif font is desired, 0 otherwise.

Returns a new font handle, or NULL if no font found (or on error).
用户提供的 cjk 字体加载钩子的类型。

name:要加载的字体的名称。

ordering:加载字体的顺序(例如
FZ_ADOBE_KOREA)

serif:如果需要衬线字体,则为 1,否则为 0。

返回一个新的字体句柄,如果没有找到字体(或出错),则返回 NULL。

*/
typedef fz_font *(fz_load_system_cjk_font_fn)(fz_context *ctx, const char *name, int ordering, int serif);

/**
Type for user supplied fallback font loading hook.

name: The name of the font to load.

script: UCDN script enum.

language: FZ_LANG enum.

serif, bold, italic: boolean style flags.

Returns a new font handle, or NULL if no font found (or on error).
用户提供的后备字体加载钩子的类型。

name:要加载的字体的名称。

脚本:UCDN 脚本枚举。

语言:FZ_LANG 枚举。

衬线、粗体、斜体:布尔样式标志。

返回一个新的字体句柄,如果没有找到字体(或出错),则返回 NULL。

*/
typedef fz_font *(fz_load_system_fallback_font_fn)(fz_context *ctx, int script, int language, int serif, int bold, int italic);

/**
Install functions to allow MuPDF to request fonts from the
system.

Only one set of hooks can be in use at a time.
安装函数以允许 MuPDF 从系统。

一次只能使用一组挂钩。

*/
void fz_install_load_system_font_funcs(fz_context *ctx,
fz_load_system_font_fn *f,
fz_load_system_cjk_font_fn *f_cjk,
fz_load_system_fallback_font_fn *f_fallback);

/**
Attempt to load a given font from the system.

name: The name of the desired font.

bold: 1 if bold desired, 0 otherwise.

italic: 1 if italic desired, 0 otherwise.

needs_exact_metrics: 1 if an exact metrical match is required,
0 otherwise.

Returns a new font handle, or NULL if no matching font was found
(or on error).

尝试从系统加载给定的字体。

name:所需字体的名称。

粗体:如果需要加粗则为 1,否则为 0。

斜体:如果需要斜体,则为 1,否则为 0。

need_exact_metrics: 1 如果需要精确的度量匹配,
0 否则。

返回一个新的字体句柄,如果没有找到匹配的字体,则返回 NULL
(或错误)。

*/
fz_font *fz_load_system_font(fz_context *ctx, const char *name, int bold, int italic, int needs_exact_metrics);

/**
Attempt to load a given font from
the system.

name: The name of the desired font.

ordering: The ordering to load the font from (e.g. FZ_ADOBE_KOREA)

serif: 1 if serif desired, 0 otherwise.

Returns a new font handle, or NULL if no matching font was found
(or on error).

尝试从系统加载给定的字体。

name:所需字体的名称。

ordering:加载字体的顺序(例如 FZ_ADOBE_KOREA)

衬线:如果需要衬线则为 1,否则为 0。

返回一个新的字体句柄,如果没有找到匹配的字体,则返回 NULL
(或错误)。

*/
fz_font *fz_load_system_cjk_font(fz_context *ctx, const char *name, int ordering, int serif);

/**
Search the builtin fonts for a match.
Whether a given font is present or not will depend on the
configuration in which MuPDF is built.

name: The name of the font desired.

bold: 1 if bold desired, 0 otherwise.

italic: 1 if italic desired, 0 otherwise.

len: Pointer to a place to receive the length of the discovered
font buffer.

Returns a pointer to the font file data, or NULL if not present.

在内置字体中搜索匹配项。
给定的字体是否存在将取决于
构建 MuPDF 的配置。

名称:所需字体的名称。

粗体:如果需要加粗则为 1,否则为 0。

斜体:如果需要斜体,则为 1,否则为 0。

len:指向接收发现的长度的地方的指针
字体缓冲区。

返回指向字体文件数据的指针,如果不存在则返回 NULL。

*/
const unsigned char *fz_lookup_builtin_font(fz_context *ctx, const char *name, int bold, int italic, int *len);

/**
Search the builtin base14 fonts for a match.
Whether a given font is present or not will depend on the
configuration in which MuPDF is built.

name: The name of the font desired.

len: Pointer to a place to receive the length of the discovered
font buffer.

Returns a pointer to the font file data, or NULL if not present.

在内置的 base14 字体中搜索匹配项。
给定的字体是否存在将取决于
构建 MuPDF 的配置。

名称:所需字体的名称。

len:指向接收发现的长度的地方的指针
字体缓冲区。

返回指向字体文件数据的指针,如果不存在则返回 NULL。

*/
const unsigned char *fz_lookup_base14_font(fz_context *ctx, const char *name, int *len);

/**
Search the builtin cjk fonts for a match.
Whether a font is present or not will depend on the
configuration in which MuPDF is built.

ordering: The desired ordering of the font (e.g. FZ_ADOBE_KOREA).

len: Pointer to a place to receive the length of the discovered
font buffer.

Returns a pointer to the font file data, or NULL if not present.
搜索内置 cjk 字体以查找匹配项。
字体是否存在将取决于
构建 MuPDF 的配置。

ordering:所需的字体排序(例如 FZ_ADOBE_KOREA)。

len:指向接收发现的长度的地方的指针
字体缓冲区。

返回指向字体文件数据的指针,如果不存在则返回 NULL。

*/
const unsigned char *fz_lookup_cjk_font(fz_context *ctx, int ordering, int *len, int *index);

/**
Search the builtin cjk fonts for a match for a given language.
Whether a font is present or not will depend on the
configuration in which MuPDF is built.

lang: Pointer to a (case sensitive) language string (e.g.
"ja", "ko", "zh-Hant" etc).

len: Pointer to a place to receive the length of the discovered
font buffer.

subfont: Pointer to a place to store the subfont index of the
discovered font.

Returns a pointer to the font file data, or NULL if not present.

搜索内置 cjk 字体以查找给定语言的匹配项。
字体是否存在将取决于
构建 MuPDF 的配置。

lang:指向(区分大小写)语言字符串的指针(例如
“ja”、“ko”、“zh-Hant”等)。

len:指向接收发现的长度的地方的指针
字体缓冲区。

子字体:指向存储子字体索引的位置的指针
发现字体。

返回指向字体文件数据的指针,如果不存在则返回 NULL。

*/
const unsigned char *fz_lookup_cjk_font_by_language(fz_context *ctx, const char *lang, int *len, int *subfont);

/**
Return the matching FZ_ADOBE_* ordering
for the given language tag, such as “zh-Hant”, “zh-Hans”, “ja”, or “ko”.
返回匹配的 FZ_ADOBE_* 排序
对于给定的语言标签,例如“zh-Hant”、“zh-Hans”、“ja”或“ko”。
*/
int fz_lookup_cjk_ordering_by_language(const char *name);

/**
Search the builtin noto fonts for a match.
Whether a font is present or not will depend on the
configuration in which MuPDF is built.

script: The script desired (e.g. UCDN_SCRIPT_KATAKANA).

lang: The language desired (e.g. FZ_LANG_ja).

len: Pointer to a place to receive the length of the discovered
font buffer.

Returns a pointer to the font file data, or NULL if not present.
字体是否存在将取决于
构建 MuPDF 的配置。

脚本:所需的脚本(例如 UCDN_SCRIPT_KATAKANA)。

lang:所需的语言(例如 FZ_LANG_ja)。

len:指向接收发现的长度的地方的指针
字体缓冲区。

返回指向字体文件数据的指针,如果不存在则返回 NULL。

*/
const unsigned char *fz_lookup_noto_font(fz_context *ctx, int script, int lang, int *len, int *subfont);

/**
Search the builtin noto fonts specific symbol fonts.
Whether a font is present or not will depend on the
configuration in which MuPDF is built.
搜索内置 noto fonts 特定符号字体。
字体是否存在将取决于
构建 MuPDF 的配置。
*/
const unsigned char *fz_lookup_noto_math_font(fz_context *ctx, int *len);
const unsigned char *fz_lookup_noto_music_font(fz_context *ctx, int *len);
const unsigned char *fz_lookup_noto_symbol1_font(fz_context *ctx, int *len);
const unsigned char *fz_lookup_noto_symbol2_font(fz_context *ctx, int *len);
const unsigned char *fz_lookup_noto_emoji_font(fz_context *ctx, int *len);

/**
Try to load a fallback font for the
given combination of font attributes. Whether a font is
present or not will depend on the configuration in which
MuPDF is built.

script: The script desired (e.g. UCDN_SCRIPT_KATAKANA).

language: The language desired (e.g. FZ_LANG_ja).

serif: 1 if serif desired, 0 otherwise.

bold: 1 if bold desired, 0 otherwise.

italic: 1 if italic desired, 0 otherwise.

Returns a new font handle, or NULL if not available.
尝试为
给定的字体属性组合。 字体是否为
存在与否将取决于其中的配置
MuPDF 已构建。

脚本:所需的脚本(例如 UCDN_SCRIPT_KATAKANA)。

语言:所需的语言(例如 FZ_LANG_ja)。

衬线:如果需要衬线则为 1,否则为 0。

粗体:如果需要加粗则为 1,否则为 0。

斜体:如果需要斜体,则为 1,否则为 0。

返回一个新的字体句柄,如果不可用则返回 NULL。

*/
fz_font *fz_load_fallback_font(fz_context *ctx, int script, int language, int serif, int bold, int italic);

/**
Create a new (empty) type3 font.

name: Name of font (or NULL).

matrix: Font matrix.

Returns a new font handle, or throws exception on
allocation failure.
创建一个新的(空)type3 字体。

name:字体名称(或NULL)。

矩阵:字体矩阵。

返回一个新的字体句柄,或抛出异常
分配失败。

*/
fz_font *fz_new_type3_font(fz_context *ctx, const char *name, fz_matrix matrix);

/**
Create a new font from a font
file in memory.

name: Name of font (leave NULL to use name from font).

data: Pointer to the font file data.

len: Length of the font file data.

index: Which font from the file to load (0 for default).

use_glyph_box: 1 if we should use the glyph bbox, 0 otherwise.

Returns new font handle, or throws exception on error.

从字体创建新字体
内存中的文件。

name:字体名称(保留 NULL 以使用字体中的名称)。

data:指向字体文件数据的指针。

len:字体文件数据的长度。

索引:要加载文件中的字体(默认为 0)。

use_glyph_box: 如果我们应该使用字形 bbox,则为 1,否则为 0。

返回新的字体句柄,或在出错时抛出异常。

*/
fz_font *fz_new_font_from_memory(fz_context *ctx, const char *name, const unsigned char *data, int len, int index, int use_glyph_bbox);

/**
Create a new font from a font file in a fz_buffer.

name: Name of font (leave NULL to use name from font).

buffer: Buffer to load from.

index: Which font from the file to load (0 for default).

use_glyph_box: 1 if we should use the glyph bbox, 0 otherwise.

Returns new font handle, or throws exception on error.


从 fz_buffer 中的字体文件创建新字体。

name:字体名称(保留 NULL 以使用字体中的名称)。

缓冲区:要从中加载的缓冲区。

索引:要加载文件中的字体(默认为 0)。

use_glyph_box: 如果我们应该使用字形 bbox,则为 1,否则为 0。

返回新的字体句柄,或在出错时抛出异常。

*/
fz_font *fz_new_font_from_buffer(fz_context *ctx, const char *name, fz_buffer *buffer, int index, int use_glyph_bbox);

/**
Create a new font from a font file.

name: Name of font (leave NULL to use name from font).

path: File path to load from.

index: Which font from the file to load (0 for default).

use_glyph_box: 1 if we should use the glyph bbox, 0 otherwise.

Returns new font handle, or throws exception on error.

从字体文件创建新字体。

name:字体名称(保留 NULL 以使用字体中的名称)。

路径:要从中加载的文件路径。

索引:要加载文件中的字体(默认为 0)。

use_glyph_box: 如果我们应该使用字形 bbox,则为 1,否则为 0。

返回新的字体句柄,或在出错时抛出异常。

*/
fz_font *fz_new_font_from_file(fz_context *ctx, const char *name, const char *path, int index, int use_glyph_bbox);

/**
Create a new font from one of the built-in fonts.
从一种内置字体创建一种新字体。
*/
fz_font *fz_new_base14_font(fz_context *ctx, const char *name);
fz_font *fz_new_cjk_font(fz_context *ctx, int ordering);
fz_font *fz_new_builtin_font(fz_context *ctx, const char *name, int is_bold, int is_italic);

/**
Add a reference to an existing fz_font.

font: The font to add a reference to.

Returns the same font.
添加对现有 fz_font 的引用。

字体:要添加引用的字体。

返回相同的字体。

*/
fz_font *fz_keep_font(fz_context *ctx, fz_font *font);

/**
Drop a reference to a fz_font, destroying the
font when the last reference is dropped.

font: The font to drop a reference to.
删除对 fz_font 的引用,破坏
删除最后一个引用时的字体。

字体:要删除引用的字体。

*/
void fz_drop_font(fz_context *ctx, fz_font *font);

/**
Set the font bbox.

font: The font to set the bbox for.

xmin, ymin, xmax, ymax: The bounding box.

删除对 fz_font 的引用,破坏
删除最后一个引用时的字体。

字体:要删除引用的字体。

*/
void fz_set_font_bbox(fz_context *ctx, fz_font *font, float xmin, float ymin, float xmax, float ymax);

/**
Return a bbox for a given glyph in a font.

font: The font to look for the glyph in.

gid: The glyph to bound.

trm: The matrix to apply to the glyph before bounding.

r: Pointer to a fz_rect to use for storage.

Returns r, after filling it in with the bounds of the given
glyph.

为字体中的给定字形返回一个 bbox。

字体:要在其中查找字形的字体。

gid:要绑定的字形。

trm:在边界之前应用于字形的矩阵。

r:指向用于存储的 fz_rect 的指针。

用给定的边界填充后返回 r
字形。

*/
fz_rect fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm);

/**
Determine if a given glyph in a font
is cacheable. Certain glyphs in a type 3 font cannot safely
be cached, as their appearance depends on the enclosing
graphic state.

font: The font to look for the glyph in.

gif: The glyph to query.

Returns non-zero if cacheable, 0 if not.
确定字体中的给定字形
是可缓存的。 type 3 字体中的某些字形不能安全
被缓存,因为它们的外观取决于封闭的
图形状态。

字体:要在其中查找字形的字体。

gif:要查询的字形。

如果可缓存,则返回非零,否则返回 0。

*/
int fz_glyph_cacheable(fz_context *ctx, fz_font *font, int gid);

/**
Run a glyph from a Type3 font to
a given device.

font: The font to find the glyph in.

gid: The glyph to run.

trm: The transform to apply.

dev: The device to render onto.
从 Type3 字体运行字形到
给定的设备。

字体:要在其中查找字形的字体。

gid:要运行的字形。

trm:要应用的变换。

dev:要渲染的设备。

*/
void fz_run_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, struct fz_device *dev);

/**
Return the advance for a given glyph.

font: The font to look for the glyph in.

glyph: The glyph to find the advance for.

wmode: 1 for vertical mode, 0 for horizontal.

Returns the advance for the glyph.
返回给定字形的预付款。

字体:要在其中查找字形的字体。

字形:要查找的字形。

wmode:1 表示垂直模式,0 表示水平模式。

返回字形的提前。

*/
float fz_advance_glyph(fz_context *ctx, fz_font *font, int glyph, int wmode);

/**
Find the glyph id for a given unicode
character within a font.

font: The font to look for the unicode character in.

unicode: The unicode character to encode.

Returns the glyph id for the given unicode value, or 0 if
unknown.
查找给定 unicode 的字形 ID
字体中的字符。

字体:要在其中查找 unicode 字符的字体。

unicode:要编码的 unicode 字符。

返回给定 unicode 值的字形 ID,如果是,则返回 0

未知。
*/
int fz_encode_character(fz_context *ctx, fz_font *font, int unicode);

/**
Encode character, preferring small-caps variant if available.

font: The font to look for the unicode character in.

unicode: The unicode character to encode.

Returns the glyph id for the given unicode value, or 0 if
unknown.

编码字符,如果可用,更喜欢小型大写字母变体。

字体:要在其中查找 unicode 字符的字体。

unicode:要编码的 unicode 字符。

返回给定 unicode 值的字形 ID,如果是,则返回 0
未知。

*/
int fz_encode_character_sc(fz_context *ctx, fz_font *font, int unicode);

/**
Encode character.

Either by direct lookup of glyphname within a font, or, failing
that, by mapping glyphname to unicode and thence to the glyph
index within the given font.

Returns zero for type3 fonts.
编码字符。

通过在字体中直接查找字形名称,或者失败
那,通过将字形名称映射到 unicode,然后再映射到字形
给定字体中的索引。

type3 字体返回零

*/
int fz_encode_character_by_glyph_name(fz_context *ctx, fz_font *font, const char *glyphname);

/**
Find the glyph id for
a given unicode character within a font, falling back to
an alternative if not found.

font: The font to look for the unicode character in.

unicode: The unicode character to encode.

script: The script in use.

language: The language in use.

out_font: The font handle in which the given glyph represents
the requested unicode character. The caller does not own the
reference it is passed, so should call fz_keep_font if it is
not simply to be used immediately.

Returns the glyph id for the given unicode value in the supplied
font (and sets *out_font to font) if it is present. Otherwise
an alternative fallback font (based on script/language) is
searched for. If the glyph is found therein, *out_font is set
to this reference, and the glyph reference is returned. If it
cannot be found anywhere, the function returns 0.

查找字形 ID
字体中的给定 unicode 字符,回退到
如果没有找到替代方案。

字体:要在其中查找 unicode 字符的字体。

unicode:要编码的 unicode 字符。

脚本:正在使用的脚本。

语言:使用的语言。

out_font:给定字形代表的字体句柄
请求的 unicode 字符。 调用者不拥有
引用它被传递,所以应该调用 fz_keep_font 如果它是
不能简单地立即使用。

返回所提供的给定 unicode 值的字形 ID
字体(并将 *out_font 设置为字体)(如果存在)。 除此以外
另一种后备字体(基于脚本/语言)是
搜索。 如果在其中找到字形,则设置 *out_font
到此引用,并返回字形引用。 如果它
找不到任何地方,函数返回 0。

*/
int fz_encode_character_with_fallback(fz_context *ctx, fz_font *font, int unicode, int script, int language, fz_font **out_font);

/**
Find the name of a glyph

font: The font to look for the glyph in.

glyph: The glyph id to look for.

buf: Pointer to a buffer for the name to be inserted into.

size: The size of the buffer.

If a font contains a name table, then the name of the glyph
will be returned in the supplied buffer. Otherwise a name
is synthesised. The name will be truncated to fit in
the buffer.
查找字形的名称

字体:要在其中查找字形的字体。

字形:要查找的字形 ID。

buf:指向要插入名称的缓冲区的指针。

大小:缓冲区的大小。

如果字体包含名称表,则字形的名称
将在提供的缓冲区中返回。 否则一个名字
是合成的。 该名称将被截断以适应
缓冲区。

*/
void fz_get_glyph_name(fz_context *ctx, fz_font *font, int glyph, char *buf, int size);

/**
Retrieve font ascender in ems.
在 em 中检索字体上升器。
*/
float fz_font_ascender(fz_context *ctx, fz_font *font);

/**
Retrieve font descender in ems.
在 em 中检索字体下降器。
*/
float fz_font_descender(fz_context *ctx, fz_font *font);

/**
Retrieve the MD5 digest for the font’s data.
检索字体数据的 MD5 摘要。
*/
void fz_font_digest(fz_context *ctx, fz_font *font, unsigned char digest[16]);

/* Implementation details: subject to change.
实施细节:可能会发生变化。
*/

void fz_decouple_type3_font(fz_context *ctx, fz_font *font, void *t3doc);

/**
map an FT error number to a
static string.

err: The error number to lookup.

Returns a pointer to a static textual representation
of a freetype error.

将 FT 错误号映射到
静态字符串。

err:要查找的错误号。

返回指向静态文本表示的指针
一个自由类型错误。

*/
const char *ft_error_string(int err);
int ft_char_index(void *face, int cid);
int ft_name_index(void *face, const char *name);

/**
Internal functions for our Harfbuzz integration
to work around the lack of thread safety.
我们 Harfbuzz 集成的内部函数
解决缺乏线程安全的问题。
*/

/**
Lock against Harfbuzz being called
simultaneously in several threads. This reuses
FZ_LOCK_FREETYPE.
锁定 Harfbuzz 被调用
同时在几个线程中。 这重用
FZ_LOCK_FREETYPE。
*/
void fz_hb_lock(fz_context *ctx);

/**
Unlock after a Harfbuzz call. This reuses
FZ_LOCK_FREETYPE.
*/
void fz_hb_unlock(fz_context *ctx);

struct fz_font
{
int refs;
char name[32];
fz_buffer *buffer;

fz_font_flags_t flags;

void *ft_face; /* has an FT_Face if used */
fz_shaper_data_t shaper_data;

fz_matrix t3matrix;
void *t3resources;
fz_buffer **t3procs; /* has 256 entries if used */
struct fz_display_list **t3lists; /* has 256 entries if used */
float *t3widths; /* has 256 entries if used */
unsigned short *t3flags; /* has 256 entries if used */
void *t3doc; /* a pdf_document for the callback */
void (*t3run)(fz_context *ctx, void *doc, void *resources, fz_buffer *contents, struct fz_device *dev, fz_matrix ctm, void *gstate, fz_default_colorspaces *default_cs);
void (*t3freeres)(fz_context *ctx, void *doc, void *resources);

fz_rect bbox;	/* font bbox is used only for t3 fonts */

int glyph_count;

/* per glyph bounding box cache */
fz_rect *bbox_table;

/* substitute metrics */
int width_count;
short width_default; /* in 1000 units */
short *width_table; /* in 1000 units */

/* cached glyph metrics */
float *advance_cache;

/* cached encoding lookup */
uint16_t *encoding_cache[256];

/* cached md5sum for caching */
int has_digest;
unsigned char digest[16];

};

#endif

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值