summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipdfm-x/xsrc
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2013-07-05 13:19:04 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2013-07-05 13:19:04 +0000
commite54eda8832ef70dfae37d4200bd56bd2dee6118e (patch)
treea039e3a605db6104dc47ead65f07061df23a847c /Build/source/texk/dvipdfm-x/xsrc
parentcf1fc7b4d3f71633ca71e17dd7044722d19ceda4 (diff)
dvipdfm-x: Continue merging dvipdfmx and xdvipdfmx
git-svn-id: svn://tug.org/texlive/trunk@31095 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm-x/xsrc')
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/cff.c91
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/cff.h156
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/dvi.c8
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/dvi.h2
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c6
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/fontmap.c2
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/pdfcolor.c4
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/pdfcolor.h5
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/spc_color.c192
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/spc_html.c944
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/spc_util.c796
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/spc_util.h44
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/tt_glyf.c673
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/type0.c687
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/type1c.c6
15 files changed, 75 insertions, 3541 deletions
diff --git a/Build/source/texk/dvipdfm-x/xsrc/cff.c b/Build/source/texk/dvipdfm-x/xsrc/cff.c
index 72db0e07f62..082d3d873e9 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/cff.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/cff.c
@@ -42,24 +42,34 @@
#define CFF_DEBUG 5
#define CFF_DEBUG_STR "CFF"
-static unsigned long get_unsigned (sfnt *sfont, int n)
+#ifdef XETEX
+#define SFNT_OR_FILE sfnt
+#define SFONT_OR_STREAM sfont
+#define get_card8(s) sfnt_get_byte((s))
+#define get_card16(s) sfnt_get_ushort((s))
+#else
+#define SFNT_OR_FILE FILE
+#define SFONT_OR_STREAM stream
+#define get_card8(s) get_unsigned_byte((s))
+#define get_card16(s) get_unsigned_pair((s))
+#endif
+
+static unsigned long get_unsigned (SFNT_OR_FILE *SFONT_OR_STREAM, int n)
{
unsigned long v = 0;
while (n-- > 0)
- v = v*0x100u + sfnt_get_byte(sfont);
+ v = v*0x100u + get_card8(SFONT_OR_STREAM);
return v;
}
#define get_offset(s, n) get_unsigned((s), (n))
-#define get_card8(s) sfnt_get_byte((s))
-#define get_card16(s) sfnt_get_ushort((s))
/*
* Read Header, Name INDEX, Top DICT INDEX, and String INDEX.
*/
-cff_font *cff_open(sfnt *sfont, long offset, int n)
+cff_font *cff_open(SFNT_OR_FILE *SFONT_OR_STREAM, long offset, int n)
{
cff_font *cff;
cff_index *idx;
@@ -68,7 +78,7 @@ cff_font *cff_open(sfnt *sfont, long offset, int n)
cff->fontname = NULL;
cff->index = n;
- cff->sfont = sfont;
+ cff->SFONT_OR_STREAM = SFONT_OR_STREAM;
cff->offset = offset;
cff->filter = 0; /* not used */
cff->flag = 0;
@@ -88,10 +98,10 @@ cff_font *cff_open(sfnt *sfont, long offset, int n)
cff->_string = NULL;
cff_seek_set(cff, 0);
- cff->header.major = get_card8(cff->sfont);
- cff->header.minor = get_card8(cff->sfont);
- cff->header.hdr_size = get_card8(cff->sfont);
- cff->header.offsize = get_card8(cff->sfont);
+ cff->header.major = get_card8(cff->SFONT_OR_STREAM);
+ cff->header.minor = get_card8(cff->SFONT_OR_STREAM);
+ cff->header.hdr_size = get_card8(cff->SFONT_OR_STREAM);
+ cff->header.offsize = get_card8(cff->SFONT_OR_STREAM);
if (cff->header.offsize < 1 ||
cff->header.offsize > 4)
ERROR("invalid offsize data");
@@ -150,7 +160,7 @@ cff_font *cff_open(sfnt *sfont, long offset, int n)
/* Number of glyphs */
offset = (long) cff_dict_get(cff->topdict, "CharStrings", 0);
cff_seek_set(cff, offset);
- cff->num_glyphs = get_card16(cff->sfont);
+ cff->num_glyphs = get_card16(cff->SFONT_OR_STREAM);
/* Check for font type */
if (cff_dict_known(cff->topdict, "ROS")) {
@@ -229,9 +239,12 @@ cff_close (cff_font *cff)
}
if (cff->_string)
cff_release_index(cff->_string);
+
#ifdef XETEX
- if (cff->ft_to_gid) RELEASE(cff->ft_to_gid);
+ if (cff->ft_to_gid)
+ RELEASE(cff->ft_to_gid);
#endif
+
RELEASE(cff);
}
@@ -304,15 +317,15 @@ cff_get_index_header (cff_font *cff)
idx = NEW(1, cff_index);
- idx->count = count = get_card16(cff->sfont);
+ idx->count = count = get_card16(cff->SFONT_OR_STREAM);
if (count > 0) {
- idx->offsize = get_card8(cff->sfont);
+ idx->offsize = get_card8(cff->SFONT_OR_STREAM);
if (idx->offsize < 1 || idx->offsize > 4)
ERROR("invalid offsize data");
idx->offset = NEW(count+1, l_offset);
for (i=0;i<count+1;i++) {
- (idx->offset)[i] = get_offset(cff->sfont, idx->offsize);
+ (idx->offset)[i] = get_offset(cff->SFONT_OR_STREAM, idx->offsize);
}
if (idx->offset[0] != 1)
@@ -337,15 +350,15 @@ cff_get_index (cff_font *cff)
idx = NEW(1, cff_index);
- idx->count = count = get_card16(cff->sfont);
+ idx->count = count = get_card16(cff->SFONT_OR_STREAM);
if (count > 0) {
- idx->offsize = get_card8(cff->sfont);
+ idx->offsize = get_card8(cff->SFONT_OR_STREAM);
if (idx->offsize < 1 || idx->offsize > 4)
ERROR("invalid offsize data");
idx->offset = NEW(count + 1, l_offset);
for (i = 0 ; i < count + 1; i++) {
- idx->offset[i] = get_offset(cff->sfont, idx->offsize);
+ idx->offset[i] = get_offset(cff->SFONT_OR_STREAM, idx->offsize);
}
if (idx->offset[0] != 1)
@@ -655,27 +668,27 @@ long cff_read_encoding (cff_font *cff)
cff_seek_set(cff, offset);
cff->encoding = encoding = NEW(1, cff_encoding);
- encoding->format = get_card8(cff->sfont);
+ encoding->format = get_card8(cff->SFONT_OR_STREAM);
length = 1;
switch (encoding->format & (~0x80)) {
case 0:
- encoding->num_entries = get_card8(cff->sfont);
+ encoding->num_entries = get_card8(cff->SFONT_OR_STREAM);
(encoding->data).codes = NEW(encoding->num_entries, card8);
for (i=0;i<(encoding->num_entries);i++) {
- (encoding->data).codes[i] = get_card8(cff->sfont);
+ (encoding->data).codes[i] = get_card8(cff->SFONT_OR_STREAM);
}
length += encoding->num_entries + 1;
break;
case 1:
{
cff_range1 *ranges;
- encoding->num_entries = get_card8(cff->sfont);
+ encoding->num_entries = get_card8(cff->SFONT_OR_STREAM);
encoding->data.range1 = ranges
= NEW(encoding->num_entries, cff_range1);
for (i=0;i<(encoding->num_entries);i++) {
- ranges[i].first = get_card8(cff->sfont);
- ranges[i].n_left = get_card8(cff->sfont);
+ ranges[i].first = get_card8(cff->SFONT_OR_STREAM);
+ ranges[i].n_left = get_card8(cff->SFONT_OR_STREAM);
}
length += (encoding->num_entries) * 2 + 1;
}
@@ -689,11 +702,11 @@ long cff_read_encoding (cff_font *cff)
/* Supplementary data */
if ((encoding->format) & 0x80) {
cff_map *map;
- encoding->num_supps = get_card8(cff->sfont);
+ encoding->num_supps = get_card8(cff->SFONT_OR_STREAM);
encoding->supp = map = NEW(encoding->num_supps, cff_map);
for (i=0;i<(encoding->num_supps);i++) {
- map[i].code = get_card8(cff->sfont);
- map[i].glyph = get_card16(cff->sfont); /* SID */
+ map[i].code = get_card8(cff->SFONT_OR_STREAM);
+ map[i].glyph = get_card16(cff->SFONT_OR_STREAM); /* SID */
}
length += (encoding->num_supps) * 3 + 1;
} else {
@@ -871,7 +884,7 @@ long cff_read_charsets (cff_font *cff)
cff_seek_set(cff, offset);
cff->charsets = charset = NEW(1, cff_charsets);
- charset->format = get_card8(cff->sfont);
+ charset->format = get_card8(cff->SFONT_OR_STREAM);
charset->num_entries = 0;
count = cff->num_glyphs - 1;
@@ -884,7 +897,7 @@ long cff_read_charsets (cff_font *cff)
charset->data.glyphs = NEW(charset->num_entries, s_SID);
length += (charset->num_entries) * 2;
for (i=0;i<(charset->num_entries);i++) {
- charset->data.glyphs[i] = get_card16(cff->sfont);
+ charset->data.glyphs[i] = get_card16(cff->SFONT_OR_STREAM);
}
count = 0;
break;
@@ -893,8 +906,8 @@ long cff_read_charsets (cff_font *cff)
cff_range1 *ranges = NULL;
while (count > 0 && charset->num_entries < cff->num_glyphs) {
ranges = RENEW(ranges, charset->num_entries + 1, cff_range1);
- ranges[charset->num_entries].first = get_card16(cff->sfont);
- ranges[charset->num_entries].n_left = get_card8(cff->sfont);
+ ranges[charset->num_entries].first = get_card16(cff->SFONT_OR_STREAM);
+ ranges[charset->num_entries].n_left = get_card8(cff->SFONT_OR_STREAM);
count -= ranges[charset->num_entries].n_left + 1; /* no-overrap */
charset->num_entries += 1;
charset->data.range1 = ranges;
@@ -907,8 +920,8 @@ long cff_read_charsets (cff_font *cff)
cff_range2 *ranges = NULL;
while (count > 0 && charset->num_entries < cff->num_glyphs) {
ranges = RENEW(ranges, charset->num_entries + 1, cff_range2);
- ranges[charset->num_entries].first = get_card16(cff->sfont);
- ranges[charset->num_entries].n_left = get_card16(cff->sfont);
+ ranges[charset->num_entries].first = get_card16(cff->SFONT_OR_STREAM);
+ ranges[charset->num_entries].n_left = get_card16(cff->SFONT_OR_STREAM);
count -= ranges[charset->num_entries].n_left + 1; /* non-overrapping */
charset->num_entries += 1;
}
@@ -1201,7 +1214,7 @@ long cff_read_fdselect (cff_font *cff)
offset = (long) cff_dict_get(cff->topdict, "FDSelect", 0);
cff_seek_set(cff, offset);
cff->fdselect = fdsel = NEW(1, cff_fdselect);
- fdsel->format = get_card8(cff->sfont);
+ fdsel->format = get_card8(cff->SFONT_OR_STREAM);
length = 1;
@@ -1210,22 +1223,22 @@ long cff_read_fdselect (cff_font *cff)
fdsel->num_entries = cff->num_glyphs;
(fdsel->data).fds = NEW(fdsel->num_entries, card8);
for (i=0;i<(fdsel->num_entries);i++) {
- (fdsel->data).fds[i] = get_card8(cff->sfont);
+ (fdsel->data).fds[i] = get_card8(cff->SFONT_OR_STREAM);
}
length += fdsel->num_entries;
break;
case 3:
{
cff_range3 *ranges;
- fdsel->num_entries = get_card16(cff->sfont);
+ fdsel->num_entries = get_card16(cff->SFONT_OR_STREAM);
fdsel->data.ranges = ranges = NEW(fdsel->num_entries, cff_range3);
for (i=0;i<(fdsel->num_entries);i++) {
- ranges[i].first = get_card16(cff->sfont);
- ranges[i].fd = get_card8(cff->sfont);
+ ranges[i].first = get_card16(cff->SFONT_OR_STREAM);
+ ranges[i].fd = get_card8(cff->SFONT_OR_STREAM);
}
if (ranges[0].first != 0)
ERROR("Range not starting with 0.");
- if (cff->num_glyphs != get_card16(cff->sfont))
+ if (cff->num_glyphs != get_card16(cff->SFONT_OR_STREAM))
ERROR("Sentinel value mismatched with number of glyphs.");
length += (fdsel->num_entries) * 3 + 4;
}
diff --git a/Build/source/texk/dvipdfm-x/xsrc/cff.h b/Build/source/texk/dvipdfm-x/xsrc/cff.h
deleted file mode 100644
index 9772d6d2a31..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/cff.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2002-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-#ifndef _CFF_H_
-#define _CFF_H_
-
-#include "mfileio.h"
-#include "cff_types.h"
-
-#include "sfnt.h"
-
-/* Flag */
-#define FONTTYPE_CIDFONT (1 << 0)
-#define FONTTYPE_FONT (1 << 1)
-#define FONTTYPE_MMASTER (1 << 2)
-
-#define ENCODING_STANDARD (1 << 3)
-#define ENCODING_EXPERT (1 << 4)
-
-#define CHARSETS_ISOADOBE (1 << 5)
-#define CHARSETS_EXPERT (1 << 6)
-#define CHARSETS_EXPSUB (1 << 7)
-
-#define HAVE_STANDARD_ENCODING (ENCODING_STANDARD|ENCODING_EXPERT)
-#define HAVE_STANDARD_CHARSETS \
- (CHARSETS_ISOADOBE|CHARSETS_EXPERT|CHARSETS_EXPSUB)
-
-#define CFF_STRING_NOTDEF 65535
-
-typedef struct
-{
- char *fontname; /* FontName */
-
- /* - CFF structure - */
- cff_header header; /* CFF Header */
- cff_index *name; /* Name INDEX */
- cff_dict *topdict; /* Top DICT (single) */
- cff_index *string; /* String INDEX */
- cff_index *gsubr; /* Global Subr INDEX */
- cff_encoding *encoding; /* Encodings */
- cff_charsets *charsets; /* Charsets */
- cff_fdselect *fdselect; /* FDSelect, CIDFont only */
- cff_index *cstrings; /* CharStrings */
- cff_dict **fdarray; /* CIDFont only */
- cff_dict **private; /* per-Font DICT */
- cff_index **subrs; /* Local Subr INDEX, per-Private DICT */
-
- /* -- extra data -- */
- l_offset offset; /* non-zero for OpenType or PostScript wrapped */
- l_offset gsubr_offset;
- card16 num_glyphs; /* number of glyphs (CharString INDEX count) */
- card8 num_fds; /* number of Font DICT */
-
- /* Updated String INDEX.
- * Please fix this. We should separate input and output.
- */
- cff_index *_string;
-
-#ifdef XETEX
- unsigned short *ft_to_gid;
-#endif
-
- sfnt *sfont;
- int filter; /* not used, ASCII Hex filter if needed */
-
- int index; /* CFF fontset index */
- int flag; /* Flag: see above */
-} cff_font;
-
-extern cff_font *cff_open (sfnt *sfont, long offset, int idx);
-extern void cff_close (cff_font *cff);
-
-#define cff_seek_set(c, p) sfnt_seek_set (((c)->sfont), ((c)->offset) + (p));
-
-/* CFF Header */
-extern long cff_put_header (cff_font *cff, card8 *dest, long destlen);
-
-/* CFF INDEX */
-extern cff_index *cff_get_index (cff_font *cff);
-extern cff_index *cff_get_index_header (cff_font *cff);
-extern void cff_release_index (cff_index *idx);
-extern cff_index *cff_new_index (card16 count);
-extern long cff_index_size (cff_index *idx);
-extern long cff_pack_index (cff_index *idx, card8 *dest, long destlen);
-
-/* Name INDEX */
-extern char *cff_get_name (cff_font *cff);
-extern long cff_set_name (cff_font *cff, char *name);
-
-/* Global and Local Subrs INDEX */
-extern long cff_read_subrs (cff_font *cff);
-
-/* Encoding */
-extern long cff_read_encoding (cff_font *cff);
-extern long cff_pack_encoding (cff_font *cff, card8 *dest, long destlen);
-extern card16 cff_encoding_lookup (cff_font *cff, card8 code);
-extern void cff_release_encoding (cff_encoding *encoding);
-
-/* Charsets */
-extern long cff_read_charsets (cff_font *cff);
-extern long cff_pack_charsets (cff_font *cff, card8 *dest, long destlen);
-
-/* Returns GID of PS name "glyph" */
-extern card16 cff_glyph_lookup (cff_font *cff, const char *glyph);
-/* Returns GID of glyph with SID/CID "cid" */
-extern card16 cff_charsets_lookup (cff_font *cff, card16 cid);
-extern void cff_release_charsets (cff_charsets *charset);
-/* Returns SID or CID */
-extern card16 cff_charsets_lookup_inverse (cff_font *cff, card16 gid);
-
-/* FDSelect */
-extern long cff_read_fdselect (cff_font *cff);
-extern long cff_pack_fdselect (cff_font *cff, card8 *dest, long destlen);
-extern card8 cff_fdselect_lookup (cff_font *cff, card16 gid);
-extern void cff_release_fdselect (cff_fdselect *fdselect);
-
-/* Font DICT(s) */
-extern long cff_read_fdarray (cff_font *cff);
-
-/* Private DICT(s) */
-extern long cff_read_private (cff_font *cff);
-
-#ifdef XETEX
-extern unsigned short* cff_get_ft_to_gid(cff_font *cff);
-#endif
-
-/* String */
-extern int cff_match_string (cff_font *cff, const char *str, s_SID sid);
-extern char *cff_get_string (cff_font *cff, s_SID id);
-extern long cff_get_sid (cff_font *cff, const char *str);
-extern long cff_get_seac_sid (cff_font *cff, const char *str);
-extern s_SID cff_add_string (cff_font *cff, const char *str, int unique);
-extern void cff_update_string (cff_font *cff);
-
-#define cff_is_stdstr(s) (cff_get_sid(NULL, (s)) >= 0)
-
-#endif /* _CFF_H_ */
diff --git a/Build/source/texk/dvipdfm-x/xsrc/dvi.c b/Build/source/texk/dvipdfm-x/xsrc/dvi.c
index f7efc9a6a2a..0db3adf96b3 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/dvi.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/dvi.c
@@ -104,9 +104,7 @@ double get_origin (int x)
#define PHYSICAL 1
#define VIRTUAL 2
#define SUBFONT 3
-#ifdef XETEX
#define NATIVE 4
-#endif
#define DVI 1
#define VF 2
@@ -163,9 +161,9 @@ static struct font_def
#define XDV_FLAG_COLORED 0x0200
#define XDV_FLAG_FEATURES 0x0400
#define XDV_FLAG_VARIATIONS 0x0800
-#define XDV_FLAG_EXTEND 0x1000
-#define XDV_FLAG_SLANT 0x2000
-#define XDV_FLAG_EMBOLDEN 0x4000
+#define XDV_FLAG_EXTEND 0x1000
+#define XDV_FLAG_SLANT 0x2000
+#define XDV_FLAG_EMBOLDEN 0x4000
#endif
static int num_def_fonts = 0, max_def_fonts = 0;
diff --git a/Build/source/texk/dvipdfm-x/xsrc/dvi.h b/Build/source/texk/dvipdfm-x/xsrc/dvi.h
index 9801309730f..8f6f7e07e59 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/dvi.h
+++ b/Build/source/texk/dvipdfm-x/xsrc/dvi.h
@@ -43,7 +43,9 @@ extern double dvi_init (char *dvi_filename, double mag); /* may append .dvi or
extern void dvi_close (void); /* Closes data structures created by dvi_open */
extern double dvi_tell_mag (void);
+#ifdef XETEX
extern double dvi_unit_size (void);
+#endif
extern double dvi_dev_xpos (void);
extern double dvi_dev_ypos (void);
extern unsigned dvi_npages (void);
diff --git a/Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c b/Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c
index d2d775d7f74..b8656256df1 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c
@@ -795,7 +795,7 @@ do_mps_pages (void)
mps_do_page(fp);
MFCLOSE(fp);
} else {
- int i, page_no, step, page_count = 0;
+ long i, page_no, step, page_count = 0;
char *filename;
/* Process filename.1, filename.2,... */
filename = NEW(strlen(dvi_filename) + 16 + 1, char);
@@ -806,10 +806,10 @@ do_mps_pages (void)
step = (page_ranges[i].first <= page_ranges[i].last) ? 1 : -1;
page_no = page_ranges[i].first;
for (;;) {
- sprintf(filename, "%s.%d", dvi_filename, page_no + 1);
+ sprintf(filename, "%s.%ld", dvi_filename, page_no + 1);
fp = MFOPEN(filename, FOPEN_RBIN_MODE);
if (fp) {
- MESG("[%d<%s>", page_no + 1, filename);
+ MESG("[%ld<%s>", page_no + 1, filename);
mps_do_page(fp);
page_count++;
MESG("]");
diff --git a/Build/source/texk/dvipdfm-x/xsrc/fontmap.c b/Build/source/texk/dvipdfm-x/xsrc/fontmap.c
index 0f220255165..082220a21b2 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/fontmap.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/fontmap.c
@@ -1156,7 +1156,7 @@ pdf_load_native_font (const char *ps_name,
}
#endif /* XETEX */
-#if 0
+#if 0
/* tfm_name="dmjhira10", map_name="dmj@DNP@10", sfd_name="DNP"
* --> sub_id="hira"
* Test if tfm_name can be really considered as subfont.
diff --git a/Build/source/texk/dvipdfm-x/xsrc/pdfcolor.c b/Build/source/texk/dvipdfm-x/xsrc/pdfcolor.c
index 373a38f5c0a..22adf8428be 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/pdfcolor.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/pdfcolor.c
@@ -1121,6 +1121,7 @@ iccp_load_profile (const char *ident,
return cspc_id;
}
+#ifdef XETEX
#define WBUF_SIZE 4096
static unsigned char wbuf[WBUF_SIZE];
@@ -1289,6 +1290,7 @@ pdf_colorspace_load_ICCBased (const char *ident, const char *filename)
return cspc_id;
}
+#endif
typedef struct {
char *ident;
@@ -1497,7 +1499,7 @@ pdf_get_colorspace_subtype (int cspc_id)
return colorspace->subtype;
}
-#endif /* 0 */
+#endif
void
pdf_init_colors (void)
diff --git a/Build/source/texk/dvipdfm-x/xsrc/pdfcolor.h b/Build/source/texk/dvipdfm-x/xsrc/pdfcolor.h
index 1d5e0f19116..ef7947c4753 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/pdfcolor.h
+++ b/Build/source/texk/dvipdfm-x/xsrc/pdfcolor.h
@@ -80,13 +80,18 @@ extern int pdf_get_colorspace_num_components (int cspc_id);
extern int pdf_get_colorspace_subtype (int cspc_id);
#endif
+#ifdef XETEX
/* Not working */
extern int pdf_colorspace_load_ICCBased (const char *ident,
const char *profile_filename);
+#endif
/* Color special
* See remark in spc_color.c.
*/
+#ifndef XETEX
+extern void pdf_color_set (pdf_color *sc, pdf_color *fc);
+#endif
extern void pdf_color_set_default (const pdf_color *color);
extern void pdf_color_push (pdf_color *sc, pdf_color *fc);
extern void pdf_color_pop (void);
diff --git a/Build/source/texk/dvipdfm-x/xsrc/spc_color.c b/Build/source/texk/dvipdfm-x/xsrc/spc_color.c
deleted file mode 100644
index b625bf7ba8d..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/spc_color.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2002-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "system.h"
-#include "mem.h"
-#include "error.h"
-#include "dpxutil.h"
-
-#include "pdfdev.h"
-#include "pdfcolor.h"
-
-#include "specials.h"
-
-#include "spc_util.h"
-#include "spc_color.h"
-
-
-/* Color stack is actually placed into pdfcolor.c.
- * The reason why we need to place stack there is
- * that we must reinstall color after grestore and
- * other operations that can change current color
- * implicitely.
- */
-
-static int
-spc_handler_color_push (struct spc_env *spe, struct spc_arg *args)
-{
- int error;
- pdf_color colorspec;
-
- error = spc_util_read_colorspec(spe, &colorspec, args, 1);
- if (!error) {
- pdf_color_push(&colorspec, &colorspec);
- }
-
- return error;
-}
-
-static int
-spc_handler_color_pop (struct spc_env *spe, struct spc_arg *args)
-{
- pdf_color_pop();
-
- return 0;
-}
-
-/* Invoked by the special command "color rgb .625 0 0".
- * DVIPS clears the color stack, and then saves and sets the given color.
- */
-static int
-spc_handler_color_default (struct spc_env *spe, struct spc_arg *args)
-{
- int error;
- pdf_color colorspec;
-
- error = spc_util_read_colorspec(spe, &colorspec, args, 1);
- if (!error) {
- pdf_color_set_default(&colorspec);
- pdf_color_clear_stack(); /* the default color is saved on color_stack */
- pdf_color_push(&colorspec, &colorspec);
- }
-
- return error;
-}
-
-
-/* This is from color special? */
-#include "pdfdoc.h"
-
-static int
-spc_handler_background (struct spc_env *spe, struct spc_arg *args)
-{
- int error;
- pdf_color colorspec;
-
- error = spc_util_read_colorspec(spe, &colorspec, args, 1);
- if (!error)
- pdf_doc_set_bgcolor(&colorspec);
-
- return error;
-}
-
-
-#ifndef ISBLANK
-#define ISBLANK(c) ((c) == ' ' || (c) == '\t' || (c) == '\v')
-#endif
-static void
-skip_blank (const char **pp, const char *endptr)
-{
- const char *p = *pp;
- for ( ; p < endptr && ISBLANK(*p); p++);
- *pp = p;
-}
-
-int
-spc_color_check_special (const char *buf, long len)
-{
- int r = 0;
- char *q;
- const char *p, *endptr;
-
- p = buf;
- endptr = p + len;
-
- skip_blank(&p, endptr);
- q = parse_c_ident(&p, endptr);
- if (!q)
- return 0;
- else if (!strcmp(q, "color"))
- r = 1;
- else if (!strcmp(q, "background")) {
- r = 1;
- }
- RELEASE(q);
-
- return r;
-}
-
-int
-spc_color_setup_handler (struct spc_handler *sph,
- struct spc_env *spe, struct spc_arg *ap)
-{
- const char *p;
- char *q;
-
- ASSERT(sph && spe && ap);
-
- skip_blank(&ap->curptr, ap->endptr);
- q = parse_c_ident(&ap->curptr, ap->endptr);
- if (!q)
- return -1;
- skip_blank(&ap->curptr, ap->endptr);
-
- if (!strcmp(q, "background")) {
- ap->command = "background";
- sph->exec = &spc_handler_background;
- RELEASE(q);
- } else if (!strcmp(q, "color")) { /* color */
- RELEASE(q);
- p = ap->curptr;
-
- q = parse_c_ident(&p, ap->endptr);
- if (!q)
- return -1;
- else if (!strcmp(q, "push")) {
- ap->command = "push";
- sph->exec = &spc_handler_color_push;
- ap->curptr = p;
- } else if (!strcmp(q, "pop")) {
- ap->command = "pop";
- sph->exec = &spc_handler_color_pop;
- ap->curptr = p;
- } else { /* cmyk, rgb, ... */
- ap->command = "";
- sph->exec = &spc_handler_color_default;
- }
- RELEASE(q);
- } else {
- spc_warn(spe, "Not color/background special?");
- RELEASE(q);
- return -1;
- }
-
- skip_blank(&ap->curptr, ap->endptr);
- return 0;
-}
-
diff --git a/Build/source/texk/dvipdfm-x/xsrc/spc_html.c b/Build/source/texk/dvipdfm-x/xsrc/spc_html.c
deleted file mode 100644
index 5c0d933ce3c..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/spc_html.c
+++ /dev/null
@@ -1,944 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2002-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "system.h"
-#include "mem.h"
-#include "error.h"
-#include "dpxutil.h"
-
-#include "pdfdraw.h"
-#include "pdfdev.h"
-#include "pdfximage.h"
-
-#include "pdfdoc.h"
-
-#include "specials.h"
-#include "spc_util.h"
-
-#include "spc_html.h"
-
-
-#define ENABLE_HTML_IMG_SUPPORT 1
-#define ENABLE_HTML_SVG_TRANSFORM 1
-#define ENABLE_HTML_SVG_OPACITY 1
-
-/* _FIXME_
- * Please rewrite this or remove html special support
- */
-
-#define ANCHOR_TYPE_HREF 0
-#define ANCHOR_TYPE_NAME 1
-
-struct spc_html_
-{
- struct {
- long extensions;
- } opts;
-
- pdf_obj *link_dict;
- char *baseurl;
- int pending_type;
-};
-
-static struct spc_html_ _html_state = {
- { 0 },
- NULL, NULL, -1
-};
-
-
-#ifdef ENABLE_HTML_SVG_TRANSFORM
-static int cvt_a_to_tmatrix (pdf_tmatrix *M, const char *ptr, const char **nextptr);
-#endif /* ENABLE_HTML_SVG_TRANSFORM */
-
-#define \
-downcasify(s) \
-if ((s)) { \
- char *_p = (char *) (s); \
- while (*(_p) != 0) { \
- if (*(_p) >= 'A' && *(_p) <= 'Z') { \
- *(_p) = (*(_p) - 'A') + 'a'; \
- } \
- _p++; \
- } \
-}
-
-static int
-parse_key_val (const char **pp, const char *endptr, char **kp, char **vp)
-{
- const char *q, *p;
- char *k, *v;
- int n, error = 0;
-
- for (p = *pp ; p < endptr && isspace(*p); p++);
-#if 0
- while (!error && p < endptr &&
- ((*p >= 'a' && *p <= 'z') ||
- (*p >= 'A' && *p <= 'Z'))
- ) {
-#endif
- k = v = NULL;
- for (q = p, n = 0;
- p < endptr &&
- ((*p >= 'a' && *p <= 'z') ||
- (*p >= 'A' && *p <= 'Z') ||
- (*p >= '0' && *p <= '9') ||
- *p == '-' || *p == ':'
- ); n++, p++);
- if (n == 0) {
-#if 0
- break;
-#else
- *kp = *vp = NULL;
- return -1;
-#endif
- }
- k = NEW(n + 1, char);
- memcpy(k, q, n); k[n] = '\0';
- if (p + 2 >= endptr || p[0] != '=' || (p[1] != '\"' && p[1] != '\'')) {
- RELEASE(k); k = NULL;
- *pp = p;
- error = -1;
- } else {
- char qchr = p[1];
- p += 2; /* skip '="' */
- for (q = p, n = 0; p < endptr && *p != qchr; p++, n++);
- if (p == endptr || *p != qchr)
- error = -1;
- else {
- v = NEW(n + 1, char);
- memcpy(v, q, n); v[n] = '\0';
-#if 0
- pdf_add_dict(t->attr,
- pdf_new_name(k),
- pdf_new_string(v, n));
- RELEASE(v);
-#endif
- p++;
- }
- }
-#if 0
- RELEASE(k);
- if (!error)
- for ( ; p < endptr && isspace(*p); p++);
- }
-#endif
-
- *kp = k; *vp = v; *pp = p;
- return error;
-}
-
-#define HTML_TAG_NAME_MAX 127
-#define HTML_TAG_TYPE_EMPTY 1
-#define HTML_TAG_TYPE_OPEN 1
-#define HTML_TAG_TYPE_CLOSE 2
-
-static int
-read_html_tag (char *name, pdf_obj *attr, int *type, const char **pp, const char *endptr)
-{
- const char *p = *pp;
- int n = 0, error = 0;
-
- for ( ; p < endptr && isspace(*p); p++);
- if (p >= endptr || *p != '<')
- return -1;
-
- *type = HTML_TAG_TYPE_OPEN;
- for (++p; p < endptr && isspace(*p); p++);
- if (p < endptr && *p == '/') {
- *type = HTML_TAG_TYPE_CLOSE;
- for (++p; p < endptr && isspace(*p); p++);
- }
-
-#define ISDELIM(c) ((c) == '>' || (c) == '/' || isspace(c))
- for (n = 0; p < endptr && n < HTML_TAG_NAME_MAX && !ISDELIM(*p); n++, p++) {
- name[n] = *p;
- }
- name[n] = '\0';
- if (n == 0 || p == endptr || !ISDELIM(*p)) {
- *pp = p;
- return -1;
- }
-
- for ( ; p < endptr && isspace(*p); p++);
- while (p < endptr && !error && *p != '/' && *p != '>') {
- char *kp = NULL, *vp = NULL;
- error = parse_key_val(&p, endptr, &kp, &vp);
- if (!error) {
- downcasify(kp);
- pdf_add_dict(attr,
- pdf_new_name(kp),
- pdf_new_string(vp, strlen(vp) + 1)); /* include trailing NULL here!!! */
- RELEASE(kp);
- RELEASE(vp);
- }
- for ( ; p < endptr && isspace(*p); p++);
- }
- if (error) {
- *pp = p;
- return error;
- }
-
- if (p < endptr && *p == '/') {
- *type = HTML_TAG_TYPE_EMPTY;
- for (++p; p < endptr && isspace(*p); p++);
- }
- if (p == endptr || *p != '>') {
- *pp = p;
- return -1;
- }
- p++;
-
- downcasify(name);
- *pp = p;
- return 0;
-}
-
-
-static int
-spc_handler_html__init (struct spc_env *spe, struct spc_arg *ap, void *dp)
-{
- struct spc_html_ *sd = dp;
-
- sd->link_dict = NULL;
- sd->baseurl = NULL;
- sd->pending_type = -1;
-
- return 0;
-}
-
-static int
-spc_handler_html__clean (struct spc_env *spe, struct spc_arg *ap, void *dp)
-{
- struct spc_html_ *sd = dp;
-
- if (sd->baseurl)
- RELEASE(sd->baseurl);
-
- if (sd->pending_type >= 0 || sd->link_dict)
- spc_warn(spe, "Unclosed html anchor found.");
-
- if (sd->link_dict)
- pdf_release_obj(sd->link_dict);
-
- sd->pending_type = -1;
- sd->baseurl = NULL;
- sd->link_dict = NULL;
-
- return 0;
-}
-
-
-static int
-spc_handler_html__bophook (struct spc_env *spe, struct spc_arg *ap, void *dp)
-{
- struct spc_html_ *sd = dp;
-
- if (sd->pending_type >= 0) {
- spc_warn(spe, "...html anchor continues from previous page processed...");
- }
-
- return 0;
-}
-
-static int
-spc_handler_html__eophook (struct spc_env *spe, struct spc_arg *ap, void *dp)
-{
- struct spc_html_ *sd = dp;
-
- if (sd->pending_type >= 0) {
- spc_warn(spe, "Unclosed html anchor at end-of-page!");
- }
-
- return 0;
-}
-
-
-static char *
-fqurl (const char *baseurl, const char *name)
-{
- char *q;
- int len = 0;
-
- len = strlen(name);
- if (baseurl)
- len += strlen(baseurl) + 1; /* we may want to add '/' */
-
- q = NEW(len + 1, char);
- *q = '\0';
- if (baseurl && baseurl[0]) {
- char *p;
- strcpy(q, baseurl);
- p = q + strlen(q) - 1;
- if (*p == '/')
- *p = '\0';
- if (name[0] && name[0] != '/')
- strcat(q, "/");
- }
- strcat(q, name);
-
- return q;
-}
-
-static int
-html_open_link (struct spc_env *spe, const char *name, struct spc_html_ *sd)
-{
- pdf_obj *color;
- char *url;
-
- ASSERT( name );
- ASSERT( sd->link_dict == NULL ); /* Should be checked somewhere else */
-
- sd->link_dict = pdf_new_dict();
- pdf_add_dict(sd->link_dict,
- pdf_new_name("Type"), pdf_new_name ("Annot"));
- pdf_add_dict(sd->link_dict,
- pdf_new_name("Subtype"), pdf_new_name ("Link"));
-
- color = pdf_new_array ();
- pdf_add_array(color, pdf_new_number(0.0));
- pdf_add_array(color, pdf_new_number(0.0));
- pdf_add_array(color, pdf_new_number(1.0));
- pdf_add_dict(sd->link_dict, pdf_new_name("C"), color);
-
- url = fqurl(sd->baseurl, name);
- if (url[0] == '#') {
- /* url++; causes memory leak in RELEASE(url) */
- pdf_add_dict(sd->link_dict,
- pdf_new_name("Dest"),
- pdf_new_string(url+1, strlen(url+1)));
- } else { /* Assume this is URL */
- pdf_obj *action = pdf_new_dict();
- pdf_add_dict(action,
- pdf_new_name("Type"),
- pdf_new_name("Action"));
- pdf_add_dict(action,
- pdf_new_name("S"),
- pdf_new_name("URI"));
- pdf_add_dict(action,
- pdf_new_name("URI"),
- pdf_new_string(url, strlen(url)));
- pdf_add_dict(sd->link_dict,
- pdf_new_name("A"),
- pdf_link_obj(action));
- pdf_release_obj(action);
- }
- RELEASE(url);
-
- spc_begin_annot(spe, sd->link_dict);
-
- sd->pending_type = ANCHOR_TYPE_HREF;
-
- return 0;
-}
-
-static int
-html_open_dest (struct spc_env *spe, const char *name, struct spc_html_ *sd)
-{
- int error;
- pdf_obj *array, *page_ref;
- pdf_coord cp;
-
- cp.x = spe->x_user; cp.y = spe->y_user;
- pdf_dev_transform(&cp, NULL);
-
- page_ref = pdf_doc_this_page_ref();
- ASSERT( page_ref ); /* Otherwise must be bug */
-
- array = pdf_new_array();
- pdf_add_array(array, page_ref);
- pdf_add_array(array, pdf_new_name("XYZ"));
- pdf_add_array(array, pdf_new_null());
- pdf_add_array(array, pdf_new_number(cp.y + 24.0));
- pdf_add_array(array, pdf_new_null());
-
- error = pdf_doc_add_names("Dests",
- name, strlen(name),
- array);
-
- if (error)
- spc_warn(spe, "Failed to add named destination: %s", name);
-
- sd->pending_type = ANCHOR_TYPE_NAME;
-
- return error;
-}
-
-#define ANCHOR_STARTED(s) ((s)->pending_type >= 0 || (s)->link_dict)
-
-static int
-spc_html__anchor_open (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd)
-{
- pdf_obj *href, *name;
- int error = 0;
-
- if (ANCHOR_STARTED(sd)) {
- spc_warn(spe, "Nested html anchors found!");
- return -1;
- }
-
- href = pdf_lookup_dict(attr, "href");
- name = pdf_lookup_dict(attr, "name");
- if (href && name) {
- spc_warn(spe, "Sorry, you can't have both \"href\" and \"name\" in anchor tag...");
- error = -1;
- } else if (href) {
- error = html_open_link(spe, pdf_string_value(href), sd);
- } else if (name) { /* name */
- error = html_open_dest(spe, pdf_string_value(name), sd);
- } else {
- spc_warn(spe, "You should have \"href\" or \"name\" in anchor tag!");
- error = -1;
- }
-
- return error;
-}
-
-static int
-spc_html__anchor_close (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd)
-{
- int error = 0;
-
- switch (sd->pending_type) {
- case ANCHOR_TYPE_HREF:
- if (sd->link_dict) {
- spc_end_annot(spe);
- pdf_release_obj(sd->link_dict);
- sd->link_dict = NULL;
- sd->pending_type = -1;
- } else {
- spc_warn(spe, "Closing html anchor (link) without starting!");
- error = -1;
- }
- break;
- case ANCHOR_TYPE_NAME:
- sd->pending_type = -1;
- break;
- default:
- spc_warn(spe, "No corresponding opening tag for html anchor.");
- error = -1;
- break;
- }
-
- return error;
-}
-
-static int
-spc_html__base_empty (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd)
-{
- pdf_obj *href;
- char *vp;
-
- href = pdf_lookup_dict(attr, "href");
- if (!href) {
- spc_warn(spe, "\"href\" not found for \"base\" tag!");
- return -1;
- }
-
- vp = (char *) pdf_string_value(href);
- if (sd->baseurl) {
- spc_warn(spe, "\"baseurl\" changed: \"%s\" --> \"%s\"", sd->baseurl, vp);
- RELEASE(sd->baseurl);
- }
- sd->baseurl = NEW(strlen(vp) + 1, char);
- strcpy(sd->baseurl, vp);
-
- return 0;
-}
-
-
-#ifdef ENABLE_HTML_IMG_SUPPORT
-/* This isn't completed.
- * Please think about placement of images.
- */
-static double
-atopt (const char *a)
-{
- char *q;
- const char *p = a;
- double v, u = 1.0;
- const char *_ukeys[] = {
-#define K_UNIT__PT 0
-#define K_UNIT__IN 1
-#define K_UNIT__CM 2
-#define K_UNIT__MM 3
-#define K_UNIT__BP 4
- "pt", "in", "cm", "mm", "bp",
-#define K_UNIT__PX 5
- "px",
- NULL
- };
- int k;
-
- q = parse_float_decimal(&p, p + strlen(p));
- if (!q) {
- WARN("Invalid length value: %s (%c)", a, *p);
- return 0.0;
- }
-
- v = atof(q);
- RELEASE(q);
-
- q = parse_c_ident(&p, p + strlen(p));
- if (q) {
- for (k = 0; _ukeys[k] && strcmp(_ukeys[k], q); k++);
- switch (k) {
- case K_UNIT__PT: u *= 72.0 / 72.27; break;
- case K_UNIT__IN: u *= 72.0; break;
- case K_UNIT__CM: u *= 72.0 / 2.54 ; break;
- case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
- case K_UNIT__BP: u *= 1.0 ; break;
- case K_UNIT__PX: u *= 1.0 ; break; /* 72dpi */
- default:
- WARN("Unknown unit of measure: %s", q);
- break;
- }
- RELEASE(q);
- }
-
- return v * u;
-}
-
-
-#ifdef ENABLE_HTML_SVG_OPACITY
-/* Replicated from spc_tpic */
-static pdf_obj *
-create_xgstate (double a /* alpha */, int f_ais /* alpha is shape */)
-{
- pdf_obj *dict;
-
- dict = pdf_new_dict();
- pdf_add_dict(dict,
- pdf_new_name("Type"),
- pdf_new_name("ExtGState"));
- if (f_ais) {
- pdf_add_dict(dict,
- pdf_new_name("AIS"),
- pdf_new_boolean(1));
- }
- pdf_add_dict(dict,
- pdf_new_name("ca"),
- pdf_new_number(a));
-
- return dict;
-}
-
-static int
-check_resourcestatus (const char *category, const char *resname)
-{
- pdf_obj *dict1, *dict2;
-
- dict1 = pdf_doc_current_page_resources();
- if (!dict1)
- return 0;
-
- dict2 = pdf_lookup_dict(dict1, category);
- if (dict2 &&
- pdf_obj_typeof(dict2) == PDF_DICT) {
- if (pdf_lookup_dict(dict2, resname))
- return 1;
- }
- return 0;
-}
-#endif /* ENABLE_HTML_SVG_OPACITY */
-
-static int
-spc_html__img_empty (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd)
-{
- pdf_obj *src, *obj;
- transform_info ti;
- int id, error = 0;
-#ifdef ENABLE_HTML_SVG_OPACITY
- double alpha = 1.0; /* meaning fully opaque */
-#endif /* ENABLE_HTML_SVG_OPACITY */
-#ifdef ENABLE_HTML_SVG_TRANSFORM
- pdf_tmatrix M;
-
- pdf_setmatrix(&M, 1.0, 0.0, 0.0, 1.0, spe->x_user, spe->y_user);
-#endif /* ENABLE_HTML_SVG_TRANSFORM */
-
- spc_warn(spe, "html \"img\" tag found (not completed, plese don't use!).");
-
- src = pdf_lookup_dict(attr, "src");
- if (!src) {
- spc_warn(spe, "\"src\" attribute not found for \"img\" tag!");
- return -1;
- }
-
- transform_info_clear(&ti);
- obj = pdf_lookup_dict(attr, "width");
- if (obj) {
- ti.width = atopt(pdf_string_value(obj));
- ti.flags |= INFO_HAS_WIDTH;
- }
- obj = pdf_lookup_dict(attr, "height");
- if (obj) {
- ti.height = atopt(pdf_string_value(obj));
- ti.flags |= INFO_HAS_HEIGHT;
- }
-
-#ifdef ENABLE_HTML_SVG_OPACITY
- obj = pdf_lookup_dict(attr, "svg:opacity");
- if (obj) {
- alpha = atof(pdf_string_value(obj));
- if (alpha < 0.0 || alpha > 1.0) {
- spc_warn(spe, "Invalid opacity value: %s", pdf_string_value(obj));
- alpha = 1.0;
- }
- }
-#endif /* ENABLE_HTML_SVG_OPCAITY */
-
-#ifdef ENABLE_HTML_SVG_TRANSFORM
- obj = pdf_lookup_dict(attr, "svg:transform");
- if (obj) {
- const char *p = pdf_string_value(obj);
- pdf_tmatrix N;
- for ( ; *p && isspace(*p); p++);
- while (*p && !error) {
- pdf_setmatrix(&N, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
- error = cvt_a_to_tmatrix(&N, p, &p);
- if (!error) {
- N.f = -N.f;
- pdf_concatmatrix(&M, &N);
- for ( ; *p && isspace(*p); p++);
- if (*p == ',')
- for (++p; *p && isspace(*p); p++);
- }
- }
- }
-#endif /* ENABLE_HTML_SVG_TRANSFORM */
-
- if (error) {
- spc_warn(spe, "Error in html \"img\" tag attribute.");
- return error;
- }
-
- id = pdf_ximage_findresource(pdf_string_value(src), 0, NULL);
- if (id < 0) {
- spc_warn(spe, "Could not find/load image: %s", pdf_string_value(src));
- error = -1;
- } else {
-#if defined(ENABLE_HTML_SVG_TRANSFORM) || defined(ENABLE_HTML_SVG_OPACITY)
- {
- char *res_name;
- pdf_rect r;
-
- graphics_mode();
-
- pdf_dev_gsave();
-
-#ifdef ENABLE_HTML_SVG_OPACITY
- {
- pdf_obj *dict;
- int a = round(100.0 * alpha);
- if (a != 0) {
- res_name = NEW(strlen("_Tps_a100_") + 1, char);
- sprintf(res_name, "_Tps_a%03d_", a); /* Not Tps prefix but... */
- if (!check_resourcestatus("ExtGState", res_name)) {
- dict = create_xgstate(round_at(0.01 * a, 0.01), 0);
- pdf_doc_add_page_resource("ExtGState",
- res_name, pdf_ref_obj(dict));
- pdf_release_obj(dict);
- }
- pdf_doc_add_page_content(" /", 2);
- pdf_doc_add_page_content(res_name, strlen(res_name));
- pdf_doc_add_page_content(" gs", 3);
- RELEASE(res_name);
- }
- }
-#endif /* ENABLE_HTML_SVG_OPACITY */
-
- pdf_dev_concat(&M);
-
- pdf_ximage_scale_image(id, &M, &r, &ti);
- pdf_dev_concat(&M);
-
- pdf_dev_rectclip(r.llx, r.lly, r.urx - r.llx, r.ury - r.lly);
-
- res_name = pdf_ximage_get_resname(id);
- pdf_doc_add_page_content(" /", 2);
- pdf_doc_add_page_content(res_name, strlen(res_name));
- pdf_doc_add_page_content(" Do", 3);
-
- pdf_dev_grestore();
-
- pdf_doc_add_page_resource("XObject",
- res_name,
- pdf_ximage_get_reference(id));
- }
-#else
- pdf_dev_put_image(id, &ti, spe->x_user, spe->y_user);
-#endif /* ENABLE_HTML_SVG_XXX */
- }
-
- return error;
-}
-#else
-static int
-spc_html__img_empty (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd)
-{
- spc_warn(spe, "IMG tag not yet supported yet...");
- return -1;
-}
-#endif /* ENABLE_HTML_IMG_SUPPORT */
-
-
-static int
-spc_handler_html_default (struct spc_env *spe, struct spc_arg *ap)
-{
- struct spc_html_ *sd = &_html_state;
- char name[HTML_TAG_NAME_MAX + 1];
- pdf_obj *attr;
- int error = 0, type = HTML_TAG_TYPE_OPEN;
-
- if (ap->curptr >= ap->endptr)
- return 0;
-
- attr = pdf_new_dict();
- error = read_html_tag(name, attr, &type, &ap->curptr, ap->endptr);
- if (error) {
- pdf_release_obj(attr);
- return error;
- }
- if (!strcmp(name, "a")) {
- switch (type) {
- case HTML_TAG_TYPE_OPEN:
- error = spc_html__anchor_open (spe, attr, sd);
- break;
- case HTML_TAG_TYPE_CLOSE:
- error = spc_html__anchor_close(spe, attr, sd);
- break;
- default:
- spc_warn(spe, "Empty html anchor tag???");
- error = -1;
- break;
- }
- } else if (!strcmp(name, "base")) {
- if (type == HTML_TAG_TYPE_CLOSE) {
- spc_warn(spe, "Close tag for \"base\"???");
- error = -1;
- } else { /* treat "open" same as "empty" */
- error = spc_html__base_empty(spe, attr, sd);
- }
- } else if (!strcmp(name, "img")) {
- if (type == HTML_TAG_TYPE_CLOSE) {
- spc_warn(spe, "Close tag for \"img\"???");
- error = -1;
- } else { /* treat "open" same as "empty" */
- error = spc_html__img_empty(spe, attr, sd);
- }
- }
- pdf_release_obj(attr);
-
- for ( ; ap->curptr < ap->endptr && isspace(ap->curptr[0]); ap->curptr++);
-
- return error;
-}
-
-
-#ifdef ENABLE_HTML_SVG_TRANSFORM
-/* translate wsp* '(' wsp* number (comma-wsp number)? wsp* ')' */
-static int
-cvt_a_to_tmatrix (pdf_tmatrix *M, const char *ptr, const char **nextptr)
-{
- char *q;
- const char *p = ptr;
- int n;
- double v[6];
- static const char *_tkeys[] = {
-#define K_TRNS__MATRIX 0
- "matrix", /* a b c d e f */
-#define K_TRNS__TRANSLATE 1
- "translate", /* tx [ty] : dflt. tf = 0 */
-#define K_TRNS__SCALE 2
- "scale", /* sx [sy] : dflt. sy = sx */
-#define K_TRNS__ROTATE 3
- "rotate", /* ang [cx cy] : dflt. cx, cy = 0 */
-#define K_TRNS__SKEWX 4
-#define K_TRNS__SKEWY 5
- "skewX", /* ang */
- "skewY", /* ang */
- NULL
- };
- int k;
-
- for ( ; *p && isspace(*p); p++);
-
- q = parse_c_ident(&p, p + strlen(p));
- if (!q)
- return -1;
- /* parsed transformation key */
- for (k = 0; _tkeys[k] && strcmp(q, _tkeys[k]); k++);
- RELEASE(q);
-
- /* handle args */
- for ( ; *p && isspace(*p); p++);
- if (*p != '(' || *(p + 1) == 0)
- return -1;
- for (++p; *p && isspace(*p); p++);
- for (n = 0; n < 6 && *p && *p != ')'; n++) {
- q = parse_float_decimal(&p, p + strlen(p));
- if (!q)
- break;
- else {
- v[n] = atof(q);
- if (*p == ',')
- p++;
- for ( ; *p && isspace(*p); p++);
- if (*p == ',')
- for (++p; *p && isspace(*p); p++);
- RELEASE(q);
- }
- }
- if (*p != ')')
- return -1;
- p++;
-
- switch (k) {
- case K_TRNS__MATRIX:
- if (n != 6)
- return -1;
- M->a = v[0]; M->c = v[1];
- M->b = v[2]; M->d = v[3];
- M->e = v[4]; M->f = v[5];
- break;
- case K_TRNS__TRANSLATE:
- if (n != 1 && n != 2)
- return -1;
- M->a = M->d = 1.0;
- M->c = M->b = 0.0;
- M->e = v[0]; M->f = (n == 2) ? v[1] : 0.0;
- break;
- case K_TRNS__SCALE:
- if (n != 1 && n != 2)
- return -1;
- M->a = v[0]; M->d = (n == 2) ? v[1] : v[0];
- M->c = M->b = 0.0;
- M->e = M->f = 0.0;
- break;
- case K_TRNS__ROTATE:
- if (n != 1 && n != 3)
- return -1;
- M->a = cos(v[0] * M_PI / 180.0);
- M->c = sin(v[0] * M_PI / 180.0);
- M->b = -M->c; M->d = M->a;
- M->e = (n == 3) ? v[1] : 0.0;
- M->f = (n == 3) ? v[2] : 0.0;
- break;
- case K_TRNS__SKEWX:
- if (n != 1)
- return -1;
- M->a = M->d = 1.0;
- M->c = 0.0;
- M->b = tan(v[0] * M_PI / 180.0);
- break;
- case K_TRNS__SKEWY:
- if (n != 1)
- return -1;
- M->a = M->d = 1.0;
- M->c = tan(v[0] * M_PI / 180.0);
- M->b = 0.0;
- break;
- }
-
- if (nextptr)
- *nextptr = p;
- return 0;
-}
-#endif /* ENABLE_HTML_SVG_TRANSFORM */
-
-int
-spc_html_at_begin_document (void)
-{
- struct spc_html_ *sd = &_html_state;
- return spc_handler_html__init(NULL, NULL, sd);
-}
-
-int
-spc_html_at_begin_page (void)
-{
- struct spc_html_ *sd = &_html_state;
- return spc_handler_html__bophook(NULL, NULL, sd);
-}
-
-int
-spc_html_at_end_page (void)
-{
- struct spc_html_ *sd = &_html_state;
- return spc_handler_html__eophook(NULL, NULL, sd);
-}
-
-int
-spc_html_at_end_document (void)
-{
- struct spc_html_ *sd = &_html_state;
- return spc_handler_html__clean(NULL, NULL, sd);
-}
-
-
-int
-spc_html_check_special (const char *buffer, long size)
-{
- const char *p, *endptr;
-
- p = buffer;
- endptr = p + size;
-
- for ( ; p < endptr && isspace(*p); p++);
- size = (long) (endptr - p);
- if (size >= strlen("html:") &&
- !memcmp(p, "html:", strlen("html:"))) {
- return 1;
- }
-
- return 0;
-}
-
-
-int
-spc_html_setup_handler (struct spc_handler *sph,
- struct spc_env *spe, struct spc_arg *ap)
-{
- ASSERT(sph && spe && ap);
-
- for ( ; ap->curptr < ap->endptr && isspace(ap->curptr[0]); ap->curptr++);
- if (ap->curptr + strlen("html:") > ap->endptr ||
- memcmp(ap->curptr, "html:", strlen("html:"))) {
- return -1;
- }
-
- ap->command = "";
-
- sph->key = "html:";
- sph->exec = &spc_handler_html_default;
-
- ap->curptr += strlen("html:");
- for ( ; ap->curptr < ap->endptr && isspace(ap->curptr[0]); ap->curptr++);
-
- return 0;
-}
-
diff --git a/Build/source/texk/dvipdfm-x/xsrc/spc_util.c b/Build/source/texk/dvipdfm-x/xsrc/spc_util.c
deleted file mode 100644
index be50644cd41..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/spc_util.c
+++ /dev/null
@@ -1,796 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2007-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "system.h"
-#include "mem.h"
-#include "error.h"
-#include "dpxutil.h"
-
-#include "pdfdev.h"
-#include "pdfparse.h"
-#include "pdfcolor.h"
-#include "pdfdraw.h"
-
-#include "specials.h"
-
-#include "spc_util.h"
-
-
-#ifndef ISBLANK
-#define ISBLANK(c) ((c) == ' ' || (c) == '\t')
-#endif
-static void
-skip_blank (const char **pp, const char *endptr)
-{
- const char *p = *pp;
- for ( ; p < endptr && ISBLANK(*p); p++);
- *pp = p;
-}
-
-
-/* From pdfcolor.c */
-static int pdf_color_namedcolor (pdf_color *color, const char *colorname);
-
-int
-spc_util_read_numbers (double *values, int num_values,
- struct spc_env *spe, struct spc_arg *args)
-{
- int count;
- char *q;
-
- skip_blank(&args->curptr, args->endptr);
- for (count = 0;
- count < num_values &&
- args->curptr < args->endptr; ) {
- q = parse_float_decimal(&args->curptr, args->endptr);
- if (!q)
- break;
- else {
- values[count] = atof(q);
- RELEASE(q);
- skip_blank(&args->curptr, args->endptr);
- count++;
- }
- }
-
- return count;
-}
-
-static void
-rgb_color_from_hsv (pdf_color *color, double h, double s, double v)
-{
- double r, g, b;
- ASSERT( color );
- r = g = b = v;
- if (s != 0.0) {
- double h6, f, v1, v2, v3;
- int i;
- h6 = h * 6; /* 360 / 60 */
- i = (int) h6;
- f = h6 - i;
- v1 = v * (1 - s);
- v2 = v * (1 - s * f);
- v3 = v * (1 - s * (1 - f));
- switch (i) {
- case 0: r = v ; g = v3; b = v1; break;
- case 1: r = v2; g = v ; b = v1; break;
- case 2: r = v1; g = v ; b = v3; break;
- case 3: r = v1; g = v2; b = v ; break;
- case 4: r = v3; g = v1; b = v ; break;
- case 5: r = v ; g = v1; b = v2; break;
- case 6: r = v ; g = v1; b = v2; break;
- }
- }
- pdf_color_rgbcolor(color, r, g, b);
-}
-
-static int
-spc_read_color_color (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap)
-{
- char *q;
- double cv[4];
- int nc;
- int error = 0;
-
- q = parse_c_ident(&ap->curptr, ap->endptr);
- if (!q) {
- spc_warn(spe, "No valid color specified?");
- return -1;
- }
- skip_blank(&ap->curptr, ap->endptr);
-
- if (!strcmp(q, "rgb")) { /* Handle rgb color */
- nc = spc_util_read_numbers(cv, 3, spe, ap);
- if (nc != 3) {
- spc_warn(spe, "Invalid value for RGB color specification.");
- error = -1;
- } else {
- pdf_color_rgbcolor(colorspec, cv[0], cv[1], cv[2]);
- }
- } else if (!strcmp(q, "cmyk")) { /* Handle cmyk color */
- nc = spc_util_read_numbers(cv, 4, spe, ap);
- if (nc != 4) {
- spc_warn(spe, "Invalid value for CMYK color specification.");
- error = -1;
- } else {
- pdf_color_cmykcolor(colorspec, cv[0], cv[1], cv[2], cv[3]);
- }
- } else if (!strcmp(q, "gray")) { /* Handle gray */
- nc = spc_util_read_numbers(cv, 1, spe, ap);
- if (nc != 1) {
- spc_warn(spe, "Invalid value for gray color specification.");
- error = -1;
- } else {
- pdf_color_graycolor(colorspec, cv[0]);
- }
- } else if (!strcmp(q, "hsb")) {
- nc = spc_util_read_numbers(cv, 3, spe, ap);
- if (nc != 3) {
- spc_warn(spe, "Invalid value for HSB color specification.");
- error = -1;
- } else {
- rgb_color_from_hsv(colorspec, cv[0], cv[1], cv[2]);
- spc_warn(spe, "HSB color converted to RGB: hsb: <%g, %g, %g> ==> rgb: <%g, %g, %g>",
- cv[0], cv[1], cv[2],
- colorspec->values[0], colorspec->values[1], colorspec->values[2]);
- }
- } else { /* Must be a "named" color */
- error = pdf_color_namedcolor(colorspec, q);
- if (error)
- spc_warn(spe, "Unrecognized color name: %s", q);
- }
- RELEASE(q);
-
- return error;
-}
-
-/* Argumaent for this is PDF_Number or PDF_Array.
- * But we ignore that since we don't want to add
- * dependency to pdfxxx and @foo can not be
- * allowed for color specification. "pdf" here
- * means pdf: special syntax.
- */
-static int
-spc_read_color_pdf (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap)
-{
- double cv[4]; /* at most four */
- int nc, isarry = 0;
- int error = 0;
- char *q;
-
- skip_blank(&ap->curptr, ap->endptr);
-
- if (ap->curptr[0] == '[') {
- ap->curptr++; skip_blank(&ap->curptr, ap->endptr);
- isarry = 1;
- }
-
- nc = spc_util_read_numbers(cv, 4, spe, ap);
- switch (nc) {
- case 1:
- pdf_color_graycolor(colorspec, cv[0]);
- break;
- case 3:
- pdf_color_rgbcolor (colorspec, cv[0], cv[1], cv[2]);
- break;
- case 4:
- pdf_color_cmykcolor(colorspec, cv[0], cv[1], cv[2], cv[3]);
- break;
- default:
- /* Try to read the color names defined in dvipsname.def */
- q = parse_c_ident(&ap->curptr, ap->endptr);
- if (!q) {
- spc_warn(spe, "No valid color specified?");
- return -1;
- }
- error = pdf_color_namedcolor(colorspec, q);
- if (error)
- spc_warn(spe, "Unrecognized color name: %s", q);
- RELEASE(q);
- break;
- }
-
- if (!error && isarry) {
- skip_blank(&ap->curptr, ap->endptr);
- if (ap->curptr >= ap->endptr || ap->curptr[0] != ']') {
- spc_warn(spe, "Unbalanced '[' and ']' in color specification.");
- error = -1;
- } else {
- ap->curptr++;
- }
- }
-
- return error;
-}
-
-
-/* This is for reading *single* color specification. */
-int
-spc_util_read_colorspec (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap, int syntax)
-{
- int error = 0;
-
- ASSERT(colorspec && spe && ap);
-
- skip_blank(&ap->curptr, ap->endptr);
- if (ap->curptr >= ap->endptr) {
- return -1;
- }
-
- if (syntax)
- error = spc_read_color_color(spe, colorspec, ap);
- else
- error = spc_read_color_pdf(spe, colorspec, ap);
-
- skip_blank(&ap->curptr, ap->endptr);
-
- return error;
-}
-
-
-/* This need to allow 'true' prefix for unit and
- * length value must be divided by current magnification.
- */
-int
-spc_util_read_length (struct spc_env *spe, double *vp /* ret. */, struct spc_arg *ap)
-{
- char *q;
- double v, u = 1.0;
- const char *ukeys[] = {
-#define K_UNIT__PT 0
-#define K_UNIT__IN 1
-#define K_UNIT__CM 2
-#define K_UNIT__MM 3
-#define K_UNIT__BP 4
- "pt", "in", "cm", "mm", "bp", NULL
- };
- int k, error = 0;
-
- q = parse_float_decimal(&ap->curptr, ap->endptr);
- if (!q)
- return -1;
-
- v = atof(q);
- RELEASE(q);
-
- skip_white(&ap->curptr, ap->endptr);
- q = parse_c_ident(&ap->curptr, ap->endptr);
- if (q) {
- char *qq = q;
- if (strlen(q) >= strlen("true") &&
- !memcmp(q, "true", strlen("true"))) {
- u /= spe->mag != 0.0 ? spe->mag : 1.0; /* inverse magnify */
- q += strlen("true");
- }
- if (strlen(q) == 0) {
- RELEASE(qq);
- skip_white(&ap->curptr, ap->endptr);
- qq = q = parse_c_ident(&ap->curptr, ap->endptr);
- }
- if (q) {
- for (k = 0; ukeys[k] && strcmp(ukeys[k], q); k++);
- switch (k) {
- case K_UNIT__PT: u *= 72.0 / 72.27; break;
- case K_UNIT__IN: u *= 72.0; break;
- case K_UNIT__CM: u *= 72.0 / 2.54 ; break;
- case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
- case K_UNIT__BP: u *= 1.0 ; break;
- default:
- spc_warn(spe, "Unknown unit of measure: %s", q);
- error = -1;
- break;
- }
- RELEASE(qq);
- }
- else {
- spc_warn(spe, "Missing unit of measure after \"true\"");
- error = -1;
- }
- }
-
- *vp = v * u;
- return error;
-}
-
-
-/*
- * Compute a transformation matrix
- * transformations are applied in the following
- * order: scaling, rotate, displacement.
- */
-static void
-make_transmatrix (pdf_tmatrix *M,
- double xoffset, double yoffset,
- double xscale, double yscale,
- double rotate)
-{
- double c, s;
-
- c = cos(rotate);
- s = sin(rotate);
-
- M->a = xscale * c; M->b = xscale * s;
- M->c = -yscale * s; M->d = yscale * c;
- M->e = xoffset; M->f = yoffset;
-}
-
-static int
-spc_read_dimtrns_dvips (struct spc_env *spe, transform_info *t, struct spc_arg *ap)
-{
- static const char *_dtkeys[] = {
-#define K_TRN__HOFFSET 0
-#define K_TRN__VOFFSET 1
- "hoffset", "voffset",
-#define K_DIM__HSIZE 2
-#define K_DIM__VSIZE 3
- "hsize", "vsize",
-#define K_TRN__HSCALE 4
-#define K_TRN__VSCALE 5
- "hscale", "vscale",
-#define K_TRN__ANGLE 6
- "angle",
-#define K__CLIP 7
- "clip",
-#define K_DIM__LLX 8
-#define K_DIM__LLY 9
-#define K_DIM__URX 10
-#define K_DIM__URY 11
- "llx", "lly", "urx", "ury",
-#define K_DIM__RWI 12
-#define K_DIM__RHI 13
- "rwi", "rhi",
- NULL
- };
- double xoffset, yoffset, xscale, yscale, rotate;
- int error = 0;
-
- xoffset = yoffset = rotate = 0.0; xscale = yscale = 1.0;
-
- skip_blank(&ap->curptr, ap->endptr);
- while (!error && ap->curptr < ap->endptr) {
- char *kp, *vp;
- int k;
-
- kp = parse_c_ident(&ap->curptr, ap->endptr);
- if (!kp)
- break;
-
- for (k = 0; _dtkeys[k] && strcmp(kp, _dtkeys[k]); k++);
- if (!_dtkeys[k]) {
- spc_warn(spe, "Unrecognized dimension/transformation key: %s", kp);
- error = -1;
- RELEASE(kp);
- break;
- }
-
- skip_blank(&ap->curptr, ap->endptr);
- if (k == K__CLIP) {
- t->flags |= INFO_DO_CLIP;
- RELEASE(kp);
- continue; /* not key-value */
- }
-
- if (ap->curptr < ap->endptr && ap->curptr[0] == '=') {
- ap->curptr++;
- skip_blank(&ap->curptr, ap->endptr);
- }
-
- vp = NULL;
- if (ap->curptr[0] == '\'' || ap->curptr[0] == '\"') {
- char qchr = ap->curptr[0];
- ap->curptr++;
- skip_blank(&ap->curptr, ap->endptr);
- vp = parse_float_decimal(&ap->curptr, ap->endptr);
- skip_blank(&ap->curptr, ap->endptr);
- if (vp && qchr != ap->curptr[0]) {
- spc_warn(spe, "Syntax error in dimension/transformation specification.");
- error = -1;
- RELEASE(vp); vp = NULL;
- }
- ap->curptr++;
- } else {
- vp = parse_float_decimal(&ap->curptr, ap->endptr);
- }
- if (!error && !vp) {
- spc_warn(spe, "Missing value for dimension/transformation: %s", kp);
- error = -1;
- }
- RELEASE(kp);
- if (!vp || error) {
- break;
- }
-
- switch (k) {
- case K_TRN__HOFFSET:
- xoffset = atof(vp);
- break;
- case K_TRN__VOFFSET:
- yoffset = atof(vp);
- break;
- case K_DIM__HSIZE:
- t->width = atof(vp);
- t->flags |= INFO_HAS_WIDTH;
- break;
- case K_DIM__VSIZE:
- t->height = atof(vp);
- t->flags |= INFO_HAS_HEIGHT;
- break;
- case K_TRN__HSCALE:
- xscale = atof(vp) / 100.0;
- break;
- case K_TRN__VSCALE:
- yscale = atof(vp) / 100.0;
- break;
- case K_TRN__ANGLE:
- rotate = M_PI * atof(vp) / 180.0;
- break;
- case K_DIM__LLX:
- t->bbox.llx = atof(vp);
- t->flags |= INFO_HAS_USER_BBOX;
- break;
- case K_DIM__LLY:
- t->bbox.lly = atof(vp);
- t->flags |= INFO_HAS_USER_BBOX;
- break;
- case K_DIM__URX:
- t->bbox.urx = atof(vp);
- t->flags |= INFO_HAS_USER_BBOX;
- break;
- case K_DIM__URY:
- t->bbox.ury = atof(vp);
- t->flags |= INFO_HAS_USER_BBOX;
- break;
- case K_DIM__RWI:
- t->width = atof(vp) / 10.0;
- t->flags |= INFO_HAS_WIDTH;
- break;
- case K_DIM__RHI:
- t->height = atof(vp) / 10.0;
- t->flags |= INFO_HAS_HEIGHT;
- break;
- }
- skip_blank(&ap->curptr, ap->endptr);
- RELEASE(vp);
- }
- make_transmatrix(&(t->matrix), xoffset, yoffset, xscale, yscale, rotate);
-
- return error;
-}
-
-
-static int
-spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *ap, long *page_no)
-{
- int has_scale, has_xscale, has_yscale, has_rotate, has_matrix;
- const char *_dtkeys[] = {
-#define K_DIM__WIDTH 0
-#define K_DIM__HEIGHT 1
-#define K_DIM__DEPTH 2
- "width", "height", "depth",
-#define K_TRN__SCALE 3
-#define K_TRN__XSCALE 4
-#define K_TRN__YSCALE 5
-#define K_TRN__ROTATE 6
- "scale", "xscale", "yscale", "rotate",
-#define K_TRN__BBOX 7
- "bbox", /* See "Dvipdfmx User's Manual", p.5 */
-#define K_TRN__MATRIX 8
- "matrix",
-#undef K__CLIP
-#define K__CLIP 9
- "clip",
-#define K__PAGE 10
- "page",
-#define K__HIDE 11
- "hide",
- NULL
- };
- double xscale, yscale, rotate;
- int error = 0;
-
- has_xscale = has_yscale = has_scale = has_rotate = has_matrix = 0;
- xscale = yscale = 1.0; rotate = 0.0;
- p->flags |= INFO_DO_CLIP; /* default: do clipping */
- p->flags &= ~INFO_DO_HIDE; /* default: do clipping */
-
- skip_blank(&ap->curptr, ap->endptr);
-
- while (!error && ap->curptr < ap->endptr) {
- char *kp, *vp;
- int k;
-
- kp = parse_c_ident(&ap->curptr, ap->endptr);
- if (!kp)
- break;
-
- skip_blank(&ap->curptr, ap->endptr);
- for (k = 0; _dtkeys[k] && strcmp(_dtkeys[k], kp); k++);
- switch (k) {
- case K_DIM__WIDTH:
- error = spc_util_read_length(spe, &p->width , ap);
- p->flags |= INFO_HAS_WIDTH;
- break;
- case K_DIM__HEIGHT:
- error = spc_util_read_length(spe, &p->height, ap);
- p->flags |= INFO_HAS_HEIGHT;
- break;
- case K_DIM__DEPTH:
- error = spc_util_read_length(spe, &p->depth , ap);
- p->flags |= INFO_HAS_HEIGHT;
- break;
- case K_TRN__SCALE:
- vp = parse_float_decimal(&ap->curptr, ap->endptr);
- if (!vp)
- error = -1;
- else {
- xscale = yscale = atof(vp);
- has_scale = 1;
- RELEASE(vp);
- }
- break;
- case K_TRN__XSCALE:
- vp = parse_float_decimal(&ap->curptr, ap->endptr);
- if (!vp)
- error = -1;
- else {
- xscale = atof(vp);
- has_xscale = 1;
- RELEASE(vp);
- }
- break;
- case K_TRN__YSCALE:
- vp = parse_float_decimal(&ap->curptr, ap->endptr);
- if (!vp)
- error = -1;
- else {
- yscale = atof(vp);
- has_yscale = 1;
- RELEASE(vp);
- }
- break;
- case K_TRN__ROTATE:
- vp = parse_float_decimal(&ap->curptr, ap->endptr);
- if (!vp)
- error = -1;
- else {
- rotate = M_PI * atof(vp) / 180.0;
- has_rotate = 1;
- RELEASE(vp);
- }
- break;
- case K_TRN__BBOX:
- {
- double v[4];
- if (spc_util_read_numbers(v, 4, spe, ap) != 4)
- error = -1;
- else {
- p->bbox.llx = v[0];
- p->bbox.lly = v[1];
- p->bbox.urx = v[2];
- p->bbox.ury = v[3];
- p->flags |= INFO_HAS_USER_BBOX;
- }
- }
- break;
- case K_TRN__MATRIX:
- {
- double v[6];
- if (spc_util_read_numbers(v, 6, spe, ap) != 6)
- error = -1;
- else {
- pdf_setmatrix(&(p->matrix), v[0], v[1], v[2], v[3], v[4], v[5]);
- has_matrix = 1;
- }
- }
- break;
- case K__CLIP:
- vp = parse_float_decimal(&ap->curptr, ap->endptr);
- if (!vp)
- error = -1;
- else {
- if (atof(vp))
- p->flags |= INFO_DO_CLIP;
- else
- p->flags &= ~INFO_DO_CLIP;
- RELEASE(vp);
- }
- break;
- case K__PAGE:
- {
- double page;
- if (page_no && spc_util_read_numbers(&page, 1, spe, ap) == 1)
- *page_no = (long) page;
- else
- error = -1;
- }
- break;
- case K__HIDE:
- p->flags |= INFO_DO_HIDE;
- break;
- default:
- error = -1;
- break;
- }
- if (error)
- spc_warn(spe, "Unrecognized key or invalid value for dimension/transformation: %s", kp);
- else
- skip_blank(&ap->curptr, ap->endptr);
- RELEASE(kp);
- }
-
- if (!error) {
- /* Check consistency */
- if (has_xscale && (p->flags & INFO_HAS_WIDTH)) {
- spc_warn(spe, "Can't supply both width and xscale. Ignore xscale.");
- xscale = 1.0;
- } else if (has_yscale &&
- (p->flags & INFO_HAS_HEIGHT)) {
- spc_warn(spe, "Can't supply both height/depth and yscale. Ignore yscale.");
- yscale = 1.0;
- } else if (has_scale &&
- (has_xscale || has_yscale)) {
- spc_warn(spe, "Can't supply overall scale along with axis scales.");
- error = -1;
- } else if (has_matrix &&
- (has_scale || has_xscale || has_yscale || has_rotate)) {
- spc_warn(spe, "Can't supply transform matrix along with scales or rotate. Ignore scales and rotate.");
- }
- }
-
- if (!has_matrix) {
- make_transmatrix(&(p->matrix), 0.0, 0.0, xscale, yscale, rotate);
- }
-
- if (!(p->flags & INFO_HAS_USER_BBOX)) {
- p->flags &= ~INFO_DO_CLIP; /* no clipping needed */
- }
-
- return error;
-}
-
-int
-spc_util_read_dimtrns (struct spc_env *spe, transform_info *ti, struct spc_arg *args, long *page_no, int syntax)
-{
- ASSERT(ti && spe && args);
-
- if (syntax) {
- ASSERT(!page_no);
- return spc_read_dimtrns_dvips(spe, ti, args);
- } else {
- return spc_read_dimtrns_pdfm (spe, ti, args, page_no);
- }
-
- return -1;
-}
-
-
-/* Color names */
-#ifdef rgb
-#undef rgb
-#endif
-#ifdef cmyk
-#undef cmyk
-#endif
-#define gray(g) {1, {g}}
-#define rgb8(r,g,b) {3, {((r)/255.0), ((g)/255.0), ((b)/255.0), 0.0}}
-#define cmyk(c,m,y,k) {4, {(c), (m), (y), (k)}}
-
-static struct colordef_
-{
- const char *key;
- pdf_color color;
-} colordefs[] = {
- {"GreenYellow", cmyk(0.15, 0.00, 0.69, 0.00)},
- {"Yellow", cmyk(0.00, 0.00, 1.00, 0.00)},
- {"Goldenrod", cmyk(0.00, 0.10, 0.84, 0.00)},
- {"Dandelion", cmyk(0.00, 0.29, 0.84, 0.00)},
- {"Apricot", cmyk(0.00, 0.32, 0.52, 0.00)},
- {"Peach", cmyk(0.00, 0.50, 0.70, 0.00)},
- {"Melon", cmyk(0.00, 0.46, 0.50, 0.00)},
- {"YellowOrange", cmyk(0.00, 0.42, 1.00, 0.00)},
- {"Orange", cmyk(0.00, 0.61, 0.87, 0.00)},
- {"BurntOrange", cmyk(0.00, 0.51, 1.00, 0.00)},
- {"Bittersweet", cmyk(0.00, 0.75, 1.00, 0.24)},
- {"RedOrange", cmyk(0.00, 0.77, 0.87, 0.00)},
- {"Mahogany", cmyk(0.00, 0.85, 0.87, 0.35)},
- {"Maroon", cmyk(0.00, 0.87, 0.68, 0.32)},
- {"BrickRed", cmyk(0.00, 0.89, 0.94, 0.28)},
- {"Red", cmyk(0.00, 1.00, 1.00, 0.00)},
- {"OrangeRed", cmyk(0.00, 1.00, 0.50, 0.00)},
- {"RubineRed", cmyk(0.00, 1.00, 0.13, 0.00)},
- {"WildStrawberry", cmyk(0.00, 0.96, 0.39, 0.00)},
- {"Salmon", cmyk(0.00, 0.53, 0.38, 0.00)},
- {"CarnationPink", cmyk(0.00, 0.63, 0.00, 0.00)},
- {"Magenta", cmyk(0.00, 1.00, 0.00, 0.00)},
- {"VioletRed", cmyk(0.00, 0.81, 0.00, 0.00)},
- {"Rhodamine", cmyk(0.00, 0.82, 0.00, 0.00)},
- {"Mulberry", cmyk(0.34, 0.90, 0.00, 0.02)},
- {"RedViolet", cmyk(0.07, 0.90, 0.00, 0.34)},
- {"Fuchsia", cmyk(0.47, 0.91, 0.00, 0.08)},
- {"Lavender", cmyk(0.00, 0.48, 0.00, 0.00)},
- {"Thistle", cmyk(0.12, 0.59, 0.00, 0.00)},
- {"Orchid", cmyk(0.32, 0.64, 0.00, 0.00)},
- {"DarkOrchid", cmyk(0.40, 0.80, 0.20, 0.00)},
- {"Purple", cmyk(0.45, 0.86, 0.00, 0.00)},
- {"Plum", cmyk(0.50, 1.00, 0.00, 0.00)},
- {"Violet", cmyk(0.79, 0.88, 0.00, 0.00)},
- {"RoyalPurple", cmyk(0.75, 0.90, 0.00, 0.00)},
- {"BlueViolet", cmyk(0.86, 0.91, 0.00, 0.04)},
- {"Periwinkle", cmyk(0.57, 0.55, 0.00, 0.00)},
- {"CadetBlue", cmyk(0.62, 0.57, 0.23, 0.00)},
- {"CornflowerBlue", cmyk(0.65, 0.13, 0.00, 0.00)},
- {"MidnightBlue", cmyk(0.98, 0.13, 0.00, 0.43)},
- {"NavyBlue", cmyk(0.94, 0.54, 0.00, 0.00)},
- {"RoyalBlue", cmyk(1.00, 0.50, 0.00, 0.00)},
- {"Blue", cmyk(1.00, 1.00, 0.00, 0.00)},
- {"Cerulean", cmyk(0.94, 0.11, 0.00, 0.00)},
- {"Cyan", cmyk(1.00, 0.00, 0.00, 0.00)},
- {"ProcessBlue", cmyk(0.96, 0.00, 0.00, 0.00)},
- {"SkyBlue", cmyk(0.62, 0.00, 0.12, 0.00)},
- {"Turquoise", cmyk(0.85, 0.00, 0.20, 0.00)},
- {"TealBlue", cmyk(0.86, 0.00, 0.34, 0.02)},
- {"Aquamarine", cmyk(0.82, 0.00, 0.30, 0.00)},
- {"BlueGreen", cmyk(0.85, 0.00, 0.33, 0.00)},
- {"Emerald", cmyk(1.00, 0.00, 0.50, 0.00)},
- {"JungleGreen", cmyk(0.99, 0.00, 0.52, 0.00)},
- {"SeaGreen", cmyk(0.69, 0.00, 0.50, 0.00)},
- {"Green", cmyk(1.00, 0.00, 1.00, 0.00)},
- {"ForestGreen", cmyk(0.91, 0.00, 0.88, 0.12)},
- {"PineGreen", cmyk(0.92, 0.00, 0.59, 0.25)},
- {"LimeGreen", cmyk(0.50, 0.00, 1.00, 0.00)},
- {"YellowGreen", cmyk(0.44, 0.00, 0.74, 0.00)},
- {"SpringGreen", cmyk(0.26, 0.00, 0.76, 0.00)},
- {"OliveGreen", cmyk(0.64, 0.00, 0.95, 0.40)},
- {"RawSienna", cmyk(0.00, 0.72, 1.00, 0.45)},
- {"Sepia", cmyk(0.00, 0.83, 1.00, 0.70)},
- {"Brown", cmyk(0.00, 0.81, 1.00, 0.60)},
- {"Tan", cmyk(0.14, 0.42, 0.56, 0.00)},
- /* Adobe Reader 7 and 8 had problem when gray and cmyk black colors
- * are mixed. No problem with Previewer.app.
- * It happens when \usepackage[dvipdfm]{graphicx} and then called
- * \usepackage{color} without dvipdfm option. */
- {"Gray", gray(0.5)},
- {"Black", gray(0.0)},
- {"White", gray(1.0)},
- {NULL}
-};
-
-
-static int
-pdf_color_namedcolor (pdf_color *color, const char *name)
-{
- int i;
- for (i = 0; colordefs[i].key; i++) {
- if (!strcmp(colordefs[i].key, name)) {
- pdf_color_copycolor(color, &colordefs[i].color);
- return 0;
- }
- }
- return -1;
-}
-
diff --git a/Build/source/texk/dvipdfm-x/xsrc/spc_util.h b/Build/source/texk/dvipdfm-x/xsrc/spc_util.h
deleted file mode 100644
index db5b16cf245..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/spc_util.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2002-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-#ifndef _SPC_UTIL_H_
-#define _SPC_UTIL_H_
-
-#include "pdfcolor.h"
-#include "pdfdev.h"
-
-#include "specials.h"
-
-/* syntax 1: ((rgb|cmyk|hsb|gray) colorvalues)|colorname
- * syntax 0: pdf_number|pdf_array
- *
- * This is for reading *single* color specification.
- */
-extern int spc_util_read_colorspec (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *args, int syntax);
-extern int spc_util_read_dimtrns (struct spc_env *spe, transform_info *dimtrns, struct spc_arg *args, long *page, int syntax);
-extern int spc_util_read_length (struct spc_env *spe, double *length, struct spc_arg *ap);
-
-extern int spc_util_read_numbers (double *values, int num_values, struct spc_env *spe, struct spc_arg *args);
-
-#endif /* _SPC_UTIL_H_ */
diff --git a/Build/source/texk/dvipdfm-x/xsrc/tt_glyf.c b/Build/source/texk/dvipdfm-x/xsrc/tt_glyf.c
deleted file mode 100644
index da0c3aa2d09..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/tt_glyf.c
+++ /dev/null
@@ -1,673 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2002-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-/*
- * Subsetting glyf, updating loca, hmtx, ...
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "system.h"
-#include "mem.h"
-#include "error.h"
-#include "dpxutil.h"
-
-#include "sfnt.h"
-#include "tt_table.h"
-#include "tt_glyf.h"
-
-#define NUM_GLYPH_LIMIT 65534
-#define TABLE_DATA_ALLOC_SIZE 40960
-#define GLYPH_ARRAY_ALLOC_SIZE 256
-
-static USHORT
-find_empty_slot (struct tt_glyphs *g)
-{
- USHORT gid;
-
- ASSERT(g);
-
- for (gid = 0; gid < NUM_GLYPH_LIMIT; gid++) {
- if (!(g->used_slot[gid/8] & (1 << (7 - (gid % 8)))))
- break;
- }
- if (gid == NUM_GLYPH_LIMIT)
- ERROR("No empty glyph slot available.");
-
- return gid;
-}
-
-USHORT
-tt_find_glyph (struct tt_glyphs *g, USHORT gid)
-{
- USHORT idx, new_gid = 0;
-
- ASSERT(g);
-
- for (idx = 0; idx < g->num_glyphs; idx++) {
- if (gid == g->gd[idx].ogid) {
- new_gid = g->gd[idx].gid;
- break;
- }
- }
-
- return new_gid;
-}
-
-USHORT
-tt_get_index (struct tt_glyphs *g, USHORT gid)
-{
- USHORT idx;
-
- ASSERT(g);
-
- for (idx = 0; idx < g->num_glyphs; idx++) {
- if (gid == g->gd[idx].gid)
- break;
- }
- if (idx == g->num_glyphs)
- idx = 0;
-
- return idx;
-}
-
-USHORT
-tt_add_glyph (struct tt_glyphs *g, USHORT gid, USHORT new_gid)
-{
- ASSERT(g);
-
- if (g->used_slot[new_gid/8] & (1 << (7 - (new_gid % 8)))) {
- WARN("Slot %u already used.", new_gid);
- } else {
- if (g->num_glyphs+1 >= NUM_GLYPH_LIMIT)
- ERROR("Too many glyphs.");
-
- if (g->num_glyphs >= g->max_glyphs) {
- g->max_glyphs += GLYPH_ARRAY_ALLOC_SIZE;
- g->gd = RENEW(g->gd, g->max_glyphs, struct tt_glyph_desc);
- }
- g->gd[g->num_glyphs].gid = new_gid;
- g->gd[g->num_glyphs].ogid = gid;
- g->gd[g->num_glyphs].length = 0;
- g->gd[g->num_glyphs].data = NULL;
- g->used_slot[new_gid/8] |= (1 << (7 - (new_gid % 8)));
- g->num_glyphs += 1;
- }
-
- if (new_gid > g->last_gid) {
- g->last_gid = new_gid;
- }
-
- return new_gid;
-}
-
-/*
- * Initialization
- */
-struct tt_glyphs *
-tt_build_init (void)
-{
- struct tt_glyphs *g;
-
- g = NEW(1, struct tt_glyphs);
-
- g->num_glyphs = 0;
- g->max_glyphs = 0;
- g->last_gid = 0;
- g->emsize = 1;
- g->default_advh = 0;
- g->default_tsb = 0;
- g->gd = NULL;
- g->used_slot = NEW(8192, unsigned char);
- memset(g->used_slot, 0, 8192);
- tt_add_glyph(g, 0, 0);
-
- return g;
-}
-
-void
-tt_build_finish (struct tt_glyphs *g)
-{
- if (g) {
- if (g->gd) {
- USHORT idx;
- for (idx = 0; idx < g->num_glyphs; idx++) {
- if (g->gd[idx].data)
- RELEASE(g->gd[idx].data);
- }
- RELEASE(g->gd);
- }
- if (g->used_slot)
- RELEASE(g->used_slot);
- RELEASE(g);
- }
-}
-
-static int CDECL
-glyf_cmp (const void *v1, const void *v2)
-{
- int cmp = 0;
- const struct tt_glyph_desc *sv1, *sv2;
-
- sv1 = (const struct tt_glyph_desc *) v1;
- sv2 = (const struct tt_glyph_desc *) v2;
-
- if (sv1->gid == sv2->gid)
- cmp = 0;
- else if (sv1->gid < sv2->gid)
- cmp = -1;
- else
- cmp = 1;
-
- return cmp;
-}
-
-/*
- * TrueType outline data.
- */
-#define ARG_1_AND_2_ARE_WORDS (1 << 0)
-#define ARGS_ARE_XY_VALUES (1 << 1)
-#define ROUND_XY_TO_GRID (1 << 2)
-#define WE_HAVE_A_SCALE (1 << 3)
-#define RESERVED (1 << 4)
-#define MORE_COMPONENT (1 << 5)
-#define WE_HAVE_AN_X_AND_Y_SCALE (1 << 6)
-#define WE_HAVE_A_TWO_BY_TWO (1 << 7)
-#define WE_HAVE_INSTRUCTIONS (1 << 8)
-#define USE_MY_METRICS (1 << 9)
-
-int
-tt_build_tables (sfnt *sfont, struct tt_glyphs *g)
-{
- char *hmtx_table_data = NULL, *loca_table_data = NULL;
- char *glyf_table_data = NULL;
- ULONG hmtx_table_size, loca_table_size, glyf_table_size;
- /* some information available from other TrueType table */
- struct tt_head_table *head = NULL;
- struct tt_hhea_table *hhea = NULL;
- struct tt_maxp_table *maxp = NULL;
- struct tt_longMetrics *hmtx, *vmtx = NULL;
- struct tt_os2__table *os2;
- /* temp */
- ULONG *location, offset;
- long i;
- USHORT *w_stat; /* Estimate most frequently appeared width */
-
- ASSERT(g);
-
- if (sfont == NULL ||
-#ifdef XETEX
- sfont->ft_face == NULL
-#else
- sfont->stream == NULL
-#endif
- )
- ERROR("File not opened.");
-
- if (sfont->type != SFNT_TYPE_TRUETYPE &&
- sfont->type != SFNT_TYPE_TTC &&
- sfont->type != SFNT_TYPE_DFONT)
- ERROR("Invalid font type");
-
- if (g->num_glyphs > NUM_GLYPH_LIMIT)
- ERROR("Too many glyphs.");
-
- /*
- * Read head, hhea, maxp, loca:
- *
- * unitsPerEm --> head
- * numHMetrics --> hhea
- * indexToLocFormat --> head
- * numGlyphs --> maxp
- */
- head = tt_read_head_table(sfont);
- hhea = tt_read_hhea_table(sfont);
- maxp = tt_read_maxp_table(sfont);
-
- if (hhea->metricDataFormat != 0)
- ERROR("Unknown metricDataFormat.");
-
- g->emsize = head->unitsPerEm;
-
- sfnt_locate_table(sfont, "hmtx");
- hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings);
-
- os2 = tt_read_os2__table(sfont);
- if (os2) {
- g->default_advh = os2->sTypoAscender - os2->sTypoDescender;
- g->default_tsb = g->default_advh - os2->sTypoAscender;
- }
-
- if (sfnt_find_table_pos(sfont, "vmtx") > 0) {
- struct tt_vhea_table *vhea;
- vhea = tt_read_vhea_table(sfont);
- sfnt_locate_table(sfont, "vmtx");
- vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings);
- RELEASE(vhea);
- } else {
- vmtx = NULL;
- }
-
- sfnt_locate_table(sfont, "loca");
- location = NEW(maxp->numGlyphs + 1, ULONG);
- if (head->indexToLocFormat == 0) {
- for (i = 0; i <= maxp->numGlyphs; i++)
- location[i] = 2*((ULONG) sfnt_get_ushort(sfont));
- } else if (head->indexToLocFormat == 1) {
- for (i = 0; i <= maxp->numGlyphs; i++)
- location[i] = sfnt_get_ulong(sfont);
- } else {
- ERROR("Unknown IndexToLocFormat.");
- }
-
- w_stat = NEW(g->emsize+2, USHORT);
- memset(w_stat, 0, sizeof(USHORT)*(g->emsize+2));
- /*
- * Read glyf table.
- */
- offset = sfnt_locate_table(sfont, "glyf");
- /*
- * The num_glyphs may grow when composite glyph is found.
- * A component of glyph refered by a composite glyph is appended
- * to used_glyphs if it is not already registered in used_glyphs.
- * Glyph programs of composite glyphs are modified so that it
- * correctly refer to new gid of their components.
- */
- for (i = 0; i < NUM_GLYPH_LIMIT; i++) {
- USHORT gid; /* old gid */
- ULONG loc, len;
- BYTE *p, *endptr;
- SHORT number_of_contours;
-
- if (i >= g->num_glyphs) /* finished */
- break;
-
- gid = g->gd[i].ogid;
- if (gid >= maxp->numGlyphs)
- ERROR("Invalid glyph index (gid %u)", gid);
-
- loc = location[gid];
- len = location[gid+1] - loc;
- g->gd[i].advw = hmtx[gid].advance;
- g->gd[i].lsb = hmtx[gid].sideBearing;
- if (vmtx) {
- g->gd[i].advh = vmtx[gid].advance;
- g->gd[i].tsb = vmtx[gid].sideBearing;
- } else {
- g->gd[i].advh = g->default_advh;
- g->gd[i].tsb = g->default_tsb;
- }
- g->gd[i].length = len;
- g->gd[i].data = NULL;
- if (g->gd[i].advw <= g->emsize) {
- w_stat[g->gd[i].advw] += 1;
- } else {
- w_stat[g->emsize+1] += 1; /* larger than em */
- }
-
- if (len == 0) { /* Does not contains any data. */
- continue;
- } else if (len < 10) {
- ERROR("Invalid TrueType glyph data (gid %u).", gid);
- }
-
- g->gd[i].data = p = NEW(len, BYTE);
- endptr = p + len;
-
- sfnt_seek_set(sfont, offset+loc);
- number_of_contours = sfnt_get_short(sfont);
- p += sfnt_put_short(p, number_of_contours);
-
- /* BoundingBox: FWord x 4 */
- g->gd[i].llx = sfnt_get_short(sfont);
- g->gd[i].lly = sfnt_get_short(sfont);
- g->gd[i].urx = sfnt_get_short(sfont);
- g->gd[i].ury = sfnt_get_short(sfont);
- /* _FIXME_ */
-#if 1
- if (!vmtx) /* vertOriginY == sTypeAscender */
- g->gd[i].tsb = g->default_advh - g->default_tsb - g->gd[i].ury;
-#endif
- p += sfnt_put_short(p, g->gd[i].llx);
- p += sfnt_put_short(p, g->gd[i].lly);
- p += sfnt_put_short(p, g->gd[i].urx);
- p += sfnt_put_short(p, g->gd[i].ury);
-
- /* Read evrything else. */
- sfnt_read(p, len - 10, sfont);
- /*
- * Fix GIDs of composite glyphs.
- */
- if (number_of_contours < 0) {
- USHORT flags, cgid, new_gid; /* flag, gid of a component */
- do {
- if (p >= endptr)
- ERROR("Invalid TrueType glyph data (gid %u): %u bytes", gid, len);
- /*
- * Flags and gid of component glyph are both USHORT.
- */
- flags = ((*p) << 8)| *(p+1);
- p += 2;
- cgid = ((*p) << 8)| *(p+1);
- if (cgid >= maxp->numGlyphs) {
- ERROR("Invalid gid (%u > %u) in composite glyph %u.", cgid, maxp->numGlyphs, gid);
- }
- new_gid = tt_find_glyph(g, cgid);
- if (new_gid == 0) {
- new_gid = tt_add_glyph(g, cgid, find_empty_slot(g));
- }
- p += sfnt_put_ushort(p, new_gid);
- /*
- * Just skip remaining part.
- */
- p += (flags & ARG_1_AND_2_ARE_WORDS) ? 4 : 2;
- if (flags & WE_HAVE_A_SCALE) /* F2Dot14 */
- p += 2;
- else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) /* F2Dot14 x 2 */
- p += 4;
- else if (flags & WE_HAVE_A_TWO_BY_TWO) /* F2Dot14 x 4 */
- p += 8;
- } while (flags & MORE_COMPONENT);
- /*
- * TrueType instructions comes here:
- * length_of_instruction (ushort)
- * instruction (byte * length_of_instruction)
- */
- }
- }
- RELEASE(location);
- RELEASE(hmtx);
- if (vmtx)
- RELEASE(vmtx);
-
- {
- int max_count = -1;
-
- g->dw = g->gd[0].advw;
- for (i = 0; i < g->emsize + 1; i++) {
- if (w_stat[i] > max_count) {
- max_count = w_stat[i];
- g->dw = i;
- }
- }
- }
- RELEASE(w_stat);
-
- qsort(g->gd, g->num_glyphs, sizeof(struct tt_glyph_desc), glyf_cmp);
- {
- USHORT prev, last_advw;
- char *p, *q;
- int padlen, num_hm_known;
-
- glyf_table_size = 0UL;
- num_hm_known = 0;
- last_advw = g->gd[g->num_glyphs - 1].advw;
- for (i = g->num_glyphs - 1; i >= 0; i--) {
- padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0;
- glyf_table_size += g->gd[i].length + padlen;
- if (!num_hm_known && last_advw != g->gd[i].advw) {
- hhea->numOfLongHorMetrics = g->gd[i].gid + 2;
- num_hm_known = 1;
- }
- }
- /* All advance widths are same. */
- if (!num_hm_known) {
- hhea->numOfLongHorMetrics = 1;
- }
- hmtx_table_size = hhea->numOfLongHorMetrics * 2 + (g->last_gid + 1) * 2;
-
- /*
- * Choosing short format does not always give good result
- * when compressed. Sometimes increases size.
- */
- if (glyf_table_size < 0x20000UL) {
- head->indexToLocFormat = 0;
- loca_table_size = (g->last_gid + 2)*2;
- } else {
- head->indexToLocFormat = 1;
- loca_table_size = (g->last_gid + 2)*4;
- }
-
- hmtx_table_data = p = NEW(hmtx_table_size, char);
- loca_table_data = q = NEW(loca_table_size, char);
- glyf_table_data = NEW(glyf_table_size, char);
-
- offset = 0UL; prev = 0;
- for (i = 0; i < g->num_glyphs; i++) {
- long gap, j;
- gap = (long) g->gd[i].gid - prev - 1;
- for (j = 1; j <= gap; j++) {
- if (prev + j == hhea->numOfLongHorMetrics - 1) {
- p += sfnt_put_ushort(p, last_advw);
- } else if (prev + j < hhea->numOfLongHorMetrics) {
- p += sfnt_put_ushort(p, 0);
- }
- p += sfnt_put_short (p, 0);
- if (head->indexToLocFormat == 0) {
- q += sfnt_put_ushort(q, (USHORT) (offset/2));
- } else {
- q += sfnt_put_ulong(q, offset);
- }
- }
- padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0;
- if (g->gd[i].gid < hhea->numOfLongHorMetrics) {
- p += sfnt_put_ushort(p, g->gd[i].advw);
- }
- p += sfnt_put_short (p, g->gd[i].lsb);
- if (head->indexToLocFormat == 0) {
- q += sfnt_put_ushort(q, (USHORT) (offset/2));
- } else {
- q += sfnt_put_ulong(q, offset);
- }
- memset(glyf_table_data + offset, 0, g->gd[i].length + padlen);
- memcpy(glyf_table_data + offset, g->gd[i].data, g->gd[i].length);
- offset += g->gd[i].length + padlen;
- prev = g->gd[i].gid;
- /* free data here since it consume much memory */
- RELEASE(g->gd[i].data);
- g->gd[i].length = 0; g->gd[i].data = NULL;
- }
- if (head->indexToLocFormat == 0) {
- q += sfnt_put_ushort(q, (USHORT) (offset/2));
- } else {
- q += sfnt_put_ulong(q, offset);
- }
-
- sfnt_set_table(sfont, "hmtx", (char *) hmtx_table_data, hmtx_table_size);
- sfnt_set_table(sfont, "loca", (char *) loca_table_data, loca_table_size);
- sfnt_set_table(sfont, "glyf", (char *) glyf_table_data, glyf_table_size);
- }
-
- head->checkSumAdjustment = 0;
- maxp->numGlyphs = g->last_gid + 1;
-
- /* TODO */
- sfnt_set_table(sfont, "maxp", tt_pack_maxp_table(maxp), TT_MAXP_TABLE_SIZE);
- sfnt_set_table(sfont, "hhea", tt_pack_hhea_table(hhea), TT_HHEA_TABLE_SIZE);
- sfnt_set_table(sfont, "head", tt_pack_head_table(head), TT_HEAD_TABLE_SIZE);
- RELEASE(maxp);
- RELEASE(hhea);
- RELEASE(head);
- if (os2)
- RELEASE(os2);
-
- return 0;
-}
-
-int
-tt_get_metrics (sfnt *sfont, struct tt_glyphs *g)
-{
- struct tt_head_table *head = NULL;
- struct tt_hhea_table *hhea = NULL;
- struct tt_maxp_table *maxp = NULL;
- struct tt_longMetrics *hmtx, *vmtx = NULL;
- struct tt_os2__table *os2;
- /* temp */
- ULONG *location, offset;
- long i;
- USHORT *w_stat;
-
- ASSERT(g);
-
- if (sfont == NULL ||
-#ifdef XETEX
- sfont->ft_face == NULL
-#else
- sfont->stream == NULL
-#endif
- )
- ERROR("File not opened.");
-
- if (sfont->type != SFNT_TYPE_TRUETYPE &&
- sfont->type != SFNT_TYPE_TTC &&
- sfont->type != SFNT_TYPE_DFONT)
- ERROR("Invalid font type");
-
- /*
- * Read head, hhea, maxp, loca:
- *
- * unitsPerEm --> head
- * numHMetrics --> hhea
- * indexToLocFormat --> head
- * numGlyphs --> maxp
- */
- head = tt_read_head_table(sfont);
- hhea = tt_read_hhea_table(sfont);
- maxp = tt_read_maxp_table(sfont);
-
- if (hhea->metricDataFormat != 0)
- ERROR("Unknown metricDataFormat.");
-
- g->emsize = head->unitsPerEm;
-
- sfnt_locate_table(sfont, "hmtx");
- hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings);
-
- os2 = tt_read_os2__table(sfont);
- g->default_advh = os2->sTypoAscender - os2->sTypoDescender;
- g->default_tsb = g->default_advh - os2->sTypoAscender;
-
- if (sfnt_find_table_pos(sfont, "vmtx") > 0) {
- struct tt_vhea_table *vhea;
- vhea = tt_read_vhea_table(sfont);
- sfnt_locate_table(sfont, "vmtx");
- vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings);
- RELEASE(vhea);
- } else {
- vmtx = NULL;
- }
-
- sfnt_locate_table(sfont, "loca");
- location = NEW(maxp->numGlyphs + 1, ULONG);
- if (head->indexToLocFormat == 0) {
- for (i = 0; i <= maxp->numGlyphs; i++)
- location[i] = 2*((ULONG) sfnt_get_ushort(sfont));
- } else if (head->indexToLocFormat == 1) {
- for (i = 0; i <= maxp->numGlyphs; i++)
- location[i] = sfnt_get_ulong(sfont);
- } else {
- ERROR("Unknown IndexToLocFormat.");
- }
-
- w_stat = NEW(g->emsize+2, USHORT);
- memset(w_stat, 0, sizeof(USHORT)*(g->emsize+2));
- /*
- * Read glyf table.
- */
- offset = sfnt_locate_table(sfont, "glyf");
- for (i = 0; i < g->num_glyphs; i++) {
- USHORT gid; /* old gid */
- ULONG loc, len;
-
- gid = g->gd[i].ogid;
- if (gid >= maxp->numGlyphs)
- ERROR("Invalid glyph index (gid %u)", gid);
-
- loc = location[gid];
- len = location[gid+1] - loc;
- g->gd[i].advw = hmtx[gid].advance;
- g->gd[i].lsb = hmtx[gid].sideBearing;
- if (vmtx) {
- g->gd[i].advh = vmtx[gid].advance;
- g->gd[i].tsb = vmtx[gid].sideBearing;
- } else {
- g->gd[i].advh = g->default_advh;
- g->gd[i].tsb = g->default_tsb;
- }
- g->gd[i].length = len;
- g->gd[i].data = NULL;
-
- if (g->gd[i].advw <= g->emsize) {
- w_stat[g->gd[i].advw] += 1;
- } else {
- w_stat[g->emsize+1] += 1; /* larger than em */
- }
-
- if (len == 0) { /* Does not contains any data. */
- continue;
- } else if (len < 10) {
- ERROR("Invalid TrueType glyph data (gid %u).", gid);
- }
-
- sfnt_seek_set(sfont, offset+loc);
- (void) sfnt_get_short(sfont);
-
- /* BoundingBox: FWord x 4 */
- g->gd[i].llx = sfnt_get_short(sfont);
- g->gd[i].lly = sfnt_get_short(sfont);
- g->gd[i].urx = sfnt_get_short(sfont);
- g->gd[i].ury = sfnt_get_short(sfont);
- /* _FIXME_ */
-#if 1
- if (!vmtx) /* vertOriginY == sTypeAscender */
- g->gd[i].tsb = g->default_advh - g->default_tsb - g->gd[i].ury;
-#endif
- }
- RELEASE(location);
- RELEASE(hmtx);
- RELEASE(maxp);
- RELEASE(hhea);
- RELEASE(head);
- RELEASE(os2);
-
- if (vmtx)
- RELEASE(vmtx);
-
- {
- int max_count = -1;
-
- g->dw = g->gd[0].advw;
- for (i = 0; i < g->emsize + 1; i++) {
- if (w_stat[i] > max_count) {
- max_count = w_stat[i];
- g->dw = i;
- }
- }
- }
- RELEASE(w_stat);
-
-
- return 0;
-}
diff --git a/Build/source/texk/dvipdfm-x/xsrc/type0.c b/Build/source/texk/dvipdfm-x/xsrc/type0.c
deleted file mode 100644
index 1a004fb9f7e..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/type0.c
+++ /dev/null
@@ -1,687 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2002-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-/*
- * Type0 font support:
- *
- * TODO:
- *
- * Composite font (multiple descendants) - not supported in PDF
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-
-#include "system.h"
-#include "mem.h"
-#include "error.h"
-#include "dpxfile.h"
-
-#include "pdfobj.h"
-#include "fontmap.h"
-
-#include "cmap.h"
-#include "cid.h"
-
-#include "type0.h"
-
-
-#define TYPE0FONT_DEBUG_STR "Type0"
-#define TYPE0FONT_DEBUG 3
-
-static int __verbose = 0;
-
-static pdf_obj *pdf_read_ToUnicode_file (const char *cmap_name);
-
-void
-Type0Font_set_verbose(void)
-{
- __verbose++;
-}
-
-/*
- * used_chars:
- *
- * Single bit is used for each CIDs since used_chars can be reused as a
- * stream content of CIDSet by doing so. See, cid.h for add_to_used() and
- * is_used().
- */
-
-static char *
-new_used_chars2(void)
-{
- char *used_chars;
-
- used_chars = NEW(8192, char);
- memset(used_chars, 0, 8192);
-
- return used_chars;
-}
-
-#define FLAG_NONE 0
-#define FLAG_USED_CHARS_SHARED (1 << 0)
-
-struct Type0Font {
- char *fontname; /* BaseFont */
- char *encoding; /* "Identity-H" or "Identity-V" (not ID) */
- char *used_chars; /* Used chars (CIDs) */
-
- /*
- * Type0 only
- */
- CIDFont *descendant; /* Only single descendant is allowed. */
- int flags;
- int wmode;
-
- /*
- * PDF Font Resource
- */
- pdf_obj *indirect;
- pdf_obj *fontdict;
- pdf_obj *descriptor; /* MUST BE NULL */
-};
-
-static void
-Type0Font_init_font_struct (Type0Font *font)
-{
- ASSERT(font);
-
- font->fontname = NULL;
- font->fontdict = NULL;
- font->indirect = NULL;
- font->descriptor = NULL;
- font->encoding = NULL;
- font->used_chars = NULL;
- font->descendant = NULL;
- font->wmode = -1;
- font->flags = FLAG_NONE;
-
- return;
-}
-
-static void
-Type0Font_clean (Type0Font *font)
-{
- if (font) {
- if (font->fontdict)
- ERROR("%s: Object not flushed.", TYPE0FONT_DEBUG_STR);
- if (font->indirect)
- ERROR("%s: Object not flushed.", TYPE0FONT_DEBUG_STR);
- if (font->descriptor)
- ERROR("%s: FontDescriptor unexpected for Type0 font.", TYPE0FONT_DEBUG_STR);
- if (!(font->flags & FLAG_USED_CHARS_SHARED) && font->used_chars)
- RELEASE(font->used_chars);
- if (font->encoding)
- RELEASE(font->encoding);
- if (font->fontname)
- RELEASE(font->fontname);
- font->fontdict = NULL;
- font->indirect = NULL;
- font->descriptor = NULL;
- font->used_chars = NULL;
- font->encoding = NULL;
- font->fontname = NULL;
- }
-}
-
-/* PLEASE FIX THIS */
-#include "tt_cmap.h"
-
-static void
-add_ToUnicode (Type0Font *font)
-{
- pdf_obj *tounicode;
- CIDFont *cidfont;
- CIDSysInfo *csi;
- char *cmap_name, *fontname;
-
- /*
- * ToUnicode CMap:
- *
- * ToUnicode CMaps are usually not required for standard character
- * collections such as Adobe-Japan1. Identity-H is used for UCS
- * ordering CID-keyed fonts. External resource must be loaded for
- * others.
- */
-
- cidfont = font->descendant;
- if (!cidfont) {
- ERROR("%s: No descendant CID-keyed font.", TYPE0FONT_DEBUG_STR);
- return;
- }
-
- if (CIDFont_is_ACCFont(cidfont)) {
- /* No need to embed ToUnicode */
- return;
- } else if (CIDFont_is_UCSFont(cidfont)) {
- /*
- * Old version of dvipdfmx mistakenly used Adobe-Identity as Unicode.
- */
- tounicode = pdf_read_ToUnicode_file("Adobe-Identity-UCS2");
- if (!tounicode) { /* This should work */
- tounicode = pdf_new_name("Identity-H");
- }
- pdf_add_dict(font->fontdict, pdf_new_name("ToUnicode"), tounicode);
- return;
- }
-
- tounicode = NULL;
- csi = CIDFont_get_CIDSysInfo(cidfont);
- fontname = CIDFont_get_fontname(cidfont);
- if (CIDFont_get_embedding(cidfont)) {
- fontname += 7; /* FIXME */
- }
-
- if (!strcmp(csi->registry, "Adobe") &&
- !strcmp(csi->ordering, "Identity")) {
- switch (CIDFont_get_subtype(cidfont)) {
- case CIDFONT_TYPE2:
- /* PLEASE FIX THIS */
- tounicode = otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont),
- CIDFont_get_opt_index(cidfont),
- CIDFont_get_ft_face(cidfont),
- Type0Font_get_usedchars(font));
- break;
- default:
- if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1C)) { /* FIXME */
- tounicode = otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont),
- CIDFont_get_opt_index(cidfont),
- CIDFont_get_ft_face(cidfont),
- Type0Font_get_usedchars(font));
- } else if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1)) { /* FIXME */
- /* Font loader will create ToUnicode and set. */
- return;
- } else {
- cmap_name = NEW(strlen(fontname) + 7, char);
- sprintf(cmap_name, "%s-UTF16", fontname);
- tounicode = pdf_read_ToUnicode_file(cmap_name);
- if (!tounicode) {
- sprintf(cmap_name, "%s-UCS2", fontname);
- tounicode = pdf_read_ToUnicode_file(cmap_name);
- }
- RELEASE(cmap_name);
- }
- break;
- }
- } else {
- cmap_name = NEW(strlen(csi->registry)+strlen(csi->ordering)+8, char);
- sprintf(cmap_name, "%s-%s-UTF16", csi->registry, csi->ordering);
- tounicode = pdf_read_ToUnicode_file(cmap_name);
- if (!tounicode) {
- sprintf(cmap_name, "%s-%s-UCS2", csi->registry, csi->ordering);
- tounicode = pdf_read_ToUnicode_file(cmap_name);
- }
- RELEASE(cmap_name);
- }
-
- if (tounicode) {
- pdf_add_dict(font->fontdict,
- pdf_new_name("ToUnicode"), tounicode);
- } else {
- WARN("Failed to load ToUnicode CMap for font \"%s\"", fontname);
- }
-
- return;
-}
-
-void
-Type0Font_set_ToUnicode (Type0Font *font, pdf_obj *cmap_ref)
-{
- ASSERT(font);
-
- pdf_add_dict(font->fontdict,
- pdf_new_name("ToUnicode"), cmap_ref);
-}
-
-static void
-Type0Font_dofont (Type0Font *font)
-{
- if (!font || !font->indirect)
- return;
-
- if (!pdf_lookup_dict(font->fontdict, "ToUnicode")) { /* FIXME */
- add_ToUnicode(font);
- }
-}
-
-static void
-Type0Font_flush (Type0Font *font)
-{
- if (font) {
- if (font->fontdict)
- pdf_release_obj(font->fontdict);
- font->fontdict = NULL;
- if (font->indirect)
- pdf_release_obj(font->indirect);
- font->indirect = NULL;
- if (font->descriptor)
- ERROR("%s: FontDescriptor unexpected for Type0 font.", TYPE0FONT_DEBUG_STR);
- font->descriptor = NULL;
- }
-}
-
-int
-Type0Font_get_wmode (Type0Font *font)
-{
- ASSERT(font);
-
- return font->wmode;
-}
-
-#if 0
-char *
-Type0Font_get_encoding (Type0Font *font)
-{
- ASSERT(font);
-
- return font->encoding;
-}
-#endif /* 0 */
-
-char *
-Type0Font_get_usedchars (Type0Font *font)
-{
- ASSERT(font);
-
- return font->used_chars;
-}
-
-pdf_obj *
-Type0Font_get_resource (Type0Font *font)
-{
- ASSERT(font);
-
- /*
- * This looks somewhat strange.
- */
- if (!font->indirect) {
- pdf_obj *array;
-
- array = pdf_new_array();
- pdf_add_array(array, CIDFont_get_resource(font->descendant));
- pdf_add_dict(font->fontdict, pdf_new_name("DescendantFonts"), array);
- font->indirect = pdf_ref_obj(font->fontdict);
- }
-
- return pdf_link_obj(font->indirect);
-}
-
-/******************************** CACHE ********************************/
-
-#define CHECK_ID(n) do {\
- if ((n) < 0 || (n) >= __cache.count)\
- ERROR("%s: Invalid ID %d", TYPE0FONT_DEBUG_STR, (n));\
-} while (0)
-
-#define CACHE_ALLOC_SIZE 16u
-
-static struct font_cache {
- int count;
- int capacity;
- Type0Font *fonts;
-} __cache = {
- 0, 0, NULL
-};
-
-void
-Type0Font_cache_init (void)
-{
- if (__cache.fonts)
- ERROR("%s: Already initialized.", TYPE0FONT_DEBUG_STR);
- __cache.count = 0;
- __cache.capacity = 0;
- __cache.fonts = NULL;
-}
-
-Type0Font *
-Type0Font_cache_get (int id)
-{
- CHECK_ID(id);
-
- return &__cache.fonts[id];
-}
-
-#ifdef XETEX
-unsigned short*
-Type0Font_get_ft_to_gid(int id)
-{
- return CIDFont_get_ft_to_gid(Type0Font_cache_get(id)->descendant);
-}
-#endif
-
-int
-Type0Font_cache_find (const char *map_name, int cmap_id, fontmap_opt *fmap_opt)
-{
- int font_id = -1;
- Type0Font *font;
- CIDFont *cidfont;
- CMap *cmap;
- CIDSysInfo *csi;
- char *fontname = NULL;
- int cid_id = -1, parent_id = -1, wmode = 0;
- int pdf_ver;
-
- pdf_ver = pdf_get_version();
- if (!map_name || cmap_id < 0 || pdf_ver < 2)
- return -1;
-
- /*
- * Encoding is Identity-H or Identity-V according as thier WMode value.
- *
- * We do not use match against the map_name since fonts (TrueType) covers
- * characters across multiple character collection (eg, Adobe-Japan1 and
- * Adobe-Japan2) must be splited into multiple CID-keyed fonts.
- */
-
- cmap = CMap_cache_get(cmap_id);
- csi = (CMap_is_Identity(cmap)) ? NULL : CMap_get_CIDSysInfo(cmap) ;
-
- cid_id = CIDFont_cache_find(map_name, csi, fmap_opt);
-
- if (cid_id < 0)
- return -1;
-
- /*
- * The descendant CID-keyed font has already been registerd.
- * If CID-keyed font with ID = cid_id is new font, then create new parent
- * Type 0 font. Otherwise, there already exists parent Type 0 font and
- * then we find him and return his ID. We must check against their WMode.
- */
-
- cidfont = CIDFont_cache_get(cid_id);
- wmode = CMap_get_wmode(cmap);
-
- /* Does CID-keyed font already have parent ? */
- parent_id = CIDFont_get_parent_id(cidfont, wmode);
- if (parent_id >= 0)
- return parent_id; /* If so, we don't need new one. */
-
- /*
- * CIDFont does not have parent or his parent's WMode does not matched with
- * wmode. Create new Type0 font.
- */
-
- if (__cache.count >= __cache.capacity) {
- __cache.capacity += CACHE_ALLOC_SIZE;
- __cache.fonts = RENEW(__cache.fonts, __cache.capacity, struct Type0Font);
- }
- font_id = __cache.count;
- font = &__cache.fonts[font_id];
-
- Type0Font_init_font_struct(font);
-
- /*
- * All CJK double-byte characters are mapped so that resulting
- * character codes coincide with CIDs of given character collection.
- * So, the Encoding is always Identity-H for horizontal fonts or
- * Identity-V for vertical fonts.
- */
- if (wmode) {
- font->encoding = NEW(strlen("Identity-V")+1, char);
- strcpy(font->encoding, "Identity-V");
- } else {
- font->encoding = NEW(strlen("Identity-H")+1, char);
- strcpy(font->encoding, "Identity-H");
- }
- font->wmode = wmode;
-
- /*
- * Now we start font dictionary.
- */
- font->fontdict = pdf_new_dict();
- pdf_add_dict(font->fontdict, pdf_new_name ("Type"), pdf_new_name ("Font"));
- pdf_add_dict(font->fontdict, pdf_new_name ("Subtype"), pdf_new_name ("Type0"));
-
- /*
- * Type0 font does not have FontDescriptor because it is not a simple font.
- * Instead, DescendantFonts appears here.
- *
- * Up to PDF version 1.5, Type0 font must have single descendant font which
- * is a CID-keyed font. Future PDF spec. will allow multiple desecendant
- * fonts.
- */
- font->descendant = cidfont;
- CIDFont_attach_parent(cidfont, font_id, wmode);
-
- /*
- * PostScript Font name:
- *
- * Type0 font's fontname is usually descendant CID-keyed font's font name
- * appended by -ENCODING.
- */
- fontname = CIDFont_get_fontname(cidfont);
-
- if (__verbose) {
- if (CIDFont_get_embedding(cidfont) && strlen(fontname) > 7)
- MESG("(CID:%s)", fontname+7); /* skip XXXXXX+ */
- else
- MESG("(CID:%s)", fontname);
- }
-
- /*
- * The difference between CID-keyed font and TrueType font appears here.
- *
- * Glyph substitution for vertical writing is done in CMap mapping process
- * for CID-keyed fonts. But we must rely on OpenType layout table in the
- * case of TrueType fonts. So, we must use different used_chars for each
- * horizontal and vertical fonts in that case.
- *
- * In most PDF file, encoding name is not appended to fontname for Type0
- * fonts having CIDFontType 2 font as their descendant.
- */
-
- font->used_chars = NULL;
- font->flags = FLAG_NONE;
-
- switch (CIDFont_get_subtype(cidfont)) {
- case CIDFONT_TYPE0:
- font->fontname = NEW(strlen(fontname)+strlen(font->encoding)+2, char);
- sprintf(font->fontname, "%s-%s", fontname, font->encoding);
- pdf_add_dict(font->fontdict,
- pdf_new_name("BaseFont"), pdf_new_name(font->fontname));
- /*
- * Need used_chars to write W, W2.
- */
- if ((parent_id = CIDFont_get_parent_id(cidfont, wmode ? 0 : 1)) < 0)
- font->used_chars = new_used_chars2();
- else {
- /* Don't allocate new one. */
- font->used_chars = Type0Font_get_usedchars(Type0Font_cache_get(parent_id));
- font->flags |= FLAG_USED_CHARS_SHARED;
- }
- break;
- case CIDFONT_TYPE2:
- /*
- * TrueType:
- *
- * Use different used_chars for H and V.
- */
- pdf_add_dict(font->fontdict,
- pdf_new_name("BaseFont"), pdf_new_name(fontname));
- font->used_chars = new_used_chars2();
- break;
- default:
- ERROR("Unrecognized CIDFont Type");
- break;
- }
-
- pdf_add_dict(font->fontdict,
- pdf_new_name("Encoding"), pdf_new_name(font->encoding));
-
- __cache.count++;
-
- return font_id;
-}
-
-void
-Type0Font_cache_close (void)
-{
- int font_id;
-
- /*
- * This need to be fixed.
- *
- * CIDFont_cache_close() before Type0Font_release because of used_chars.
- * ToUnicode support want descendant CIDFont's CSI and fontname.
- */
- if (__cache.fonts) {
- for (font_id = 0; font_id < __cache.count; font_id++)
- Type0Font_dofont(&__cache.fonts[font_id]);
- }
- CIDFont_cache_close();
- if (__cache.fonts) {
- for (font_id = 0; font_id < __cache.count; font_id++) {
- Type0Font_flush(&__cache.fonts[font_id]);
- Type0Font_clean(&__cache.fonts[font_id]);
- }
- RELEASE(__cache.fonts);
- }
- __cache.fonts = NULL;
- __cache.count = 0;
- __cache.capacity = 0;
-}
-
-
-/************************************************************************/
-
-int
-pdf_font_findfont0 (const char *font_name, int cmap_id, fontmap_opt *fmap_opt)
-{
- return Type0Font_cache_find(font_name, cmap_id, fmap_opt);
-}
-
-/******************************** COMPAT ********************************/
-
-#ifndef WITHOUT_COMPAT
-
-#include "cmap_read.h"
-#include "cmap_write.h"
-#include "pdfresource.h"
-#include "pdfencoding.h"
-
-static pdf_obj *
-create_dummy_CMap (void)
-{
- pdf_obj *stream;
- char buf[32];
- int i, n;
-
-#define CMAP_PART0 "\
-%!PS-Adobe-3.0 Resource-CMap\n\
-%%DocumentNeededResources: ProcSet (CIDInit)\n\
-%%IncludeResource: ProcSet (CIDInit)\n\
-%%BeginResource: CMap (Adobe-Identity-UCS2)\n\
-%%Title: (Adobe-Identity-UCS2 Adobe UCS2 0)\n\
-%%Version: 1.0\n\
-%%Copyright:\n\
-%% ---\n\
-%%EndComments\n\n\
-"
-#define CMAP_PART1 "\
-/CIDInit /ProcSet findresource begin\n\
-\n\
-12 dict begin\n\nbegincmap\n\n\
-/CIDSystemInfo 3 dict dup begin\n\
- /Registry (Adobe) def\n\
- /Ordering (UCS2) def\n\
- /Supplement 0 def\n\
-end def\n\n\
-/CMapName /Adobe-Identity-UCS2 def\n\
-/CMapVersion 1.0 def\n\
-/CMapType 2 def\n\n\
-2 begincodespacerange\n\
-<0000> <FFFF>\n\
-endcodespacerange\n\
-"
-#define CMAP_PART3 "\
-endcmap\n\n\
-CMapName currentdict /CMap defineresource pop\n\n\
-end\nend\n\n\
-%%EndResource\n\
-%%EOF\n\
-"
-
- stream = pdf_new_stream(STREAM_COMPRESS);
- pdf_add_stream(stream, CMAP_PART0, strlen(CMAP_PART0));
- pdf_add_stream(stream, CMAP_PART1, strlen(CMAP_PART1));
- pdf_add_stream(stream, "\n100 beginbfrange\n", strlen("\n100 beginbfrange\n"));
- for (i = 0; i < 0x64; i++) {
- n = sprintf(buf,
- "<%02X00> <%02XFF> <%02X00>\n", i, i, i);
- pdf_add_stream(stream, buf, n);
- }
- pdf_add_stream(stream, "endbfrange\n\n", strlen("endbfrange\n\n"));
-
- pdf_add_stream(stream, "\n100 beginbfrange\n", strlen("\n100 beginbfrange\n"));
- for (i = 0x64; i < 0xc8; i++) {
- n = sprintf(buf,
- "<%02X00> <%02XFF> <%02X00>\n", i, i, i);
- pdf_add_stream(stream, buf, n);
- }
- pdf_add_stream(stream, "endbfrange\n\n", strlen("endbfrange\n\n"));
-
- pdf_add_stream(stream, "\n48 beginbfrange\n", strlen("\n48 beginbfrange\n"));
- for (i = 0xc8; i <= 0xd7; i++) {
- n = sprintf(buf,
- "<%02X00> <%02XFF> <%02X00>\n", i, i, i);
- pdf_add_stream(stream, buf, n);
- }
- for (i = 0xe0; i <= 0xff; i++) {
- n = sprintf(buf,
- "<%02X00> <%02XFF> <%02X00>\n", i, i, i);
- pdf_add_stream(stream, buf, n);
- }
- pdf_add_stream(stream, "endbfrange\n\n", strlen("endbfrange\n\n"));
-
- pdf_add_stream(stream, CMAP_PART3, strlen(CMAP_PART3));
-
- return stream;
-}
-
-static pdf_obj *
-pdf_read_ToUnicode_file (const char *cmap_name)
-{
- pdf_obj *stream;
- long res_id = -1;
-
- ASSERT(cmap_name);
-
- res_id = pdf_findresource("CMap", cmap_name);
- if (res_id < 0) {
- if (!strcmp(cmap_name, "Adobe-Identity-UCS2"))
- stream = create_dummy_CMap();
- else {
- stream = pdf_load_ToUnicode_stream(cmap_name);
- }
- if (stream) {
- res_id = pdf_defineresource("CMap",
- cmap_name,
- stream, PDF_RES_FLUSH_IMMEDIATE);
- }
- }
-
- return (res_id < 0 ? NULL : pdf_get_resource_reference(res_id));
-}
-#endif /* !WITHOUT_COMPAT */
diff --git a/Build/source/texk/dvipdfm-x/xsrc/type1c.c b/Build/source/texk/dvipdfm-x/xsrc/type1c.c
index 1fd55fb8de6..7a51b8f15c4 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/type1c.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/type1c.c
@@ -70,6 +70,9 @@ int
pdf_font_open_type1c (pdf_font *font)
{
char *fontname;
+#ifndef XETEX
+ char *ident;
+#endif
FILE *fp = NULL;
sfnt *sfont;
cff_font *cffont;
@@ -79,6 +82,9 @@ pdf_font_open_type1c (pdf_font *font)
ASSERT(font);
+#ifndef XETEX
+ ident =
+#endif
pdf_font_get_ident (font);
encoding_id = pdf_font_get_encoding(font);