summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-01-04 23:33:38 +0000
committerKarl Berry <karl@freefriends.org>2021-01-04 23:33:38 +0000
commitd9310700dfc1f19c6c61efb0f9972644517331e0 (patch)
tree598a8599708469697a7d3a49b40b7c5d272288cf /Build
parentf5b0f37013bf131c2ef2e58959388f790e8c5312 (diff)
fontname info in ttf2afm output, pdftex r841
git-svn-id: svn://tug.org/texlive/trunk@57328 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/pdftexdir/ChangeLog6
-rw-r--r--Build/source/texk/web2c/pdftexdir/ttf2afm.c46
2 files changed, 42 insertions, 10 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog
index 3541330b096..a195a622d51 100644
--- a/Build/source/texk/web2c/pdftexdir/ChangeLog
+++ b/Build/source/texk/web2c/pdftexdir/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-04 Thanh Han The <hanthethanh@gmail.com>
+
+ * ttf2afm.c (make_name): new fn.
+ (read_font): output FontName etc. in afm.
+ Request from Doug McAllaster, mail to Thanh of 4 Jan 2021 14:17:40.
+
2020-10-31 Thanh Han The <hanthethanh@gmail.com>
* pdftex.web (pdf_begin_string): don't output fake space
diff --git a/Build/source/texk/web2c/pdftexdir/ttf2afm.c b/Build/source/texk/web2c/pdftexdir/ttf2afm.c
index be3d4369449..dc91c68da06 100644
--- a/Build/source/texk/web2c/pdftexdir/ttf2afm.c
+++ b/Build/source/texk/web2c/pdftexdir/ttf2afm.c
@@ -426,11 +426,36 @@ static void read_cmap(void)
select_unicode, unicode_map_count);
}
+static char *make_name(long platform_id, int len)
+{
+ char buf[1024];
+ char *p = buf;
+ int i = 0;
+
+ if (len >= sizeof(buf))
+ len = sizeof(buf) - 1;
+ while (i < len) {
+ *p = get_char();
+ i++;
+ if (*p == 0 && platform_id == 3) {
+ /* assume this is an UTF-16BE encoded string but contains english
+ * text, which is the most common case; simply copy the 2nd byte.
+ * Note: will not work for non-ascii text */
+ *p = get_char();
+ i++;
+ }
+ if (isprint(*p)) /* copy only printable chars */
+ p++;
+ }
+ *p = 0;
+ return xstrdup(buf);
+}
+
static void read_font(void)
{
- long i, j, k, l, n, m, platform_id, encoding_id;
+ long i, j, k, l, n, m, platform_id, encoding_id, name_id;
TTF_FWORD kern_value;
- char buf[1024], *p;
+ char *p;
dirtab_entry *pd;
kern_entry *pk;
mtx_entry *pm;
@@ -561,16 +586,17 @@ static void read_font(void)
platform_id = get_ushort();
encoding_id = get_ushort();
(void) get_ushort(); /* skip language_id */
- k = get_ushort(); /* name_id */
+ name_id = get_ushort(); /* name_id */
l = get_ushort(); /* string length */
- if ((platform_id == 1 && encoding_id == 0) &&
- (k == 0 || k == 1 || k == 4 || k == 5 || k == 6)) {
+ if (((platform_id == 1 && encoding_id == 0) || /* legacy */
+ (platform_id == 3 || encoding_id == 1) /* most common for modern fonts */
+ ) &&
+ (name_id == 0 || name_id == 1 || name_id == 4 || name_id == 5 || name_id == 6)
+ )
+ {
ttf_seek_off("name", j + get_ushort());
- for (p = buf; l-- > 0; p++)
- *p = get_char();
- *p++ = 0;
- p = xstrdup(buf);
- switch (k) {
+ p = make_name(platform_id, l);
+ switch (name_id) {
case 0:
Notice = p;
break;