summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipdfm-x/cid.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvipdfm-x/cid.c')
-rw-r--r--Build/source/texk/dvipdfm-x/cid.c617
1 files changed, 211 insertions, 406 deletions
diff --git a/Build/source/texk/dvipdfm-x/cid.c b/Build/source/texk/dvipdfm-x/cid.c
index 42554ad3123..bb3fb18604c 100644
--- a/Build/source/texk/dvipdfm-x/cid.c
+++ b/Build/source/texk/dvipdfm-x/cid.c
@@ -40,14 +40,8 @@
#include "cidtype0.h"
#include "cidtype2.h"
-#include "cid_p.h"
#include "cid.h"
-#include "cff.h"
-
-#define CIDFONT_DEBUG 3
-#define CIDFONT_DEBUG_STR "CIDFont"
-
#define PDF_CID_SUPPORT_MIN 2
#define PDF_CID_SUPPORT_MAX 6
@@ -104,6 +98,7 @@ CIDSysInfo CSI_UNICODE = {
/*
* Optional supplement after alias name.
*/
+
static struct {
const char *name;
int index;
@@ -115,275 +110,134 @@ static struct {
};
static void release_opt (cid_opt *opt);
-static CIDSysInfo *get_cidsysinfo (const char *map_name, fontmap_opt *fmap_opt);
-
-static int cidoptflags = 0;
-
-#if 0
-int
-CIDFont_require_version (void)
-{
- return PDF_CID_SUPPORT_MIN;
-}
-#endif
-
-static CIDFont *
-CIDFont_new (void)
-{
- CIDFont *font = NULL;
-
- font = NEW(1, struct CIDFont);
-
- font->name = NULL;
- font->fontname = NULL;
- font->ident = NULL;
-
- /*
- * CIDFont
- */
- font->subtype = -1;
- font->flags = FONT_FLAG_NONE;
- font->csi = NULL;
- font->options = NULL;
- (font->parent)[0] = -1; /* Horizontal */
- (font->parent)[1] = -1; /* Vertical */
+static int get_cidsysinfo (CIDSysInfo *csi, const char *map_name, fontmap_opt *fmap_opt);
- /*
- * PDF Font Resource
- */
- font->indirect = NULL;
- font->fontdict = NULL;
- font->descriptor = NULL;
-
- return font;
-}
-
-/* It does write PDF objects. */
-static void
-CIDFont_flush (CIDFont *font)
-{
- if (font) {
- if (font->indirect) pdf_release_obj(font->indirect);
- font->indirect = NULL;
- if (font->fontdict) pdf_release_obj(font->fontdict);
- font->fontdict = NULL;
- if (font->descriptor) pdf_release_obj(font->descriptor);
- font->descriptor = NULL;
- }
-}
-
-static void
-CIDFont_release (CIDFont *font)
-{
- if (font) {
- if (font->indirect)
- ERROR("%s: Object not flushed.", CIDFONT_DEBUG_STR);
- if (font->fontdict)
- ERROR("%s: Object not flushed.", CIDFONT_DEBUG_STR);
- if (font->descriptor)
- ERROR("%s: Object not flushed.", CIDFONT_DEBUG_STR);
-
- if (font->fontname) RELEASE(font->fontname);
- if (font->name) RELEASE(font->name);
- if (font->ident) RELEASE(font->ident);
- if (font->csi) {
- if (font->csi->registry)
- RELEASE(font->csi->registry);
- if (font->csi->ordering)
- RELEASE(font->csi->ordering);
- RELEASE(font->csi);
- }
- if (font->options)
- release_opt(font->options);
- }
-}
-
-char *
-CIDFont_get_fontname (CIDFont *font)
-{
- ASSERT(font);
- return font->fontname;
-}
-
-char *
-CIDFont_get_ident (CIDFont *font)
-{
- ASSERT(font);
- return font->ident;
-}
+int opt_flags_cidfont = 0;
int
-CIDFont_get_opt_index (CIDFont *font)
+CIDFont_is_ACCFont (pdf_font *font)
{
- int opt_index;
+ int i;
+ CIDSysInfo *csi;
ASSERT(font);
- if (font->options)
- opt_index = font->options->index;
- else {
- opt_index = 0;
+ csi = &font->cid.csi;
+ for (i = ACC_START; i <= ACC_END ; i++) {
+ if (!strcmp(csi->registry, CIDFont_stdcc_def[i].registry) &&
+ !strcmp(csi->ordering, CIDFont_stdcc_def[i].ordering))
+ return 1;
}
- return opt_index;
-}
-
-int
-CIDFont_get_subtype (CIDFont *font)
-{
- ASSERT(font);
- return font->subtype;
+ return 0;
}
int
-CIDFont_get_embedding (CIDFont *font)
+CIDFont_is_UCSFont (pdf_font *font)
{
- ASSERT(font);
- return font->options->embed;
-}
+ CIDSysInfo *csi;
-CIDSysInfo *
-CIDFont_get_CIDSysInfo (CIDFont *font)
-{
ASSERT(font);
- return font->csi;
-}
-
-/*
- * Returns ID of parent Type0 font
- * wmode: 0 for horizontal, 1 for vertical
- */
-int
-CIDFont_get_parent_id (CIDFont *font, int wmode)
-{
- ASSERT(font);
+ csi = &font->cid.csi;
- if (wmode < 0 || wmode > 1)
- ERROR("%s: Invalid wmode value.", CIDFONT_DEBUG_STR);
+ if (!strcmp(csi->ordering, "UCS") ||
+ !strcmp(csi->ordering, "UCS2"))
+ return 1;
- return (font->parent)[wmode];
+ return 0;
}
-pdf_obj *
-CIDFont_get_resource (CIDFont *font)
+char *
+CIDFont_get_usedchars (pdf_font *font)
{
- ASSERT(font);
-
- if (!font->indirect)
- font->indirect = pdf_ref_obj(font->fontdict);
+ if (!font->usedchars) {
+ font->usedchars = NEW(8192, char);
+ memset(font->usedchars, 0, 8192*sizeof(char));
+ }
- return pdf_link_obj(font->indirect);
+ return font->usedchars;
}
-/*
- * Set parent Type0 font.
- */
-void
-CIDFont_attach_parent (CIDFont *font, int parent_id, int wmode)
+char *
+CIDFont_get_usedchars_v (pdf_font *font)
{
- ASSERT(font);
-
- if (wmode < 0 || wmode > 1)
- ERROR("%s: Invalid wmode value.", CIDFONT_DEBUG_STR);
-
- if (font->parent[wmode] >= 0)
- WARN("%s: CIDFont already have a parent Type1 font.", CIDFONT_DEBUG_STR);
+ if (!font->cid.usedchars_v) {
+ font->cid.usedchars_v = NEW(8192, char);
+ memset(font->cid.usedchars_v, 0, 8192*sizeof(char));
+ }
- font->parent[wmode] = parent_id;
+ return font->cid.usedchars_v;
}
-int
-CIDFont_is_ACCFont (CIDFont *font)
+
+static int
+source_font_type (pdf_font *font)
{
- int i;
+ int type = PDF_FONT_FONTTYPE_CIDTYPE0;
ASSERT(font);
- if (!font->csi)
- ERROR("%s: CIDSystemInfo undefined.", CIDFONT_DEBUG_STR);
-
- for (i = ACC_START; i <= ACC_END ; i++) {
- if (!strcmp(font->csi->registry, CIDFont_stdcc_def[i].registry) &&
- !strcmp(font->csi->ordering, CIDFont_stdcc_def[i].ordering))
- return 1;
+ if (font->flags & CIDFONT_FLAG_TYPE1) {
+ type = PDF_FONT_FONTTYPE_TYPE1;
+ } else if (font->flags & CIDFONT_FLAG_TYPE1C) {
+ type = PDF_FONT_FONTTYPE_TYPE1C;
+ } else if (font->flags & CIDFONT_FLAG_TRUETYPE) {
+ type = PDF_FONT_FONTTYPE_TRUETYPE;
}
- return 0;
-}
-
-int
-CIDFont_is_UCSFont (CIDFont *font)
-{
- ASSERT(font);
- if (!strcmp(font->csi->ordering, "UCS") ||
- !strcmp(font->csi->ordering, "UCS2"))
- return 1;
- return 0;
+ return type;
}
-/* FIXME */
-int
-CIDFont_get_flag (CIDFont *font, int mask)
+void
+pdf_font_load_cidfont (pdf_font *font)
{
- ASSERT(font);
- return ((font->flags & mask) ? 1 : 0);
-}
+ int error = 0;
-static void
-CIDFont_dofont (CIDFont *font)
-{
- if (!font || !font->indirect)
+ if (!font || !font->reference)
return;
if (dpx_conf.verbose_level > 0)
- MESG(":%s", font->ident);
+ MESG(":%s", font->filename);
if (dpx_conf.verbose_level > 1) {
if (font->fontname)
MESG("[%s]", font->fontname);
}
switch (font->subtype) {
- case CIDFONT_TYPE0:
+ case PDF_FONT_FONTTYPE_CIDTYPE0:
if(dpx_conf.verbose_level > 0)
MESG("[CIDFontType0]");
- if (CIDFont_get_flag(font, CIDFONT_FLAG_TYPE1))
- CIDFont_type0_t1dofont(font);
- else if (CIDFont_get_flag(font, CIDFONT_FLAG_TYPE1C))
- CIDFont_type0_t1cdofont(font);
- else
- CIDFont_type0_dofont(font);
+ switch (source_font_type(font)) {
+ case PDF_FONT_FONTTYPE_TYPE1:
+ error = CIDFont_type0_t1dofont(font);
+ break;
+ case PDF_FONT_FONTTYPE_TYPE1C:
+ error = CIDFont_type0_t1cdofont(font);
+ break;
+ default:
+ error = CIDFont_type0_dofont(font);
+ break;
+ }
break;
- case CIDFONT_TYPE2:
+ case PDF_FONT_FONTTYPE_CIDTYPE2:
if(dpx_conf.verbose_level > 0)
MESG("[CIDFontType2]");
- CIDFont_type2_dofont(font);
- break;
- default:
- ERROR("%s: Unknown CIDFontType %d.", CIDFONT_DEBUG_STR, font->subtype);
+ error = CIDFont_type2_dofont(font);
break;
}
-}
-
-/*
- *
- */
-int
-CIDFont_is_BaseFont (CIDFont *font)
-{
- ASSERT(font);
- return (font->flags & FONT_FLAG_BASEFONT) ? 1 : 0;
+ if (error)
+ ERROR("Error occurred while loading font: %s", font->filename);
+
+ return;
}
#include "pdfparse.h"
#include "cid_basefont.h"
-static int CIDFont_base_open (CIDFont *font,
- const char *name, CIDSysInfo *cmap_csi, cid_opt *opt);
-
static int
-CIDFont_base_open (CIDFont *font, const char *name, CIDSysInfo *cmap_csi, cid_opt *opt)
+CIDFont_base_open (pdf_font *font, const char *name, cid_opt *opt)
{
pdf_obj *fontdict, *descriptor;
char *fontname = NULL;
@@ -433,7 +287,7 @@ CIDFont_base_open (CIDFont *font, const char *name, CIDSysInfo *cmap_csi, cid_op
}
font->fontname = fontname;
- font->flags |= FONT_FLAG_BASEFONT;
+ font->flags |= PDF_FONT_FLAG_BASEFONT;
{
char *registry, *ordering;
int supplement;
@@ -446,22 +300,12 @@ CIDFont_base_open (CIDFont *font, const char *name, CIDSysInfo *cmap_csi, cid_op
registry = pdf_string_value(pdf_lookup_dict(tmp, "Registry"));
ordering = pdf_string_value(pdf_lookup_dict(tmp, "Ordering"));
supplement = pdf_number_value(pdf_lookup_dict(tmp, "Supplement"));
- if (cmap_csi) { /* NULL for accept any */
- if (strcmp(registry, cmap_csi->registry) ||
- strcmp(ordering, cmap_csi->ordering))
- ERROR("Inconsistent CMap used for CID-keyed font %s.",
- cid_basefont[idx].fontname);
- else if (supplement < cmap_csi->supplement) {
- WARN("CMap has higher supplement number than CIDFont: %s", fontname);
- WARN("Some chracters may not be displayed or printed.");
- }
- }
- font->csi = NEW(1, CIDSysInfo);
- font->csi->registry = NEW(strlen(registry)+1, char);
- font->csi->ordering = NEW(strlen(ordering)+1, char);
- strcpy(font->csi->registry, registry);
- strcpy(font->csi->ordering, ordering);
- font->csi->supplement = supplement;
+
+ font->cid.csi.registry = NEW(strlen(registry)+1, char);
+ font->cid.csi.ordering = NEW(strlen(ordering)+1, char);
+ strcpy(font->cid.csi.registry, registry);
+ strcpy(font->cid.csi.ordering, ordering);
+ font->cid.csi.supplement = supplement;
}
{
@@ -473,15 +317,15 @@ CIDFont_base_open (CIDFont *font, const char *name, CIDSysInfo *cmap_csi, cid_op
type = pdf_name_value(tmp);
if (!strcmp(type, "CIDFontType0"))
- font->subtype = CIDFONT_TYPE0;
+ font->subtype = PDF_FONT_FONTTYPE_CIDTYPE0;
else if (!strcmp(type, "CIDFontType2"))
- font->subtype = CIDFONT_TYPE2;
+ font->subtype = PDF_FONT_FONTTYPE_CIDTYPE2;
else {
ERROR("Unknown CIDFontType \"%s\"", type);
}
}
- if (cidoptflags & CIDFONT_FORCE_FIXEDPITCH) {
+ if (opt_flags_cidfont & CIDFONT_FORCE_FIXEDPITCH) {
if (pdf_lookup_dict(fontdict, "W")) {
pdf_remove_dict(fontdict, "W");
}
@@ -495,7 +339,7 @@ CIDFont_base_open (CIDFont *font, const char *name, CIDSysInfo *cmap_csi, cid_op
pdf_add_dict(descriptor, pdf_new_name("Type"), pdf_new_name("FontDescriptor"));
pdf_add_dict(descriptor, pdf_new_name("FontName"), pdf_new_name(fontname));
- font->fontdict = fontdict;
+ font->resource = fontdict;
font->descriptor = descriptor;
opt->embed = 0;
@@ -503,184 +347,154 @@ CIDFont_base_open (CIDFont *font, const char *name, CIDSysInfo *cmap_csi, cid_op
return 0;
}
-
-
-#define CACHE_ALLOC_SIZE 16u
-
-struct FontCache {
- int num;
- int max;
- CIDFont **fonts;
-};
-
-static struct FontCache *__cache = NULL;
-
-#define CHECK_ID(n) do {\
- if (! __cache)\
- ERROR("%s: CIDFont cache not initialized.", CIDFONT_DEBUG_STR);\
- if ((n) < 0 || (n) >= __cache->num)\
- ERROR("%s: Invalid ID %d", CIDFONT_DEBUG_STR, (n));\
- } while (0)
-
-static void
-CIDFont_cache_init (void)
-{
- if (__cache)
- ERROR("%s: Already initialized.", CIDFONT_DEBUG_STR);
-
- __cache = NEW(1, struct FontCache);
-
- __cache->max = CACHE_ALLOC_SIZE;
- __cache->fonts = NEW(__cache->max, struct CIDFont *);
- __cache->num = 0;
-}
-
-CIDFont *
-CIDFont_cache_get (int font_id)
-{
- CHECK_ID(font_id);
- return __cache->fonts[font_id];
-}
-
-/*
- * cmap_csi is NULL if CMap is Identity.
- */
int
-CIDFont_cache_find (const char *map_name,
- CIDSysInfo *cmap_csi, fontmap_opt *fmap_opt)
+pdf_font_cidfont_lookup_cache (pdf_font *fonts, int count, const char *map_name, CIDSysInfo *cmap_csi, fontmap_opt *fmap_opt)
{
- int font_id = -1;
- CIDFont *font = NULL;
- cid_opt *opt = NULL;
-
- if (!__cache)
- CIDFont_cache_init();
-
- opt = NEW(1, cid_opt);
- opt->style = fmap_opt->style;
- opt->index = fmap_opt->index;
- opt->embed = (fmap_opt->flags & FONTMAP_OPT_NOEMBED) ? 0 : 1;
- opt->name = NULL;
- opt->csi = get_cidsysinfo(map_name, fmap_opt);
- opt->stemv = fmap_opt->stemv;
-
- if (!opt->csi && cmap_csi) {
+ int font_id = -1;
+ pdf_font *font = NULL;
+ cid_opt opt;
+ int has_csi;
+
+ ASSERT(fonts);
+
+ opt.style = fmap_opt->style;
+ opt.embed = (fmap_opt->flags & FONTMAP_OPT_NOEMBED) ? 0 : 1;
+ opt.csi.registry = NULL;
+ opt.csi.ordering = NULL;
+ opt.csi.supplement = 0;
+ has_csi = get_cidsysinfo(&opt.csi, map_name, fmap_opt);
+ opt.stemv = fmap_opt->stemv;
+
+ if (!has_csi && cmap_csi) {
/*
* No CIDSystemInfo supplied explicitly. Copy from CMap's one if available.
* It is not neccesary for CID-keyed fonts. But TrueType requires them.
*/
- opt->csi = NEW(1, CIDSysInfo);
- opt->csi->registry = NEW(strlen(cmap_csi->registry)+1, char);
- strcpy(opt->csi->registry, cmap_csi->registry);
- opt->csi->ordering = NEW(strlen(cmap_csi->ordering)+1, char);
- strcpy(opt->csi->ordering, cmap_csi->ordering);
- opt->csi->supplement = cmap_csi->supplement;
+ opt.csi.registry = NEW(strlen(cmap_csi->registry)+1, char);
+ strcpy(opt.csi.registry, cmap_csi->registry);
+ opt.csi.ordering = NEW(strlen(cmap_csi->ordering)+1, char);
+ strcpy(opt.csi.ordering, cmap_csi->ordering);
+ opt.csi.supplement = cmap_csi->supplement;
+ has_csi = 1;
}
/*
* Here, we do not compare font->ident and map_name because of
* implicit CIDSystemInfo supplied by CMap for TrueType.
*/
- for (font_id = 0; font_id < __cache->num; font_id++) {
- font = __cache->fonts[font_id];
- if (!strcmp(font->name, map_name) &&
- font->options->style == opt->style &&
- font->options->index == opt->index) {
- if (font->options->embed == opt->embed) {
+ for (font_id = 0; font_id < count; font_id++) {
+ font = &fonts[font_id];
+ if (font->subtype != PDF_FONT_FONTTYPE_CIDTYPE0 &&
+ font->subtype != PDF_FONT_FONTTYPE_CIDTYPE2)
+ continue;
+ if (!strcmp(font->filename, map_name) &&
+ font->cid.options.style == opt.style &&
+ font->index == fmap_opt->index) {
+ if (font->cid.options.embed == opt.embed) {
/*
* Case 1: CSI not available (Identity CMap)
* Font is TrueType --> continue
* Font is CIDFont --> break
* Case 2: CSI matched --> break
*/
- if (!opt->csi) {
- if (font->subtype == CIDFONT_TYPE2)
+ if (!has_csi) {
+ if (font->subtype == PDF_FONT_FONTTYPE_CIDTYPE2)
continue;
else
break;
- } else if (!strcmp(font->csi->registry, opt->csi->registry) &&
- !strcmp(font->csi->ordering, opt->csi->ordering)) {
- if (font->subtype == CIDFONT_TYPE2)
- font->csi->supplement =
- MAX(opt->csi->supplement, font->csi->supplement);
+ } else if (!strcmp(font->cid.csi.registry, opt.csi.registry) &&
+ !strcmp(font->cid.csi.ordering, opt.csi.ordering)) {
+ if (font->subtype == PDF_FONT_FONTTYPE_CIDTYPE2)
+ font->cid.csi.supplement =
+ MAX(opt.csi.supplement, font->cid.csi.supplement); /* FIXME: font modified */
break;
}
- } else if (CIDFont_is_BaseFont(font)) {
- opt->embed = 0;
+ } else if (font->flags & PDF_FONT_FLAG_BASEFONT) {
break;
}
}
}
+ release_opt(&opt);
- if (font_id < __cache->num && cmap_csi) {
- if (strcmp(font->csi->registry, cmap_csi->registry) ||
- strcmp(font->csi->ordering, cmap_csi->ordering))
- ERROR("%s: Incompatible CMap for CIDFont \"%s\"",
- CIDFONT_DEBUG_STR, map_name);
- }
-
- if (font_id == __cache->num) {
- font = CIDFont_new();
- if (CIDFont_type0_open(font, map_name, cmap_csi, opt, 0) < 0 &&
- CIDFont_type2_open(font, map_name, cmap_csi, opt) < 0 &&
- CIDFont_type0_open(font, map_name, cmap_csi, opt,
- CIDFONT_FLAG_TYPE1) < 0 &&
- CIDFont_type0_open(font, map_name, cmap_csi, opt,
- CIDFONT_FLAG_TYPE1C) < 0 &&
- CIDFont_base_open (font, map_name, cmap_csi, opt) < 0) {
- CIDFont_release(font);
- release_opt(opt);
- return -1;
- } else {
- if (__cache->num >= __cache->max) {
- __cache->max += CACHE_ALLOC_SIZE;
- __cache->fonts = RENEW(__cache->fonts,
- __cache->max, struct CIDFont *);
- }
- font->name = NEW(strlen(map_name)+1, char);
- strcpy(font->name, map_name);
- font->ident = NEW(strlen(map_name)+1, char);
- strcpy(font->ident, map_name);
- font->options = opt;
- __cache->fonts[font_id] = font;
- (__cache->num)++;
- }
- } else if (opt) {
- release_opt(opt);
- }
-
- return font_id;
+ return (font_id < count) ? font_id : -1;
}
-void
-CIDFont_cache_close (void)
+int
+pdf_font_open_cidfont (pdf_font *font, const char *map_name, CIDSysInfo *cmap_csi, fontmap_opt *fmap_opt)
{
- int font_id;
-
- if (__cache) {
- for (font_id = 0;
- font_id < __cache->num; font_id++) {
- CIDFont *font;
-
- font = __cache->fonts[font_id];
-
- if (dpx_conf.verbose_level > 0)
- MESG("(CID");
-
- CIDFont_dofont (font);
- CIDFont_flush (font);
- CIDFont_release(font);
+ cid_opt opt;
+ int has_csi;
+
+ opt.style = fmap_opt->style;
+ opt.embed = (fmap_opt->flags & FONTMAP_OPT_NOEMBED) ? 0 : 1;
+ opt.csi.registry = NULL;
+ opt.csi.ordering = NULL;
+ opt.csi.supplement = 0;
+ has_csi = get_cidsysinfo(&opt.csi, map_name, fmap_opt);
+ opt.stemv = fmap_opt->stemv;
+
+ if (!has_csi && cmap_csi) {
+ /*
+ * No CIDSystemInfo supplied explicitly. Copy from CMap's one if available.
+ * It is not neccesary for CID-keyed fonts. But TrueType requires them.
+ */
+ opt.csi.registry = NEW(strlen(cmap_csi->registry)+1, char);
+ strcpy(opt.csi.registry, cmap_csi->registry);
+ opt.csi.ordering = NEW(strlen(cmap_csi->ordering)+1, char);
+ strcpy(opt.csi.ordering, cmap_csi->ordering);
+ opt.csi.supplement = cmap_csi->supplement;
+ has_csi = 1;
+ }
- RELEASE(font);
+ if (CIDFont_type0_open(font, map_name, fmap_opt->index, &opt) < 0 &&
+ CIDFont_type2_open(font, map_name, fmap_opt->index, &opt) < 0 &&
+ CIDFont_type0_open_from_t1 (font, map_name, fmap_opt->index, &opt) < 0 &&
+ CIDFont_type0_open_from_t1c(font, map_name, fmap_opt->index, &opt) < 0 &&
+ CIDFont_base_open (font, map_name, &opt) < 0) {
+ release_opt(&opt);
+ return -1;
+ }
- if (dpx_conf.verbose_level > 0)
- MESG(")");
+ font->filename = NEW(strlen(map_name)+1, char);
+ strcpy(font->filename, map_name);
+ font->ident = NEW(strlen(map_name)+1, char);
+ strcpy(font->ident, map_name);
+ font->index = fmap_opt->index;
+ font->cid.options = opt;
+
+ if (font->cid.csi.registry && font->cid.csi.ordering) {
+ if (cmap_csi) {
+ if (strcmp(font->cid.csi.registry, cmap_csi->registry) ||
+ strcmp(font->cid.csi.ordering, cmap_csi->ordering)) {
+ WARN("Inconsistent ROS found:\n");
+ MESG("\tFont: %s-%s-%d\n", font->cid.csi.registry, font->cid.csi.ordering, font->cid.csi.supplement);
+ MESG("\tCMap: %s-%s-%d\n", cmap_csi->registry, cmap_csi->ordering, cmap_csi->supplement);
+ ERROR("Incompatible CMap specified for this font.");
+ }
+ if (font->cid.csi.supplement < cmap_csi->supplement) {
+ font->cid.csi.supplement = cmap_csi->supplement;
+ }
+ }
+ } else {
+ ASSERT(font->subtype == PDF_FONT_FONTTYPE_CIDTYPE2);
+ if (cmap_csi) {
+ font->cid.csi.registry = NEW(strlen(cmap_csi->registry)+1, char);
+ strcpy(font->cid.csi.registry, cmap_csi->registry);
+ font->cid.csi.ordering = NEW(strlen(cmap_csi->ordering)+1, char);
+ strcpy(font->cid.csi.ordering, cmap_csi->ordering);
+ font->cid.csi.supplement = cmap_csi->supplement;
+ } else { /* This means font's internal glyph ordering. */
+ font->cid.csi.registry = NEW(strlen("Adobe")+1, char);
+ strcpy(font->cid.csi.registry, "Adobe");
+ font->cid.csi.ordering = NEW(strlen("Identity")+1, char);
+ strcpy(font->cid.csi.ordering, "Identity");
+ font->cid.csi.supplement = 0;
}
- RELEASE(__cache->fonts);
- RELEASE(__cache);
- __cache = NULL;
}
+
+ return 0;
}
+
/******************************* OPTIONS *******************************/
/*
@@ -692,20 +506,16 @@ CIDFont_cache_close (void)
static void
release_opt (cid_opt *opt)
{
- if (opt->csi) {
- if (opt->csi->registry)
- RELEASE(opt->csi->registry);
- if (opt->csi->ordering)
- RELEASE(opt->csi->ordering);
- RELEASE(opt->csi);
- }
- RELEASE(opt);
+ if (opt->csi.registry)
+ RELEASE(opt->csi.registry);
+ if (opt->csi.ordering)
+ RELEASE(opt->csi.ordering);
}
-static CIDSysInfo *
-get_cidsysinfo (const char *map_name, fontmap_opt *fmap_opt)
+static int
+get_cidsysinfo (CIDSysInfo *csi, const char *map_name, fontmap_opt *fmap_opt)
{
- CIDSysInfo *csi = NULL;
+ int has_csi = 0;
int sup_idx;
int i, csi_idx = -1, n, m;
@@ -713,7 +523,7 @@ get_cidsysinfo (const char *map_name, fontmap_opt *fmap_opt)
sup_idx = (sup_idx > SUP_IDX_MAX) ? SUP_IDX_MAX : sup_idx;
if (!fmap_opt || !fmap_opt->charcoll)
- return NULL;
+ return 0;
/* First try alias for standard one. */
for (i = 0; CIDFont_stdcc_alias[i].name != NULL; i++) {
@@ -721,7 +531,6 @@ get_cidsysinfo (const char *map_name, fontmap_opt *fmap_opt)
if (!strncmp(fmap_opt->charcoll,
CIDFont_stdcc_alias[i].name, n)) {
csi_idx = CIDFont_stdcc_alias[i].index;
- csi = NEW(1, CIDSysInfo);
csi->registry = NEW(strlen(CIDFont_stdcc_def[csi_idx].registry)+1, char);
strcpy(csi->registry, CIDFont_stdcc_def[csi_idx].registry);
csi->ordering = NEW(strlen(CIDFont_stdcc_def[csi_idx].ordering)+1, char);
@@ -731,31 +540,28 @@ get_cidsysinfo (const char *map_name, fontmap_opt *fmap_opt)
} else { /* Use heighest supported value for current output PDF version. */
csi->supplement = CIDFont_stdcc_def[csi_idx].supplement[sup_idx];
}
+ has_csi = 1;
break;
}
}
- if (csi == NULL) {
+ if (!has_csi) {
char *p, *q;
p = (char *) fmap_opt->charcoll;
- csi = NEW(1, CIDSysInfo);
/* Full REGISTRY-ORDERING-SUPPLEMENT */
p = strchr(fmap_opt->charcoll, '-');
if (!p || p[1] == '\0')
- ERROR("%s: String can't be converted to REGISTRY-ORDERING-SUPPLEMENT: %s",
- CIDFONT_DEBUG_STR, fmap_opt->charcoll);
+ ERROR("String can't be converted to REGISTRY-ORDERING-SUPPLEMENT: %s", fmap_opt->charcoll);
p++;
q = strchr(p, '-');
if (!q || q[1] == '\0')
- ERROR("%s: String can't be converted to REGISTRY-ORDERING-SUPPLEMENT: %s",
- CIDFONT_DEBUG_STR, fmap_opt->charcoll);
+ ERROR("String can't be converted to REGISTRY-ORDERING-SUPPLEMENT: %s", fmap_opt->charcoll);
q++;
if (!isdigit((unsigned char)q[0]))
- ERROR("%s: String can't be converted to REGISTRY-ORDERING-SUPPLEMENT: %s",
- CIDFONT_DEBUG_STR, fmap_opt->charcoll);
+ ERROR("String can't be converted to REGISTRY-ORDERING-SUPPLEMENT: %s", fmap_opt->charcoll);
n = strlen(fmap_opt->charcoll) - strlen(p) - 1;
csi->registry = NEW(n+1, char);
@@ -769,6 +575,8 @@ get_cidsysinfo (const char *map_name, fontmap_opt *fmap_opt)
csi->supplement = (int) strtoul(q, NULL, 10);
+ has_csi = 1;
+
/* Check for standart character collections. */
for (i = 0; CIDFont_stdcc_def[i].ordering != NULL; i++) {
if ((CIDFont_stdcc_def[i].registry &&
@@ -783,22 +591,19 @@ get_cidsysinfo (const char *map_name, fontmap_opt *fmap_opt)
if (csi && csi_idx >= 0) {
if (csi->supplement > CIDFont_stdcc_def[csi_idx].supplement[sup_idx]
&& (fmap_opt->flags & FONTMAP_OPT_NOEMBED)) {
- WARN("%s: Heighest supplement number supported in PDF-%d.%d for %s-%s is %d.",
- CIDFONT_DEBUG_STR, pdf_get_version_major(), pdf_get_version_minor(),
+ WARN("Heighest supplement number supported in PDF-%d.%d for %s-%s is %d.",
+ pdf_get_version_major(), pdf_get_version_minor(),
csi->registry, csi->ordering,
CIDFont_stdcc_def[csi_idx].supplement[sup_idx]);
- WARN("%s: Some character may not shown without embedded font (--> %s).",
- CIDFONT_DEBUG_STR, map_name);
+ WARN("Some character may not shown without embedded font (--> %s).", map_name);
}
}
- return csi;
+ return has_csi;
}
void
CIDFont_set_flags (int flags)
{
- CIDFont_type0_set_flags(flags);
- CIDFont_type2_set_flags(flags);
- cidoptflags |= flags;
+ opt_flags_cidfont |= flags;
}