Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow UTF-8 input for name entries #1133

Merged
merged 5 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion c/makeotf/makeotf_lib/api/hotconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This software is licensed as OpenSource, under the Apache License, Version 2.0.
extern "C" {
#endif

#define HOT_VERSION 0x010071 /* Library version (1.0.113) */
#define HOT_VERSION 0x010072 /* Library version (1.0.114) */
/* Major, minor, build = (HOT_VERSION >> 16) & 0xff, (HOT_VERSION >> 8) & 0xff, HOT_VERSION & 0xff) */
/* Warning: this string is now part of heuristic used by CoolType to identify the
first round of CoolType fonts which had the backtrack sequence of a chaining
Expand Down
2 changes: 1 addition & 1 deletion c/makeotf/makeotf_lib/build/hotpccts/featgram.g
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ hotCtx g;
#token "\r\n" <<zzskip(); zzline++;>>
#token "[\r\n]" <<zzskip(); zzline++;>>

#token "[\0x20-\0x7E]" <<featAddNameStringChar(zzlextext[0]); zzskip();>>
#token "[\0x20-\0x7E\0x80-\0xF7]" <<featAddNameStringChar(zzlextext[0]); zzskip();>>

#lexclass START // ------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion c/makeotf/makeotf_lib/source/hotconv/featerr.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ANTLRChar *zztokens[159] = {
/* 27 */ "\"",
/* 28 */ "\\r\\n",
/* 29 */ "[\\r\\n]",
/* 30 */ "[\\0x20-\\0x7E]",
/* 30 */ "[\\0x20-\\0x7E\\0x80-\\0xF7]",
/* 31 */ "#~[\\r\\n]*",
/* 32 */ "[\\ \\t]+",
/* 33 */ "\\r\\n",
Expand Down
2 changes: 1 addition & 1 deletion c/makeotf/makeotf_lib/source/hotconv/featpars.dlg
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ include
zzskip(); zzline++;
>>

[\0x20-\0x7E]
[\0x20-\0x7E\0x80-\0xF7]
<<
NLA = 30;
featAddNameStringChar(zzlextext[0]); zzskip();
Expand Down
26 changes: 13 additions & 13 deletions c/makeotf/makeotf_lib/source/hotconv/featscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,19 +1038,19 @@ static unsigned char shift7[257] = {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
4, 4, 4, 4, 4, 4, 4, 4, 5, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
5, 5, 5, 5, 5, 5, 5};

#define DfaStates 976
Expand Down
2 changes: 1 addition & 1 deletion c/makeotf/makeotf_lib/source/hotconv/feattoks.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef feattoks_h
#define feattoks_h
/* feattoks.h -- List of labeled tokens and stuff
/* feattoks.h -- List of labelled tokens and stuff
*
* Generated from: featgram.g
*
Expand Down
4 changes: 4 additions & 0 deletions c/makeotf/makeotf_lib/source/hotconv/hot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,10 @@ static int prepMacName(hotCtx g, char *src) {
int actn; /* Action flags */
int c = *src++;

/* Direct UTF-8 input is not supported. */
if (c < 0)
return 1;

switch (c) {
case '\\':
class = 0;
Expand Down
2 changes: 1 addition & 1 deletion c/makeotf/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

jmp_buf mark;

#define MAKEOTF_VERSION "2.5.65598"
#define MAKEOTF_VERSION "2.5.65599"
/* Warning: this string is now part of heuristic used by CoolType to identify the
first round of CoolType fonts which had the backtrack sequence of a chaining
contextual substitution ordered incorrectly. Fonts with the old ordering MUST match
Expand Down
22 changes: 14 additions & 8 deletions docs/OpenTypeFeatureFileSpecification.md
Original file line number Diff line number Diff line change
Expand Up @@ -3289,16 +3289,16 @@ that are assigned.
nameid 1 1 <string>; 1 1 0 0
nameid 1 1 S L <string>; 1 1 S L

A string is composed of 1-byte ASCII characters enclosed by ASCII double quote
A string is composed of UTF-8 characters enclosed by ASCII double quote
characters (`"`). Newlines embedded within the string are removed from the
character sequence to be stored.

Strings are converted to Unicode for the Windows platform by adding a high byte
of 0. 2-byte Unicode values for the Windows platform may be specified using a
special character sequence of a backslash character (`\`) followed by exactly
four hexadecimal numbers (of either case) which may not all be zero, e.g. \4e2d.
The ASCII backslash character must be represented as the sequence \005c or \005C
and the ASCII double quote character must be represented as the sequence \0022.
Strings are converted to UTF-16 for the Windows platform. Unicode values for
the Windows platform may also be specified using a special character sequence
of a backslash character (`\`) followed by exactly four hexadecimal numbers (of
either case) which may not all be zero, e.g. \4e2d. The ASCII backslash
character must be represented as the sequence \005c or \005C and the ASCII
double quote character must be represented as the sequence \0022.

There is no corresponding conversion to Unicode for the Macintosh platform but
character codes in the range 128-255 may be specified using a special character
Expand All @@ -3311,7 +3311,13 @@ double quote character must be represented as the sequence \22.

```fea
table name {
nameid 9 "Joachim M\00fcller-Lanc\00e9"; # Windows (Unicode)
nameid 9 "Joachim Müller-Lancé"; # Windows (Unicode), UTF-8 input
} name;
```

```fea
table name {
nameid 9 "Joachim M\00fcller-Lanc\00e9"; # Windows (Unicode), escaped Unicode values
nameid 9 1 "Joachim M\9fller-Lanc\8e"; # Macintosh (Mac Roman)
} name;
```
Expand Down
2 changes: 1 addition & 1 deletion python/afdko/makeotf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""

__version__ = """\
makeotf.py v2.7.10 Dec 3 2019
makeotf.py v2.7.11 May 20 2020
"""

__methods__ = """
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ booleanOperations==0.9.0
cu2qu[cli]==1.6.7
defcon[lxml,pens]==0.6.0
fontMath==0.6.0
fontTools[unicode,lxml,ufo,woff]==4.10.0
fontTools[unicode,lxml,ufo,woff]==4.10.2
mutatorMath==3.0.1
psautohint==2.0.1
ufonormalizer==0.4.1
Expand Down
10 changes: 5 additions & 5 deletions tests/buildcff2vf_data/expected_output/GSUBVar.ttx
Original file line number Diff line number Diff line change
Expand Up @@ -324,31 +324,31 @@

<!-- Regular -->
<!-- PostScript: SourceCodeRoman-Regular -->
<NamedInstance flags="0x0" postscriptNameID="262" subfamilyNameID="261">
<NamedInstance flags="0x0" postscriptNameID="261" subfamilyNameID="2">
<coord axis="wght" value="400.0"/>
</NamedInstance>

<!-- Medium -->
<!-- PostScript: SourceCodeRoman-Medium -->
<NamedInstance flags="0x0" postscriptNameID="264" subfamilyNameID="263">
<NamedInstance flags="0x0" postscriptNameID="263" subfamilyNameID="262">
<coord axis="wght" value="500.0"/>
</NamedInstance>

<!-- Semibold -->
<!-- PostScript: SourceCodeRoman-Semibold -->
<NamedInstance flags="0x0" postscriptNameID="266" subfamilyNameID="265">
<NamedInstance flags="0x0" postscriptNameID="265" subfamilyNameID="264">
<coord axis="wght" value="600.0"/>
</NamedInstance>

<!-- Bold -->
<!-- PostScript: SourceCodeRoman-Bold -->
<NamedInstance flags="0x0" postscriptNameID="268" subfamilyNameID="267">
<NamedInstance flags="0x0" postscriptNameID="267" subfamilyNameID="266">
<coord axis="wght" value="700.0"/>
</NamedInstance>

<!-- Black -->
<!-- PostScript: SourceCodeRoman-Black -->
<NamedInstance flags="0x0" postscriptNameID="270" subfamilyNameID="269">
<NamedInstance flags="0x0" postscriptNameID="269" subfamilyNameID="268">
<coord axis="wght" value="900.0"/>
</NamedInstance>
</fvar>
Expand Down
46 changes: 46 additions & 0 deletions tests/makeotfexe_data/expected_output/spec/9e-14.ttx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont>

<name>
<namerecord nameID="1" platformID="1" platEncID="0" langID="0x0" unicode="True">
Untitled1
</namerecord>
<namerecord nameID="2" platformID="1" platEncID="0" langID="0x0" unicode="True">
Regular
</namerecord>
<namerecord nameID="3" platformID="1" platEncID="0" langID="0x0" unicode="True">
1.000;UKWN;Untitled1
</namerecord>
<namerecord nameID="4" platformID="1" platEncID="0" langID="0x0" unicode="True">
Untitled1
</namerecord>
<namerecord nameID="5" platformID="1" platEncID="0" langID="0x0" unicode="True">

</namerecord>
<namerecord nameID="6" platformID="1" platEncID="0" langID="0x0" unicode="True">
Untitled1
</namerecord>
<namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
Untitled1
</namerecord>
<namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
Regular
</namerecord>
<namerecord nameID="3" platformID="3" platEncID="1" langID="0x409">
1.000;UKWN;Untitled1
</namerecord>
<namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
Untitled1
</namerecord>
<namerecord nameID="5" platformID="3" platEncID="1" langID="0x409">

</namerecord>
<namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
Untitled1
</namerecord>
<namerecord nameID="9" platformID="3" platEncID="1" langID="0x409">
Joachim Müller-Lancé
</namerecord>
</name>

</ttFont>
4 changes: 4 additions & 0 deletions tests/makeotfexe_data/input/spec/9e-14.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# TABLES: name
table name {
nameid 9 "Joachim Müller-Lancé"; # Windows (Unicode)
} name;
3 changes: 3 additions & 0 deletions tests/makeotfexe_data/input/spec/9e-15.bad.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table name {
nameid 9 1 "Joachim Müller-Lancé"; # Macintosh (Mac Roman)
} name;