summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-font.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2013-11-11 14:37:16 +0100
committerTor Andersson <tor.andersson@artifex.com>2013-11-11 16:12:46 +0100
commit7570e7fa8a40cb41db6a1ab14b225cf00c4f56f5 (patch)
tree1b2853d64609e8365715521beaf079f533ebe84a /source/pdf/pdf-font.c
parenta2c945506ea2a2b58edbde84124094c6b4f69eac (diff)
downloadmupdf-7570e7fa8a40cb41db6a1ab14b225cf00c4f56f5.tar.xz
Add hooks to load system fonts. Use them in PDF interpreter.
Diffstat (limited to 'source/pdf/pdf-font.c')
-rw-r--r--source/pdf/pdf-font.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 78ee7f18..638b5b35 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -198,14 +198,24 @@ pdf_load_builtin_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname)
static void
pdf_load_substitute_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname, int mono, int serif, int bold, int italic)
{
- unsigned char *data;
- unsigned int len;
+ fz_buffer *buffer;
- data = pdf_lookup_substitute_font(mono, serif, bold, italic, &len);
- if (!data)
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find substitute font");
+ buffer = fz_load_system_font(ctx, fontname);
+ if (buffer)
+ {
+ fontdesc->font = fz_new_font_from_buffer(ctx, fontname, buffer, 0, 1);
+ }
+ else
+ {
+ unsigned char *data;
+ unsigned int len;
- fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 1);
+ data = pdf_lookup_substitute_font(mono, serif, bold, italic, &len);
+ if (!data)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find substitute font");
+
+ fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 1);
+ }
fontdesc->font->ft_substitute = 1;
fontdesc->font->ft_bold = bold && !ft_is_bold(fontdesc->font->ft_face);