adobe-type-tools / afdko

Adobe Font Development Kit for OpenType
https://adobe-type-tools.github.io/afdko/
Other
1.04k stars 168 forks source link

[otf2otc] quotation marks not working on Windows for -t option #1442

Open NightFurySL2001 opened 2 years ago

NightFurySL2001 commented 2 years ago

When using -t option for otf2otc on Windows, it always warn about "Badly formed table override" no matter mergable or not and failed to continue making the TTC font file. The font files are provided to another friend to test on Mac OS and the -t option was build successfully. Font files are provided as below:

WD-XL.zip

Commands tried:

otf2otc -t "CFF "=0 -o WD-XLLubrifont.ttc .\WD-XLLubrifontSC-Regular.otf .\WD-XLLubrifontTC-Regular.otf
otf2otc -t 'CFF '=0 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
otf2otc -t "CFF "=0 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
otf2otc -t 'CFF '=1 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
otf2otc -t "CFF "=1 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
otf2otc -t 'hhea'=0 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
otf2otc -t "hhea"=0 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
otf2otc -t 'hhea'=1 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
otf2otc -t "hhea"=1 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf

On Mac OS: (Expected)

% otf2otc -t 'CFF '=0 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
Input fonts: ['WD-XLLubrifontSC-Regular.otf', 'WD-XLLubrifontTC-Regular.otf']
Output font: WD-XLLubrifont.ttc
Shared tables: ['CFF ', 'GDEF', 'GPOS', 'VORG', 'hhea', 'hmtx', 'maxp', 'post', 'vhea', 'vmtx']
Un-shared tables: ['GSUB', 'OS/2', 'cmap', 'head', 'name']
Done

WD-XLLubrifont.zip

On Windows without -t: (Not wanted as two CFF make the font bigger)

> otf2otc -o WD-XLLubrifont.ttc .\WD-XLLubrifontSC-Regular.otf .\WD-XLLubrifontTC-Regular.otf
Input fonts: ['.\\WD-XLLubrifontSC-Regular.otf', '.\\WD-XLLubrifontTC-Regular.otf']
Output font: WD-XLLubrifont.ttc
Shared tables: ['GDEF', 'GPOS', 'VORG', 'hhea', 'hmtx', 'maxp', 'post', 'vhea', 'vmtx']
Un-shared tables: ['CFF ', 'GSUB', 'OS/2', 'cmap', 'head', 'name']
Done

WD-XLLubrifont-TTC-Win.zip

On Windows with -t: (Failed)

D:\Desktop\huangyou\merge-code> otf2otc -t 'CFF '=0 -o WD-XLLubrifont.ttc WD-XLLubrifontSC-Regular.otf WD-XLLubrifontTC-Regular.otf
Badly formed table override.
otf2otc  -t <table tag=src font index> -o <output ttc file name> <input font file 0> ... <input font file n>

-t <table tag=source font index>  Optional. When this option is present, the matching table from the specified font file is
used for all the font files.

example:
  otf2otc -t 'CFF '=2 -o LogoCutStd.ttc LogoCutStd-Light.otf LogoCutStd-Medium.otf LogoCutStd-Bold.otf LogoCutStd-Ultra.otf
# The 'ttc' file will contain only one CFF table, taken from  LogoCutStd-Bold.otf.

The script mbe invoked with either the FDK command:
  otf2otc
or directly with the command:
  python <path to FDK directory>/python/afdko/otf2otc.py

Build an OpenType Collection font file from two or more OpenType font
files. The fonts are ordered in the output 'ttc' file in the same order
that the file names are listed in the command line. If a table is
identical for more than one font file, it is shared.

Environment

OS: Windows 10 Pro 21H1 (10.0.19043 Build 19043) Python: Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] AFDKO (pip3 show afdko):

Name: afdko
Version: 3.7.1
Summary: Adobe Font Development Kit for OpenType
Home-page: https://github.com/adobe-type-tools/afdko
Author: Adobe Type team & friends
Author-email: afdko@adobe.com
License: Apache License, Version 2.0
Location: c:\users\nksl\appdata\local\programs\python\python39\lib\site-packages
Requires: booleanOperations, defcon, fontMath, fontTools, lxml, psautohint, tqdm, ufonormalizer, ufoProcessor
Required-by:
NightFurySL2001 commented 2 years ago

