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

Too big letter spacing for BIZ-UDGothic font #808

Closed
nu774 opened this issue Oct 7, 2018 · 13 comments
Closed

Too big letter spacing for BIZ-UDGothic font #808

nu774 opened this issue Oct 7, 2018 · 13 comments

Comments

@nu774
Copy link

nu774 commented Oct 7, 2018

Like this: https://i.imgur.com/AGjgvrW.png
BIZ-UDGothic is a Japanese font introduced in Windows 10 1809.
If I understand correctly, tmAvgCharWidth field of TEXTMETRIC structure is usually set to the width of alphanumeric characters in case of dual spaced East Asian fonts.
However, in this BIZ-UDGothic font, tmAvgCharWidth is set to a bigger value than that (maybe, actual average of all glyphs contains in this font), and mintty fails to compute appropriate cell size.

@mintty
Copy link
Owner

mintty commented Oct 7, 2018

I have 1809 but not this font. Is it available for download?
Anyway, if the issue is as you describe, it's a font bug, I don't see what mintty could do about it.
You can try option ColSpacing with a negative value.

@nu774
Copy link
Author

nu774 commented Oct 7, 2018

Well, negative ColSpacing doesn't work quite well:
https://i.imgur.com/KMblzs3.png
Some characters hear and there are cut off even with some leading space left.
Native ConsoleHost can render this font correctly:
https://i.imgur.com/dLnOAki.png

@mintty
Copy link
Owner

mintty commented Oct 7, 2018

Can't view those screenshots. The server pops up a hint that it's going to collect data from me if I continue.
If you have a significant screenshot, why don't you upload it here?

@nu774
Copy link
Author

nu774 commented Oct 7, 2018

Oh, sorry.
First image:
clip001
Second image (with negative ColSpacing):
clip002
Third image (ConsoleHost):
clip003

@nu774
Copy link
Author

nu774 commented Oct 7, 2018

As for BIZ-UD Gothic font not present in your system, it may be treated as Japanese language specific optional feature. Does this helps?
https://answers.microsoft.com/en-us/windows/forum/windows_10-start/some-fonts-are-missing-after-upgrade/95839dfa-0df2-4bc0-875a-fd6b57e61fe4

@mintty
Copy link
Owner

mintty commented Oct 7, 2018

The font mentioned is not among those listed on that page. Is it available somewhere for download?

@nu774
Copy link
Author

nu774 commented Oct 7, 2018

Since that page is written at 2015 for build 1607, this font cannot be listed there.
BIZ-UD gothic font can be downloaded from here: https://bizplus.morisawa.co.jp/ (written in Japanese, registration required).
I guess it's easier to get from Microsoft in some way, it's officially provided for Japanese language at least.

@mintty
Copy link
Owner

mintty commented Oct 7, 2018

OK, it's in the Japanese language pack.
The font reports an average width of 19, as opposed to 11 or 12 with other fonts.
I see no obvious way to determine a suitable cell width in this situation;
I do not agree that "mintty fails to compute appropriate cell size", rather the font fails to report an appropriate character width. Back to comment 1, this is a font bug.

@mintty
Copy link
Owner

mintty commented Oct 7, 2018

By the way, notepad isn't a good example to compare with; it does not adjust its window width to the font at all. Also it seems to stretch the width of BIZ UDGothic, which is likely neither what most people appreciate. If you have a good design proposal how to deal with the situation, I'll consider it.

@nu774
Copy link
Author

nu774 commented Oct 8, 2018

I don't understand why you are so sure that this is a "font bug".
tmAveCharWidth of GDI TEXTMETRIC structure comes from OS/2 compatibility table of TrueType fonts described here:
https://docs.microsoft.com/en-us/typography/opentype/spec/os2#xavgcharwidth
If I understand the doc correctly, it's not a font bug. The meaning of xAvgCharWidth has changed, and the doc strongly recommends not to rely on the value for computing layout.
If you need to obtain pitch of latin alphabets to compute cell width, why don't you use GetCharWidth32() on them?

@mintty
Copy link
Owner

mintty commented Oct 8, 2018

Well, all other fonts I checked maintain an average width that indicates cell width, but you are right, formally.
GetCharWidth32 cannot be used, also formally, because it is documented not to work for TrueType fonts, although it does in practice. It would be GetCharWidthFloatW then, to be measured for some selected character. What a crap.
Issue acknowledged, DPI dependencies checked (works fine, the determined width can be taken as a replacement for the average width).

@nu774
Copy link
Author

nu774 commented Oct 10, 2018

Tried the latest commit just now, looks good to me.
Thanks!

@nu774 nu774 closed this as completed Oct 10, 2018
@mintty
Copy link
Owner

mintty commented Nov 10, 2018

Released 2.9.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants