diff --git a/c/mergefonts/source/mergeFonts.c b/c/mergefonts/source/mergeFonts.c index 6df6772eb..f2fc7dd33 100644 --- a/c/mergefonts/source/mergeFonts.c +++ b/c/mergefonts/source/mergeFonts.c @@ -1177,21 +1177,21 @@ static void stringStrip(char *str) { if (end == 0) return; - while (start < MAX_DICT_ENTRY_LEN) { - if ((str[start] == ' ') || (str[start] == '\t') || (str[start] == '(') || (str[start] == '\r') || (str[start] == '\n')) - start++; + while (end >= 0) { + if ((str[end] == ' ') || (str[end] == '\t') || (str[end] == ')') || (str[end] == '\r') || (str[end] == '\n')) + end--; else break; } + str[end + 1] = 0; - while (end >= 0) { - if ((str[end] == ' ') || (str[end] == '\t') || (str[end] == ')') || (str[end] == '\r') || (str[end] == '\n')) - end--; + while (start < MAX_DICT_ENTRY_LEN) { + if ((str[start] == ' ') || (str[start] == '\t') || (str[start] == '(') || (str[start] == '\r') || (str[start] == '\n')) + start++; else break; } - str[end + 1] = 0; if (start > 0) memmove(str, &str[start], (end - start) + 2); if (strlen(str) == 0) { diff --git a/tests/mergefonts_data/input/cidwhitespace/cidfontinfo.txt b/tests/mergefonts_data/input/cidwhitespace/cidfontinfo.txt new file mode 100644 index 000000000..033579fd6 --- /dev/null +++ b/tests/mergefonts_data/input/cidwhitespace/cidfontinfo.txt @@ -0,0 +1,9 @@ +FontName ( ) +Registry Adobe +Ordering Identity +Supplement 0 +FSType 4 +Weight (Regular) +FamilyName (Source Sans) +version (2.20) +AdobeCopyright (Copyright 2010, 2012, 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'.) diff --git a/tests/mergefonts_test.py b/tests/mergefonts_test.py index b8c79e402..b63e58e50 100644 --- a/tests/mergefonts_test.py +++ b/tests/mergefonts_test.py @@ -83,3 +83,21 @@ def test_camel_case(): expected_path = generate_ps_dump(expected_path) assert differ([expected_path, actual_path, '-s', r'%ADOt1write:']) + + +def test_cidwhitespace(): + font1_filename = 'font1.pfa' + font2_filename = 'font2.pfa' + font3_filename = 'font3.pfa' + alias1_filename = 'alias1.txt' + alias2_filename = 'alias2.txt' + alias3_filename = 'alias3.txt' + fontinfo_filename = 'cidwhitespace/cidfontinfo.txt' + actual_path = get_temp_file_path() + + # without fix this dies with + runner(CMD + ['-o', 'cid', '-f', fontinfo_filename, actual_path, + alias1_filename, font1_filename, + alias2_filename, font2_filename, + alias3_filename, font3_filename]) +