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

[feature request] quickly setting the font's information before outputting #3

Open
hooke007 opened this issue Mar 16, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@hooke007
Copy link

能否在批处理里增加选项,在合并输出前自定义 合成字体的名字 和 版本信息?

@CyanoHao CyanoHao added the enhancement New feature or request label Mar 27, 2021
@CyanoHao
Copy link
Collaborator

CyanoHao commented Mar 27, 2021

Status: WIP - working in progress.

计划通过命令行参数提供自定义字体名、版本等信息的选项。

  • 主程序 merge-otd 同时接受 json (otd) 和 ttf / otf 文件,以方便直接通过命令行调用。
    • 迁移到 CMake 构建系统并集成 otfcc。
    • 在主程序中以库的方式调用 otfcc 以解析 ttf / otf 文件。
  • 增加命令行参数 --name-table-overridemerge-otd font1.ttf font2.ttf --name-table-override name.json
  • 增加命令行参数 -n <Font Family;Weight;Width;Slope>
  • 增加指定版本信息的命令行参数。

@shirok1
Copy link
Contributor

shirok1 commented Dec 25, 2021

刚刚才发现这里有一样的需求……在 #4 里实现了个类似的,但是没有用到 name-table 这种东西,而是直接指定字体名字 🤣

@CyanoHao
Copy link
Collaborator

CyanoHao commented Jun 4, 2022

自定义字体的名字已经通过命令行参数 -n <Font Family;Weight;Width;Slope> 实现。

字体样式(字重、宽度、倾斜)不能只在 name 表中指定,还要更新 head、OS/2 表中的相关信息。目前我只能想到这种严格限制取值的方式。

此外,字体名和字体样式也是相关联的,因此要求同时指定字体名和样式。

版本信息我还要考虑如何实现(和字体名一样,版本信息不止一处,而且格式不统一)。

-n 参数的用法:

        -n, --name <Font Name;Weight;Width;Slope>
                    指定字体家族名和样式。如果不指定,则自动根据原字体名合成新的字体名。
                    格式:"字体名;字重;宽度;倾斜"
                    字重的取值范围
                     数字:100 至 950 之间的整数(含两端点)。
                     下列单词(不区分大小写,忽略连字符;括号内的单词视作左边单词的同义词):
                      Thin       = 100(UltraLight)
                      ExtraLight = 200
                      Light      = 300
                      SemiLight  = 350(DemiLight)
                      Normal     = 372
                      Regular    = 400(Roman、"")
                      Book       = 450
                      Medium     = 500
                      SemiBold   = 600(Demi、DemiBold)
                      Bold       = 700
                      ExtraBold  = 800
                      Black      = 900(Heavy、UltraBold)
                      ExtraBlack = 950
                    宽度的取值范围
                     数字:1 至 9 之间的整数(含两端点)。
                     下列单词(不区分大小写,忽略连字符;括号内的单词视作左边单词的同义词):
                      UltraCondensed = 1
                      ExtraCondensed = 2
                      Condensed      = 3
                      SemiCondensed  = 4
                      Normal         = 5("")
                      SemiExtended   = 6(SemiExpanded)
                      Extended       = 7(Expanded)
                      ExtraExtended  = 8(ExtraExpanded)
                      UltraExtended  = 9(UltraExpanded)
                    倾斜的取值范围
                     下列单词(不区分大小写;括号内的单词视作左边单词的同义词):
                      Upright(Normal、Roman、Unslanted、"")
                      Italic (Italized)
                      Oblique(Slant)

示例:

merge-otd -n "My Font;SemiBold;;Italic" # 设为 My Font 半粗、斜体,默认宽度(留空)
merge-otd -n "My Font;600;5;Italic" # 等价写法

一些问题的进一步解释

如果只修改 name 表会怎样?

#4 中所说,一些环境会显示出错;更严重的问题在于,如果字体名是 Bold、Italic 样式而相关元数据不匹配,MS Word 中没法选择该字体。

字体名和字体样式如何相关联?

OpenType 有很多种字体名(Family)和样式 (Subfamily)模型,用来支持不同的用法。

  1. 包括 MS Word 等软件的 “加粗” “倾斜” 按钮,对应 OpenType 的 RBIBI (Regular, Bold, Italic, Bold Italic) 模型,Subfamily 只能填这 4 个值。
  2. 现代 UI 常常按字重、宽度、倾斜来组织字体,对应 OpenType 的 WWS (Weight, Width, Slope) 模型,Subfamily 只能有字重、宽度、倾斜属性。
  3. 专业排版软件严格按字体家族和样式组织字体,对应 OpenType 的 Typographic 模型,Subfamily 可以有任何属性,如标题/文本 Display/Text、特殊样式 Outline、Smallcaps 等。

举个例子,要让各种软件都能正常显示,像 My Font Display SemiBold Italic 就必须这样填写

字体名 样式
RBIBI My Font Display SemiBold Italic
WWS My Font Display SemiBold Italic
Typographic My Font Display SemiBold Italic

我的想法是:现在 WFM 的使用已经超出了《魔兽世界》的范围,既然要实现指定字体名和样式,就应该尽量兼容各种软件。兼顾功能和实现难度,我选择了目前的方案——采用 WWS 模型,要求同时指定字体名和样式。

至于 Typographic 模型,一方面专业排版软件有 “复合字体” 等功能,一般不需要合并字体,另一方面 WFM 也达不到专业排版的要求,如果确实需要合并字体应该考虑更专业的方案。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants