diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-01-06 16:12:36 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-01-06 16:12:36 +0100 |
commit | 990c79c8e5288a3315a73d8c55084a594f82ccac (patch) | |
tree | d6d1ceb1feee2902b4e71d605a1aaf962c50569f /source/fitz | |
parent | 0ae5e72a2baa3a19aa51be4d6a91c4d23edac20f (diff) | |
download | mupdf-990c79c8e5288a3315a73d8c55084a594f82ccac.tar.xz |
epub: Cache font encoding lookups.
Add a caching table for the lower planes of unicode, which cover the
latin, greek, cyrillic, hebrew and arabic scripts.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/font.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/fitz/font.c b/source/fitz/font.c index 6a1e9232..7ac4d41f 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -7,6 +7,7 @@ #define MAX_BBOX_TABLE_SIZE 4096 #define MAX_ADVANCE_TABLE_SIZE 4096 +#define MAX_UNICODE_TABLE_SIZE 2304 /* covers latin, greek, cyrillic, hebrew and arabic */ /* 20 degrees */ #define SHEAR 0.36397f @@ -69,6 +70,8 @@ fz_new_font(fz_context *ctx, const char *name, int use_glyph_bbox, int glyph_cou font->width_count = 0; font->width_table = NULL; + font->unicode_table = NULL; + return font; } @@ -148,6 +151,8 @@ fz_drop_font(fz_context *ctx, fz_font *font) fz_free(ctx, font->ft_filepath); fz_free(ctx, font->bbox_table); fz_free(ctx, font->width_table); + fz_free(ctx, font->advance_table); + fz_free(ctx, font->unicode_table); fz_free(ctx, font); } @@ -1343,6 +1348,19 @@ fz_advance_glyph(fz_context *ctx, fz_font *font, int gid) static int fz_encode_ft_character(fz_context *ctx, fz_font *font, int ucs) { + if (ucs >= 0 && ucs < MAX_UNICODE_TABLE_SIZE) + { + if (!font->unicode_table) + { + int i; + font->unicode_table = fz_malloc_array(ctx, MAX_UNICODE_TABLE_SIZE, sizeof(int)); + for (i = 0; i < MAX_UNICODE_TABLE_SIZE; ++i) + font->unicode_table[i] = -2; + } + if (font->unicode_table[ucs] == -2) + font->unicode_table[ucs] = FT_Get_Char_Index(font->ft_face, ucs); + return font->unicode_table[ucs]; + } return FT_Get_Char_Index(font->ft_face, ucs); } |