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

7字重的問題 #6

Closed
UltimateAmitieKaiNiC opened this issue Nov 18, 2020 · 18 comments · Fixed by #8
Closed

7字重的問題 #6

UltimateAmitieKaiNiC opened this issue Nov 18, 2020 · 18 comments · Fixed by #8

Comments

@UltimateAmitieKaiNiC
Copy link
Collaborator

我安裝了字體,但是每個字重的字體安裝名稱卻是一樣的,裝了其他字重卻替換粗度了,能不能7字重裝在一個字體?

@UltimateAmitieKaiNiC
Copy link
Collaborator Author

因為字體名稱全是Regular,能不能修正?

@ayaka14732
Copy link
Owner

這應該是正常的,可以參考 https://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids

如果這樣會出現問題的話,有沒有更好的解決方法?

@UltimateAmitieKaiNiC
Copy link
Collaborator Author

修改字體名稱的Regular,因為字重不同。
不然只裝一個字重了。

@UltimateAmitieKaiNiC
Copy link
Collaborator Author

再裝另一個字重就替換同一個了。

@ayaka14732
Copy link
Owner

ayaka14732 commented Nov 18, 2020

我沒有遇到過這種現象,所以不清楚怎樣解決。定義字體名稱的部分見 https://github.com/ayaka14732/FanWunMing/blob/979419e3d104dda29543574d01540c9e2194a049/build/name.json,請問具體應該修改哪一個名稱呢?

@UltimateAmitieKaiNiC
Copy link
Collaborator Author

分別有7個字重:
ExtraLight、Light、Regular、Medium、SemiBold、Bold、Heavy

@ayaka14732
Copy link
Owner

經查看 https://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids 可知,目前的做法是在 name ID 17 中設定 7 個字重,而在 name ID 2 中填寫 Regular,這是合理的做法:

Screenshot_20201118_221828

因為 name ID 2 最多僅支援 4 種樣式,即 regular, italic (or oblique), bold, bold italic (or bold oblique)。如果在 name ID 2 中設定 7 個字重,會出現相容性問題。

@ayaka14732
Copy link
Owner

請問最初提到的問題解決了嗎?如果沒有解決,能否提供一下作業系統或出現問題的程式?

@UltimateAmitieKaiNiC
Copy link
Collaborator Author

無所謂,反正這樣也好

@NightFurySL2001
Copy link

NightFurySL2001 commented Nov 20, 2020

image
请见图。

同样的 https://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids 下面已经阐明如何处理:
image

Within an extended typographic family that includes fonts beyond regular, bold, italic, or bold italic, distinctions are made in the Font Family name, so that fonts appear to be in separate families. In some cases, this may lead to specifying a Subfamily name of “Regular” for a font that might not otherwise be considered a regular font. For example, the Arial Black font has a Font Family name of “Arial Black” and a Subfamily name of “Regular”. Note that, in such cases, name IDs 16 and 17 should also be included, using a shared value for name ID 16 that reflects the full typographic family, and values for name ID 17 that appropriately reflect the actual design variant of each font.

nameID = 4 里面不只是 1+2,也可以是 16+17,这里应该取 16+17。只有 langID = 1033 (en_US) 设置正确。(其实其他语言没必要可以不设定,但是设定了比较保险)

修改方法:
https://github.com/ayaka14732/FanWunMing/blob/979419e3d104dda29543574d01540c9e2194a049/build/name.json

    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1028,
        "nameID": 1,
        "nameString": "繁媛明朝 <Style>"
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1028,
        "nameID": 2,
        "nameString": "Regular" //请增加检查 Bold 的代码替换
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1028,
        "nameID": 4,
        "nameString": "繁媛明朝 <Style>"
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1033,
        "nameID": 1,
        "nameString": "Fan Wun Ming <Style>"
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1033,
        "nameID": 2,
        "nameString": "Regular" //请增加检查 Bold 的代码替换
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1041,
        "nameID": 1,
        "nameString": "繁媛明朝 <Style>"
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1041,
        "nameID": 2,
        "nameString": "Regular" //请增加检查 Bold 的代码替换
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1041,
        "nameID": 4,
        "nameString": "繁媛明朝 <Style>"
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 2052,
        "nameID": 1,
        "nameString": "繁媛明朝 <Style>"
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 2052,
        "nameID": 2,
        "nameString": "Regular" //请增加检查 Bold 的代码替换
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 2052,
        "nameID": 4,
        "nameString": "繁媛明朝 <Style>"
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 3076,
        "nameID": 1,
        "nameString": "繁媛明朝 <Style>"
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 3076,
        "nameID": 2,
        "nameString": "Regular" //请增加检查 Bold 的代码替换
    },
    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 3076,
        "nameID": 4,
        "nameString": "繁媛明朝 <Style>"
    },

