summaryrefslogtreecommitdiff
path: root/source/fitz/font.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-01-21 12:34:56 +0100
committerTor Andersson <tor.andersson@artifex.com>2016-01-21 12:34:56 +0100
commit000b8df004b175781af5b071590cf3867ae16f3a (patch)
tree1d57886b3cd2fb62a146cf1e367b20c30dd0e951 /source/fitz/font.c
parent1ceb3b2acf3b8b8c1d009a01e94957698e6ec142 (diff)
downloadmupdf-000b8df004b175781af5b071590cf3867ae16f3a.tar.xz
epub: Put font fallback chain in fz_font.
fz_encode_character_with_fallback finds the first font in the fallback chain that has the glyph encoded, and if none do then try to encode a bullet character.
Diffstat (limited to 'source/fitz/font.c')
-rw-r--r--source/fitz/font.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/source/fitz/font.c b/source/fitz/font.c
index 0350674f..bdfee584 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -120,14 +120,14 @@ fz_drop_font(fz_context *ctx, fz_font *font)
if (!fz_drop_imp(ctx, font, &font->refs))
return;
- free_resources(ctx, font);
+ fz_drop_font(ctx, font->fallback);
+
if (font->t3lists)
{
+ free_resources(ctx, font);
for (i = 0; i < 256; i++)
- {
if (font->t3lists[i])
fz_drop_display_list(ctx, font->t3lists[i]);
- }
fz_free(ctx, font->t3procs);
fz_free(ctx, font->t3lists);
fz_free(ctx, font->t3widths);
@@ -1366,3 +1366,33 @@ fz_encode_character(fz_context *ctx, fz_font *font, int ucs)
}
return ucs;
}
+
+int
+fz_encode_character_with_fallback(fz_context *ctx, fz_font *first_font, int ucs, fz_font **out_font)
+{
+ fz_font *font;
+
+ for (font = first_font; font; font = font->fallback)
+ {
+ int gid = fz_encode_character(ctx, font, ucs);
+ if (gid > 0)
+ {
+ *out_font = font;
+ return gid;
+ }
+ }
+
+ ucs = 0x25CF; /* bullet */
+ for (font = first_font; font; font = font->fallback)
+ {
+ int gid = fz_encode_character(ctx, font, ucs);
+ if (gid > 0)
+ {
+ *out_font = font;
+ return gid;
+ }
+ }
+
+ *out_font = first_font;
+ return 0;
+}