1
/* Copyright (C) 2001-2012 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied,
8
modified or distributed except as expressly authorized under the terms
9
of the license contained in the file LICENSE in this distribution.
11
Refer to licensing information at http://www.artifex.com or contact
12
Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
13
CA 94903, U.S.A., +1(415)492-9861, for further information.
17
/* BaseFont implementation for pdfwrite */
22
#include "gsutil.h" /* for bytes_compare */
25
#include "gxfont.h" /* for gxfont42.h */
33
#include "gxfcache.h" /* for gs_purge_font_from_char_caches_completely */
35
* Adobe's Distiller Parameters documentation for Acrobat Distiller 5
36
* says that all fonts other than Type 1 are always subsetted; the
37
* documentation for Distiller 4 says that fonts other than Type 1 and
38
* TrueType are subsetted. We do the latter, except that we always
39
* subset large TrueType fonts.
41
#define MAX_NO_SUBSET_GLYPHS 4096 /* arbitrary */
43
/* ---------------- Private ---------------- */
45
private_st_pdf_base_font();
46
gs_private_st_basic(st_pdf_base_font, pdf_base_font_t, "pdf_base_font_t",\
47
pdf_base_font_ptrs, pdf_base_font_data);
49
#define SUBSET_PREFIX_SIZE 7 /* XXXXXX+ */
51
typedef struct pdf_base14_font_info_s {
54
} pdf_base14_font_info_t;
56
static const pdf_base14_font_info_t base14_font_info[] = {
57
/* Standard mapping of URW fonts */
58
{"NimbusMonL-Regu", "Courier" },
59
{"NimbusMonL-Bold", "Courier-Bold" },
60
{"NimbusMonL-ReguObli", "Courier-Oblique" },
61
{"NimbusMonL-BoldObli", "Courier-BoldOblique" },
62
{"NimbusSanL-Regu", "Helvetica" },
63
{"NimbusSanL-Bold", "Helvetica-Bold" },
64
{"NimbusSanL-ReguItal", "Helvetica-Oblique" },
65
{"NimbusSanL-BoldItal", "Helvetica-BoldOblique"},
66
{"StandardSymL", "Symbol" },
67
{"NimbusRomNo9L-Regu", "Times-Roman" },
68
{"NimbusRomNo9L-Medi", "Times-Bold" },
69
{"NimbusRomNo9L-ReguItal","Times-Italic" },
70
{"NimbusRomNo9L-MediItal","Times-BoldItalic" },
71
{"Dingbats", "ZapfDingbats" },
72
/* A few other mappings of URW fonts */
73
{"NimbusMono-Reg", "Courier" },
74
{"NimbusMono-Bol", "Courier-Bold" },
75
{"NimbusMono-Ita", "Courier-Oblique" },
76
{"NimbusMono-BolIta", "Courier-BoldOblique" },
77
{"NimbusSan-Reg", "Helvetica" },
78
{"NimbusSan-Bol", "Helvetica-Bold" },
79
{"NimbusSan-Ita", "Helvetica-Oblique" },
80
{"NimbusSan-BolIta", "Helvetica-BoldOblique"},
81
{"A030-Reg", "Helvetica" },
82
{"A030-Bol", "Helvetica-Bold" },
83
{"A030-Ita", "Helvetica-Oblique" },
84
{"A030-BolIta", "Helvetica-BoldOblique"},
85
{"NimbusSanNo2-Reg", "Helvetica" },
86
{"NimbusSanNo2-Bol", "Helvetica-Bold" },
87
{"NimbusSanNo2-Ita", "Helvetica-Oblique" },
88
{"NimbusSanNo2-BolIta", "Helvetica-BoldOblique"},
89
{"NimbusRomanNo4-Lig", "Times-Roman" },
90
{"NimbusRomanNo4-Bol", "Times-Bold" },
91
{"NimbusRomanNo4-LigIta", "Times-Italic" },
92
{"NimbusRomanNo4-BolIta", "Times-BoldItalic" },
93
{"NimbusRomanNo9-Reg", "Times-Roman" },
94
{"NimbusRomanNo9-Med", "Times-Bold" },
95
{"NimbusRomanNo9-Ita", "Times-Italic" },
96
{"NimbusRomanNo9-MedIta", "Times-BoldItalic" },
97
{"NimbusRom-Reg", "Times-Roman" },
98
{"NimbusRom-Med", "Times-Bold" },
99
{"NimbusRom-Ita", "Times-Italic" },
100
{"NimbusRom-MedIta", "Times-BoldItalic" },
101
{"NimbusRomNo9-Reg", "Times-Roman" },
102
{"NimbusRomNo9-Bol", "Times-Bold" },
103
{"NimbusRomNo9-Ita", "Times-Italic" },
104
{"NimbusRomNo9-MedIta", "Times-BoldItalic" },
108
/* Given a pointer to a font name, return a pointer to an
109
* equivalent base 14 font name, of NULL if there is no
112
const char *pdf_find_base14_name(const byte *str, uint size)
114
const pdf_base14_font_info_t *ppsf;
116
for (ppsf = base14_font_info; ppsf->urwname; ++ppsf)
117
if (!memcmp(ppsf->urwname, (const char *)str, size))
118
return ppsf->stdname;
124
* Determine whether a font is a subset font by examining the name.
127
pdf_has_subset_prefix(const byte *str, uint size)
131
if (size < SUBSET_PREFIX_SIZE || str[SUBSET_PREFIX_SIZE - 1] != '+')
133
for (i = 0; i < SUBSET_PREFIX_SIZE - 1; ++i)
134
if ((uint)(str[i] - 'A') >= 26)
140
hash(ulong v, int index, ushort w)
142
return v * 3141592653u + w;
146
* Add the XXXXXX+ prefix for a subset font.
149
pdf_add_subset_prefix(const gx_device_pdf *pdev, gs_string *pstr, byte *used, int count, char *md5_hash)
151
uint size = pstr->size;
152
byte *data = gs_resize_string(pdev->pdf_memory, pstr->data, size,
153
size + SUBSET_PREFIX_SIZE,
154
"pdf_add_subset_prefix");
155
int len = (count + 7) / 8;
156
int len0 = len & ~(sizeof(ushort) - 1);
161
return_error(gs_error_VMerror);
164
for (i = 0; i < 8; i += sizeof(ushort)) {
165
v = hash(v, i, (*(md5_hash + i) | *(md5_hash + i + 1) << 8));
169
/* Hash the 'used' array. */
170
for (i = 0; i < len0; i += sizeof(ushort))
171
v = hash(v, i, *(ushort *)(used + i));
173
v = hash(v, i, used[i]);
175
memmove(data + SUBSET_PREFIX_SIZE, data, size);
176
for (i = 0; i < SUBSET_PREFIX_SIZE - 1; ++i, v /= 26)
177
data[i] = 'A' + (v % 26);
178
data[SUBSET_PREFIX_SIZE - 1] = '+';
180
pstr->size = size + SUBSET_PREFIX_SIZE;
184
/* Finish writing FontFile* data. */
186
pdf_end_fontfile(gx_device_pdf *pdev, pdf_data_writer_t *pdw)
188
/* We would like to call pdf_end_data,
189
but we don't want to write the object to the output file now. */
190
return pdf_close_aside(pdw->pdev);
193
static int copied_font_notify(void *proc_data, void *event_data)
195
return gs_purge_font_from_char_caches_completely((gs_font *)proc_data);
198
/* ---------------- Public ---------------- */
200
* Allocate and initialize a base font structure, making the required
201
* stable copy/ies of the gs_font. Note that this removes any XXXXXX+
202
* font name prefix from the copy. If is_standard is true, the copy is
203
* a complete one, and adding glyphs or Encoding entries is not allowed.
206
pdf_base_font_alloc(gx_device_pdf *pdev, pdf_base_font_t **ppbfont,
207
gs_font_base *font, const gs_matrix *orig_matrix,
210
gs_memory_t *mem = pdev->pdf_memory;
213
pdf_base_font_t *pbfont =
214
gs_alloc_struct(mem, pdf_base_font_t,
215
&st_pdf_base_font, "pdf_base_font_alloc");
216
const gs_font_name *pfname = &font->font_name;
217
gs_const_string font_name;
218
char fnbuf[2*sizeof(long) + 3]; /* .F########\0 */
219
int code, reserve_glyphs = -1;
222
return_error(gs_error_VMerror);
223
memset(pbfont, 0, sizeof(*pbfont));
224
switch (font->FontType) {
231
for (index = 0, count = 0;
232
(font->procs.enumerate_glyph((gs_font *)font, &index,
233
GLYPH_SPACE_NAME, &glyph),
237
pbfont->num_glyphs = count;
238
pbfont->do_subset = (is_standard ? DO_SUBSET_NO : DO_SUBSET_UNKNOWN);
240
/* If we find an excessively large type 1 font we won't be able to emit
241
* a complete copy. Instead we will emit multiple subsets. Detect that here
242
* and only reserve enough space in the font copy for the maximum subset
244
* This also prevents us making a 'complete' copy of the font below. NB the
245
* value 2048 is merely a guess, intended to prevent copying very large fonts.
247
if(pbfont->num_glyphs > 2048 && !is_standard) {
248
reserve_glyphs = 257;
249
if(pbfont->do_subset != DO_SUBSET_NO){
250
char buf[gs_font_name_max + 1];
251
int l = min(font->font_name.size, sizeof(buf) - 1);
253
memcpy(buf, font->font_name.chars, l);
255
emprintf1(pdev->memory,
256
"Can't embed the complete font %s as it is too large, embedding a subset.\n",
262
pbfont->num_glyphs = ((gs_font_type42 *)font)->data.trueNumGlyphs;
264
(pbfont->num_glyphs <= MAX_NO_SUBSET_GLYPHS ?
265
DO_SUBSET_UNKNOWN : DO_SUBSET_YES);
267
case ft_CID_encrypted:
268
pbfont->num_glyphs = ((gs_font_cid0 *)font)->cidata.common.CIDCount;
270
case ft_CID_TrueType:
271
pbfont->num_glyphs = ((gs_font_cid2 *)font)->cidata.common.CIDCount;
273
pbfont->do_subset = DO_SUBSET_YES;
275
gs_alloc_bytes(mem, (pbfont->num_glyphs + 7) / 8,
276
"pdf_base_font_alloc(CIDSet)");
277
if (pbfont->CIDSet == 0) {
278
code = gs_note_error(gs_error_VMerror);
281
pbfont->CIDSetLength = (pbfont->num_glyphs + 7) / 8;
282
memset(pbfont->CIDSet, 0, (pbfont->num_glyphs + 7) / 8);
285
code = gs_note_error(gs_error_rangecheck);
289
code = gs_copy_font((gs_font *)font, orig_matrix, mem, &copied, reserve_glyphs);
292
gs_notify_register(&copied->notify_list, copied_font_notify, copied);
295
* Adobe Technical Note # 5012 "The Type 42 Font Format Specification" says :
297
* There is a known bug in the TrueType rasterizer included in versions of the
298
* PostScript interpreter previous to version 2013. The problem is that the
299
* translation components of the FontMatrix, as used as an argument to the
300
* definefont or makefont operators, are ignored. Translation of user space is
301
* not affected by this bug.
303
* Besides that, we found that Adobe Acrobat Reader 4 and 5 ignore
306
copied->FontMatrix.tx = copied->FontMatrix.ty = 0;
309
if (pbfont->do_subset != DO_SUBSET_YES && reserve_glyphs == -1) {
310
/* The only possibly non-subsetted fonts are Type 1/2 and Type 42. */
314
code = gs_copy_font((gs_font *)font, &font->FontMatrix, mem, &complete, -1);
318
code = gs_copy_font_complete((gs_font *)font, complete);
319
if (code < 0 && pbfont->do_subset == DO_SUBSET_NO) {
320
char buf[gs_font_name_max + 1];
321
int l = min(copied->font_name.size, sizeof(buf) - 1);
323
memcpy(buf, copied->font_name.chars, l);
325
emprintf1(pdev->memory,
326
"Can't embed the complete font %s due to font error.\n",
331
/* A font error happened, but it may be caused by a glyph,
332
which is not used in the document. Continue with subsetting the font.
333
If the failed glyph will be used in the document,
334
another error will hgappen when the glyph is used.
336
gs_free_copied_font(complete);
341
pbfont->copied = (gs_font_base *)copied;
342
pbfont->complete = (gs_font_base *)complete;
343
pbfont->is_standard = is_standard;
344
if (pfname->size > 0) {
345
font_name.data = pfname->chars;
346
font_name.size = pfname->size;
347
while (pdf_has_subset_prefix(font_name.data, font_name.size)) {
348
/* Strip off an existing subset prefix. */
349
font_name.data += SUBSET_PREFIX_SIZE;
350
font_name.size -= SUBSET_PREFIX_SIZE;
353
gs_sprintf(fnbuf, ".F%lx", (ulong)copied);
354
font_name.data = (byte *)fnbuf;
355
font_name.size = strlen(fnbuf);
357
pbfont->font_name.data =
358
gs_alloc_string(mem, font_name.size, "pdf_base_font_alloc(font_name)");
359
if (pbfont->font_name.data == 0)
361
memcpy(pbfont->font_name.data, font_name.data, font_name.size);
362
pbfont->font_name.size = font_name.size;
366
gs_free_object(mem, pbfont, "pdf_base_font_alloc");
371
* Return a reference to the name of a base font. This name is guaranteed
372
* not to have a XXXXXX+ prefix. The client may change the name at will,
373
* but must not add a XXXXXX+ prefix.
376
pdf_base_font_name(pdf_base_font_t *pbfont)
378
return &pbfont->font_name;
382
* Return the (copied, subset) font associated with a base font.
383
* This procedure probably shouldn't exist....
386
pdf_base_font_font(const pdf_base_font_t *pbfont, bool complete)
388
return (complete ? pbfont->complete : pbfont->copied);
392
* Check for subset font.
395
pdf_base_font_is_subset(const pdf_base_font_t *pbfont)
397
return pbfont->do_subset == DO_SUBSET_YES;
401
* Drop the copied complete font associated with a base font.
404
pdf_base_font_drop_complete(pdf_base_font_t *pbfont)
406
pbfont->complete = NULL;
410
* Copy a glyph (presumably one that was just used) into a saved base
411
* font. Note that it is the client's responsibility to determine that
412
* the source font is compatible with the target font. (Normally they
416
pdf_base_font_copy_glyph(pdf_base_font_t *pbfont, gs_glyph glyph,
420
gs_copy_glyph_options((gs_font *)font, glyph,
421
(gs_font *)pbfont->copied,
422
(pbfont->is_standard ? COPY_GLYPH_NO_NEW : 0));
426
if (pbfont->CIDSet != 0 &&
427
(uint)(glyph - GS_MIN_CID_GLYPH) < pbfont->num_glyphs
429
uint cid = glyph - GS_MIN_CID_GLYPH;
431
pbfont->CIDSet[cid >> 3] |= 0x80 >> (cid & 7);
437
* Determine whether a font should be subsetted.
440
pdf_do_subset_font(gx_device_pdf *pdev, pdf_base_font_t *pbfont, gs_id rid)
442
gs_font_base *copied = pbfont->copied;
445
* If the decision has not been made already, determine whether or not
446
* to subset the font.
448
if (pbfont->do_subset == DO_SUBSET_UNKNOWN) {
449
int max_pct = pdev->params.MaxSubsetPct;
450
bool do_subset = pdev->params.SubsetFonts && max_pct > 0;
452
if (do_subset && max_pct < 100) {
453
/* We want to subset iff used <= total * MaxSubsetPct / 100. */
456
int max_subset_used = pbfont->num_glyphs * max_pct / 100;
458
gs_glyph ignore_glyph;
461
for (index = 0, used = 0;
462
(copied->procs.enumerate_glyph((gs_font *)copied,
463
&index, GLYPH_SPACE_INDEX,
464
&ignore_glyph), index != 0);
466
if (++used > max_subset_used) {
472
pbfont->do_subset = (do_subset ? DO_SUBSET_YES : DO_SUBSET_NO);
474
return (pbfont->do_subset == DO_SUBSET_YES);
478
* Write the FontFile entry for an embedded font, /FontFile<n> # # R.
481
pdf_write_FontFile_entry(gx_device_pdf *pdev, pdf_base_font_t *pbfont)
483
stream *s = pdev->strm;
484
const char *FontFile_key;
486
switch (pbfont->copied->FontType) {
488
case ft_CID_TrueType:
489
FontFile_key = "/FontFile2";
491
default: /* Type 1/2, CIDFontType 0 */
492
if (pdev->ResourcesBeforeUsage)
493
FontFile_key = "/FontFile";
495
FontFile_key = "/FontFile3";
497
stream_puts(s, FontFile_key);
498
pprintld1(s, " %ld 0 R", pbfont->FontFile->id);
503
* Adjust font name for Acrobat Reader 3.
506
pdf_adjust_font_name(gx_device_pdf *pdev, long id, pdf_base_font_t *pbfont)
509
* In contradiction with previous version of pdfwrite,
510
* this always adds a suffix. We don't check the original name
511
* for uniquity bacause the layered architecture
512
* (see gdevpdtx.h) doesn't provide an easy access for
513
* related information.
516
byte *chars = (byte *)pbfont->font_name.data; /* break 'const' */
518
uint size = pbfont->font_name.size;
519
char suffix[sizeof(long) * 2 + 2];
522
#define SUFFIX_CHAR '~'
524
* If the name looks as though it has one of our unique suffixes,
528
i > 0 && isxdigit(chars[i - 1]);
531
if (i < size && i > 0 && chars[i - 1] == SUFFIX_CHAR) {
534
} while (i > 0 && chars[i - 1] == SUFFIX_CHAR);
537
/* Create a unique name. */
538
gs_sprintf(suffix, "%c%lx", SUFFIX_CHAR, id);
539
suffix_size = strlen(suffix);
540
data = gs_resize_string(pdev->pdf_memory, chars, size,
542
"pdf_adjust_font_name");
544
return_error(gs_error_VMerror);
545
memcpy(data + size, (const byte *)suffix, suffix_size);
546
pbfont->font_name.data = data;
547
pbfont->font_name.size = size + suffix_size;
553
* Write an embedded font.
556
pdf_write_embedded_font(gx_device_pdf *pdev, pdf_base_font_t *pbfont, font_type FontType,
557
gs_int_rect *FontBBox, gs_id rid, cos_dict_t **ppcd)
559
bool do_subset = pdf_do_subset_font(pdev, pbfont, rid);
560
gs_font_base *out_font =
561
(do_subset || pbfont->complete == NULL ? pbfont->copied : pbfont->complete);
562
gs_const_string fnstr;
563
pdf_data_writer_t writer;
564
byte digest[6] = {0,0,0,0,0,0};
569
return 0; /* already written */
570
code = copied_order_font((gs_font *)out_font);
573
/* Since we now always ASCIIHex encode the eexec encrypted portion of a
574
* Type 1 font, such a font cannot contain any binary data, if its not being
575
* compressed then there is no reason to ASCII encode it (which will happen
576
* we set DATA_STREAM_BINARY and the device does not permit binary output)
577
* NB if HaveCFF is true then we convert type 1 to CFF which is a binary
578
* format, so we still need to set DATA_STREAM_BINARY.
580
if (pdev->CompressFonts)
581
options = DATA_STREAM_BINARY | DATA_STREAM_COMPRESS;
583
if (FontType != ft_encrypted || pdev->HaveCFF)
584
options = DATA_STREAM_BINARY;
585
/* Don't set DATA_STREAM_ENCRYPT since we write to a temporary file.
586
* See comment in pdf_begin_encrypt.
588
code = pdf_begin_data_stream(pdev, &writer, options, 0);
591
if (pdev->PDFA != 0) {
592
stream *s = s_MD5C_make_stream(pdev->pdf_memory, writer.binary.strm);
595
return_error(gs_error_VMerror);
596
writer.binary.strm = s;
598
if (pdev->CompatibilityLevel == 1.2 &&
599
!do_subset && !pbfont->is_standard ) {
601
* Due to a bug in Acrobat Reader 3, we need to generate
602
* unique font names, except base 14 fonts being not embedded.
603
* To recognize base 14 fonts here we used the knowledge
604
* that pbfont->is_standard is true for base 14 fonts only.
605
* Note that subsetted fonts already have an unique name
606
* due to subset prefix.
608
int code = pdf_adjust_font_name(pdev, writer.pres->object->id, pbfont);
612
fnstr.data = pbfont->font_name.data;
613
fnstr.size = pbfont->font_name.size;
614
/* Now write the font (or subset). */
618
/* Nothing to embed -- the descendant fonts do it all. */
623
if (!pdev->HaveCFF) {
624
/* Must convert to Type 1 charstrings. */
625
return_error(gs_error_unregistered); /* Not implemented yet. */
628
if (pdev->HavePDFWidths) {
629
code = copied_drop_extension_glyphs((gs_font *)out_font);
633
if (!pdev->HaveCFF) {
634
/* Write the type 1 font with no converting to CFF. */
637
code = psf_write_type1_font(writer.binary.strm,
638
(gs_font_type1 *)out_font,
639
WRITE_TYPE1_WITH_LENIV | WRITE_TYPE1_EEXEC |
640
WRITE_TYPE1_EEXEC_PAD | WRITE_TYPE1_ASCIIHEX,
641
NULL, 0, &fnstr, lengths);
642
if (lengths[0] > 0) {
647
code = cos_dict_put_c_key_int((cos_dict_t *)writer.pres->object,
648
"/Length1", lengths[0]);
650
if (lengths[1] > 0) {
655
code = cos_dict_put_c_key_int((cos_dict_t *)writer.pres->object,
656
"/Length2", lengths[1]);
659
code = cos_dict_put_c_key_int((cos_dict_t *)writer.pres->object,
660
"/Length3", lengths[2]);
664
* Since we only support PDF 1.2 and later, always write Type 1
665
* fonts as Type1C (Type 2). Acrobat Reader apparently doesn't
666
* accept CFF fonts with Type 1 CharStrings, so we need to convert
667
* them. Also remove lenIV, so Type 2 fonts will compress better.
669
#define TYPE2_OPTIONS (WRITE_TYPE2_NO_LENIV | WRITE_TYPE2_CHARSTRINGS)
670
code = cos_dict_put_string_copy((cos_dict_t *)writer.pres->object, "/Subtype", "/Type1C");
673
code = psf_write_type2_font(writer.binary.strm,
674
(gs_font_type1 *)out_font,
676
(pdev->CompatibilityLevel < 1.3 ? WRITE_TYPE2_AR3 : 0),
677
NULL, 0, &fnstr, FontBBox);
683
gs_font_type42 *const pfont = (gs_font_type42 *)out_font;
684
#define TRUETYPE_OPTIONS (WRITE_TRUETYPE_NAME | WRITE_TRUETYPE_HVMTX)
685
/* Acrobat Reader 3 doesn't handle cmap format 6 correctly. */
686
const int options = TRUETYPE_OPTIONS |
687
(pdev->PDFA != 0 ? WRITE_TRUETYPE_UNICODE_CMAP : 0) |
688
(pdev->CompatibilityLevel <= 1.2 ?
689
WRITE_TRUETYPE_NO_TRIMMED_TABLE : 0) |
690
/* Generate a cmap only for incrementally downloaded fonts
691
and for subsetted fonts. */
692
(pfont->data.numGlyphs != pfont->data.trueNumGlyphs ||
693
pbfont->do_subset == DO_SUBSET_YES ?
694
WRITE_TRUETYPE_CMAP : 0);
697
if (pdev->HavePDFWidths) {
698
code = copied_drop_extension_glyphs((gs_font *)out_font);
702
s_init(&poss, pdev->memory);
703
swrite_position_only(&poss);
704
code = psf_write_truetype_font(&poss, pfont, options, NULL, 0, &fnstr);
707
code = cos_dict_put_c_key_int((cos_dict_t *)writer.pres->object, "/Length1", stell(&poss));
710
code = psf_write_truetype_font(writer.binary.strm, pfont,
711
options, NULL, 0, &fnstr);
715
case ft_CID_encrypted:
716
code = cos_dict_put_string_copy((cos_dict_t *)writer.pres->object, "/Subtype", "/CIDFontType0C");
719
code = psf_write_cid0_font(writer.binary.strm,
720
(gs_font_cid0 *)out_font, TYPE2_OPTIONS,
724
case ft_CID_TrueType:
725
/* CIDFontType 2 fonts don't use cmap, name, OS/2, or post. */
726
#define CID2_OPTIONS WRITE_TRUETYPE_HVMTX
727
code = psf_write_cid2_font(writer.binary.strm,
728
(gs_font_cid2 *)out_font,
729
CID2_OPTIONS, NULL, 0, &fnstr);
731
if (pdev->PDFA != 0) {
732
sflush(writer.binary.strm);
733
s_MD5C_get_digest(writer.binary.strm, digest, sizeof(digest));
735
*ppcd = (cos_dict_t *)writer.pres->object;
737
pdf_end_fontfile(pdev, &writer);
740
code = pdf_end_fontfile(pdev, &writer);
744
code = gs_note_error(gs_error_rangecheck);
747
if (code >=0 && code1 < 0) {
750
pbfont->written = true;
755
* Write the CharSet for a subsetted font, as a PDF string.
758
pdf_write_CharSet(gx_device_pdf *pdev, pdf_base_font_t *pbfont)
760
stream *s = pdev->strm;
761
gs_font_base *font = pbfont->copied;
767
(font->procs.enumerate_glyph((gs_font *)font, &index,
768
GLYPH_SPACE_NAME, &glyph),
771
gs_const_string gstr;
772
int code = font->procs.glyph_name((gs_font *)font, glyph, &gstr);
774
/* Don't include .notdef. */
776
bytes_compare(gstr.data, gstr.size, (const byte *)".notdef", 7)
778
pdf_put_name(pdev, gstr.data, gstr.size);
785
* Write the CIDSet object for a subsetted CIDFont.
788
pdf_write_CIDSet(gx_device_pdf *pdev, pdf_base_font_t *pbfont,
791
pdf_data_writer_t writer;
794
code = pdf_begin_data_stream(pdev, &writer,
796
(pdev->CompressFonts ? DATA_STREAM_COMPRESS : 0),
800
stream_write(writer.binary.strm, pbfont->CIDSet,
801
pbfont->CIDSetLength);
802
code = pdf_end_data(&writer);
805
*pcidset_id = pdf_resource_id(writer.pres);
809
* Check whether a base font is standard.
812
pdf_is_standard_font(pdf_base_font_t *bfont)
813
{ return bfont->is_standard;
817
pdf_set_FontFile_object(pdf_base_font_t *bfont, cos_dict_t *pcd)
819
bfont->FontFile = pcd;
822
pdf_get_FontFile_object(pdf_base_font_t *bfont)
824
return bfont->FontFile;