mupdf
Loading...
Searching...
No Matches
text.h File Reference
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/font.h"
#include "mupdf/fitz/path.h"
#include "mupdf/fitz/bidi.h"
Include dependency graph for text.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fz_text_item
struct  fz_text_span
struct  fz_text

Macros

#define FZ_LANG_TAG2(c1, c2)
#define FZ_LANG_TAG3(c1, c2, c3)

Typedefs

typedef struct fz_text_span fz_text_span

Enumerations

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')
}

Functions

fz_textfz_new_text (fz_context *ctx)
fz_textfz_keep_text (fz_context *ctx, const fz_text *text)
void fz_drop_text (fz_context *ctx, const fz_text *text)
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)
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)
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)
fz_rect fz_bound_text (fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, fz_matrix ctm)
fz_text_language fz_text_language_from_string (const char *str)
char * fz_string_from_text_language (char str[8], fz_text_language lang)

Macro Definition Documentation

◆ FZ_LANG_TAG2

#define FZ_LANG_TAG2 ( c1,
c2 )
Value:
((c1-'a'+1) + ((c2-'a'+1)*27))

◆ FZ_LANG_TAG3

#define FZ_LANG_TAG3 ( c1,
c2,
c3 )
Value:
((c1-'a'+1) + ((c2-'a'+1)*27) + ((c3-'a'+1)*27*27))

Typedef Documentation

◆ fz_text_span

typedef struct fz_text_span fz_text_span

Enumeration Type Documentation

◆ fz_text_language

Enumerator
FZ_LANG_UNSET 
FZ_LANG_ur 
FZ_LANG_urd 
FZ_LANG_ko 
FZ_LANG_ja 
FZ_LANG_zh 
FZ_LANG_zh_Hans 
FZ_LANG_zh_Hant 

Function Documentation

◆ fz_bound_text()

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.

text: The text object to find the bounds of.

stroke: Pointer to the stroke attributes (for stroked text), or NULL (for filled text).

ctm: The matrix in use.

r: pointer to storage for the bounds.

Returns a pointer to r, which is updated to contain the bounding box for the text object.

◆ fz_drop_text()

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.

◆ fz_keep_text()

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.

◆ fz_measure_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_new_text()

fz_text * fz_new_text ( fz_context * ctx)

Create a new empty fz_text object.

Throws exception on failure to allocate.

◆ fz_show_glyph()

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.

text: Text object to add to.

font: The font the glyph should be added in.

trm: The transform to use for the glyph.

glyph: The glyph id to add.

unicode: The unicode character for the glyph.

cid: The CJK CID value or raw character code.

wmode: 1 for vertical mode, 0 for horizontal.

bidi_level: The bidirectional level for this glyph.

markup_dir: The direction of the text as specified in the markup.

language: The language in use (if known, 0 otherwise) (e.g. FZ_LANG_zh_Hans).

Throws exception on failure to allocate.

◆ fz_show_glyph_aux()

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_show_string()

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.

text: Text object to add to.

font: The font the string should be added in.

trm: The transform to use.

s: The utf-8 string to add.

wmode: 1 for vertical mode, 0 for horizontal.

bidi_level: The bidirectional level for this glyph.

markup_dir: The direction of the text as specified in the markup.

language: The language in use (if known, 0 otherwise) (e.g. FZ_LANG_zh_Hans).

Returns the transform updated with the advance width of the string.

◆ fz_string_from_text_language()

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.

◆ fz_text_language_from_string()

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.