summaryrefslogtreecommitdiff
path: root/Build/source/texk
diff options
context:
space:
mode:
authorHan The Thanh <hanthethanh@gmail.com>2008-07-03 16:11:52 +0000
committerHan The Thanh <hanthethanh@gmail.com>2008-07-03 16:11:52 +0000
commitc2c5c262b00a301d7731c9422843454457fb4429 (patch)
treeb7718cf68b709954f17758871b7580fa07891ecb /Build/source/texk
parentc51e576c58e88a1f340770fe162fb2c1ac98ff87 (diff)
some bugfixes for pdftex:
- a bugfix for TrueType font handling - a bugfix for pdf inclusion git-svn-id: svn://tug.org/texlive/trunk@9192 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
-rw-r--r--Build/source/texk/web2c/pdftexdir/pdftoepdf.cc34
-rw-r--r--Build/source/texk/web2c/pdftexdir/ttf2afm.c15
-rw-r--r--Build/source/texk/web2c/pdftexdir/writettf.c27
3 files changed, 56 insertions, 20 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc b/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc
index 35683d600c9..76ba973eb76 100644
--- a/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc
+++ b/Build/source/texk/web2c/pdftexdir/pdftoepdf.cc
@@ -958,9 +958,37 @@ void write_epdf(void)
// write the page contents
page->getContents(&contents);
if (contents->isStream()) {
- initDictFromDict(obj1, contents->streamGetDict());
- contents->streamGetDict()->incRef();
- copyDict(&obj1);
+
+ // Variant A: get stream and recompress under control
+ // of \pdfcompresslevel
+ //
+ // pdfbeginstream();
+ // copyStream(contents->getStream());
+ // pdfendstream();
+
+ // Variant B: copy stream without recompressing
+ //
+ contents->streamGetDict()->lookup("F", &obj1);
+ if (!obj1->isNull()) {
+ pdftex_fail("PDF inclusion: Unsupported external stream");
+ }
+ contents->streamGetDict()->lookup("Length", &obj1);
+ assert(!obj1->isNull());
+ pdf_puts("/Length ");
+ copyObject(&obj1);
+ pdf_puts("\n");
+ contents->streamGetDict()->lookup("Filter", &obj1);
+ if (!obj1->isNull()) {
+ pdf_puts("/Filter ");
+ copyObject(&obj1);
+ pdf_puts("\n");
+ contents->streamGetDict()->lookup("DecodeParms", &obj1);
+ if (!obj1->isNull()) {
+ pdf_puts("/DecodeParms ");
+ copyObject(&obj1);
+ pdf_puts("\n");
+ }
+ }
pdf_puts(">>\nstream\n");
copyStream(contents->getStream()->getUndecodedStream());
pdfendstream();
diff --git a/Build/source/texk/web2c/pdftexdir/ttf2afm.c b/Build/source/texk/web2c/pdftexdir/ttf2afm.c
index e5916cfeb24..ef6563f186c 100644
--- a/Build/source/texk/web2c/pdftexdir/ttf2afm.c
+++ b/Build/source/texk/web2c/pdftexdir/ttf2afm.c
@@ -117,7 +117,7 @@ TTF_USHORT ntabs;
int nhmtx;
int post_format;
int loca_format;
-int nglyphs;
+long nglyphs;
int nkernpairs = 0;
int names_count = 0;
char *ps_glyphs_buf = NULL;
@@ -533,8 +533,13 @@ void read_font()
ttf_fail("unsupported format (%.8X) of `post' table", post_format);
}
ttf_seek_tab("loca", 0);
- for (pm = mtx_tab; pm - mtx_tab < nglyphs + 1; pm++)
- pm->offset = (loca_format == 1 ? get_ulong() : get_ushort() << 1);
+ if (loca_format == 1) {
+ for (pm = mtx_tab; pm - mtx_tab < nglyphs + 1; pm++)
+ pm->offset = get_ulong();
+ } else {
+ for (pm = mtx_tab; pm - mtx_tab < nglyphs + 1; pm++)
+ pm->offset = get_ushort() << 1;
+ }
if ((pd = name_lookup("glyf")) == NULL)
ttf_fail("can't find table `glyf'");
for (n = pd->offset, pm = mtx_tab; pm - mtx_tab < nglyphs; pm++) {
@@ -748,7 +753,7 @@ void print_afm(char *date, char *fontname)
{
int ncharmetrics;
mtx_entry *pm;
- short mtx_index[256], *idx;
+ long mtx_index[256], *idx;
unsigned int index;
char **pe;
kern_entry *pk, *qk;
@@ -804,7 +809,7 @@ void print_afm(char *date, char *fontname)
}
/* scan form `index123' */
if (sscanf(*pe, GLYPH_PREFIX_INDEX "%u", &index) == 1) {
- if (index >= nglyphs)
+ if (index >= (unsigned int) nglyphs)
ttf_fail("`%s' out of valid range [0..%i)", *pe, nglyphs);
pm = mtx_tab + index;
mtx_index[pe - enc_names] = pm - mtx_tab;
diff --git a/Build/source/texk/web2c/pdftexdir/writettf.c b/Build/source/texk/web2c/pdftexdir/writettf.c
index 9e3900c5de0..19c137bed48 100644
--- a/Build/source/texk/web2c/pdftexdir/writettf.c
+++ b/Build/source/texk/web2c/pdftexdir/writettf.c
@@ -53,7 +53,7 @@ typedef struct {
typedef struct {
char *name; /* name of glyph */
long code; /* charcode in case of subfonts */
- short newindex; /* new index of glyph in output file */
+ long newindex; /* new index of glyph in output file */
} ttfenc_entry;
@@ -72,7 +72,7 @@ typedef struct {
char *ttf_name;
TTF_USHORT pid;
TTF_USHORT eid;
- short *table;
+ long *table;
} ttf_cmap_entry;
static TTF_USHORT ntabs;
@@ -348,7 +348,7 @@ static void ttf_read_name(void)
{
int i, j;
dirtab_entry *tab = ttf_seek_tab("name", TTF_USHORT_SIZE);
- char *p;
+ char *p, buf[SMALL_BUF_SIZE];
name_record_num = get_ushort();
name_tab = xtalloc(name_record_num, name_record);
name_buf_size = tab->length -
@@ -380,12 +380,14 @@ static void ttf_read_name(void)
if (!fd_cur->font_dim[FONTNAME_CODE].set) {
for (i = 0; i < name_record_num; i++) {
if (name_tab[i].platform_id == 3 &&
- (name_tab[i].encoding_id == 0 ||
- name_tab[i].encoding_id == 1) && name_tab[i].name_id == 6) {
- for (j = 0, p = fd_cur->fontname; j < name_tab[i].length;
- j += 2)
+ (name_tab[i].encoding_id == 0 || name_tab[i].encoding_id == 1) &&
+ name_tab[i].name_id == 6) {
+ xfree(fd_cur->fontname);
+ assert(name_tab[i].length < sizeof(buf));
+ for (j = 0, p = buf; j < name_tab[i].length; j += 2)
*p++ = name_buf[name_tab[i].offset + j + 1];
*p = 0;
+ fd_cur->fontname = xstrdup(strip_spaces_and_delims(buf, strlen(buf)));
fd_cur->font_dim[FONTNAME_CODE].set = true;
break;
}
@@ -616,7 +618,7 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid,
p->ttf_name = xstrdup(ttf_name);
p->pid = pid;
p->eid = eid;
- p->table = xtalloc(0x10000, short);
+ p->table = xtalloc(0x10000, long);
for (i = 0; i < 0x10000; ++i)
p->table[i] = -1; /* unassigned yet */
@@ -663,7 +665,7 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid,
if (p->table[i] != -1)
pdftex_warn
("cmap: multiple glyphs are mapped to unicode %.4lX, "
- "only %i will be used (glyph %li being ignored)", i,
+ "only %li will be used (glyph %li being ignored)", i,
p->table[i], index);
else
p->table[i] = index;
@@ -846,9 +848,10 @@ static void ttf_write_cmap(void)
static int prepend_subset_tags(int index, char *p)
{
- const boolean is_unicode = (name_tab[index].platform_id == 3);
+ boolean is_unicode;
int i;
assert(index >= 0 && index < name_record_num && fd_cur->subset_tag != NULL);
+ is_unicode = (name_tab[index].platform_id == 3);
if (is_unicode) {
for (i = 0; i < 6; ++i) {
*p++ = 0;
@@ -1025,7 +1028,7 @@ static void ttf_reindex_glyphs(void)
ttfenc_entry *e;
glyph_entry *glyph;
int index;
- short *t;
+ long *t;
ttf_cmap_entry *cmap = NULL;
boolean cmap_not_found = false;
@@ -1098,7 +1101,7 @@ static void ttf_reindex_glyphs(void)
if (t[index] != -1) {
if (t[index] >= glyphs_count) {
pdftex_warn
- ("`%s' is mapped to index %i which is out of valid range [0..%i)",
+ ("`%s' is mapped to index %li which is out of valid range [0..%i)",
e->name, t[index], glyphs_count);
continue;
}