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

请问为什么我的等距更纱黑体并不是等距 #108

Closed
KagurasakaAkuryou opened this issue Jul 29, 2019 · 10 comments
Closed

请问为什么我的等距更纱黑体并不是等距 #108

KagurasakaAkuryou opened this issue Jul 29, 2019 · 10 comments

Comments

@KagurasakaAkuryou
Copy link

image

@leokvw
Copy link

leokvw commented Jul 30, 2019

@be5invis
Copy link
Owner

Notepad++ again.
Notepad++'s text size doesn't mean how many pixels you are using, so you may need to adjust it to make the pixels become an even number.

@CyanoHao
Copy link
Contributor

应该是没有勾选 “启用全局字号”,导致实际的字号不是 12pt。
image

Notepad++ 的字号单位是 pt,字号 x pt 和 y px 的换算关系是
y=\frac{x}{72}\times\mathrm{dpi}
在默认的 100% 缩放下(dpi = 96),3pt 的倍数对应的像素数都是偶数,能对齐的。其他字号就需要试一试了。

@KagurasakaAkuryou
Copy link
Author

image
image
image
以上都是推荐分辨率 100%缩放

@be5invis
Copy link
Owner

This is the thing: GDI only support glyph widths bing integer pixels (while DWRITE/FreeType support fractional advance widths) so if the PPEM is not an even integer number (yes PPEM can be a faction too) then you won't have perfect alignment. Old Microsoft fonts like SimHei have hdmx tables to deal with such rounding errors, which are some data very hard to maintain and automate.
AFAIK there is some method to force NotePad++ to use DWRITE to deal with text, which should enable ligatures and fractional advance widths: notepad-plus-plus/notepad-plus-plus#2287

@be5invis
Copy link
Owner

@CyanoHao GDI's "pt" seems related with (font's built-in) line height rather than a fixed DPI

@CyanoHao
Copy link
Contributor

CyanoHao commented Aug 1, 2019

TTF 的黑魔法真多啊…… 😂

我试着给 Sarasa 写了 hdmx 表,从 11 到 48 的所有奇数 ppem,半角字符的宽度向上取整,全角字符宽度为半角字符的 2 倍,现在可以在 Notepad++ 里面对齐了。
hdmx-sarasa

下载链接:https://pan.baidu.com/s/1xl5p2-NtNW6vmRCuiwXklQ

字体名前面加了 “hdmx: ”,可以直接安装,不会和现有的 Sarasa 字体冲突。
fontname

这是写 hdmx 表的 Python 程序:build-hdmx-for-sarasa.zip(依赖 fonttools,很慢,处理一个 ttf 文件要 1 分多钟。)

@be5invis be5invis closed this as completed Nov 1, 2019
@fireattack
Copy link

Notepad++ again.
Notepad++'s text size doesn't mean how many pixels you are using, so you may need to adjust it to make the pixels become an even number.

@be5invis: this bug is not notepad++ only though, I can reproduce it in notepad.exe with font size = 11.

@asmwarrior
Copy link

Notepad++ again.
Notepad++'s text size doesn't mean how many pixels you are using, so you may need to adjust it to make the pixels become an even number.

@be5invis: this bug is not notepad++ only though, I can reproduce it in notepad.exe with font size = 11.

Hi, I also see the same issue.

I'm currently see this issue in Code::Blocks IDE(in-fact, it happens in all wxWidgets based application) and notepad.exe(shipped by Windows), when the font size = 11,
Two English characters' width is a bit wider than a single Chinese character. This won't happens in font size = 10 or 12.

I'm using the 等距更纱黑体 SC font which is the mono-space Simplified Chinese version.

Anyone know how to fix this issue?

@asmwarrior
Copy link

I just download the latest release from this site:

CJK characters alignment issue in some applications · Issue #1 · jonz94/Sarasa-Gothic-Nerd-Fonts

And it did solve my issue both in Code::Blocks and notepad.exe.

Thanks.

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

No branches or pull requests

6 participants