struct fz_text_item
{
float x, y;
float adv; /* advance width given by input format */
int gid; /* -1 for one gid to many ucs mappings */
int ucs; /* -1 for one ucs to many gid mappings */
int cid; /* CID for CJK fonts, raw character code for other fonts; or unicode for non-PDF formats. */
}
Text buffer.
The trm field contains the a, b, c and d coefficients. The e and f coefficients come from the individual elements, together they form the transform matrix for the glyph.
Glyphs are referenced by glyph ID. The Unicode text equivalent is kept in a separate array with indexes into the glyph array.
#define FZ_LANG_TAG2(c1,c2)
#define FZ_LANG_TAG3(c1,c2,c3)
enum fz_text_language
{
FZ_LANG_UNSET = 0,
FZ_LANG_ur = FZ_LANG_TAG2('u','r'),
FZ_LANG_urd = FZ_LANG_TAG3('u','r','d'),
FZ_LANG_ko = FZ_LANG_TAG2('k','o'),
FZ_LANG_ja = FZ_LANG_TAG2('j','a'),
FZ_LANG_zh = FZ_LANG_TAG2('z','h'),
FZ_LANG_zh_Hans = FZ_LANG_TAG3('z','h','s'),
FZ_LANG_zh_Hant = FZ_LANG_TAG3('z','h','t'),
}
struct fz_text_span
{
fz_font *font;
fz_matrix trm;
unsigned wmode : 1; /* 0 horizontal, 1 vertical */
unsigned bidi_level : 7; /* The bidirectional level of text */
unsigned markup_dir : 2; /* The direction of text as marked in the original document */
unsigned language : 15; /* The language as marked in the original document */
int len, cap;
fz_text_item *items;
struct fz_text_span *next;
}
struct fz_text
{
int refs;
fz_text_span *head, *tail;
}
fz_text *
fz_new_text (
fz_context *ctx
)
Create a new empty fz_text object.
Throws exception on failure to allocate.
fz_text *
fz_keep_text (
fz_context *ctx,
const fz_text *text
)
Increment the reference count for the text object. The same pointer is returned.
Never throws exceptions.
void
fz_drop_text (
fz_context *ctx,
const fz_text *text
)
Decrement the reference count for the text object. When the reference count hits zero, the text object is freed.
Never throws exceptions.
void
fz_show_glyph (
fz_context *ctx,
fz_text *text,
fz_font *font,
fz_matrix trm,
int glyph,
int unicode,
int wmode,
int bidi_level,
fz_bidi_direction markup_dir,
fz_text_language language
)
Add a glyph/unicode value to a text object.
Throws exception on failure to allocate.
void
fz_show_glyph_aux (
fz_context *ctx,
fz_text *text,
fz_font *font,
fz_matrix trm,
float adv,
int glyph,
int unicode,
int cid,
int wmode,
int bidi_level,
fz_bidi_direction markup_dir,
fz_text_language lang
)
fz_matrix
fz_show_string (
fz_context *ctx,
fz_text *text,
fz_font *font,
fz_matrix trm,
const char *s,
int wmode,
int bidi_level,
fz_bidi_direction markup_dir,
fz_text_language language
)
Add a UTF8 string to a text object.
Returns the transform updated with the advance width of the string.
fz_matrix
fz_measure_string (
fz_context *ctx,
fz_font *user_font,
fz_matrix trm,
const char *s,
int wmode,
int bidi_level,
fz_bidi_direction markup_dir,
fz_text_language language
)
Measure the advance width of a UTF8 string should it be added to a text object.
This uses the same layout algorithms as fz_show_string, and can be used to calculate text alignment adjustments.
fz_rect
fz_bound_text (
fz_context *ctx,
const fz_text *text,
const fz_stroke_state *stroke,
fz_matrix ctm
)
Find the bounds of a given text object.
Returns a pointer to r, which is updated to contain the bounding box for the text object.
fz_text_language
fz_text_language_from_string (
const char *str
)
Convert ISO 639 (639-{1,2,3,5}) language specification strings losslessly to a 15 bit fz_text_language code.
No validation is carried out. Obviously invalid (out of spec) codes will be mapped to FZ_LANG_UNSET, but well-formed (but undefined) codes will be blithely accepted.
char *
fz_string_from_text_language (
char str[8],
fz_text_language lang
)
Recover ISO 639 (639-{1,2,3,5}) language specification strings losslessly from a 15 bit fz_text_language code.
No validation is carried out. See note above.