summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-06 15:43:43 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-06 15:43:43 +0200
commitd1ca1560865a196d1caa10a27110880b58905db3 (patch)
tree43ef49c5dbe0c544aae7fc44a9470794c43e825c
parente516feff18c3223a597ba23cbefba01b042c70bd (diff)
downloadmupdf-d1ca1560865a196d1caa10a27110880b58905db3.tar.xz
pdf: Change how CMap and font data files are generated and compiled.
-rw-r--r--.gitignore1
-rw-r--r--Makefile79
-rw-r--r--pdf/mupdf.h31
-rw-r--r--pdf/pdf_cmap_load.c28
-rw-r--r--pdf/pdf_cmap_table.c485
-rw-r--r--pdf/pdf_font.c191
-rw-r--r--pdf/pdf_fontfile.c348
-rw-r--r--pdf/pdf_metrics.c (renamed from pdf/pdf_fontmtx.c)0
-rw-r--r--scripts/cmapdump.c22
-rw-r--r--scripts/fontdump.c29
-rw-r--r--win32/libmupdf.vcproj40
11 files changed, 530 insertions, 724 deletions
diff --git a/.gitignore b/.gitignore
index 6079c1f0..6acef018 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
*~
build
+generated
thirdparty
cscope.*
tags
diff --git a/Makefile b/Makefile
index 47145b8c..02776d59 100644
--- a/Makefile
+++ b/Makefile
@@ -9,23 +9,13 @@ build ?= debug
prefix ?= /usr/local
OBJDIR := build/$(build)
-GENDIR := build/generated
+GENDIR := generated
$(OBJDIR):
mkdir -p $@
$(GENDIR):
mkdir -p $@
-# If no pregen directory is supplied, then generate (dump) the
-# font and cmap .c files as part of the build.
-# If it is supplied, then just use the files from that directory.
-
-pregen := $(wildcard pregen)
-
-ifneq "$(pregen)" ""
-GENDIR := $(pregen)
-endif
-
# Compiler flags and configuration options are kept in Makerules.
# Thirdparty libs will be built by Makethird if the thirdparty
# directory exists.
@@ -145,11 +135,11 @@ MUPDF_SRC := \
pdf/pdf_encoding.c \
pdf/pdf_font.c \
pdf/pdf_fontfile.c \
- pdf/pdf_fontmtx.c \
pdf/pdf_function.c \
pdf/pdf_image.c \
pdf/pdf_interpret.c \
pdf/pdf_lex.c \
+ pdf/pdf_metrics.c \
pdf/pdf_nametree.c \
pdf/pdf_outline.c \
pdf/pdf_page.c \
@@ -198,14 +188,12 @@ $(OBJDIR)/%.o: xps/%.c
$(CC_CMD)
$(OBJDIR)/%.o: scripts/%.c
$(CC_CMD)
-$(OBJDIR)/%.o: $(GENDIR)/%.c
- $(CC_CMD)
#
# Generated font file dumps
#
-BASEFONT_FILES := \
+BASE_FONT_FILES := \
fonts/Dingbats.cff \
fonts/NimbusMonL-Bold.cff \
fonts/NimbusMonL-BoldObli.cff \
@@ -221,24 +209,19 @@ BASEFONT_FILES := \
fonts/NimbusSanL-ReguItal.cff \
fonts/StandardSymL.cff
-CJKFONT_FILES := \
+CJK_FONT_FILES := \
fonts/droid/DroidSansFallback.ttf
-ifeq "$(pregen)" ""
-
-$(GENDIR)/font_base14.c: $(FONTDUMP_EXE) $(BASEFONT_FILES)
+$(GENDIR)/font_base14.h: $(FONTDUMP_EXE) $(BASE_FONT_FILES)
$(GENFILE_CMD)
-$(GENDIR)/font_cjk.c: $(FONTDUMP_EXE) $(CJKFONT_FILES)
+$(GENDIR)/font_cjk.h: $(FONTDUMP_EXE) $(CJK_FONT_FILES)
$(GENFILE_CMD)
-endif
-
-FONT_SRC := \
- $(GENDIR)/font_base14.c \
- $(GENDIR)/font_cjk.c
-
-FONT_OBJ := $(FONT_SRC:$(GENDIR)/%.c=$(OBJDIR)/%.o)
+FONT_HDR := \
+ $(GENDIR)/font_base14.h \
+ $(GENDIR)/font_cjk.h
+$(OBJDIR)/pdf_fontfile.o: $(FONT_HDR)
#
# Generated CMap file dumps
@@ -285,29 +268,25 @@ CMAP_KOREA_FILES := $(addprefix cmaps/, \
KSCms-UHC-HW-H KSCms-UHC-HW-V KSCms-UHC-V KSCpc-EUC-H \
KSCpc-EUC-V UniKS-UCS2-H UniKS-UCS2-V UniKS-UTF16-H UniKS-UTF16-V )
-ifeq "$(pregen)" ""
-
-$(GENDIR)/cmap_unicode.c: $(CMAPDUMP_EXE) $(CMAP_UNICODE_FILES)
+$(GENDIR)/cmap_unicode.h: $(CMAPDUMP_EXE) $(CMAP_UNICODE_FILES)
$(GENFILE_CMD)
-$(GENDIR)/cmap_cns.c: $(CMAPDUMP_EXE) $(CMAP_CNS_FILES)
+$(GENDIR)/cmap_cns.h: $(CMAPDUMP_EXE) $(CMAP_CNS_FILES)
$(GENFILE_CMD)
-$(GENDIR)/cmap_gb.c: $(CMAPDUMP_EXE) $(CMAP_GB_FILES)
+$(GENDIR)/cmap_gb.h: $(CMAPDUMP_EXE) $(CMAP_GB_FILES)
$(GENFILE_CMD)
-$(GENDIR)/cmap_japan.c: $(CMAPDUMP_EXE) $(CMAP_JAPAN_FILES)
+$(GENDIR)/cmap_japan.h: $(CMAPDUMP_EXE) $(CMAP_JAPAN_FILES)
$(GENFILE_CMD)
-$(GENDIR)/cmap_korea.c: $(CMAPDUMP_EXE) $(CMAP_KOREA_FILES)
+$(GENDIR)/cmap_korea.h: $(CMAPDUMP_EXE) $(CMAP_KOREA_FILES)
$(GENFILE_CMD)
-endif
+CMAP_HDR := \
+ $(GENDIR)/cmap_unicode.h \
+ $(GENDIR)/cmap_cns.h \
+ $(GENDIR)/cmap_gb.h \
+ $(GENDIR)/cmap_japan.h \
+ $(GENDIR)/cmap_korea.h
-CMAP_SRC := \
- $(GENDIR)/cmap_unicode.c \
- $(GENDIR)/cmap_cns.c \
- $(GENDIR)/cmap_gb.c \
- $(GENDIR)/cmap_japan.c \
- $(GENDIR)/cmap_korea.c
-
-CMAP_OBJ := $(CMAP_SRC:$(GENDIR)/%.c=$(OBJDIR)/%.o)
+$(OBJDIR)/pdf_cmap_table.o: $(CMAP_HDR)
#
# Library
@@ -317,10 +296,6 @@ FITZ_LIB = $(OBJDIR)/libfitz.a
$(FITZ_LIB): $(FITZ_OBJ) $(DRAW_OBJ)
$(AR_CMD)
-DATA_LIB = $(OBJDIR)/libmupdfdata.a
-$(DATA_LIB): $(CMAP_OBJ) $(FONT_OBJ)
- $(AR_CMD)
-
MUPDF_LIB = $(OBJDIR)/libmupdf.a
$(MUPDF_LIB): $(MUPDF_OBJ)
$(AR_CMD)
@@ -329,8 +304,8 @@ MUXPS_LIB = $(OBJDIR)/libmuxps.a
$(MUXPS_LIB): $(MUXPS_OBJ)
$(AR_CMD)
-ALL_LIBS = $(MUXPS_LIB) $(MUPDF_LIB) $(DATA_LIB) $(FITZ_LIB)
-PDF_LIBS = $(MUPDF_LIB) $(DATA_LIB) $(FITZ_LIB)
+ALL_LIBS = $(MUXPS_LIB) $(MUPDF_LIB) $(FITZ_LIB)
+PDF_LIBS = $(MUPDF_LIB) $(FITZ_LIB)
XPS_LIBS = $(MUXPS_LIB) $(FITZ_LIB)
#
@@ -416,9 +391,9 @@ $(WINVIEW_EXE): $(WINVIEW_OBJ) $(ALL_LIBS) $(THIRD_LIBS)
# Default rules
#
-.PHONY: default all pregen clean nuke install
+.PHONY: default all clean nuke install
-all: $(OBJDIR) $(GENDIR) $(THIRD_LIBS) $(FITZ_LIB) $(DATA_LIB) $(MUPDF_LIB) $(MUXPS_LIB) $(APPS)
+all: $(OBJDIR) $(THIRD_LIBS) $(FITZ_LIB) $(MUPDF_LIB) $(MUXPS_LIB) $(APPS)
clean:
rm -rf $(OBJDIR)/*
@@ -431,7 +406,7 @@ LIBDIR ?= $(prefix)/lib
INCDIR ?= $(prefix)/include
MANDIR ?= $(prefix)/share/man/man1
-install: $(OBJDIR) $(GENDIR) $(MUPDF_LIB) $(APPS)
+install: $(OBJDIR) $(MUPDF_LIB) $(APPS)
install -d $(BINDIR) $(LIBDIR) $(INCDIR) $(MANDIR)
install $(APPS) $(BINDIR)
install $(APPS_MAN) $(MANDIR)
diff --git a/pdf/mupdf.h b/pdf/mupdf.h
index a3509d38..a85d23a7 100644
--- a/pdf/mupdf.h
+++ b/pdf/mupdf.h
@@ -311,8 +311,6 @@ struct pdf_cmap_s
unsigned short *table;
};
-extern pdf_cmap *pdf_cmap_table[]; /* list of builtin system cmaps */
-
pdf_cmap *pdf_new_cmap(void);
pdf_cmap *pdf_keep_cmap(pdf_cmap *cmap);
void pdf_drop_cmap(pdf_cmap *cmap);
@@ -336,11 +334,27 @@ pdf_cmap *pdf_new_identity_cmap(int wmode, int bytes);
fz_error pdf_parse_cmap(pdf_cmap **cmapp, fz_stream *file);
fz_error pdf_load_embedded_cmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *ref);
fz_error pdf_load_system_cmap(pdf_cmap **cmapp, char *name);
+pdf_cmap *pdf_find_builtin_cmap(char *cmap_name);
/*
* Font
*/
+enum
+{
+ PDF_FD_FIXED_PITCH = 1 << 0,
+ PDF_FD_SERIF = 1 << 1,
+ PDF_FD_SYMBOLIC = 1 << 2,
+ PDF_FD_SCRIPT = 1 << 3,
+ PDF_FD_NONSYMBOLIC = 1 << 5,
+ PDF_FD_ITALIC = 1 << 6,
+ PDF_FD_ALL_CAP = 1 << 16,
+ PDF_FD_SMALL_CAP = 1 << 17,
+ PDF_FD_FORCE_BOLD = 1 << 18
+};
+
+enum { PDF_ROS_CNS, PDF_ROS_GB, PDF_ROS_JAPAN, PDF_ROS_KOREA };
+
void pdf_load_encoding(char **estrings, char *encoding);
int pdf_lookup_agl(char *name);
const char **pdf_lookup_agl_duplicates(int ucs);
@@ -350,9 +364,6 @@ extern const char * const pdf_mac_roman[256];
extern const char * const pdf_mac_expert[256];
extern const char * const pdf_win_ansi[256];
extern const char * const pdf_standard[256];
-extern const char * const pdf_expert[256];
-extern const char * const pdf_symbol[256];
-extern const char * const pdf_zapfdingbats[256];
typedef struct pdf_font_desc_s pdf_font_desc;
typedef struct pdf_hmtx_s pdf_hmtx;
@@ -411,7 +422,7 @@ struct pdf_font_desc_s
pdf_vmtx dvmtx;
pdf_vmtx *vmtx;
- int isembedded;
+ int is_embedded;
};
/* fontmtx.c */
@@ -429,9 +440,11 @@ pdf_vmtx pdf_get_vmtx(pdf_font_desc *font, int cid);
fz_error pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm);
/* fontfile.c */
-fz_error pdf_load_builtin_font(pdf_font_desc *font, char *basefont);
-fz_error pdf_load_embedded_font(pdf_font_desc *font, pdf_xref *xref, fz_obj *stmref);
-fz_error pdf_load_system_font(pdf_font_desc *font, char *basefont, char *collection);
+unsigned char *pdf_find_builtin_font(char *name, unsigned int *len);
+unsigned char *pdf_find_builtin_cjk_font(int ros, int gothic, unsigned int *len);
+
+char *pdf_find_system_font(char *name);
+char *pdf_find_system_cjk_font(char *name, int ros, int gothic);
/* type3.c */
fz_error pdf_load_type3_font(pdf_font_desc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj);
diff --git a/pdf/pdf_cmap_load.c b/pdf/pdf_cmap_load.c
index f6ea4bf8..d671b234 100644
--- a/pdf/pdf_cmap_load.c
+++ b/pdf/pdf_cmap_load.c
@@ -107,29 +107,23 @@ pdf_new_identity_cmap(int wmode, int bytes)
fz_error
pdf_load_system_cmap(pdf_cmap **cmapp, char *cmap_name)
{
- fz_error error;
pdf_cmap *usecmap;
pdf_cmap *cmap;
- int i;
pdf_log_font("loading system cmap %s\n", cmap_name);
- for (i = 0; pdf_cmap_table[i]; i++)
+ cmap = pdf_find_builtin_cmap(cmap_name);
+ if (!cmap)
+ return fz_throw("no builtin cmap file: %s", cmap_name);
+
+ if (cmap->usecmap_name[0] && !cmap->usecmap)
{
- if (!strcmp(cmap_name, pdf_cmap_table[i]->cmap_name))
- {
- cmap = pdf_cmap_table[i];
- if (cmap->usecmap_name[0] && !cmap->usecmap)
- {
- error = pdf_load_system_cmap(&usecmap, cmap->usecmap_name);
- if (error)
- return fz_rethrow(error, "cannot load usecmap: %s", cmap->usecmap_name);
- pdf_set_usecmap(cmap, usecmap);
- }
- *cmapp = cmap;
- return fz_okay;
- }
+ usecmap = pdf_find_builtin_cmap(cmap->usecmap_name);
+ if (!usecmap)
+ return fz_throw("nu builtin cmap file: %s", cmap->usecmap_name);
+ pdf_set_usecmap(cmap, usecmap);
}
- return fz_throw("no builtin cmap file: %s", cmap_name);
+ *cmapp = cmap;
+ return fz_okay;
}
diff --git a/pdf/pdf_cmap_table.c b/pdf/pdf_cmap_table.c
index 1413de25..aaa83f4c 100644
--- a/pdf/pdf_cmap_table.c
+++ b/pdf/pdf_cmap_table.c
@@ -1,316 +1,185 @@
-/*
- * :r !grep -h '^pdf_cmap' build/macosx-x86-debug/cmap_*.c
- * :.,'as/\(pdf_cmap.*\) =/extern \1;/
- * :.,'as/pdf_cmap \(pdf_cmap.*\) =/\&\1;/
- */
-
#include "fitz.h"
#include "mupdf.h"
-extern pdf_cmap pdf_cmap_Adobe_CNS1_0;
-extern pdf_cmap pdf_cmap_Adobe_CNS1_1;
-extern pdf_cmap pdf_cmap_Adobe_CNS1_2;
-extern pdf_cmap pdf_cmap_Adobe_CNS1_3;
-extern pdf_cmap pdf_cmap_Adobe_CNS1_4;
-extern pdf_cmap pdf_cmap_Adobe_CNS1_5;
-extern pdf_cmap pdf_cmap_Adobe_CNS1_6;
-extern pdf_cmap pdf_cmap_B5_H;
-extern pdf_cmap pdf_cmap_B5_V;
-extern pdf_cmap pdf_cmap_B5pc_H;
-extern pdf_cmap pdf_cmap_B5pc_V;
-extern pdf_cmap pdf_cmap_CNS_EUC_H;
-extern pdf_cmap pdf_cmap_CNS_EUC_V;
-extern pdf_cmap pdf_cmap_CNS1_H;
-extern pdf_cmap pdf_cmap_CNS1_V;
-extern pdf_cmap pdf_cmap_CNS2_H;
-extern pdf_cmap pdf_cmap_CNS2_V;
-extern pdf_cmap pdf_cmap_ETen_B5_H;
-extern pdf_cmap pdf_cmap_ETen_B5_V;
-extern pdf_cmap pdf_cmap_ETenms_B5_H;
-extern pdf_cmap pdf_cmap_ETenms_B5_V;
-extern pdf_cmap pdf_cmap_ETHK_B5_H;
-extern pdf_cmap pdf_cmap_ETHK_B5_V;
-extern pdf_cmap pdf_cmap_HKdla_B5_H;
-extern pdf_cmap pdf_cmap_HKdla_B5_V;
-extern pdf_cmap pdf_cmap_HKdlb_B5_H;
-extern pdf_cmap pdf_cmap_HKdlb_B5_V;
-extern pdf_cmap pdf_cmap_HKgccs_B5_H;
-extern pdf_cmap pdf_cmap_HKgccs_B5_V;
-extern pdf_cmap pdf_cmap_HKm314_B5_H;
-extern pdf_cmap pdf_cmap_HKm314_B5_V;
-extern pdf_cmap pdf_cmap_HKm471_B5_H;
-extern pdf_cmap pdf_cmap_HKm471_B5_V;
-extern pdf_cmap pdf_cmap_HKscs_B5_H;
-extern pdf_cmap pdf_cmap_HKscs_B5_V;
-extern pdf_cmap pdf_cmap_UniCNS_UCS2_H;
-extern pdf_cmap pdf_cmap_UniCNS_UCS2_V;
-extern pdf_cmap pdf_cmap_UniCNS_UTF16_H;
-extern pdf_cmap pdf_cmap_UniCNS_UTF16_V;
-extern pdf_cmap pdf_cmap_Adobe_GB1_0;
-extern pdf_cmap pdf_cmap_Adobe_GB1_1;
-extern pdf_cmap pdf_cmap_Adobe_GB1_2;
-extern pdf_cmap pdf_cmap_Adobe_GB1_3;
-extern pdf_cmap pdf_cmap_Adobe_GB1_4;
-extern pdf_cmap pdf_cmap_Adobe_GB1_5;
-extern pdf_cmap pdf_cmap_GB_EUC_H;
-extern pdf_cmap pdf_cmap_GB_EUC_V;
-extern pdf_cmap pdf_cmap_GB_H;
-extern pdf_cmap pdf_cmap_GB_V;
-extern pdf_cmap pdf_cmap_GBK_EUC_H;
-extern pdf_cmap pdf_cmap_GBK_EUC_V;
-extern pdf_cmap pdf_cmap_GBK2K_H;
-extern pdf_cmap pdf_cmap_GBK2K_V;
-extern pdf_cmap pdf_cmap_GBKp_EUC_H;
-extern pdf_cmap pdf_cmap_GBKp_EUC_V;
-extern pdf_cmap pdf_cmap_GBpc_EUC_H;
-extern pdf_cmap pdf_cmap_GBpc_EUC_V;
-extern pdf_cmap pdf_cmap_GBT_EUC_H;
-extern pdf_cmap pdf_cmap_GBT_EUC_V;
-extern pdf_cmap pdf_cmap_GBT_H;
-extern pdf_cmap pdf_cmap_GBT_V;
-extern pdf_cmap pdf_cmap_GBTpc_EUC_H;
-extern pdf_cmap pdf_cmap_GBTpc_EUC_V;
-extern pdf_cmap pdf_cmap_UniGB_UCS2_H;
-extern pdf_cmap pdf_cmap_UniGB_UCS2_V;
-extern pdf_cmap pdf_cmap_UniGB_UTF16_H;
-extern pdf_cmap pdf_cmap_UniGB_UTF16_V;
-extern pdf_cmap pdf_cmap_78_EUC_H;
-extern pdf_cmap pdf_cmap_78_EUC_V;
-extern pdf_cmap pdf_cmap_78_H;
-extern pdf_cmap pdf_cmap_78_RKSJ_H;
-extern pdf_cmap pdf_cmap_78_RKSJ_V;
-extern pdf_cmap pdf_cmap_78_V;
-extern pdf_cmap pdf_cmap_78ms_RKSJ_H;
-extern pdf_cmap pdf_cmap_78ms_RKSJ_V;
-extern pdf_cmap pdf_cmap_83pv_RKSJ_H;
-extern pdf_cmap pdf_cmap_90ms_RKSJ_H;
-extern pdf_cmap pdf_cmap_90ms_RKSJ_V;
-extern pdf_cmap pdf_cmap_90msp_RKSJ_H;
-extern pdf_cmap pdf_cmap_90msp_RKSJ_V;
-extern pdf_cmap pdf_cmap_90pv_RKSJ_H;
-extern pdf_cmap pdf_cmap_90pv_RKSJ_V;
-extern pdf_cmap pdf_cmap_Add_H;
-extern pdf_cmap pdf_cmap_Add_RKSJ_H;
-extern pdf_cmap pdf_cmap_Add_RKSJ_V;
-extern pdf_cmap pdf_cmap_Add_V;
-extern pdf_cmap pdf_cmap_Adobe_Japan1_0;
-extern pdf_cmap pdf_cmap_Adobe_Japan1_1;
-extern pdf_cmap pdf_cmap_Adobe_Japan1_2;
-extern pdf_cmap pdf_cmap_Adobe_Japan1_3;
-extern pdf_cmap pdf_cmap_Adobe_Japan1_4;
-extern pdf_cmap pdf_cmap_Adobe_Japan1_5;
-extern pdf_cmap pdf_cmap_Adobe_Japan1_6;
-extern pdf_cmap pdf_cmap_EUC_H;
-extern pdf_cmap pdf_cmap_EUC_V;
-extern pdf_cmap pdf_cmap_Ext_H;
-extern pdf_cmap pdf_cmap_Ext_RKSJ_H;
-extern pdf_cmap pdf_cmap_Ext_RKSJ_V;
-extern pdf_cmap pdf_cmap_Ext_V;
-extern pdf_cmap pdf_cmap_H;
-extern pdf_cmap pdf_cmap_Hankaku;
-extern pdf_cmap pdf_cmap_Hiragana;
-extern pdf_cmap pdf_cmap_Katakana;
-extern pdf_cmap pdf_cmap_NWP_H;
-extern pdf_cmap pdf_cmap_NWP_V;
-extern pdf_cmap pdf_cmap_RKSJ_H;
-extern pdf_cmap pdf_cmap_RKSJ_V;
-extern pdf_cmap pdf_cmap_Roman;
-extern pdf_cmap pdf_cmap_UniJIS_UCS2_H;
-extern pdf_cmap pdf_cmap_UniJIS_UCS2_HW_H;
-extern pdf_cmap pdf_cmap_UniJIS_UCS2_HW_V;
-extern pdf_cmap pdf_cmap_UniJIS_UCS2_V;
-extern pdf_cmap pdf_cmap_UniJISPro_UCS2_HW_V;
-extern pdf_cmap pdf_cmap_UniJISPro_UCS2_V;
-extern pdf_cmap pdf_cmap_V;
-extern pdf_cmap pdf_cmap_WP_Symbol;
-extern pdf_cmap pdf_cmap_Adobe_Japan2_0;
-extern pdf_cmap pdf_cmap_Hojo_EUC_H;
-extern pdf_cmap pdf_cmap_Hojo_EUC_V;
-extern pdf_cmap pdf_cmap_Hojo_H;
-extern pdf_cmap pdf_cmap_Hojo_V;
-extern pdf_cmap pdf_cmap_UniHojo_UCS2_H;
-extern pdf_cmap pdf_cmap_UniHojo_UCS2_V;
-extern pdf_cmap pdf_cmap_UniHojo_UTF16_H;
-extern pdf_cmap pdf_cmap_UniHojo_UTF16_V;
-extern pdf_cmap pdf_cmap_UniJIS_UTF16_H;
-extern pdf_cmap pdf_cmap_UniJIS_UTF16_V;
-extern pdf_cmap pdf_cmap_Adobe_Korea1_0;
-extern pdf_cmap pdf_cmap_Adobe_Korea1_1;
-extern pdf_cmap pdf_cmap_Adobe_Korea1_2;
-extern pdf_cmap pdf_cmap_KSC_EUC_H;
-extern pdf_cmap pdf_cmap_KSC_EUC_V;
-extern pdf_cmap pdf_cmap_KSC_H;
-extern pdf_cmap pdf_cmap_KSC_Johab_H;
-extern pdf_cmap pdf_cmap_KSC_Johab_V;
-extern pdf_cmap pdf_cmap_KSC_V;
-extern pdf_cmap pdf_cmap_KSCms_UHC_H;
-extern pdf_cmap pdf_cmap_KSCms_UHC_HW_H;
-extern pdf_cmap pdf_cmap_KSCms_UHC_HW_V;
-extern pdf_cmap pdf_cmap_KSCms_UHC_V;
-extern pdf_cmap pdf_cmap_KSCpc_EUC_H;
-extern pdf_cmap pdf_cmap_KSCpc_EUC_V;
-extern pdf_cmap pdf_cmap_UniKS_UCS2_H;
-extern pdf_cmap pdf_cmap_UniKS_UCS2_V;
-extern pdf_cmap pdf_cmap_UniKS_UTF16_H;
-extern pdf_cmap pdf_cmap_UniKS_UTF16_V;
-extern pdf_cmap pdf_cmap_Adobe_CNS1_UCS2;
-extern pdf_cmap pdf_cmap_Adobe_GB1_UCS2;
-extern pdf_cmap pdf_cmap_Adobe_Japan1_UCS2;
-extern pdf_cmap pdf_cmap_Adobe_Korea1_UCS2;
+#ifndef NOCJK
+#include "../generated/cmap_unicode.h"
+#include "../generated/cmap_cns.h"
+#include "../generated/cmap_gb.h"
+#include "../generated/cmap_japan.h"
+#include "../generated/cmap_korea.h"
+#endif
-pdf_cmap *pdf_cmap_table[] =
+static const struct { char *name; pdf_cmap *cmap; } cmap_table[] =
{
#ifndef NOCJK
- &pdf_cmap_Adobe_CNS1_0,
- &pdf_cmap_Adobe_CNS1_1,
- &pdf_cmap_Adobe_CNS1_2,
- &pdf_cmap_Adobe_CNS1_3,
- &pdf_cmap_Adobe_CNS1_4,
- &pdf_cmap_Adobe_CNS1_5,
- &pdf_cmap_Adobe_CNS1_6,
- &pdf_cmap_B5_H,
- &pdf_cmap_B5_V,
- &pdf_cmap_B5pc_H,
- &pdf_cmap_B5pc_V,
- &pdf_cmap_CNS_EUC_H,
- &pdf_cmap_CNS_EUC_V,
- &pdf_cmap_CNS1_H,
- &pdf_cmap_CNS1_V,
- &pdf_cmap_CNS2_H,
- &pdf_cmap_CNS2_V,
- &pdf_cmap_ETen_B5_H,
- &pdf_cmap_ETen_B5_V,
- &pdf_cmap_ETenms_B5_H,
- &pdf_cmap_ETenms_B5_V,
- &pdf_cmap_ETHK_B5_H,
- &pdf_cmap_ETHK_B5_V,
- &pdf_cmap_HKdla_B5_H,
- &pdf_cmap_HKdla_B5_V,
- &pdf_cmap_HKdlb_B5_H,
- &pdf_cmap_HKdlb_B5_V,
- &pdf_cmap_HKgccs_B5_H,
- &pdf_cmap_HKgccs_B5_V,
- &pdf_cmap_HKm314_B5_H,
- &pdf_cmap_HKm314_B5_V,
- &pdf_cmap_HKm471_B5_H,
- &pdf_cmap_HKm471_B5_V,
- &pdf_cmap_HKscs_B5_H,
- &pdf_cmap_HKscs_B5_V,
- &pdf_cmap_UniCNS_UCS2_H,
- &pdf_cmap_UniCNS_UCS2_V,
- &pdf_cmap_UniCNS_UTF16_H,
- &pdf_cmap_UniCNS_UTF16_V,
- &pdf_cmap_Adobe_GB1_0,
- &pdf_cmap_Adobe_GB1_1,
- &pdf_cmap_Adobe_GB1_2,
- &pdf_cmap_Adobe_GB1_3,
- &pdf_cmap_Adobe_GB1_4,
- &pdf_cmap_Adobe_GB1_5,
- &pdf_cmap_GB_EUC_H,
- &pdf_cmap_GB_EUC_V,
- &pdf_cmap_GB_H,
- &pdf_cmap_GB_V,
- &pdf_cmap_GBK_EUC_H,
- &pdf_cmap_GBK_EUC_V,
- &pdf_cmap_GBK2K_H,
- &pdf_cmap_GBK2K_V,
- &pdf_cmap_GBKp_EUC_H,
- &pdf_cmap_GBKp_EUC_V,
- &pdf_cmap_GBpc_EUC_H,
- &pdf_cmap_GBpc_EUC_V,
- &pdf_cmap_GBT_EUC_H,
- &pdf_cmap_GBT_EUC_V,
- &pdf_cmap_GBT_H,
- &pdf_cmap_GBT_V,
- &pdf_cmap_GBTpc_EUC_H,
- &pdf_cmap_GBTpc_EUC_V,
- &pdf_cmap_UniGB_UCS2_H,
- &pdf_cmap_UniGB_UCS2_V,
- &pdf_cmap_UniGB_UTF16_H,
- &pdf_cmap_UniGB_UTF16_V,
- &pdf_cmap_78_EUC_H,
- &pdf_cmap_78_EUC_V,
- &pdf_cmap_78_H,
- &pdf_cmap_78_RKSJ_H,
- &pdf_cmap_78_RKSJ_V,
- &pdf_cmap_78_V,
- &pdf_cmap_78ms_RKSJ_H,
- &pdf_cmap_78ms_RKSJ_V,
- &pdf_cmap_83pv_RKSJ_H,
- &pdf_cmap_90ms_RKSJ_H,
- &pdf_cmap_90ms_RKSJ_V,
- &pdf_cmap_90msp_RKSJ_H,
- &pdf_cmap_90msp_RKSJ_V,
- &pdf_cmap_90pv_RKSJ_H,
- &pdf_cmap_90pv_RKSJ_V,
- &pdf_cmap_Add_H,
- &pdf_cmap_Add_RKSJ_H,
- &pdf_cmap_Add_RKSJ_V,
- &pdf_cmap_Add_V,
- &pdf_cmap_Adobe_Japan1_0,
- &pdf_cmap_Adobe_Japan1_1,
- &pdf_cmap_Adobe_Japan1_2,
- &pdf_cmap_Adobe_Japan1_3,
- &pdf_cmap_Adobe_Japan1_4,
- &pdf_cmap_Adobe_Japan1_5,
- &pdf_cmap_Adobe_Japan1_6,
- &pdf_cmap_EUC_H,
- &pdf_cmap_EUC_V,
- &pdf_cmap_Ext_H,
- &pdf_cmap_Ext_RKSJ_H,
- &pdf_cmap_Ext_RKSJ_V,
- &pdf_cmap_Ext_V,
- &pdf_cmap_H,
- &pdf_cmap_Hankaku,
- &pdf_cmap_Hiragana,
- &pdf_cmap_Katakana,
- &pdf_cmap_NWP_H,
- &pdf_cmap_NWP_V,
- &pdf_cmap_RKSJ_H,
- &pdf_cmap_RKSJ_V,
- &pdf_cmap_Roman,
- &pdf_cmap_UniJIS_UCS2_H,
- &pdf_cmap_UniJIS_UCS2_HW_H,
- &pdf_cmap_UniJIS_UCS2_HW_V,
- &pdf_cmap_UniJIS_UCS2_V,
- &pdf_cmap_UniJISPro_UCS2_HW_V,
- &pdf_cmap_UniJISPro_UCS2_V,
- &pdf_cmap_V,
- &pdf_cmap_WP_Symbol,
- &pdf_cmap_Adobe_Japan2_0,
- &pdf_cmap_Hojo_EUC_H,
- &pdf_cmap_Hojo_EUC_V,
- &pdf_cmap_Hojo_H,
- &pdf_cmap_Hojo_V,
- &pdf_cmap_UniHojo_UCS2_H,
- &pdf_cmap_UniHojo_UCS2_V,
- &pdf_cmap_UniHojo_UTF16_H,
- &pdf_cmap_UniHojo_UTF16_V,
- &pdf_cmap_UniJIS_UTF16_H,
- &pdf_cmap_UniJIS_UTF16_V,
- &pdf_cmap_Adobe_Korea1_0,
- &pdf_cmap_Adobe_Korea1_1,
- &pdf_cmap_Adobe_Korea1_2,
- &pdf_cmap_KSC_EUC_H,
- &pdf_cmap_KSC_EUC_V,
- &pdf_cmap_KSC_H,
- &pdf_cmap_KSC_Johab_H,
- &pdf_cmap_KSC_Johab_V,
- &pdf_cmap_KSC_V,
- &pdf_cmap_KSCms_UHC_H,
- &pdf_cmap_KSCms_UHC_HW_H,
- &pdf_cmap_KSCms_UHC_HW_V,
- &pdf_cmap_KSCms_UHC_V,
- &pdf_cmap_KSCpc_EUC_H,
- &pdf_cmap_KSCpc_EUC_V,
- &pdf_cmap_UniKS_UCS2_H,
- &pdf_cmap_UniKS_UCS2_V,
- &pdf_cmap_UniKS_UTF16_H,
- &pdf_cmap_UniKS_UTF16_V,
- &pdf_cmap_Adobe_CNS1_UCS2,
- &pdf_cmap_Adobe_GB1_UCS2,
- &pdf_cmap_Adobe_Japan1_UCS2,
- &pdf_cmap_Adobe_Korea1_UCS2,
+ {"78-EUC-H",&cmap_78_EUC_H},
+ {"78-EUC-V",&cmap_78_EUC_V},
+ {"78-H",&cmap_78_H},
+ {"78-RKSJ-H",&cmap_78_RKSJ_H},
+ {"78-RKSJ-V",&cmap_78_RKSJ_V},
+ {"78-V",&cmap_78_V},
+ {"78ms-RKSJ-H",&cmap_78ms_RKSJ_H},
+ {"78ms-RKSJ-V",&cmap_78ms_RKSJ_V},
+ {"83pv-RKSJ-H",&cmap_83pv_RKSJ_H},
+ {"90ms-RKSJ-H",&cmap_90ms_RKSJ_H},
+ {"90ms-RKSJ-V",&cmap_90ms_RKSJ_V},
+ {"90msp-RKSJ-H",&cmap_90msp_RKSJ_H},
+ {"90msp-RKSJ-V",&cmap_90msp_RKSJ_V},
+ {"90pv-RKSJ-H",&cmap_90pv_RKSJ_H},
+ {"90pv-RKSJ-V",&cmap_90pv_RKSJ_V},
+ {"Add-H",&cmap_Add_H},
+ {"Add-RKSJ-H",&cmap_Add_RKSJ_H},
+ {"Add-RKSJ-V",&cmap_Add_RKSJ_V},
+ {"Add-V",&cmap_Add_V},
+ {"Adobe-CNS1-0",&cmap_Adobe_CNS1_0},
+ {"Adobe-CNS1-1",&cmap_Adobe_CNS1_1},
+ {"Adobe-CNS1-2",&cmap_Adobe_CNS1_2},
+ {"Adobe-CNS1-3",&cmap_Adobe_CNS1_3},
+ {"Adobe-CNS1-4",&cmap_Adobe_CNS1_4},
+ {"Adobe-CNS1-5",&cmap_Adobe_CNS1_5},
+ {"Adobe-CNS1-6",&cmap_Adobe_CNS1_6},
+ {"Adobe-CNS1-UCS2",&cmap_Adobe_CNS1_UCS2},
+ {"Adobe-GB1-0",&cmap_Adobe_GB1_0},
+ {"Adobe-GB1-1",&cmap_Adobe_GB1_1},
+ {"Adobe-GB1-2",&cmap_Adobe_GB1_2},
+ {"Adobe-GB1-3",&cmap_Adobe_GB1_3},
+ {"Adobe-GB1-4",&cmap_Adobe_GB1_4},
+ {"Adobe-GB1-5",&cmap_Adobe_GB1_5},
+ {"Adobe-GB1-UCS2",&cmap_Adobe_GB1_UCS2},
+ {"Adobe-Japan1-0",&cmap_Adobe_Japan1_0},
+ {"Adobe-Japan1-1",&cmap_Adobe_Japan1_1},
+ {"Adobe-Japan1-2",&cmap_Adobe_Japan1_2},
+ {"Adobe-Japan1-3",&cmap_Adobe_Japan1_3},
+ {"Adobe-Japan1-4",&cmap_Adobe_Japan1_4},
+ {"Adobe-Japan1-5",&cmap_Adobe_Japan1_5},
+ {"Adobe-Japan1-6",&cmap_Adobe_Japan1_6},
+ {"Adobe-Japan1-UCS2",&cmap_Adobe_Japan1_UCS2},
+ {"Adobe-Japan2-0",&cmap_Adobe_Japan2_0},
+ {"Adobe-Korea1-0",&cmap_Adobe_Korea1_0},
+ {"Adobe-Korea1-1",&cmap_Adobe_Korea1_1},
+ {"Adobe-Korea1-2",&cmap_Adobe_Korea1_2},
+ {"Adobe-Korea1-UCS2",&cmap_Adobe_Korea1_UCS2},
+ {"B5-H",&cmap_B5_H},
+ {"B5-V",&cmap_B5_V},
+ {"B5pc-H",&cmap_B5pc_H},
+ {"B5pc-V",&cmap_B5pc_V},
+ {"CNS-EUC-H",&cmap_CNS_EUC_H},
+ {"CNS-EUC-V",&cmap_CNS_EUC_V},
+ {"CNS1-H",&cmap_CNS1_H},
+ {"CNS1-V",&cmap_CNS1_V},
+ {"CNS2-H",&cmap_CNS2_H},
+ {"CNS2-V",&cmap_CNS2_V},
+ {"ETHK-B5-H",&cmap_ETHK_B5_H},
+ {"ETHK-B5-V",&cmap_ETHK_B5_V},
+ {"ETen-B5-H",&cmap_ETen_B5_H},
+ {"ETen-B5-V",&cmap_ETen_B5_V},
+ {"ETenms-B5-H",&cmap_ETenms_B5_H},
+ {"ETenms-B5-V",&cmap_ETenms_B5_V},
+ {"EUC-H",&cmap_EUC_H},
+ {"EUC-V",&cmap_EUC_V},
+ {"Ext-H",&cmap_Ext_H},
+ {"Ext-RKSJ-H",&cmap_Ext_RKSJ_H},
+ {"Ext-RKSJ-V",&cmap_Ext_RKSJ_V},
+ {"Ext-V",&cmap_Ext_V},
+ {"GB-EUC-H",&cmap_GB_EUC_H},
+ {"GB-EUC-V",&cmap_GB_EUC_V},
+ {"GB-H",&cmap_GB_H},
+ {"GB-V",&cmap_GB_V},
+ {"GBK-EUC-H",&cmap_GBK_EUC_H},
+ {"GBK-EUC-V",&cmap_GBK_EUC_V},
+ {"GBK2K-H",&cmap_GBK2K_H},
+ {"GBK2K-V",&cmap_GBK2K_V},
+ {"GBKp-EUC-H",&cmap_GBKp_EUC_H},
+ {"GBKp-EUC-V",&cmap_GBKp_EUC_V},
+ {"GBT-EUC-H",&cmap_GBT_EUC_H},
+ {"GBT-EUC-V",&cmap_GBT_EUC_V},
+ {"GBT-H",&cmap_GBT_H},
+ {"GBT-V",&cmap_GBT_V},
+ {"GBTpc-EUC-H",&cmap_GBTpc_EUC_H},
+ {"GBTpc-EUC-V",&cmap_GBTpc_EUC_V},
+ {"GBpc-EUC-H",&cmap_GBpc_EUC_H},
+ {"GBpc-EUC-V",&cmap_GBpc_EUC_V},
+ {"H",&cmap_H},
+ {"HKdla-B5-H",&cmap_HKdla_B5_H},
+ {"HKdla-B5-V",&cmap_HKdla_B5_V},
+ {"HKdlb-B5-H",&cmap_HKdlb_B5_H},
+ {"HKdlb-B5-V",&cmap_HKdlb_B5_V},
+ {"HKgccs-B5-H",&cmap_HKgccs_B5_H},
+ {"HKgccs-B5-V",&cmap_HKgccs_B5_V},
+ {"HKm314-B5-H",&cmap_HKm314_B5_H},
+ {"HKm314-B5-V",&cmap_HKm314_B5_V},
+ {"HKm471-B5-H",&cmap_HKm471_B5_H},
+ {"HKm471-B5-V",&cmap_HKm471_B5_V},
+ {"HKscs-B5-H",&cmap_HKscs_B5_H},
+ {"HKscs-B5-V",&cmap_HKscs_B5_V},
+ {"Hankaku",&cmap_Hankaku},
+ {"Hiragana",&cmap_Hiragana},
+ {"Hojo-EUC-H",&cmap_Hojo_EUC_H},
+ {"Hojo-EUC-V",&cmap_Hojo_EUC_V},
+ {"Hojo-H",&cmap_Hojo_H},
+ {"Hojo-V",&cmap_Hojo_V},
+ {"KSC-EUC-H",&cmap_KSC_EUC_H},
+ {"KSC-EUC-V",&cmap_KSC_EUC_V},
+ {"KSC-H",&cmap_KSC_H},
+ {"KSC-Johab-H",&cmap_KSC_Johab_H},
+ {"KSC-Johab-V",&cmap_KSC_Johab_V},
+ {"KSC-V",&cmap_KSC_V},
+ {"KSCms-UHC-H",&cmap_KSCms_UHC_H},
+ {"KSCms-UHC-HW-H",&cmap_KSCms_UHC_HW_H},
+ {"KSCms-UHC-HW-V",&cmap_KSCms_UHC_HW_V},
+ {"KSCms-UHC-V",&cmap_KSCms_UHC_V},
+ {"KSCpc-EUC-H",&cmap_KSCpc_EUC_H},
+ {"KSCpc-EUC-V",&cmap_KSCpc_EUC_V},
+ {"Katakana",&cmap_Katakana},
+ {"NWP-H",&cmap_NWP_H},
+ {"NWP-V",&cmap_NWP_V},
+ {"RKSJ-H",&cmap_RKSJ_H},
+ {"RKSJ-V",&cmap_RKSJ_V},
+ {"Roman",&cmap_Roman},
+ {"UniCNS-UCS2-H",&cmap_UniCNS_UCS2_H},
+ {"UniCNS-UCS2-V",&cmap_UniCNS_UCS2_V},
+ {"UniCNS-UTF16-H",&cmap_UniCNS_UTF16_H},
+ {"UniCNS-UTF16-V",&cmap_UniCNS_UTF16_V},
+ {"UniGB-UCS2-H",&cmap_UniGB_UCS2_H},
+ {"UniGB-UCS2-V",&cmap_UniGB_UCS2_V},
+ {"UniGB-UTF16-H",&cmap_UniGB_UTF16_H},
+ {"UniGB-UTF16-V",&cmap_UniGB_UTF16_V},
+ {"UniHojo-UCS2-H",&cmap_UniHojo_UCS2_H},
+ {"UniHojo-UCS2-V",&cmap_UniHojo_UCS2_V},
+ {"UniHojo-UTF16-H",&cmap_UniHojo_UTF16_H},
+ {"UniHojo-UTF16-V",&cmap_UniHojo_UTF16_V},
+ {"UniJIS-UCS2-H",&cmap_UniJIS_UCS2_H},
+ {"UniJIS-UCS2-HW-H",&cmap_UniJIS_UCS2_HW_H},
+ {"UniJIS-UCS2-HW-V",&cmap_UniJIS_UCS2_HW_V},
+ {"UniJIS-UCS2-V",&cmap_UniJIS_UCS2_V},
+ {"UniJIS-UTF16-H",&cmap_UniJIS_UTF16_H},
+ {"UniJIS-UTF16-V",&cmap_UniJIS_UTF16_V},
+ {"UniJISPro-UCS2-HW-V",&cmap_UniJISPro_UCS2_HW_V},
+ {"UniJISPro-UCS2-V",&cmap_UniJISPro_UCS2_V},
+ {"UniKS-UCS2-H",&cmap_UniKS_UCS2_H},
+ {"UniKS-UCS2-V",&cmap_UniKS_UCS2_V},
+ {"UniKS-UTF16-H",&cmap_UniKS_UTF16_H},
+ {"UniKS-UTF16-V",&cmap_UniKS_UTF16_V},
+ {"V",&cmap_V},
+ {"WP-Symbol",&cmap_WP_Symbol},
#endif
- 0
};
+
+pdf_cmap *
+pdf_find_builtin_cmap(char *cmap_name)
+{
+ int l = 0;
+ int r = nelem(cmap_table) - 1;
+ while (l < r)
+ {
+ int m = (l + r) >> 1;
+ int c = strcmp(cmap_name, cmap_table[m].name);
+ if (c < 0)
+ r = m - 1;
+ else if (c > 0)
+ l = m + 1;
+ else
+ return cmap_table[m].cmap;
+ }
+ return NULL;
+}
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
index f723ff6e..73193707 100644
--- a/pdf/pdf_font.c
+++ b/pdf/pdf_font.c
@@ -35,7 +35,7 @@ static char *base_font_names[14][7] =
{ "ZapfDingbats", NULL }
};
-static int isdynalab(char *name)
+static int is_dynalab(char *name)
{
if (strstr(name, "HuaTian"))
return 1;
@@ -144,11 +144,7 @@ static int ft_width(pdf_font_desc *fontdesc, int cid)
return ((FT_Face)fontdesc->font->ft_face)->glyph->advance.x;
}
-/*
- * Basic encoding tables
- */
-
-static int mre_code(char *name)
+static int lookup_mre_code(char *name)
{
int i;
for (i = 0; i < 256; i++)
@@ -158,6 +154,179 @@ static int mre_code(char *name)
}
/*
+ * Load font files.
+ */
+
+static fz_error
+pdf_load_builtin_font(pdf_font_desc *fontdesc, char *fontname)
+{
+ fz_error error;
+ unsigned char *data;
+ unsigned int len;
+
+ data = pdf_find_builtin_font(fontname, &len);
+ if (!data)
+ return fz_throw("cannot find font: '%s'", fontname);
+
+ pdf_log_font("load builtin font %s\n", fontname);
+
+ error = fz_new_font_from_memory(&fontdesc->font, data, len, 0);
+ if (error)
+ return fz_rethrow(error, "cannot load freetype font from memory");
+
+ fz_strlcpy(fontdesc->font->name, fontname, sizeof fontdesc->font->name);
+
+ if (!strcmp(fontname, "Symbol") || !strcmp(fontname, "ZapfDingbats"))
+ fontdesc->flags |= PDF_FD_SYMBOLIC;
+
+ return fz_okay;
+}
+
+static fz_error
+pdf_load_builtin_cjk_font(pdf_font_desc *fontdesc, int ros, int gothic)
+{
+ fz_error error;
+ unsigned char *data;
+ unsigned int len;
+
+ pdf_log_font("loading builtin CJK font\n");
+
+ data = pdf_find_builtin_cjk_font(ros, gothic, &len);
+ if (!data)
+ return fz_throw("cannot find builtin CJK font");
+
+ error = fz_new_font_from_memory(&fontdesc->font, data, len, 0);
+ if (error)
+ return fz_rethrow(error, "cannot load builtin CJK font");
+
+ fontdesc->font->ft_substitute = 1;
+ return fz_okay;
+}
+
+static fz_error
+pdf_load_system_font(pdf_font_desc *fontdesc, char *fontname, char *collection)
+{
+ fz_error error;
+ char *name;
+
+ int isbold = 0;
+ int isitalic = 0;
+ int isserif = 0;
+ int isscript = 0;
+ int isfixed = 0;
+
+ if (strstr(fontname, "Bold"))
+ isbold = 1;
+ if (strstr(fontname, "Italic"))
+ isitalic = 1;
+ if (strstr(fontname, "Oblique"))
+ isitalic = 1;
+
+ if (fontdesc->flags & PDF_FD_FIXED_PITCH)
+ isfixed = 1;
+ if (fontdesc->flags & PDF_FD_SERIF)
+ isserif = 1;
+ if (fontdesc->flags & PDF_FD_ITALIC)
+ isitalic = 1;
+ if (fontdesc->flags & PDF_FD_SCRIPT)
+ isscript = 1;
+ if (fontdesc->flags & PDF_FD_FORCE_BOLD)
+ isbold = 1;
+
+ pdf_log_font("fixed-%d serif-%d italic-%d script-%d bold-%d\n",
+ isfixed, isserif, isitalic, isscript, isbold);
+
+ if (collection)
+ {
+ if (!strcmp(collection, "Adobe-CNS1"))
+ return pdf_load_builtin_cjk_font(fontdesc, PDF_ROS_CNS, !isserif);
+ else if (!strcmp(collection, "Adobe-GB1"))
+ return pdf_load_builtin_cjk_font(fontdesc, PDF_ROS_GB, !isserif);
+ else if (!strcmp(collection, "Adobe-Japan1"))
+ return pdf_load_builtin_cjk_font(fontdesc, PDF_ROS_JAPAN, !isserif);
+ else if (!strcmp(collection, "Adobe-Japan2"))
+ return pdf_load_builtin_cjk_font(fontdesc, PDF_ROS_JAPAN, !isserif);
+ else if (!strcmp(collection, "Adobe-Korea1"))
+ return pdf_load_builtin_cjk_font(fontdesc, PDF_ROS_KOREA, !isserif);
+ fz_warn("unknown cid collection: %s", collection);
+ }
+
+ else if (isfixed)
+ {
+ if (isitalic) {
+ if (isbold) name = "Courier-BoldOblique";
+ else name = "Courier-Oblique";
+ }
+ else {
+ if (isbold) name = "Courier-Bold";
+ else name = "Courier";
+ }
+ }
+
+ else if (isserif)
+ {
+ if (isitalic) {
+ if (isbold) name = "Times-BoldItalic";
+ else name = "Times-Italic";
+ }
+ else {
+ if (isbold) name = "Times-Bold";
+ else name = "Times-Roman";
+ }
+ }
+
+ else
+ {
+ if (isitalic) {
+ if (isbold) name = "Helvetica-BoldOblique";
+ else name = "Helvetica-Oblique";
+ }
+ else {
+ if (isbold) name = "Helvetica-Bold";
+ else name = "Helvetica";
+ }
+ }
+
+ error = pdf_load_builtin_font(fontdesc, name);
+ if (error)
+ return fz_throw("cannot load builtin substitute font: %s", name);
+
+ /* it's a substitute font: override the metrics */
+ fontdesc->font->ft_substitute = 1;
+
+ return fz_okay;
+}
+
+static fz_error
+pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *stmref)
+{
+ fz_error error;
+ fz_buffer *buf;
+
+ pdf_log_font("load embedded font\n");
+
+ error = pdf_load_stream(&buf, xref, fz_to_num(stmref), fz_to_gen(stmref));
+ if (error)
+ return fz_rethrow(error, "cannot load font stream (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref));
+
+ error = fz_new_font_from_memory(&fontdesc->font, buf->data, buf->len, 0);
+ if (error)
+ {
+ fz_drop_buffer(buf);
+ return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref));
+ }
+
+ /* save the buffer so we can free it later */
+ fontdesc->font->ft_data = buf->data;
+ fontdesc->font->ft_size = buf->len;
+ fz_free(buf); /* only free the fz_buffer struct, not the contained data */
+
+ fontdesc->is_embedded = 1;
+
+ return fz_okay;
+}
+
+/*
* Create and destroy
*/
@@ -235,7 +404,7 @@ pdf_new_font_desc(void)
fontdesc->dvmtx.y = 880;
fontdesc->dvmtx.w = -1000;
- fontdesc->isembedded = 0;
+ fontdesc->is_embedded = 0;
return fontdesc;
}
@@ -255,8 +424,8 @@ load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict)
pdf_font_desc *fontdesc;
FT_Face face;
FT_CharMap cmap;
- int kind;
int symbolic;
+ int kind;
char *basefont;
char *fontname;
@@ -381,7 +550,7 @@ load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict)
base = fz_dict_gets(encoding, "BaseEncoding");
if (fz_is_name(base))
pdf_load_encoding(estrings, fz_to_name(base));
- else if (!fontdesc->isembedded && !symbolic)
+ else if (!fontdesc->is_embedded && !symbolic)
pdf_load_encoding(estrings, "StandardEncoding");
diff = fz_dict_gets(encoding, "Differences");
@@ -460,7 +629,7 @@ load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict)
{
if (estrings[i])
{
- k = mre_code(estrings[i]);
+ k = lookup_mre_code(estrings[i]);
if (k <= 0)
etable[i] = FT_Get_Name_Index(face, estrings[i]);
else
@@ -630,7 +799,7 @@ load_cid_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *e
/* Check for DynaLab fonts that must use hinting */
if (kind == TRUETYPE)
{
- if (FT_IS_TRICKY(face) || isdynalab(fontdesc->font->name))
+ if (FT_IS_TRICKY(face) || is_dynalab(fontdesc->font->name))
{
fontdesc->font->ft_hint = 1;
pdf_log_font("forced hinting for dynalab font\n");
diff --git a/pdf/pdf_fontfile.c b/pdf/pdf_fontfile.c
index 79eee737..59a30594 100644
--- a/pdf/pdf_fontfile.c
+++ b/pdf/pdf_fontfile.c
@@ -1,287 +1,95 @@
#include "fitz.h"
#include "mupdf.h"
-extern const unsigned char pdf_font_Dingbats_cff_buf[];
-extern const unsigned int pdf_font_Dingbats_cff_len;
-extern const unsigned char pdf_font_NimbusMonL_Bold_cff_buf[];
-extern const unsigned int pdf_font_NimbusMonL_Bold_cff_len;
-extern const unsigned char pdf_font_NimbusMonL_BoldObli_cff_buf[];
-extern const unsigned int pdf_font_NimbusMonL_BoldObli_cff_len;
-extern const unsigned char pdf_font_NimbusMonL_Regu_cff_buf[];
-extern const unsigned int pdf_font_NimbusMonL_Regu_cff_len;
-extern const unsigned char pdf_font_NimbusMonL_ReguObli_cff_buf[];
-extern const unsigned int pdf_font_NimbusMonL_ReguObli_cff_len;
-extern const unsigned char pdf_font_NimbusRomNo9L_Medi_cff_buf[];
-extern const unsigned int pdf_font_NimbusRomNo9L_Medi_cff_len;
-extern const unsigned char pdf_font_NimbusRomNo9L_MediItal_cff_buf[];
-extern const unsigned int pdf_font_NimbusRomNo9L_MediItal_cff_len;
-extern const unsigned char pdf_font_NimbusRomNo9L_Regu_cff_buf[];
-extern const unsigned int pdf_font_NimbusRomNo9L_Regu_cff_len;
-extern const unsigned char pdf_font_NimbusRomNo9L_ReguItal_cff_buf[];
-extern const unsigned int pdf_font_NimbusRomNo9L_ReguItal_cff_len;
-extern const unsigned char pdf_font_NimbusSanL_Bold_cff_buf[];
-extern const unsigned int pdf_font_NimbusSanL_Bold_cff_len;
-extern const unsigned char pdf_font_NimbusSanL_BoldItal_cff_buf[];
-extern const unsigned int pdf_font_NimbusSanL_BoldItal_cff_len;
-extern const unsigned char pdf_font_NimbusSanL_Regu_cff_buf[];
-extern const unsigned int pdf_font_NimbusSanL_Regu_cff_len;
-extern const unsigned char pdf_font_NimbusSanL_ReguItal_cff_buf[];
-extern const unsigned int pdf_font_NimbusSanL_ReguItal_cff_len;
-extern const unsigned char pdf_font_StandardSymL_cff_buf[];
-extern const unsigned int pdf_font_StandardSymL_cff_len;
-
-#ifndef NOCJK
-extern const unsigned char pdf_font_DroidSansFallback_ttf_buf[];
-extern const unsigned int pdf_font_DroidSansFallback_ttf_len;
+#ifdef NOCJK
+#define NOCJKFONT
#endif
-enum
-{
- FD_FIXED_PITCH = 1 << 0,
- FD_SERIF = 1 << 1,
- FD_SYMBOLIC = 1 << 2,
- FD_SCRIPT = 1 << 3,
- FD_NONSYMBOLIC = 1 << 5,
- FD_ITALIC = 1 << 6,
- FD_ALL_CAP = 1 << 16,
- FD_SMALL_CAP = 1 << 17,
- FD_FORCE_BOLD = 1 << 18
-};
-
-enum { CNS, GB, Japan, Korea };
-enum { MINCHO, GOTHIC };
-
-static const struct {
- const char *name;
- const unsigned char *cff;
- const unsigned int *len;
-} base_fonts[] = {
- { "Courier",
- pdf_font_NimbusMonL_Regu_cff_buf,
- &pdf_font_NimbusMonL_Regu_cff_len },
- { "Courier-Bold",
- pdf_font_NimbusMonL_Bold_cff_buf,
- &pdf_font_NimbusMonL_Bold_cff_len },
- { "Courier-Oblique",
- pdf_font_NimbusMonL_ReguObli_cff_buf,
- &pdf_font_NimbusMonL_ReguObli_cff_len },
- { "Courier-BoldOblique",
- pdf_font_NimbusMonL_BoldObli_cff_buf,
- &pdf_font_NimbusMonL_BoldObli_cff_len },
- { "Helvetica",
- pdf_font_NimbusSanL_Regu_cff_buf,
- &pdf_font_NimbusSanL_Regu_cff_len },
- { "Helvetica-Bold",
- pdf_font_NimbusSanL_Bold_cff_buf,
- &pdf_font_NimbusSanL_Bold_cff_len },
- { "Helvetica-Oblique",
- pdf_font_NimbusSanL_ReguItal_cff_buf,
- &pdf_font_NimbusSanL_ReguItal_cff_len },
- { "Helvetica-BoldOblique",
- pdf_font_NimbusSanL_BoldItal_cff_buf,
- &pdf_font_NimbusSanL_BoldItal_cff_len },
- { "Times-Roman",
- pdf_font_NimbusRomNo9L_Regu_cff_buf,
- &pdf_font_NimbusRomNo9L_Regu_cff_len },
- { "Times-Bold",
- pdf_font_NimbusRomNo9L_Medi_cff_buf,
- &pdf_font_NimbusRomNo9L_Medi_cff_len },
- { "Times-Italic",
- pdf_font_NimbusRomNo9L_ReguItal_cff_buf,
- &pdf_font_NimbusRomNo9L_ReguItal_cff_len },
- { "Times-BoldItalic",
- pdf_font_NimbusRomNo9L_MediItal_cff_buf,
- &pdf_font_NimbusRomNo9L_MediItal_cff_len },
- { "Symbol",
- pdf_font_StandardSymL_cff_buf,
- &pdf_font_StandardSymL_cff_len },
- { "ZapfDingbats",
- pdf_font_Dingbats_cff_buf,
- &pdf_font_Dingbats_cff_len },
- { NULL, NULL, NULL }
-};
-
-fz_error
-pdf_load_builtin_font(pdf_font_desc *fontdesc, char *fontname)
-{
- fz_error error;
- unsigned char *data;
- unsigned int len;
- int i;
-
- for (i = 0; base_fonts[i].name; i++)
- if (!strcmp(fontname, base_fonts[i].name))
- goto found;
+#include "../generated/font_base14.h"
- return fz_throw("cannot find font: '%s'", fontname);
-
-found:
- pdf_log_font("load builtin font %s\n", fontname);
-
- data = (unsigned char *) base_fonts[i].cff;
- len = *base_fonts[i].len;
-
- error = fz_new_font_from_memory(&fontdesc->font, data, len, 0);
- if (error)
- return fz_rethrow(error, "cannot load freetype font from buffer");
-
- fz_strlcpy(fontdesc->font->name, fontname, sizeof fontdesc->font->name);
-
- if (!strcmp(fontname, "Symbol") || !strcmp(fontname, "ZapfDingbats"))
- fontdesc->flags |= FD_SYMBOLIC;
-
- return fz_okay;
-}
-
-static fz_error
-load_system_cid_font(pdf_font_desc *fontdesc, int ros, int kind)
-{
-#ifndef NOCJK
- fz_error error;
- /*
- We only have one builtin fallback font.
- We'd really like to have one for each combination of ROS and Kind.
- */
- pdf_log_font("loading builtin CJK font\n");
- error = fz_new_font_from_memory(&fontdesc->font,
- (unsigned char *)pdf_font_DroidSansFallback_ttf_buf,
- pdf_font_DroidSansFallback_ttf_len, 0);
- if (error)
- return fz_rethrow(error, "cannot load builtin CJK font");
- fontdesc->font->ft_substitute = 1; /* substitute font */
- return fz_okay;
-#else
- return fz_throw("no builtin CJK font file");
+#ifndef NOCJKFONT
+#include "../generated/font_cjk.h"
#endif
-}
-fz_error
-pdf_load_system_font(pdf_font_desc *fontdesc, char *fontname, char *collection)
+unsigned char *
+pdf_find_builtin_font(char *name, unsigned int *len)
{
- fz_error error;
- char *name;
-
- int isbold = 0;
- int isitalic = 0;
- int isserif = 0;
- int isscript = 0;
- int isfixed = 0;
-
- if (strstr(fontname, "Bold"))
- isbold = 1;
- if (strstr(fontname, "Italic"))
- isitalic = 1;
- if (strstr(fontname, "Oblique"))
- isitalic = 1;
-
- if (fontdesc->flags & FD_FIXED_PITCH)
- isfixed = 1;
- if (fontdesc->flags & FD_SERIF)
- isserif = 1;
- if (fontdesc->flags & FD_ITALIC)
- isitalic = 1;
- if (fontdesc->flags & FD_SCRIPT)
- isscript = 1;
- if (fontdesc->flags & FD_FORCE_BOLD)
- isbold = 1;
-
- pdf_log_font("fixed-%d serif-%d italic-%d script-%d bold-%d\n",
- isfixed, isserif, isitalic, isscript, isbold);
-
- if (collection)
- {
- int kind;
-
- if (isserif)
- kind = MINCHO;
- else
- kind = GOTHIC;
-
- if (!strcmp(collection, "Adobe-CNS1"))
- return load_system_cid_font(fontdesc, CNS, kind);
- else if (!strcmp(collection, "Adobe-GB1"))
- return load_system_cid_font(fontdesc, GB, kind);
- else if (!strcmp(collection, "Adobe-Japan1"))
- return load_system_cid_font(fontdesc, Japan, kind);
- else if (!strcmp(collection, "Adobe-Japan2"))
- return load_system_cid_font(fontdesc, Japan, kind);
- else if (!strcmp(collection, "Adobe-Korea1"))
- return load_system_cid_font(fontdesc, Korea, kind);
-
- fz_warn("unknown cid collection: %s", collection);
+ if (!strcmp("Courier", name)) {
+ *len = sizeof pdf_font_NimbusMonL_Regu;
+ return (unsigned char*) pdf_font_NimbusMonL_Regu;
}
-
- else if (isfixed)
- {
- if (isitalic) {
- if (isbold) name = "Courier-BoldOblique";
- else name = "Courier-Oblique";
- }
- else {
- if (isbold) name = "Courier-Bold";
- else name = "Courier";
- }
+ if (!strcmp("Courier-Bold", name)) {
+ *len = sizeof pdf_font_NimbusMonL_Bold;
+ return (unsigned char*) pdf_font_NimbusMonL_Bold;
}
-
- else if (isserif)
- {
- if (isitalic) {
- if (isbold) name = "Times-BoldItalic";
- else name = "Times-Italic";
- }
- else {
- if (isbold) name = "Times-Bold";
- else name = "Times-Roman";
- }
+ if (!strcmp("Courier", name)) {
+ *len = sizeof pdf_font_NimbusMonL_Regu;
+ return (unsigned char*) pdf_font_NimbusMonL_Regu;
}
-
- else
- {
- if (isitalic) {
- if (isbold) name = "Helvetica-BoldOblique";
- else name = "Helvetica-Oblique";
- }
- else {
- if (isbold) name = "Helvetica-Bold";
- else name = "Helvetica";
- }
+ if (!strcmp("Courier-Bold", name)) {
+ *len = sizeof pdf_font_NimbusMonL_Bold;
+ return (unsigned char*) pdf_font_NimbusMonL_Bold;
}
-
- error = pdf_load_builtin_font(fontdesc, name);
- if (error)
- return fz_throw("cannot load builtin substitute font: %s", name);
-
- /* it's a substitute font: override the metrics */
- fontdesc->font->ft_substitute = 1;
-
- return fz_okay;
+ if (!strcmp("Courier-Oblique", name)) {
+ *len = sizeof pdf_font_NimbusMonL_ReguObli;
+ return (unsigned char*) pdf_font_NimbusMonL_ReguObli;
+ }
+ if (!strcmp("Courier-BoldOblique", name)) {
+ *len = sizeof pdf_font_NimbusMonL_BoldObli;
+ return (unsigned char*) pdf_font_NimbusMonL_BoldObli;
+ }
+ if (!strcmp("Helvetica", name)) {
+ *len = sizeof pdf_font_NimbusSanL_Regu;
+ return (unsigned char*) pdf_font_NimbusSanL_Regu;
+ }
+ if (!strcmp("Helvetica-Bold", name)) {
+ *len = sizeof pdf_font_NimbusSanL_Bold;
+ return (unsigned char*) pdf_font_NimbusSanL_Bold;
+ }
+ if (!strcmp("Helvetica-Oblique", name)) {
+ *len = sizeof pdf_font_NimbusSanL_ReguItal;
+ return (unsigned char*) pdf_font_NimbusSanL_ReguItal;
+ }
+ if (!strcmp("Helvetica-BoldOblique", name)) {
+ *len = sizeof pdf_font_NimbusSanL_BoldItal;
+ return (unsigned char*) pdf_font_NimbusSanL_BoldItal;
+ }
+ if (!strcmp("Times-Roman", name)) {
+ *len = sizeof pdf_font_NimbusRomNo9L_Regu;
+ return (unsigned char*) pdf_font_NimbusRomNo9L_Regu;
+ }
+ if (!strcmp("Times-Bold", name)) {
+ *len = sizeof pdf_font_NimbusRomNo9L_Medi;
+ return (unsigned char*) pdf_font_NimbusRomNo9L_Medi;
+ }
+ if (!strcmp("Times-Italic", name)) {
+ *len = sizeof pdf_font_NimbusRomNo9L_ReguItal;
+ return (unsigned char*) pdf_font_NimbusRomNo9L_ReguItal;
+ }
+ if (!strcmp("Times-BoldItalic", name)) {
+ *len = sizeof pdf_font_NimbusRomNo9L_MediItal;
+ return (unsigned char*) pdf_font_NimbusRomNo9L_MediItal;
+ }
+ if (!strcmp("Symbol", name)) {
+ *len = sizeof pdf_font_StandardSymL;
+ return (unsigned char*) pdf_font_StandardSymL;
+ }
+ if (!strcmp("ZapfDingbats", name)) {
+ *len = sizeof pdf_font_Dingbats;
+ return (unsigned char*) pdf_font_Dingbats;
+ }
+ *len = 0;
+ return NULL;
}
-fz_error
-pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *stmref)
+unsigned char *
+pdf_find_builtin_cjk_font(int ros, int gothic, unsigned int *len)
{
- fz_error error;
- fz_buffer *buf;
-
- pdf_log_font("load embedded font\n");
-
- error = pdf_load_stream(&buf, xref, fz_to_num(stmref), fz_to_gen(stmref));
- if (error)
- return fz_rethrow(error, "cannot load font stream (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref));
-
- error = fz_new_font_from_memory(&fontdesc->font, buf->data, buf->len, 0);
- if (error)
- {
- fz_drop_buffer(buf);
- return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref));
- }
-
- /* save the buffer so we can free it later */
- fontdesc->font->ft_data = buf->data;
- fontdesc->font->ft_size = buf->len;
- fz_free(buf); /* only free the fz_buffer struct, not the contained data */
-
- fontdesc->isembedded = 1;
-
- return fz_okay;
+#ifndef NOCJKFONT
+ *len = sizeof pdf_font_DroidSansFallback;
+ return (unsigned char*) pdf_font_DroidSansFallback;
+#else
+ *len = 0;
+ return NULL;
+#endif
}
diff --git a/pdf/pdf_fontmtx.c b/pdf/pdf_metrics.c
index 2fc085de..2fc085de 100644
--- a/pdf/pdf_fontmtx.c
+++ b/pdf/pdf_metrics.c
diff --git a/scripts/cmapdump.c b/scripts/cmapdump.c
index 94f3c140..16ef1b8a 100644
--- a/scripts/cmapdump.c
+++ b/scripts/cmapdump.c
@@ -52,9 +52,7 @@ main(int argc, char **argv)
return 1;
}
- fprintf(fo, "#include \"fitz.h\"\n");
- fprintf(fo, "#include \"mupdf.h\"\n");
- fprintf(fo, "\n");
+ fprintf(fo, "/* This is an automatically generated file. Do not edit. */\n");
for (i = 2; i < argc; i++)
{
@@ -86,7 +84,9 @@ main(int argc, char **argv)
return 1;
}
- fprintf(fo, "static const pdf_range pdf_cmap_%s_ranges[] = {", name);
+ fprintf(fo, "\n/* %s */\n\n", cmap->cmap_name);
+
+ fprintf(fo, "static const pdf_range cmap_%s_ranges[] = {", name);
if (cmap->rlen == 0)
{
fprintf(fo, " {0,%d,0}", PDF_CMAP_RANGE);
@@ -102,11 +102,11 @@ main(int argc, char **argv)
if (cmap->tlen == 0)
{
- fprintf(fo, "static const unsigned short pdf_cmap_%s_table[] = { 0 };\n\n", name);
+ fprintf(fo, "static const unsigned short cmap_%s_table[] = { 0 };\n\n", name);
}
else
{
- fprintf(fo, "static const unsigned short pdf_cmap_%s_table[%d] = {",
+ fprintf(fo, "static const unsigned short cmap_%s_table[%d] = {",
name, cmap->tlen);
for (k = 0; k < cmap->tlen; k++)
{
@@ -117,7 +117,7 @@ main(int argc, char **argv)
fprintf(fo, "\n};\n\n");
}
- fprintf(fo, "pdf_cmap pdf_cmap_%s = {\n", name);
+ fprintf(fo, "static pdf_cmap cmap_%s = {\n", name);
fprintf(fo, "\t-1, ");
fprintf(fo, "\"%s\", ", cmap->cmap_name);
fprintf(fo, "\"%s\", 0, ", cmap->usecmap_name);
@@ -134,13 +134,15 @@ main(int argc, char **argv)
}
fprintf(fo, " },\n");
- fprintf(fo, "\t%d, %d, (pdf_range*) pdf_cmap_%s_ranges,\n",
+ fprintf(fo, "\t%d, %d, (pdf_range*) cmap_%s_ranges,\n",
cmap->rlen, cmap->rlen, name);
- fprintf(fo, "\t%d, %d, (unsigned short*) pdf_cmap_%s_table,\n",
+ fprintf(fo, "\t%d, %d, (unsigned short*) cmap_%s_table,\n",
cmap->tlen, cmap->tlen, name);
- fprintf(fo, "};\n\n");
+ fprintf(fo, "};\n");
+
+ printf("\t{\"%s\",&cmap_%s},\n", cmap->cmap_name, name);
fz_close(fi);
}
diff --git a/scripts/fontdump.c b/scripts/fontdump.c
index 37572bea..e40bf4ab 100644
--- a/scripts/fontdump.c
+++ b/scripts/fontdump.c
@@ -28,7 +28,8 @@ main(int argc, char **argv)
{
FILE *fo;
FILE *fi;
- char name[256];
+ char fontname[256];
+ char origname[256];
char *basename;
char *p;
int i, len;
@@ -50,7 +51,7 @@ main(int argc, char **argv)
fprintf(fo, "#if defined(__linux__) || defined(__FreeBSD__)\n");
fprintf(fo, "#define HAVE_INCBIN\n");
fprintf(fo, "#endif\n");
- fprintf(fo, "#endif\n\n");
+ fprintf(fo, "#endif\n");
for (i = 2; i < argc; i++)
{
@@ -69,11 +70,16 @@ main(int argc, char **argv)
basename++;
else
basename = argv[i];
- strcpy(name, basename);
- p = name;
+
+ strcpy(origname, basename);
+ p = strrchr(origname, '.');
+ if (p) *p = 0;
+ strcpy(fontname, origname);
+
+ p = fontname;
while (*p)
{
- if ((*p == '/') || (*p == '.') || (*p == '\\') || (*p == '-'))
+ if (*p == '/' || *p == '.' || *p == '\\' || *p == '-')
*p = '_';
p ++;
}
@@ -82,18 +88,19 @@ main(int argc, char **argv)
len = ftell(fi);
fseek(fi, 0, SEEK_SET);
- fprintf(fo, "const unsigned int pdf_font_%s_len = %d;\n", name, len);
+ printf("\t{\"%s\",pdf_font_%s,%d},\n", origname, fontname, len);
- fprintf(fo, "#ifdef HAVE_INCBIN\n");
- fprintf(fo, "asm(\".globl pdf_font_%s_buf\");\n", name);
+ fprintf(fo, "\n#ifdef HAVE_INCBIN\n");
+ fprintf(fo, "extern const unsigned char pdf_font_%s[%d];\n", fontname, len);
+ fprintf(fo, "asm(\".globl pdf_font_%s\");\n", fontname);
fprintf(fo, "asm(\".balign 8\");\n");
- fprintf(fo, "asm(\"pdf_font_%s_buf:\");\n", name);
+ fprintf(fo, "asm(\"pdf_font_%s:\");\n", fontname);
fprintf(fo, "asm(\".incbin \\\"%s\\\"\");\n", argv[i]);
fprintf(fo, "#else\n");
- fprintf(fo, "const unsigned char pdf_font_%s_buf[%d] = {\n", name, len);
+ fprintf(fo, "static const unsigned char pdf_font_%s[%d] = {\n", fontname, len);
hexdump(fo, fi);
fprintf(fo, "};\n");
- fprintf(fo, "#endif\n\n");
+ fprintf(fo, "#endif\n");
fclose(fi);
}
diff --git a/win32/libmupdf.vcproj b/win32/libmupdf.vcproj
index e68fb697..0017a340 100644
--- a/win32/libmupdf.vcproj
+++ b/win32/libmupdf.vcproj
@@ -140,38 +140,6 @@
</References>
<Files>
<Filter
- Name="pregen"
- >
- <File
- RelativePath="..\pregen\cmap_cns.c"
- >
- </File>
- <File
- RelativePath="..\pregen\cmap_gb.c"
- >
- </File>
- <File
- RelativePath="..\pregen\cmap_japan.c"
- >
- </File>
- <File
- RelativePath="..\pregen\cmap_korea.c"
- >
- </File>
- <File
- RelativePath="..\pregen\cmap_unicode.c"
- >
- </File>
- <File
- RelativePath="..\pregen\font_base14.c"
- >
- </File>
- <File
- RelativePath="..\pregen\font_cjk.c"
- >
- </File>
- </Filter>
- <Filter
Name="pdf"
>
<File
@@ -227,10 +195,6 @@
>
</File>
<File
- RelativePath="..\pdf\pdf_fontmtx.c"
- >
- </File>
- <File
RelativePath="..\pdf\pdf_function.c"
>
</File>
@@ -247,6 +211,10 @@
>
</File>
<File
+ RelativePath="..\pdf\pdf_metrics.c"
+ >
+ </File>
+ <File
RelativePath="..\pdf\pdf_nametree.c"
>
</File>