P/S: 为什么有这么多语言名字?

@ayaka14732 ayaka14732 reopened this Nov 20, 2020
ayaka14732 added a commit that referenced this issue Nov 20, 2020
ayaka14732 added a commit that referenced this issue Nov 20, 2020
@ayaka14732
Copy link
Owner

ayaka14732 commented Nov 20, 2020

@NightFurySL2001 请问这样修改是正确的嘛?#8

P/S: 为什么有这么多语言名字?

一般是什么样的?

@NightFurySL2001
Copy link

NightFurySL2001 commented Nov 20, 2020

nameID=1 还没加上Style,其他没问题。

main.py:

        if style == 'EL':
                font_family_style = ' Extralight'
		typographic_subfamily_name = 'ExtraLight'
	elif style == 'L':
                font_family_style = ' Light'
		typographic_subfamily_name = 'Light'
	elif style == 'R':
                font_family_style = ''
		typographic_subfamily_name = 'Regular'
	elif style == 'M':
                font_family_style = ' Medium'
		typographic_subfamily_name = 'Medium'
	elif style == 'SB':
                font_family_style = ' SemiBold'
		typographic_subfamily_name = 'SemiBold'
	elif style == 'B':
                font_family_style = ''
		typographic_subfamily_name = 'Bold'
	elif style == 'H':
                font_family_style = ' Heavy'
		typographic_subfamily_name = 'Heavy'

name.json:

    {
        "platformID": 3,
        "encodingID": 1,
        "languageID": 1028,
        "nameID": 1,
        "nameString": "繁媛明朝<Font Family Style>" //没有空格(Regular和Bold没有字重名),空格加在font_family_style
    },

对了,如果要 Microsoft Office Word 里面的 B bold button 按时自动加载Bold版,需要额外设置 OS/2.fsSelection bit 5 跟 head.macStyle bit 0 以正确链接字体 (style linking),否则 Word 会自行伪加粗。(这个是真的丑)

一般是什么样的?

一般上只加这个字体使用语言的名字(英文必须有,这里则再加上简中繁中),主要是考虑到跨语言系统时可能因为不同名字导致无法选择字体。这里的每个语言都一样名字虽然不会导致问题,但是要maintain也是蛮耗力的。

ayaka14732 added a commit that referenced this issue Nov 20, 2020
* Fix name strings

#6 (comment)

* Set proper name ID 1 and remove redundant language

#6 (comment)

* Simplify code
@NightFurySL2001
Copy link

obj['head']['fontRevision'] = FONT_VERSION

这一行下面不知道可不可以给 Bold 加上 [OS/2][fsSelection] bit 5 (hex 0x0010 0000,应该等于int 32) 跟 [head][macStyle] bit 0 (hex 0x0000 0001,应该等于int 1),Regular 加上 [OS/2][fsSelection] bit 6 (hex 0x0100 0000,应该等于int 64) 吗?这样可以方便 Microsoft Office Word 处理。(参考

@ayaka14732
Copy link
Owner

@NightFurySL2001 我先向 GenYoMin 提交了一个 issue:ButTaiwan/genyo-font#32

@ayaka14732
Copy link
Owner

@NightFurySL2001 源樣明體的作者回覆了我提交的 issue,見 ButTaiwan/genyo-font#32 (comment)

@NightFurySL2001
Copy link

NightFurySL2001 commented Nov 22, 2020

emmm 这样啊… 如果不要style linking 的话,Office 使用会有点奇怪… 我个人是建议 style link 的。

思源也有人提出过未连接的 bug:adobe-fonts/source-han-sans#103
但是反派也有:adobe-fonts/source-han-sans#220

这个只好看你如何决定了。

分开最主要是担心伪加粗的情况,如下:
image

好处是,最后显示里面7字重都会分开单独显示,用户不会混淆。

如果要分开,命名上 nameID = 1 则加回 Regular/Bold, nameID = 2则全部设置 Regular 即可。

ayaka14732 added a commit that referenced this issue Nov 22, 2020
@ayaka14732
Copy link
Owner

@NightFurySL2001 感謝!我決定不要 style linking,因為源樣明體沒有 style linking。我以後開發其他字體時,會再嘗試使用 style linking 的做法。

@NightFurySL2001
Copy link

NightFurySL2001 commented Nov 22, 2020

Ok 没问题,merge 了后应该可以 build 过再 release 了。可以先检查每个environment里面的字体名显示(Office Word, Adobe, Windows Fonts文件夹)是否正常后才 release。

ayaka14732 added a commit that referenced this issue Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants