1
/* $Header: /home/cvsroot/dvipdfmx/src/truetype.c,v 1.5 2005/12/29 04:07:04 chofchof Exp $
3
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
5
Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
6
the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
38
#include "pdfresource.h"
41
#include "pdfencoding.h"
56
/* Modifying this has no effect :P */
58
# undef ENABLE_NOEMBED
62
pdf_font_open_truetype (pdf_font *font)
66
pdf_obj *fontdict, *descriptor;
68
int embedding = 1; /* Must be embedded. */
70
int length, error = 0;
74
ident = pdf_font_get_ident(font);
79
sfont = sfnt_open(pdf_font_get_ft_face(font), SFNT_TYPE_TTC | SFNT_TYPE_TRUETYPE);
83
fp = DPXFOPEN(ident, DPX_RES_TYPE_TTFONT);
87
sfont = sfnt_open(fp);
90
WARN("Could not open TrueType font: %s", ident);
96
if (sfont->type == SFNT_TYPE_TTC)
97
error = sfnt_read_table_directory(sfont, ttc_read_offset(sfont, 0));
99
error = sfnt_read_table_directory(sfont, 0);
104
return -1; /* Silently */
107
/* Reading fontdict before checking fonttype conflicts with PKFONT
108
* because pdf_font_get_resource() always makes a dictionary.
110
encoding_id = pdf_font_get_encoding(font);
111
fontdict = pdf_font_get_resource(font);
112
descriptor = pdf_font_get_descriptor(font);
113
#ifdef ENABLE_NOEMBED
114
embedding = pdf_font_get_flag(font, PDF_FONT_FLAG_NOEMBED) ? 0 : 1;
115
#endif /* ENABLE_NOEMBED */
117
ASSERT( fontdict && descriptor );
121
tmp = tt_get_fontdesc(sfont, &embedding, 1);
123
ERROR("Could not obtain neccesary font info.");
129
ASSERT(pdf_obj_typeof(tmp) == PDF_DICT);
131
pdf_merge_dict(descriptor, tmp);
132
pdf_release_obj(tmp);
136
if (encoding_id >= 0 &&
137
!pdf_encoding_is_predefined(encoding_id)) {
138
ERROR("Custum encoding not allowed for non-embedded TrueType font.");
142
/* There are basically no guarantee for font substitution
143
* can work with "symblic" fonts. At least all glyphs
144
* contained in the font must be identified; glyphs covers
145
* by this instance of font should contain glyphs only from
146
* Adobe Standard Latin Set. We allow non-embedded font
147
* only to predefined encodings for this reason. Note that
148
* "builtin" encoding means "MacRoman" here.
153
#ifndef ENABLE_NOEMBED
154
ERROR("Font file=\"%s\" can't be embedded due to liscence restrictions.", ident);
155
#endif /* ENABLE_NOEMBED */
156
pdf_font_set_flags(font, PDF_FONT_FLAG_NOEMBED);
157
tmp = pdf_lookup_dict(descriptor, "Flags");
158
if (tmp && pdf_obj_typeof(tmp) == PDF_NUMBER) {
159
flags = (long) pdf_number_value(tmp);
160
flags &= (1 << 2); /* clear Symbolic */
161
flags |= (1 << 5); /* set Nonsymbolic */
162
pdf_add_dict(descriptor, pdf_new_name("Flags"), pdf_new_number(flags));
171
memset(fontname, 0, 256);
172
length = tt_get_ps_fontname(sfont, fontname, 255);
174
length = MIN(strlen(ident), 255);
175
strncpy(fontname, ident, length);
177
fontname[length] = '\0';
178
for (n = 0; n < length; n++) {
179
if (fontname[n] == 0) {
180
memmove(fontname + n, fontname + n + 1, length - n - 1);
183
if (strlen(fontname) == 0)
184
ERROR("Can't find valid fontname for \"%s\".", ident);
185
pdf_font_set_fontname(font, fontname);
192
pdf_add_dict(fontdict,
193
pdf_new_name("Type"), pdf_new_name("Font"));
194
pdf_add_dict(fontdict,
195
pdf_new_name("Subtype"), pdf_new_name("TrueType"));
198
* We use MacRoman as "default" encoding.
200
if (encoding_id >= 0)
201
pdf_add_dict(fontdict,
202
pdf_new_name("Encoding"),
203
pdf_new_name(pdf_encoding_get_name(encoding_id)));
205
pdf_add_dict(fontdict,
206
pdf_new_name("Encoding"),
207
pdf_new_name("MacRomanEncoding"));
214
* The 'name' table should be preserved since it contains copyright
215
* information, but it might cause problem when there are invalid
216
* table entries (wrongly encoded text which is often the case in
217
* CJK fonts). Acrobat does not use 'name' table. Unicode TrueType
218
* fonts may have 10K bytes 'name' table...
220
* We preserve the 'OS/2' table too, since it contains the license
221
* information. PDF applications should use this table to decide
222
* whether the font is embedded only for the purpose of preview &
223
* printing. Otherwise, we must encrypt the document. Acrobat does
224
* not use 'OS/2' table, though...
230
} required_table[] = {
231
{"OS/2", 1}, {"head", 1}, {"hhea", 1}, {"loca", 1}, {"maxp", 1},
232
{"name", 1}, {"glyf", 1}, {"hmtx", 1}, {"fpgm", 0}, {"cvt ", 0},
233
{"prep", 0}, {"cmap", 1}, {NULL, 0}
237
do_widths (pdf_font *font, double *widths)
239
pdf_obj *fontdict = pdf_font_get_resource (font);
240
char *usedchars = pdf_font_get_usedchars(font);
242
int code, firstchar, lastchar;
244
firstchar = 255; lastchar = 0;
245
for (code = 0; code < 256; code++) {
246
if (usedchars[code]) {
247
if (code < firstchar) firstchar = code;
248
if (code > lastchar) lastchar = code;
251
if (firstchar > lastchar) {
252
WARN("No glyphs actually used???");
256
tmparray = pdf_new_array();
257
for (code = firstchar; code <= lastchar; code++) {
259
pdf_add_array(tmparray,
260
pdf_new_number(ROUND(widths[code], 1)));
262
pdf_add_array(tmparray, pdf_new_number(0.0));
265
if (pdf_array_length(tmparray) > 0) {
266
pdf_add_dict(fontdict,
267
pdf_new_name("Widths"), pdf_ref_obj(tmparray)); /* _FIXME_ */
269
pdf_release_obj(tmparray);
270
pdf_add_dict(fontdict,
271
pdf_new_name("FirstChar"), pdf_new_number(firstchar));
272
pdf_add_dict(fontdict,
273
pdf_new_name("LastChar"), pdf_new_number(lastchar));
278
static int verbose = 0;
280
#define PDFUNIT(v) ((double) (ROUND(1000.0*(v)/(glyphs->emsize), 1)))
283
* There are several issues in TrueType font support in PDF.
284
* How PDF viewers select TrueType cmap table is not so clear.
285
* Most reliable way seem to reencode font and sort glyphs as
286
* charcode == gid and to use Mac-Roman format 0 subtable.
287
* It does not work with encodings that uses full 256 range since
288
* GID = 0 is reserved for .notdef, so GID = 256 is not accessible.
291
do_builtin_encoding (pdf_font *font, const char *usedchars, sfnt *sfont)
293
struct tt_glyphs *glyphs;
300
ttcm = tt_cmap_read(sfont, TT_MAC, TT_MAC_ROMAN);
302
WARN("Could not read Mac-Roman TrueType cmap table...");
306
cmap_table = NEW(274, char);
307
memset(cmap_table, 0, 274);
308
sfnt_put_ushort(cmap_table, 0); /* Version */
309
sfnt_put_ushort(cmap_table+2, 1); /* Number of subtables */
310
sfnt_put_ushort(cmap_table+4, TT_MAC); /* Platform ID */
311
sfnt_put_ushort(cmap_table+6, TT_MAC_ROMAN); /* Encoding ID */
312
sfnt_put_ulong (cmap_table+8, 12); /* Offset */
313
sfnt_put_ushort(cmap_table+12, 0); /* Format */
314
sfnt_put_ushort(cmap_table+14, 262); /* Length */
315
sfnt_put_ushort(cmap_table+16, 0); /* Language */
317
glyphs = tt_build_init();
320
MESG("[glyphs:/.notdef");
322
count = 1; /* .notdef */
323
for (code = 0; code < 256; code++) {
324
if (!usedchars[code])
328
MESG("/.c0x%02x", code);
330
gid = tt_cmap_lookup(ttcm, code);
332
WARN("Glyph for character code=0x%02x missing in font font-file=\"%s\".",
333
code, pdf_font_get_ident(font));
336
idx = tt_find_glyph(glyphs, gid);
338
idx = tt_add_glyph(glyphs, gid, count); /* count returned. */
340
cmap_table[18+code] = idx & 0xff; /* bug here */
343
tt_cmap_release(ttcm);
348
if (tt_build_tables(sfont, glyphs) < 0) {
349
WARN("Packing TrueType font into SFNT failed!");
350
tt_build_finish(glyphs);
355
for (code = 0; code < 256; code++) {
356
if (usedchars[code]) {
357
idx = tt_get_index(glyphs, (USHORT) cmap_table[18+code]);
358
widths[code] = PDFUNIT(glyphs->gd[idx].advw);
363
do_widths(font, widths);
366
MESG("[%d glyphs]", glyphs->num_glyphs);
368
tt_build_finish(glyphs);
370
sfnt_set_table(sfont, "cmap", cmap_table, 274);
375
/* Order of lookup should be
383
struct tt_post_table *nametogid;
387
/* WARNING: This modifies glyphname itself */
389
agl_decompose_glyphname (char *glyphname, char **nptrs, int size, char **suffix)
391
char *q, *p = glyphname;
394
q = strchr(p, '.'); /* chop every thing after *first* dot */
403
for (n = 1; p && *p; n++) {
405
if (!p || p[1] == '\0')
408
ERROR("Uh ah..."); /* _FIXME_ */
417
select_gsub (const char *feat, struct glyph_mapper *gm)
421
if (!feat || *feat == 0 || !gm || !gm->gsub)
424
/* First treat as is */
425
idx = otl_gsub_select(gm->gsub, "*", "*", feat);
430
MESG("\ntrutype>> Try loading OTL GSUB for \"*.*.%s\"...", feat);
431
error = otl_gsub_add_feat(gm->gsub, "*", "*", feat, gm->sfont);
433
idx = otl_gsub_select(gm->gsub, "*", "*", feat);
434
return (idx >= 0 ? 0 : -1);
440
static int findparanoiac (const char *glyph_name, USHORT *gid, struct glyph_mapper *gm);
441
static int resolve_glyph (const char *glyph_name, USHORT *gid, struct glyph_mapper *gm);
443
/* Apply GSUB. This is a bit tricky... */
445
selectglyph (USHORT in, const char *suffix, struct glyph_mapper *gm, USHORT *out)
450
ASSERT(suffix && gm && out);
451
ASSERT(suffix && *suffix != 0);
453
s = NEW(strlen(suffix) + 1, char);
456
/* First try converting suffix to feature tag.
457
* agl.c currently only knows less ambiguos cases;
458
* e.g., 'sc', 'superior', etc.
460
q = (char *) agl_suffix_to_otltag(s);
461
if (q) { /* We found feature tag for 'suffix'. */
462
error = select_gsub(q, gm); /* no fallback for this */
464
error = otl_gsub_apply(gm->gsub, &in);
465
} else { /* 'suffix' may represent feature tag. */
466
/* Try loading GSUB only when length of 'suffix' is less
467
* than or equal to 4. tt_gsub give a warning otherwise.
471
else if (strlen(s) == 4)
472
error = select_gsub(s, gm);
473
else { /* less than 4. pad ' '. */
474
memset(t, ' ', 4); t[4] = '\0';
475
memcpy(t, s, strlen(s));
476
error = select_gsub(t, gm);
478
if (!error) /* 'suffix' represents feature tag. */
479
error = otl_gsub_apply(gm->gsub, &in);
480
else { /* other case: alt1, nalt10... (alternates) */
481
for (q = s + strlen(s) - 1; q > s && *q >= '0' && *q <= '9'; q--);
484
else { /* starting at 1 */
485
n = atoi(q + 1) - 1; q[1] = '\0';
488
else { /* This may be alternate substitution. */
489
memset(t, ' ', 4); t[4] = '\0';
490
memcpy(t, s, strlen(s));
491
error = select_gsub(s, gm);
493
error = otl_gsub_apply_alt(gm->gsub, n, &in);
505
/* Compose glyphs via ligature substitution. */
507
composeglyph (USHORT *glyphs, int n_glyphs,
508
const char *feat, struct glyph_mapper *gm, USHORT *gid)
511
char t[5] = {' ', ' ', ' ', ' ', 0};
513
ASSERT(glyphs && n_glyphs > 0 && gm && gid);
515
if (!feat || feat[0] == '\0') /* meaning "Unknown" */
516
error = select_gsub("(?lig|lig?|?cmp|cmp?|frac|afrc)", gm);
518
if (strlen(feat) > 4)
521
memcpy(t, feat, strlen(feat));
522
error = select_gsub(t, gm);
527
error = otl_gsub_apply_lig(gm->gsub, glyphs, n_glyphs, gid);
532
/* This may be called by findparanoiac(). */
534
composeuchar (long *unicodes, int n_unicodes,
535
const char *feat, struct glyph_mapper *gm, USHORT *gid)
543
gids = NEW(n_unicodes, USHORT);
545
!error && i < n_unicodes; i++) {
546
gids[i] = tt_cmap_lookup(gm->codetogid, unicodes[i]);
547
error = (gids[i] == 0) ? -1 : 0;
551
error = composeglyph(gids, n_unicodes, feat, gm, gid);
558
/* Search 'post' table. */
560
findposttable (const char *glyph_name, USHORT *gid, struct glyph_mapper *gm)
565
*gid = tt_lookup_post_table(gm->nametogid, glyph_name);
570
MESG("%s =post=> 0x%04X\n", glyph_name, *gid);
574
return (*gid == 0 ? -1 : 0);
577
/* This is wrong. We must care about '.'. */
578
#define is_comp(n) (strchr((n), '_') != NULL)
580
/* Glyph names are concatinated with '_'. */
582
findcomposite (const char *glyphname, USHORT *gid, struct glyph_mapper *gm)
584
char *gname, *suffix = NULL;
590
error = findposttable(glyphname, gid, gm);
594
gname = NEW(strlen(glyphname) + 1, char);
595
strcpy(gname, glyphname);
597
memset(gids, 0, 32 * sizeof(USHORT));
598
n_comp = agl_decompose_glyphname(gname, nptrs, 32, &suffix);
599
for (error = 0, i = 0; !error && i < n_comp; i++) {
600
error = resolve_glyph(nptrs[i], &gids[i], gm);
602
WARN("Could not resolve glyph \"%s\" (%dth component of glyph \"%s\").",
603
nptrs[i], i, glyphname);
608
(!strcmp(suffix, "liga") || !strcmp(suffix, "dlig") ||
609
!strcmp(suffix, "hlig") || !strcmp(suffix, "frac") ||
610
!strcmp(suffix, "ccmp") || !strcmp(suffix, "afrc")
613
error = composeglyph(gids, n_comp, suffix, gm, gid);
614
} else { /* first try composing glyph */
615
error = composeglyph(gids, n_comp, NULL, gm, gid);
616
if (!error && suffix) /* a_b_c.vert */
617
error = selectglyph(*gid, suffix, gm, gid);
625
/* glyphname should not have suffix here */
627
findparanoiac (const char *glyphname, USHORT *gid, struct glyph_mapper *gm)
633
agln = agl_lookup_list(glyphname);
634
while (agln && idx == 0) {
636
error = findparanoiac(agln->name, &idx, gm);
640
error = selectglyph(idx, agln->suffix, gm, &idx);
642
WARN("Variant \"%s\" for glyph \"%s\" might not be found.",
643
agln->suffix, agln->name);
644
WARN("Using glyph name without suffix instead...");
645
error = 0; /* ignore */
648
if (agln->n_components == 1)
649
idx = tt_cmap_lookup(gm->codetogid, agln->unicodes[0]);
650
else if (agln->n_components > 1) {
651
if (verbose >= 0) /* give warning */
652
WARN("Glyph \"%s\" looks like a composite glyph...",
654
error = composeuchar(agln->unicodes, agln->n_components, NULL, gm, &idx);
657
WARN("Not found...");
661
WARN(">> Composite glyph glyph-name=\"%s\" found at glyph-id=\"%u\".",
663
for (_p = _buf, _i = 0; _i < agln->n_components && _n < 245; _i++) {
664
_p[_n++] = _i == 0 ? '<' : ' ';
665
if (agln->unicodes[_i] >= 0x10000)
666
_n += sprintf(_p+_n, "U+%06lX", agln->unicodes[_i]);
668
_n += sprintf(_p+_n, "U+%04lX", agln->unicodes[_i]);
669
_p[_n++] = _i == agln->n_components - 1 ? '>' : ',';
672
WARN(">> Input Unicode seq.=\"%s\" ==> glyph-id=\"%u\" in font-file=\"_please_try_-v_\".", _buf, idx);
675
} else ASSERT(0); /* Boooo */
677
agln = agln->alternate;
681
return (idx == 0 ? -1 : 0);
685
resolve_glyph (const char *glyphname, USHORT *gid, struct glyph_mapper *gm)
688
char *name, *suffix = NULL;
694
* First we try glyph name to GID mapping using post table if post table
695
* is available. If post table is not available or glyph is not listed
696
* in the post table, then we try Unicode if Windows-Unicode TrueType
699
error = findposttable(glyphname, gid, gm);
706
name = agl_chop_suffix(glyphname, &suffix);
707
if (!name) /* .notdef, .foo */
709
else if (agl_name_is_unicode(name)) {
710
ucv = agl_name_convert_unicode(name);
711
*gid = tt_cmap_lookup(gm->codetogid, ucv);
712
error = (*gid == 0) ? -1 : 0;
714
error = findparanoiac(name, gid, gm);
716
if (!error && suffix) {
717
error = selectglyph(*gid, suffix, gm, gid);
719
WARN("Variant \"%s\" for glyph \"%s\" might not be found.",
721
WARN("Using glyph name without suffix instead...");
722
error = 0; /* ignore */
733
/* Things are complicated. We still need to use PostScript
734
* glyph names. But OpenType fonts may not have PS name to
735
* glyph mapping. We use Unicode plus OTL GSUB for finding
736
* glyphs in this case.
739
setup_glyph_mapper (struct glyph_mapper *gm, sfnt *sfont)
742
gm->nametogid = tt_read_post_table(sfont);
743
gm->codetogid = tt_cmap_read(sfont, TT_WIN, TT_WIN_UCS4);
745
gm->codetogid = tt_cmap_read(sfont, TT_WIN, TT_WIN_UNICODE);
747
if (!gm->nametogid && !gm->codetogid)
750
gm->gsub = otl_gsub_new();
756
clean_glyph_mapper (struct glyph_mapper *gm)
759
otl_gsub_release(gm->gsub);
761
tt_cmap_release (gm->codetogid);
763
tt_release_post_table(gm->nametogid);
766
gm->codetogid = NULL;
767
gm->nametogid = NULL;
774
do_custum_encoding (pdf_font *font,
775
char **encoding, const char *usedchars, sfnt *sfont)
777
struct tt_glyphs *glyphs;
781
struct glyph_mapper gm;
785
ASSERT(font && encoding && usedchars && sfont);
787
error = setup_glyph_mapper(&gm, sfont);
789
WARN("No post table nor Unicode cmap found in font: %s",
790
pdf_font_get_ident(font));
791
WARN(">> I can't find glyphs without this!");
795
cmap_table = NEW(274, char);
796
memset(cmap_table, 0, 274);
797
sfnt_put_ushort(cmap_table, 0); /* Version */
798
sfnt_put_ushort(cmap_table+2, 1); /* Number of subtables */
799
sfnt_put_ushort(cmap_table+4, TT_MAC); /* Platform ID */
800
sfnt_put_ushort(cmap_table+6, TT_MAC_ROMAN); /* Encoding ID */
801
sfnt_put_ulong (cmap_table+8, 12); /* Offset */
802
sfnt_put_ushort(cmap_table+12, 0); /* Format */
803
sfnt_put_ushort(cmap_table+14, 262); /* Length */
804
sfnt_put_ushort(cmap_table+16, 0); /* Language */
806
glyphs = tt_build_init();
808
count = 1; /* +1 for .notdef */
809
for (code = 0; code < 256; code++) {
810
if (!usedchars[code])
813
if (!encoding[code] || !strcmp(encoding[code], ".notdef")) {
814
WARN("Character code=\"0x%02X\" mapped to \".notdef\" glyph used in font font-file=\"%s\"",
815
code, pdf_font_get_ident(font));
816
WARN(">> Maybe incorrect encoding specified?");
819
if (is_comp(encoding[code]))
820
error = findcomposite(encoding[code], &gid, &gm);
822
error = resolve_glyph(encoding[code], &gid, &gm);
825
* Older versions of gs had problem with glyphs (other than .notdef)
829
WARN("Glyph \"%s\" not available in font \"%s\".",
830
encoding[code], pdf_font_get_ident(font));
833
MESG("truetype>> Glyph glyph-name=\"%s\" found at glyph-id=\"%u\".\n", encoding[code], gid);
835
idx = tt_find_glyph(glyphs, gid);
837
idx = tt_add_glyph(glyphs, gid, count); /* count returned. */
841
cmap_table[18 + code] = idx & 0xff; /* bug here */
843
clean_glyph_mapper(&gm);
845
if (tt_build_tables(sfont, glyphs) < 0) {
846
WARN("Packing TrueType font into SFNT file faild..."); /* _FIXME_: wrong message */
847
tt_build_finish(glyphs);
852
for (code = 0; code < 256; code++) {
853
if (usedchars[code]) {
854
idx = tt_get_index(glyphs, (USHORT) cmap_table[18+code]);
855
widths[code] = PDFUNIT(glyphs->gd[idx].advw);
860
do_widths(font, widths);
863
MESG("[%d glyphs]", glyphs->num_glyphs);
865
tt_build_finish(glyphs);
867
sfnt_set_table(sfont, "cmap", cmap_table, 274);
873
pdf_font_load_truetype (pdf_font *font)
875
pdf_obj *fontdict = pdf_font_get_resource(font);
876
pdf_obj *descriptor = pdf_font_get_descriptor(font);
877
char *ident = pdf_font_get_ident(font);
878
int encoding_id = pdf_font_get_encoding(font);
879
char *usedchars = pdf_font_get_usedchars(font);
880
#ifdef ENABLE_NOEMBED
881
int embedding = pdf_font_get_flag(font, PDF_FONT_FLAG_NOEMBED) ? 0 : 1;
882
#endif /* ENABLE_NOEMBED */
889
if (!pdf_font_is_in_use(font))
892
verbose = pdf_font_get_verbose();
894
if (!pdf_lookup_dict(fontdict, "ToUnicode")) {
895
if (encoding_id >= 0)
896
pdf_attach_ToUnicode_CMap(fontdict,
897
encoding_id, usedchars);
898
/* encoding_id < 0 means MacRoman here (but not really) */
902
sfont = sfnt_open(pdf_font_get_ft_face(font), SFNT_TYPE_TTC | SFNT_TYPE_TRUETYPE);
904
fp = DPXFOPEN(ident, DPX_RES_TYPE_TTFONT);
906
ERROR("Unable to open TrueType font file: %s", ident); /* Should find *truetype* here */
908
sfont = sfnt_open(fp);
911
ERROR("Unable to open TrueType file: %s", ident);
915
} else if (sfont->type != SFNT_TYPE_TRUETYPE &&
916
sfont->type != SFNT_TYPE_TTC) {
917
ERROR("Font \"%s\" not a TrueType font?", ident);
924
if (sfont->type == SFNT_TYPE_TTC)
925
error = sfnt_read_table_directory(sfont, ttc_read_offset(sfont, 0));
927
error = sfnt_read_table_directory(sfont, 0);
930
ERROR("Reading SFND table dir failed for font-file=\"%s\"... Not a TrueType font?", ident);
938
* Create new TrueType cmap table with MacRoman encoding.
941
error = do_builtin_encoding(font, usedchars, sfont);
943
enc_vec = pdf_encoding_get_encoding(encoding_id);
944
error = do_custum_encoding(font, enc_vec, usedchars, sfont);
947
ERROR("Error occured while creating font subfont for \"%s\"", ident);
961
#endif /* ENABLE_NOEMBED */
967
for (i = 0; required_table[i].name != NULL; i++) {
968
if (sfnt_require_table(sfont,
969
required_table[i].name,
970
required_table[i].must_exist) < 0) {
971
ERROR("Required TrueType table \"%s\" does not exist in font: %s",
972
required_table[i].name, ident);
983
fontfile = sfnt_create_FontFile_stream(sfont);
985
ERROR("Could not created FontFile stream for \"%s\".", ident);
992
MESG("[%ld bytes]", pdf_stream_length(fontfile));
994
pdf_add_dict(descriptor,
995
pdf_new_name("FontFile2"), pdf_ref_obj(fontfile)); /* XXX */
996
pdf_release_obj(fontfile);