|
|
@ -5,7 +5,7 @@ index 5e54e0b..38bd1d8 100644
|
|
|
|
@@ -182,8 +182,13 @@ pdf_load_builtin_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname)
|
|
|
|
@@ -182,8 +182,13 @@ pdf_load_builtin_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname)
|
|
|
|
if (!data)
|
|
|
|
if (!data)
|
|
|
|
fz_throw(ctx, "cannot find builtin font: '%s'", fontname);
|
|
|
|
fz_throw(ctx, "cannot find builtin font: '%s'", fontname);
|
|
|
|
|
|
|
|
|
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 1);
|
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 1);
|
|
|
|
/* RJW: "cannot load freetype font from memory" */
|
|
|
|
/* RJW: "cannot load freetype font from memory" */
|
|
|
@ -13,13 +13,13 @@ index 5e54e0b..38bd1d8 100644
|
|
|
|
+ fontdesc->font = fz_new_font_from_file(ctx, data, 0, 1);
|
|
|
|
+ fontdesc->font = fz_new_font_from_file(ctx, data, 0, 1);
|
|
|
|
+ free(data);
|
|
|
|
+ free(data);
|
|
|
|
+#endif
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (!strcmp(fontname, "Symbol") || !strcmp(fontname, "ZapfDingbats"))
|
|
|
|
if (!strcmp(fontname, "Symbol") || !strcmp(fontname, "ZapfDingbats"))
|
|
|
|
fontdesc->flags |= PDF_FD_SYMBOLIC;
|
|
|
|
fontdesc->flags |= PDF_FD_SYMBOLIC;
|
|
|
|
@@ -199,8 +204,13 @@ pdf_load_substitute_font(fz_context *ctx, pdf_font_desc *fontdesc, int mono, int
|
|
|
|
@@ -199,8 +204,13 @@ pdf_load_substitute_font(fz_context *ctx, pdf_font_desc *fontdesc, int mono, int
|
|
|
|
if (!data)
|
|
|
|
if (!data)
|
|
|
|
fz_throw(ctx, "cannot find substitute font");
|
|
|
|
fz_throw(ctx, "cannot find substitute font");
|
|
|
|
|
|
|
|
|
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 1);
|
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 1);
|
|
|
|
/* RJW: "cannot load freetype font from memory" */
|
|
|
|
/* RJW: "cannot load freetype font from memory" */
|
|
|
@ -27,12 +27,12 @@ index 5e54e0b..38bd1d8 100644
|
|
|
|
+ fontdesc->font = fz_new_font_from_file(ctx, data, 0, 1);
|
|
|
|
+ fontdesc->font = fz_new_font_from_file(ctx, data, 0, 1);
|
|
|
|
+ free(data);
|
|
|
|
+ free(data);
|
|
|
|
+#endif
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
|
|
fontdesc->font->ft_substitute = 1;
|
|
|
|
fontdesc->font->ft_substitute = 1;
|
|
|
|
fontdesc->font->ft_bold = bold && !ft_is_bold(fontdesc->font->ft_face);
|
|
|
|
fontdesc->font->ft_bold = bold && !ft_is_bold(fontdesc->font->ft_face);
|
|
|
|
@@ -218,7 +228,12 @@ pdf_load_substitute_cjk_font(fz_context *ctx, pdf_font_desc *fontdesc, int ros,
|
|
|
|
@@ -218,7 +228,12 @@ pdf_load_substitute_cjk_font(fz_context *ctx, pdf_font_desc *fontdesc, int ros,
|
|
|
|
fz_throw(ctx, "cannot find builtin CJK font");
|
|
|
|
fz_throw(ctx, "cannot find builtin CJK font");
|
|
|
|
|
|
|
|
|
|
|
|
/* a glyph bbox cache is too big for droid sans fallback (51k glyphs!) */
|
|
|
|
/* a glyph bbox cache is too big for droid sans fallback (51k glyphs!) */
|
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 0);
|
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, data, len, 0, 0);
|
|
|
@ -41,7 +41,7 @@ index 5e54e0b..38bd1d8 100644
|
|
|
|
+ free(data);
|
|
|
|
+ free(data);
|
|
|
|
+#endif
|
|
|
|
+#endif
|
|
|
|
/* RJW: "cannot load builtin CJK font" */
|
|
|
|
/* RJW: "cannot load builtin CJK font" */
|
|
|
|
|
|
|
|
|
|
|
|
fontdesc->font->ft_substitute = 1;
|
|
|
|
fontdesc->font->ft_substitute = 1;
|
|
|
|
diff --git a/pdf/pdf_fontfile.c b/pdf/pdf_fontfile.c
|
|
|
|
diff --git a/pdf/pdf_fontfile.c b/pdf/pdf_fontfile.c
|
|
|
|
index 543ce76..a076033 100644
|
|
|
|
index 543ce76..a076033 100644
|
|
|
@ -50,7 +50,7 @@ index 543ce76..a076033 100644
|
|
|
|
@@ -1,6 +1,8 @@
|
|
|
|
@@ -1,6 +1,8 @@
|
|
|
|
#include "fitz.h"
|
|
|
|
#include "fitz.h"
|
|
|
|
#include "mupdf.h"
|
|
|
|
#include "mupdf.h"
|
|
|
|
|
|
|
|
|
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
+
|
|
|
|
+
|
|
|
|
#ifdef NOCJK
|
|
|
|
#ifdef NOCJK
|
|
|
@ -83,7 +83,7 @@ index 543ce76..a076033 100644
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+unsigned char *
|
|
|
|
+unsigned char *
|
|
|
|
+pdf_find_builtin_font(char *name, unsigned int *len)
|
|
|
|
+pdf_lookup_builtin_font(char *name, unsigned int *len)
|
|
|
|
+{
|
|
|
|
+{
|
|
|
|
+ *len = 0;
|
|
|
|
+ *len = 0;
|
|
|
|
+ if (!strcmp("Courier", name)) {
|
|
|
|
+ if (!strcmp("Courier", name)) {
|
|
|
@ -132,37 +132,37 @@ index 543ce76..a076033 100644
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+unsigned char *
|
|
|
|
+unsigned char *
|
|
|
|
+pdf_find_substitute_font(int mono, int serif, int bold, int italic, unsigned int *len)
|
|
|
|
+pdf_lookup_substitute_font(int mono, int serif, int bold, int italic, unsigned int *len)
|
|
|
|
+{
|
|
|
|
+{
|
|
|
|
+ if (mono) {
|
|
|
|
+ if (mono) {
|
|
|
|
+ if (bold) {
|
|
|
|
+ if (bold) {
|
|
|
|
+ if (italic) return pdf_find_builtin_font("Courier-BoldOblique", len);
|
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Courier-BoldOblique", len);
|
|
|
|
+ else return pdf_find_builtin_font("Courier-Bold", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Courier-Bold", len);
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
+ if (italic) return pdf_find_builtin_font("Courier-Oblique", len);
|
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Courier-Oblique", len);
|
|
|
|
+ else return pdf_find_builtin_font("Courier", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Courier", len);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (serif) {
|
|
|
|
+ } else if (serif) {
|
|
|
|
+ if (bold) {
|
|
|
|
+ if (bold) {
|
|
|
|
+ if (italic) return pdf_find_builtin_font("Times-BoldItalic", len);
|
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Times-BoldItalic", len);
|
|
|
|
+ else return pdf_find_builtin_font("Times-Bold", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Times-Bold", len);
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
+ if (italic) return pdf_find_builtin_font("Times-Italic", len);
|
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Times-Italic", len);
|
|
|
|
+ else return pdf_find_builtin_font("Times-Roman", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Times-Roman", len);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
+ if (bold) {
|
|
|
|
+ if (bold) {
|
|
|
|
+ if (italic) return pdf_find_builtin_font("Helvetica-BoldOblique", len);
|
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Helvetica-BoldOblique", len);
|
|
|
|
+ else return pdf_find_builtin_font("Helvetica-Bold", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Helvetica-Bold", len);
|
|
|
|
+ } else {
|
|
|
|
+ } else {
|
|
|
|
+ if (italic) return pdf_find_builtin_font("Helvetica-Oblique", len);
|
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Helvetica-Oblique", len);
|
|
|
|
+ else return pdf_find_builtin_font("Helvetica", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Helvetica", len);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+unsigned char *
|
|
|
|
+unsigned char *
|
|
|
|
+pdf_find_substitute_cjk_font(int ros, int serif, unsigned int *len)
|
|
|
|
+pdf_lookup_substitute_cjk_font(int ros, int serif, unsigned int *len)
|
|
|
|
+{
|
|
|
|
+{
|
|
|
|
+ *len = 0;
|
|
|
|
+ *len = 0;
|
|
|
|
+ return get_font_file("droid/DroidSansFallback.ttf");
|
|
|
|
+ return get_font_file("droid/DroidSansFallback.ttf");
|
|
|
|