2012-04-09 16:52:20 +00:00
|
|
|
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
|
2012-11-03 16:15:12 +00:00
|
|
|
index 33a1a65..c2fdee3 100644
|
2012-04-09 16:52:20 +00:00
|
|
|
--- a/pdf/pdf_font.c
|
|
|
|
+++ b/pdf/pdf_font.c
|
2012-11-03 16:15:12 +00:00
|
|
|
@@ -185,7 +185,12 @@ pdf_load_builtin_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname)
|
2012-04-09 16:52:20 +00:00
|
|
|
if (!data)
|
|
|
|
fz_throw(ctx, "cannot find builtin font: '%s'", fontname);
|
2012-11-03 16:15:12 +00:00
|
|
|
|
2012-04-09 16:52:20 +00:00
|
|
|
+#ifndef NOBUILTINFONT
|
2012-11-03 16:15:12 +00:00
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 1);
|
2012-04-09 16:52:20 +00:00
|
|
|
+#else
|
2012-11-03 16:15:12 +00:00
|
|
|
+ fontdesc->font = fz_new_font_from_file(ctx, fontname, data, 0, 1);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ free(data);
|
|
|
|
+#endif
|
2012-11-03 16:15:12 +00:00
|
|
|
|
2012-04-09 16:52:20 +00:00
|
|
|
if (!strcmp(fontname, "Symbol") || !strcmp(fontname, "ZapfDingbats"))
|
|
|
|
fontdesc->flags |= PDF_FD_SYMBOLIC;
|
2012-11-03 16:15:12 +00:00
|
|
|
@@ -201,7 +206,12 @@ pdf_load_substitute_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontnam
|
2012-04-09 16:52:20 +00:00
|
|
|
if (!data)
|
|
|
|
fz_throw(ctx, "cannot find substitute font");
|
2012-11-03 16:15:12 +00:00
|
|
|
|
2012-04-09 16:52:20 +00:00
|
|
|
+#ifndef NOBUILTINFONT
|
2012-11-03 16:15:12 +00:00
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 1);
|
2012-04-09 16:52:20 +00:00
|
|
|
+#else
|
2012-11-03 16:15:12 +00:00
|
|
|
+ fontdesc->font = fz_new_font_from_file(ctx, fontname, data, 0, 1);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ free(data);
|
|
|
|
+#endif
|
2012-11-03 16:15:12 +00:00
|
|
|
|
2012-04-09 16:52:20 +00:00
|
|
|
fontdesc->font->ft_substitute = 1;
|
|
|
|
fontdesc->font->ft_bold = bold && !ft_is_bold(fontdesc->font->ft_face);
|
2012-11-03 16:15:12 +00:00
|
|
|
@@ -219,7 +229,12 @@ pdf_load_substitute_cjk_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fon
|
2012-04-09 16:52:20 +00:00
|
|
|
fz_throw(ctx, "cannot find builtin CJK font");
|
2012-11-03 16:15:12 +00:00
|
|
|
|
2012-04-09 16:52:20 +00:00
|
|
|
/* a glyph bbox cache is too big for droid sans fallback (51k glyphs!) */
|
|
|
|
+#ifndef NOBUILTINFONT
|
2012-11-03 16:15:12 +00:00
|
|
|
fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 0);
|
2012-04-09 16:52:20 +00:00
|
|
|
+#else
|
2012-11-03 16:15:12 +00:00
|
|
|
+ fontdesc->font = fz_new_font_from_file(ctx, fontname, data, 0, 1);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ free(data);
|
|
|
|
+#endif
|
2012-11-03 16:15:12 +00:00
|
|
|
|
2012-04-09 16:52:20 +00:00
|
|
|
fontdesc->font->ft_substitute = 1;
|
2012-11-03 16:15:12 +00:00
|
|
|
}
|
2012-04-09 16:52:20 +00:00
|
|
|
diff --git a/pdf/pdf_fontfile.c b/pdf/pdf_fontfile.c
|
2012-11-03 16:15:12 +00:00
|
|
|
index 99565da..a91380f 100644
|
2012-04-09 16:52:20 +00:00
|
|
|
--- a/pdf/pdf_fontfile.c
|
|
|
|
+++ b/pdf/pdf_fontfile.c
|
2012-11-03 16:15:12 +00:00
|
|
|
@@ -15,6 +15,8 @@
|
|
|
|
Set NODROIDFONT to use the base 14 fonts as substitute fonts.
|
|
|
|
*/
|
|
|
|
|
2012-04-09 16:52:20 +00:00
|
|
|
+#ifndef NOBUILTINFONT
|
|
|
|
+
|
|
|
|
#ifdef NOCJK
|
|
|
|
#define NOCJKFONT
|
|
|
|
#endif
|
2012-11-03 16:15:12 +00:00
|
|
|
@@ -152,3 +154,112 @@ pdf_lookup_substitute_cjk_font(int ros, int serif, unsigned int *len)
|
2012-04-09 16:52:20 +00:00
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+#else // NOBUILTINFONT
|
|
|
|
+
|
|
|
|
+unsigned char *
|
|
|
|
+get_font_file(char *name)
|
|
|
|
+{
|
|
|
|
+ char *fontdir;
|
|
|
|
+ char *filename;
|
|
|
|
+ int len;
|
|
|
|
+ fontdir = getenv("FONTDIR");
|
|
|
|
+ if(fontdir == NULL) {
|
|
|
|
+ fontdir = "./fonts";
|
|
|
|
+ }
|
|
|
|
+ len = strlen(fontdir) + strlen(name) + 2;
|
|
|
|
+ filename = malloc(len);
|
|
|
|
+ if(filename == NULL) {
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+ snprintf(filename, len, "%s/%s", fontdir, name);
|
|
|
|
+ return filename;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+unsigned char *
|
2012-04-15 22:10:41 +00:00
|
|
|
+pdf_lookup_builtin_font(char *name, unsigned int *len)
|
2012-04-09 16:52:20 +00:00
|
|
|
+{
|
|
|
|
+ *len = 0;
|
|
|
|
+ if (!strcmp("Courier", name)) {
|
|
|
|
+ return get_font_file("NimbusMonL-Regu.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Courier-Bold", name)) {
|
|
|
|
+ return get_font_file("NimbusMonL-Bold.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Courier-Oblique", name)) {
|
|
|
|
+ return get_font_file("NimbusMonL-ReguObli.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Courier-BoldOblique", name)) {
|
|
|
|
+ return get_font_file("NimbusMonL-BoldObli.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Helvetica", name)) {
|
|
|
|
+ return get_font_file("NimbusSanL-Regu.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Helvetica-Bold", name)) {
|
|
|
|
+ return get_font_file("NimbusSanL-Bold.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Helvetica-Oblique", name)) {
|
|
|
|
+ return get_font_file("NimbusSanL-ReguItal.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Helvetica-BoldOblique", name)) {
|
|
|
|
+ return get_font_file("NimbusSanL-BoldItal.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Times-Roman", name)) {
|
|
|
|
+ return get_font_file("NimbusRomNo9L-Regu.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Times-Bold", name)) {
|
|
|
|
+ return get_font_file("NimbusRomNo9L-Medi.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Times-Italic", name)) {
|
|
|
|
+ return get_font_file("NimbusRomNo9L-ReguItal.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Times-BoldItalic", name)) {
|
|
|
|
+ return get_font_file("NimbusRomNo9L-MediItal.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("Symbol", name)) {
|
|
|
|
+ return get_font_file("StandardSymL.cff");
|
|
|
|
+ }
|
|
|
|
+ if (!strcmp("ZapfDingbats", name)) {
|
|
|
|
+ return get_font_file("Dingbats.cff");
|
|
|
|
+ }
|
|
|
|
+ return NULL;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+unsigned char *
|
2012-04-15 22:10:41 +00:00
|
|
|
+pdf_lookup_substitute_font(int mono, int serif, int bold, int italic, unsigned int *len)
|
2012-04-09 16:52:20 +00:00
|
|
|
+{
|
|
|
|
+ if (mono) {
|
|
|
|
+ if (bold) {
|
2012-04-15 22:10:41 +00:00
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Courier-BoldOblique", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Courier-Bold", len);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ } else {
|
2012-04-15 22:10:41 +00:00
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Courier-Oblique", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Courier", len);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ }
|
|
|
|
+ } else if (serif) {
|
|
|
|
+ if (bold) {
|
2012-04-15 22:10:41 +00:00
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Times-BoldItalic", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Times-Bold", len);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ } else {
|
2012-04-15 22:10:41 +00:00
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Times-Italic", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Times-Roman", len);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (bold) {
|
2012-04-15 22:10:41 +00:00
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Helvetica-BoldOblique", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Helvetica-Bold", len);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ } else {
|
2012-04-15 22:10:41 +00:00
|
|
|
+ if (italic) return pdf_lookup_builtin_font("Helvetica-Oblique", len);
|
|
|
|
+ else return pdf_lookup_builtin_font("Helvetica", len);
|
2012-04-09 16:52:20 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+unsigned char *
|
2012-04-15 22:10:41 +00:00
|
|
|
+pdf_lookup_substitute_cjk_font(int ros, int serif, unsigned int *len)
|
2012-04-09 16:52:20 +00:00
|
|
|
+{
|
|
|
|
+ *len = 0;
|
|
|
|
+ return get_font_file("droid/DroidSansFallback.ttf");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif // NOBUILTINFONT
|