From 5a945e393be9acda7593f648d83f44c12e014f1c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 18 Jan 2021 23:54:21 +0000 Subject: another attempt at clearing control characters git-svn-id: svn://tug.org/texlive/trunk@57464 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/pdftexdir/ChangeLog | 7 +++++++ Build/source/texk/web2c/pdftexdir/ttf2afm.c | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'Build') diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index 8fb078ee65b..faa05f20db1 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,10 @@ +2021-01-04 Thanh Han The + + * ttf2afm.c (make_name): yet another attempt at filtering + control characters, since the test font, SourceCodePro (as well + as many other Mac fonts), actually contains control characters + (24 and 25), due to UTF-16BE. + 2021-01-11 Karl Berry * ttf2afm.c (make_name): better to use unsigned char. diff --git a/Build/source/texk/web2c/pdftexdir/ttf2afm.c b/Build/source/texk/web2c/pdftexdir/ttf2afm.c index d0205030dce..0750173355c 100644 --- a/Build/source/texk/web2c/pdftexdir/ttf2afm.c +++ b/Build/source/texk/web2c/pdftexdir/ttf2afm.c @@ -1,5 +1,5 @@ /* -Copyright 1996-2014 Han The Thanh, +Copyright 1996-2021 Han The Thanh, This file is part of pdfTeX. @@ -438,13 +438,23 @@ static char *make_name(long platform_id, int len) *p = (unsigned char) 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 */ + /* assume this is an UTF-16BE encoded string but contains latin + * chars, which is the most common case; simply copy the 2nd byte. + * Note: will not work for non-latin text */ *p = (unsigned char) get_char(); i++; } - p++; + /* sometime a UTF-16BE string will contain chars where the 1st + or 2nd byte is in range (0..32) */ + if (*p < 32 + && *p != '\r' + && *p != '\n' + && *p != '\t' + ) { + ttf_warn("skipping unsafe character: %i", *p); + } else { + p++; + } } *p = 0; return xstrdup(buf); -- cgit v1.2.3