summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/font/writettf.w
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/font/writettf.w')
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writettf.w119
1 files changed, 55 insertions, 64 deletions
diff --git a/Build/source/texk/web2c/luatexdir/font/writettf.w b/Build/source/texk/web2c/luatexdir/font/writettf.w
index 77fef925507..e1edea5e2ab 100644
--- a/Build/source/texk/web2c/luatexdir/font/writettf.w
+++ b/Build/source/texk/web2c/luatexdir/font/writettf.w
@@ -485,7 +485,7 @@ long ttf_getnum(int s)
int c;
while (s > 0) {
if (ttf_eof())
- luatex_fail("unexpected EOF");
+ normal_error("ttf font","unexpected EOF");
c = ttf_getchar();
i = (i << 8) + c;
s--;
@@ -516,7 +516,7 @@ dirtab_entry *ttf_name_lookup(const char *s, boolean required)
}
if (tab - dir_tab == ntabs) {
if (required)
- luatex_fail("can't find table `%s'", s);
+ formatted_error("ttf font","can't find table '%s'", s);
else
tab = NULL;
}
@@ -586,9 +586,7 @@ static void ttf_copy_encoding(void)
e = ttfenc_tab + *q;
e->code = charcodes[*q];
if (e->code == -1)
- luatex_warn
- ("character %i in subfont %s is not mapped to any charcode",
- *q, fd_cur->fm->tfm_name);
+ formatted_warning("ttf font", "character %i in subfont %s is not mapped to any charcode", *q, fd_cur->fm->tfm_name);
else {
assert(e->code < 0x10000);
sprintf(buf, "/c%4.4X", (int) e->code);
@@ -816,8 +814,7 @@ void ttf_read_post(void)
}
break;
default:
- luatex_warn("unsupported format (%.8X) of `post' table, assuming 3.0",
- (unsigned int) post_format);
+ formatted_warning("ttf font", "unsupported format '%.8X' of 'post' table, assuming 3.0", (unsigned int) post_format);
case 0x00030000:
for (glyph = glyph_tab; glyph - glyph_tab < NMACGLYPHS; glyph++) {
glyph->name_index = (TTF_USHORT) (glyph - glyph_tab);
@@ -915,14 +912,13 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid,
goto read_cmap_format_4;
else {
if (warn)
- luatex_warn("cmap format %i unsupported", format);
+ formatted_warning("ttf font", "cmap format %i unsupported", format);
return NULL;
}
}
}
if (warn)
- luatex_warn("cannot find cmap subtable for (pid,eid) = (%i, %i)",
- pid, eid);
+ formatted_warning("ttf font", "cannot find cmap subtable for (pid,eid) = (%i,%i)", pid, eid);
return NULL;
read_cmap_format_4:
/* initialize the new entry */
@@ -972,13 +968,13 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid,
index = (index + s->idDelta) & 0xFFFF;
}
if (index >= glyphs_count)
- luatex_fail("cmap: glyph index %li out of range [0..%i)",
- index, glyphs_count);
+ formatted_error("ttf font",
+ "cmap issue, glyph index %li out of range [0..%i)",
+ index, glyphs_count);
if (p->table[i] != -1)
- luatex_warn
- ("cmap: multiple glyphs are mapped to unicode %.4lX, "
- "only %li will be used (glyph %li being ignored)", i,
- p->table[i], index);
+ formatted_warning("ttf font",
+ "cmap issue, multiple glyphs are mapped to unicode %.4lX, %li will be used, %li is ignored)",
+ i, p->table[i], index);
else
p->table[i] = index;
}
@@ -991,7 +987,7 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid,
return p;
}
-@
+@
@c
static void ttf_read_font(void)
{
@@ -1021,7 +1017,7 @@ static void ttf_reset_chksm(PDF pdf, dirtab_entry * tab)
tmp_ulong = 0;
tab->offset = (TTF_ULONG) ttf_offset();
if (tab->offset % 4 != 0)
- luatex_warn("offset of `%4.4s' is not a multiple of 4", tab->tag);
+ formatted_warning("ttf font","offset of `%4.4s' is not a multiple of 4", tab->tag);
}
@@ -1041,7 +1037,7 @@ static void ttf_copytab(PDF pdf, const char *name)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
#define BYTE_ENCODING_LENGTH \
((256)*TTF_BYTE_SIZE + 3*TTF_USHORT_SIZE)
@@ -1057,14 +1053,14 @@ static void ttf_byte_encoding(PDF pdf)
put_byte(e->newindex);
} else {
if (e->name != notdef)
- luatex_warn
- ("glyph `%s' has been mapped to `%s' in `ttf_byte_encoding' cmap table",
- e->name, notdef);
+ formatted_warning("ttf font",
+ "glyph '%s' has been mapped to '%s' in 'ttf_byte_encoding' cmap table",
+ e->name, notdef);
put_byte(0); /* notdef */
}
}
-@
+@
@c
#define TRIMMED_TABLE_MAP_LENGTH (TTF_USHORT_SIZE*(5 + (256)))
@@ -1080,7 +1076,7 @@ static void ttf_trimmed_table_map(PDF pdf)
(void) put_ushort(e->newindex);
}
-@
+@
@c
#define SEG_MAP_DELTA_LENGTH ((16 + (256))*TTF_USHORT_SIZE)
@@ -1107,7 +1103,7 @@ static void ttf_seg_map_delta(PDF pdf)
(void) put_ushort(e->newindex);
}
-@
+@
@c
#define CMAP_ENTRY_LENGTH (2*TTF_USHORT_SIZE + TTF_ULONG_SIZE)
@@ -1146,7 +1142,7 @@ static void ttf_write_cmap(PDF pdf)
offset += TRIMMED_TABLE_MAP_LENGTH;
break;
default:
- luatex_fail("invalid format (it should not have happened)");
+ normal_error("ttf font","invalid format (it should not have happened)");
}
(void) put_ushort(ce->platform_id);
(void) put_ushort(ce->encoding_id);
@@ -1168,7 +1164,7 @@ static void ttf_write_cmap(PDF pdf)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
static int prepend_subset_tags(int index, char *p)
{
@@ -1249,7 +1245,7 @@ static void ttf_write_name(PDF pdf)
xfree(new_name_buf);
}
-@
+@
@c
static void ttf_write_dirtab(PDF pdf)
{
@@ -1290,7 +1286,7 @@ static void ttf_write_dirtab(PDF pdf)
}
}
if (i % 4 != 0) {
- luatex_warn("font length is not a multiple of 4 (%li)", i);
+ formatted_warning("ttf font","font length '%li' is not a multiple of 4", i);
checksum <<= 8 * (4 - i % 4);
}
k = 0xB1B0AFBA - checksum;
@@ -1299,7 +1295,7 @@ static void ttf_write_dirtab(PDF pdf)
ttf_seek_outbuf(save_offset);
}
-@
+@
@c
static void ttf_write_glyf(PDF pdf)
{
@@ -1323,7 +1319,7 @@ static void ttf_write_glyf(PDF pdf)
if (glyph_tab[idx].newindex < 0) {
glyph_tab[idx].newindex = (TTF_SHORT) new_glyphs_count;
glyph_index[new_glyphs_count++] = idx;
- /*
+ /*
N.B.: Here we change |new_glyphs_count|,
which appears in the condition of the |for| loop
*/
@@ -1356,7 +1352,7 @@ static void ttf_write_glyf(PDF pdf)
while going through |ttfenc_tab|. After appending a new entry to
|glyph_index| we set field |newindex| of corresponding entries in both
|glyph_tab| and |ttfenc_tab| to the newly created index.
-
+
@c
static void ttf_reindex_glyphs(void)
{
@@ -1387,8 +1383,8 @@ static void ttf_reindex_glyphs(void)
t = cmap->table;
assert(t != NULL && e->code < 0x10000);
if (t[e->code] < 0) {
- luatex_warn
- ("subfont %s: wrong mapping: character %li --> 0x%4.4lX --> .notdef",
+ formatted_warning("ttf font",
+ "subfont %s has a wrong mapping, character %li -> 0x%4.4lX -> .notdef",
fd_cur->fm->tfm_name, (long) (e - ttfenc_tab), e->code);
continue;
}
@@ -1403,8 +1399,7 @@ static void ttf_reindex_glyphs(void)
/* scan form `index123' */
if (sscanf(e->name, GLYPH_PREFIX_INDEX "%i", &index) == 1) {
if (index >= glyphs_count) {
- luatex_warn("`%s' out of valid range [0..%i)",
- e->name, glyphs_count);
+ formatted_warning("ttf font","'%s' out of valid range [0..%i)", e->name, glyphs_count);
continue;
}
glyph = glyph_tab + index;
@@ -1418,8 +1413,7 @@ static void ttf_reindex_glyphs(void)
if (cmap == NULL)
cmap = ttf_read_cmap(fd_cur->fm->ff_name, 0, 3, false);
if (cmap == NULL) {
- luatex_warn
- ("no unicode mapping found, all `uniXXXX' names will be ignored");
+ normal_warning("ttf font", "no unicode mapping found, all 'uniXXXX' names will be ignored");
cmap_not_found = true; /* once only */
}
}
@@ -1429,16 +1423,14 @@ static void ttf_reindex_glyphs(void)
assert(t != NULL);
if (t[index] != -1) {
if (t[index] >= glyphs_count) {
- luatex_warn
- ("`%s' is mapped to index %li which is out of valid range [0..%i)",
+ formatted_warning("ttf font", "'%s' is mapped to index %li which is out of valid range [0..%i)",
e->name, t[index], glyphs_count);
continue;
}
glyph = glyph_tab + t[index];
goto append_new_glyph;
} else {
- luatex_warn("`unicode %s%.4X' is not mapped to any glyph",
- GLYPH_PREFIX_UNICODE, index);
+ formatted_warning("ttf font","unicode %s%.4X is not mapped to any glyph", GLYPH_PREFIX_UNICODE, index);
continue;
}
}
@@ -1447,7 +1439,7 @@ static void ttf_reindex_glyphs(void)
if (glyph->name != notdef && strcmp(glyph->name, e->name) == 0)
break;
if (!(glyph - glyph_tab < glyphs_count)) {
- luatex_warn("glyph `%s' not found", e->name);
+ formatted_warning("ttf font","glyph '%s' not found", e->name);
continue;
}
append_new_glyph:
@@ -1502,7 +1494,7 @@ static void ttf_write_head(PDF pdf)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
static void ttf_write_hhea(PDF pdf)
{
@@ -1515,7 +1507,7 @@ static void ttf_write_hhea(PDF pdf)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
static void ttf_write_htmx(PDF pdf)
{
@@ -1529,7 +1521,7 @@ static void ttf_write_htmx(PDF pdf)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
static void ttf_write_loca(PDF pdf)
{
@@ -1557,7 +1549,7 @@ static void ttf_write_loca(PDF pdf)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
static void ttf_write_mapx(PDF pdf)
{
@@ -1569,7 +1561,7 @@ static void ttf_write_mapx(PDF pdf)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
static void ttf_write_OS2(PDF pdf)
{
@@ -1578,7 +1570,7 @@ static void ttf_write_OS2(PDF pdf)
ttf_reset_chksm(pdf, tab);
version = get_ushort();
if (version > 3)
- luatex_fail("unknown version of OS/2 table (%.4X)", version);
+ formatted_error("ttf font","unknown version '%.4X' of OS/2 table", version);
(void) put_ushort(0x0001); /* fix version to 1 */
ttf_ncopy(pdf,
2 * TTF_USHORT_SIZE + 13 * TTF_SHORT_SIZE + 10 * TTF_BYTE_SIZE);
@@ -1598,7 +1590,7 @@ static void ttf_write_OS2(PDF pdf)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
static boolean unsafe_name(const char *s)
{
@@ -1647,7 +1639,7 @@ static void ttf_write_post(PDF pdf)
ttf_set_chksm(pdf, tab);
}
-@
+@
@c
static void ttf_init_font(PDF pdf, int n)
{
@@ -1661,7 +1653,7 @@ static void ttf_init_font(PDF pdf, int n)
ttf_seek_outbuf(TABDIR_OFF + n * 4 * TTF_ULONG_SIZE);
}
-@
+@
@c
static void ttf_subset_font(PDF pdf)
{
@@ -1688,7 +1680,7 @@ static void ttf_subset_font(PDF pdf)
ttf_write_dirtab(pdf);
}
-@
+@
@c
static void ttf_copy_font(PDF pdf)
{
@@ -1703,7 +1695,7 @@ static void ttf_copy_font(PDF pdf)
ttf_write_dirtab(pdf);
}
-@
+@
@c
void writettf(PDF pdf, fd_entry * fd)
{
@@ -1714,9 +1706,8 @@ void writettf(PDF pdf, fd_entry * fd)
assert(is_truetype(fd_cur->fm));
assert(is_included(fd_cur->fm));
- if (is_subsetted(fd_cur->fm) && (fd_cur->fe == NULL)
- && !is_subfont(fd_cur->fm)) {
- luatex_fail("Subset TrueType must be a reencoded or a subfont");
+ if (is_subsetted(fd_cur->fm) && (fd_cur->fe == NULL) && !is_subfont(fd_cur->fm)) {
+ normal_error("ttf font","subset must be a reencoded or a subfont");
}
ttf_curbyte = 0;
ttf_size = 0;
@@ -1724,7 +1715,7 @@ void writettf(PDF pdf, fd_entry * fd)
cur_file_name =
luatex_find_file(fd_cur->fm->ff_name, find_truetype_file_callback);
if (cur_file_name == NULL) {
- luatex_fail("cannot find TrueType font file for reading (%s)", fd_cur->fm->ff_name);
+ formatted_error("ttf font","cannot find font file for reading '%s'", fd_cur->fm->ff_name);
}
callback_id = callback_defined(read_truetype_file_callback);
if (callback_id > 0) {
@@ -1732,11 +1723,11 @@ void writettf(PDF pdf, fd_entry * fd)
&file_opened, &ttf_buffer, &ttf_size) &&
file_opened && ttf_size > 0) {
} else {
- luatex_fail("cannot open TrueType font file for reading (%s)", cur_file_name);
+ formatted_error("ttf font","cannot open font file for reading '%s'", cur_file_name);
}
} else {
if (!ttf_open(cur_file_name)) {
- luatex_fail("cannot open TrueType font file for reading (%s)", cur_file_name);
+ formatted_error("ttf font","cannot open font file for reading '%s'", cur_file_name);
}
ttf_read_file();
ttf_close();
@@ -1812,7 +1803,7 @@ static void do_writeotf(PDF pdf, fd_entry * fd)
tex_printf(">>");
}
-@
+@
@c
void writeotf(PDF pdf, fd_entry * fd)
{
@@ -1829,7 +1820,7 @@ void writeotf(PDF pdf, fd_entry * fd)
cur_file_name =
luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback);
if (cur_file_name == NULL) {
- luatex_fail("cannot find OpenType font file for reading (%s)", fd_cur->fm->ff_name);
+ formatted_error("otf font","cannot find font file for reading '%s'", fd_cur->fm->ff_name);
}
callback_id = callback_defined(read_opentype_file_callback);
if (callback_id > 0) {
@@ -1837,11 +1828,11 @@ void writeotf(PDF pdf, fd_entry * fd)
&file_opened, &ttf_buffer, &ttf_size) &&
file_opened && ttf_size > 0) {
} else {
- luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
+ formatted_error("otf font","cannot open font file for reading '%s'", cur_file_name);
}
} else {
if (!otf_open(cur_file_name)) {
- luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name);
+ formatted_error("otf font","cannot open font file for reading '%s'", cur_file_name);
}
ttf_read_file();
ttf_close();