After a bit more messing around, I found out that -t does work without quotation marks. E.g. with the font given above in WD-XL.zip:

otf2otc -t head=0 -o WD-XL-test.ttc .\WD-XLLubrifontSC-Regular.otf .\WD-XLLubrifontTC-Regular.otf

does return a result:

> otf2otc -t head=0 -o WD-XL-test.ttc .\WD-XLLubrifontSC-Regular.otf .\WD-XLLubrifontTC-Regular.otf
Input fonts: ['.\\WD-XLLubrifontSC-Regular.otf', '.\\WD-XLLubrifontTC-Regular.otf']
Output font: WD-XL-test.ttc
Shared tables: ['GDEF', 'GPOS', 'VORG', 'head', 'hhea', 'hmtx', 'maxp', 'post', 'vhea', 'vmtx']
Un-shared tables: ['CFF ', 'GSUB', 'OS/2', 'cmap', 'name']
Done

but with quotation mark it fails:

> otf2otc -t "head"=0 -o WD-XL-test.ttc .\WD-XLLubrifontSC-Regular.otf .\WD-XLLubrifontTC-Regular.otf
Badly formed table override.
otf2otc  -t <table tag=src font index> -o <output ttc file name> <input font file 0> ... <input font file n>

-t <table tag=source font index>  Optional. When this option is present, the matching table from the specified font file is
used for all the font files.

example:
  otf2otc -t 'CFF '=2 -o LogoCutStd.ttc LogoCutStd-Light.otf LogoCutStd-Medium.otf LogoCutStd-Bold.otf LogoCutStd-Ultra.otf
# The 'ttc' file will contain only one CFF table, taken from  LogoCutStd-Bold.otf.

The script mbe invoked with either the FDK command:
  otf2otc
or directly with the command:
  python <path to FDK directory>/python/afdko/otf2otc.py

Build an OpenType Collection font file from two or more OpenType font
files. The fonts are ordered in the output 'ttc' file in the same order
that the file names are listed in the command line. If a table is
identical for more than one font file, it is shared.

However, since CFF has a space right after the label, it will require quotation marks to include the space in the command, but since quotation marks lead to error, it mean otf2otc currently will not be able to specify CFF as a table option to merge. Putting the space of CFF without quotation mark will just lead to an error since the parameter is broken up.

Edit: using parameter -t CFF=0 does nothing.

> otf2otc -t CFF=0 -o WD-XL-test.ttc .\WD-XLLubrifontSC-Regular.otf .\WD-XLLubrifontTC-Regular.otf
Input fonts: ['.\\WD-XLLubrifontSC-Regular.otf', '.\\WD-XLLubrifontTC-Regular.otf']
Output font: WD-XL-test.ttc
Shared tables: ['GDEF', 'GPOS', 'VORG', 'hhea', 'hmtx', 'maxp', 'post', 'vhea', 'vmtx']
Un-shared tables: ['CFF ', 'GSUB', 'OS/2', 'cmap', 'head', 'name']
Done
NightFurySL2001 commented 2 years ago

Escaping the space command with grave accent (`) works, but only for PowerShell. Caret (^) for Command Prompt does not escape the space.

> otf2otc -t CFF` =0 -o wd-xl-test2.ttc .\WD-XLLubrifontSC-Regular.otf .\WD-XLLubrifontTC-Regular.otf
Input fonts: ['.\\WD-XLLubrifontSC-Regular.otf', '.\\WD-XLLubrifontTC-Regular.otf']
Output font: wd-xl-test2.ttc
Shared tables: ['CFF ', 'GDEF', 'GPOS', 'VORG', 'hhea', 'hmtx', 'maxp', 'post', 'vhea', 'vmtx']
Un-shared tables: ['GSUB', 'OS/2', 'cmap', 'head', 'name']
Done

However, please still fix this comand to be able to use quotation marks since it is the example given by the program:

example:
  otf2otc -t 'CFF '=2 -o LogoCutStd.ttc LogoCutStd-Light.otf LogoCutStd-Medium.otf LogoCutStd-Bold.otf LogoCutStd-Ultra.otf
# The 'ttc' file will contain only one CFF table, taken from  LogoCutStd-Bold.otf.