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

"medium_font" setting is not applied properly in korean #7615

Closed
telk5093 opened this issue Jun 4, 2019 · 16 comments · Fixed by #8559
Closed

"medium_font" setting is not applied properly in korean #7615

telk5093 opened this issue Jun 4, 2019 · 16 comments · Fixed by #8559

Comments

@telk5093
Copy link
Contributor

telk5093 commented Jun 4, 2019

Version of OpenTTD

1.9.1 and recent nightlies

Expected result

image
Font must be seemed like readme's fonts (="mono_font" setting)

Actual result

image

Steps to reproduce

  • Used fonts: Fonts.zip
    • NanumGothic.ttf
    • KoPubBatangLight.ttf

and both ttf files stored into ./font/ directory under the directory which openttd.exe is.

  • openttd.cfg (that works):
(...)
small_font = ./font/KoPubBatangLight.ttf
medium_font = ./font/NanumGothic.ttf
large_font = ./font/KoPubBatangLight.ttf
mono_font = ./font/KoPubBatangLight.ttf
(...)
  • openttd.cfg (that occurs errors):
(...)
small_font = ./font/KoPubBatangLight.ttf
medium_font = ./font/KoPubBatangLight.ttf
large_font = ./font/KoPubBatangLight.ttf
mono_font = ./font/KoPubBatangLight.ttf
(...)

It's been a long time problem as korean users to set fonts correctly in OpenTTD, and I have provided korean users to proper openttd.cfg file to users who suffer as font errors.

But recently, I have noticed that only medium_font setting in openttd.cfg works differently.

I had tried to change my game font as KoPubBatangLight (by someone's request),
but the only medium_font is not applied.
The only korean fonts that is applied as medium_font are default Windows fonts such as Gulim, Dotum or NanumGothic (which I attached, not a default) as I know.

As you can see above actual result, small/large/mono_font setting works very fine for me, but not for medium_font.

The questions are:

  1. I have no idea why NanumGothic doesn't make errors while other fonts including KoPubBatangLight does.
  2. Why only medium_font setting's are not applied while small/large/mono_font setting are applied.
  • I'm using Windows 10, but lots of errors without openttd.cfg has been occured since OpenTTD supports korean.
  • I've also installed the font file, it was the same.
  • I've setted medium_font = C:\\Windows\\Fonts\\KoPubBatangLight.ttf, it was the same. Single backslash was the same.
@telk5093 telk5093 changed the title "medium_font" setting is not applied properly "medium_font" setting is not applied properly in korean Jun 4, 2019
@glx22
Copy link
Contributor

glx22 commented Jun 4, 2019

Please also test with nightlies, some changes related to fonts on windows are not in releases

@telk5093
Copy link
Contributor Author

telk5093 commented Jun 5, 2019

@glx22 Thanks for noticing me, I forgot that nightlies has been changed about fonts.
Nightly does not returns lots of errors, so I'll edit the context of this issue.
However, medium_font is still not applied as below image.
You can see that mono_font in the readme is applied correctly, and medium_font is not.
image

@TrueBrain
Copy link
Member

Hi @telk5093 ,

Sorry it took us so long to get back to you. I looked into your issue, and either it is already fixed over the years, or I do not understand the problem correctly :) If I use your font and start the game with 1 config over the other, I can clearly see that medium_font is correctly loaded:

NanumGothic.ttf:
image

KoPubBatangLight.ttf:
image

(forgive me doing this in English; I am pretty sure I get lost in Korean :D).

Would you be able to test this with latest nightly: https://www.openttd.org/downloads/openttd-nightlies/latest.html
And see if the problem still exists?

If so, can you help me out exactly what you expect to happen and what happens? The screenshots are not all that clear to me, in what you expect vs what you get, sorry about that :)

Thank you!

@telk5093
Copy link
Contributor Author

telk5093 commented Jan 12, 2021

@TrueBrain Thanks for reviewing this issue even time has flowed.
From your attached screenshots, NanumGothic.ttf is correctly applied but KoPubBatangLight.ttf isn't applied.
KoPubBatangLight.ttf should be like this (with anti-aliasing on):
image

But the above image is made by Photoshop, not the actual game screenshot.
I was trying to check this issue still exists in the latest nightly but I couldn't since all TrueTypeFont are not applied whatever it is.
I changed the value of small_font, medium_font, large_font, mono_font like below and none worked, every try showed MalgunGothic (default font in Korea after Vista) instead.

  1. ./font/KoPubBatangLight.ttf (while this ttf file is stored at C:\(blahblah)\OpenTTDnightly\font\KoPubBatangLight.ttf)
  2. font/KoPubBatangLight.ttf
  3. .\font\KoPubBatangLight.ttf
  4. KoPubBatangLight.ttf
  5. KoPubBatangLight
  6. C:\WINDOWS\Fonts\KoPubBatangLight.ttf
  7. C:\\WINDOWS\\Fonts\\KoPubBatangLight.ttf

Not only KoPubBatangLight but also all korean ttf file did not work, except for NanumGothic.
I think all truetype font is ignored and considered as MalgunGothic.

Font settings what was successful were these:

  • Gulim, Dotum, Batang, Gungsuh (which are basic fonts in Korean Windows)
  • NanumGothic, ./font/NanumGothic.ttf (with file exists)

I have no idea why truetype font setting is not working at 1.10.x while it worked in the past.
I'm so sorry that I'm not replying what you want but saying another issue. Please let me know if you think this should be an another issue.

Thank you :)

@TrueBrain
Copy link
Member

Thank you for this much detail, that is really appreciated.

After some digging and looking around, the problem is a bit complicated.

On start-up, OpenTTD validates fonts to see if it has all the glyphs of all the strings we will be rendering. If it finds any glyph missing, it doesn't tell you, but loads the system fallback. This is very confusing, and results in you trying different paths to the font, while the font itself is the problem. Sorry about that ...

The real problem: your KoPubBatangLight.ttf is missing certain glyphs: NBSP (0xA0), Pound sign (0xA3) and copyright sign (0xA9) on medium font-size. And this is the reason it is not picking up your font when you use it as medium_font.

I am preparing a change in the code, that gives a bit more helpful indication what is going on. First, it will display this to the console:

dbg: [freetype] Font is missing glyphs to display char 0xA0 in normal font size

Second, in-game it will show you a window:

image

That hopefully helps you a bit more what is going on, and that it has little to do with where the font is located. This hopefully also helps you to resolve this issue.
We find it extremely odd there is a font that does not implement NBSP btw .. or copyright for that matter :D You would think that is one of the first glyphs they add :P But yeah .. seems you need to look for another font or see if you can contact the author to add a few basic glyphs there. Or do it yourself of course :D (be mindful of the license!)

For the difference between 1.9 and the nightly, that I do not understand fully. It might be that we now also use a NBSP for small or large font; that might explain why KoPubBatangLight.ttf is rejected in all cases. When my PR is accepted into master, with the nightly after that, we can see what the error is, and if that sheds some light on this.

Sorry for the trouble, and let me know if there is anything else I can help you with :)

@telk5093
Copy link
Contributor Author

If so, most of true type fonts what I tested might have missing glyphs, it sounds too bad.
Such fonts are not personal made, usually made for business (with legal license for personal use) so it would be hard to contact authors 😅

Would it be impossible to use the way using some alternative font if such glyphs are missing?

Anyway thanks again!

@TrueBrain
Copy link
Member

TrueBrain commented Jan 13, 2021

Well, I am as surprised as you are that these things are not supplied, I have to admit :D

image

I had to look it up in the TTF itself to ensure myself they are really not there :P You can see A3 and A9 really are not in the font :D Silly, really.

I did not really check out earlier why other fonts won't load for you, so I just downloaded Gulim from ufonts.com (first hit I got from searching for it); that font does load correct for me, without any issues, both on Windows and Linux. I simply put the file next to my openttd.cfg, in the same folder, and used:

small_font = gulim.ttf
medium_font = gulim.ttf
large_font = gulim.ttf
mono_font = gulim.ttf

If this is not working for you, would you mind start OpenTTD with -dfreetype=2 as argument to the application, and let me know what the console is telling you? That would allow me to get a peek what your system is doing :) Tnx!

Oops, misread you. Gulim was one that was working. Do you have any other font for me that isn't?

@telk5093
Copy link
Contributor Author

Here's some fonts that does not work:
이롭게바탕체(IropkeBatang) IropkeBatangM.zip
잘풀리는오늘(Jalpullineun) JalpullineunFonts.zip
나눔명조(NanumMyeongjo) NanumFontSetup_TTF_MYUNGJO.zip

@TrueBrain
Copy link
Member

I tested IropkeBatang, which works fine for me. So that means I need a bit more information from you after all :)

Would you mind start OpenTTD with -dfreetype=2 as argument to the application, and let me know what the console is telling you? That would allow me to get a peek what your system is doing :) Tnx!

@telk5093
Copy link
Contributor Author

telk5093 commented Jan 13, 2021

Tried to ./fonts/NanumMyeongjo.ttf in nightly

dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Trying fallback fonts
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font 'dbg: [freetype] Fallback font: dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Trying fallback fonts
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font 'dbg: [freetype] Fallback font: dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Trying fallback fonts
dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '3.01;RIXF;NanumMyeongjo' with size 16
dbg: [freetype] Loaded font 'dbg: [freetype] Fallback font: dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '

@TrueBrain
Copy link
Member

NanumMyeongjo is indeed missing glyphs (at least 0xA3, haven't checked for others). Would you mind checking IropkeBatang, as that should really work, as far as I can tell?

@telk5093
Copy link
Contributor Author

Oh, you meant IropkeBatang, sorry!

dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Trying fallback fonts
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font 'dbg: [freetype] Fallback font: dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Trying fallback fonts
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font 'dbg: [freetype] Fallback font: dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Trying fallback fonts
dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 14
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 12
dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '1.001;IropkeBatangM' with size 16
dbg: [freetype] Loaded font 'dbg: [freetype] Fallback font: dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font 'dbg: [freetype] Loaded font '

@TrueBrain
Copy link
Member

TrueBrain commented Jan 13, 2021

No worries, it just meant I had to test yet-another-font :P I am just being lazy :)

Okay, I was testing only English language, as I assume such fonts at least do all Korean glyphs. I was wrong:

dbg: [freetype] Font is missing glyphs to display char 0x20AC in medium font size
(0x20AC is the euro-sign, it seems: https://www.fileformat.info/info/unicode/char/20ac/index.htm)

Yeah, let me ask if someone can review the PR, so you get these nicer errors too .. :D

@TrueBrain
Copy link
Member

Oops, didn't mean to close this already, but okay. In the new nightly of today (which will run in ~6 hours from now), there is code to tell you why it failed to load the fonts. Hopefully this helps you out a bit finding a font that implements all glyphs.

I understand this is far from ideal, but I also don't really know what to do otherwise. We can't just do a font partial .. can you see if with this extra information you have sufficient information to find a suitable font?

Sorry for the trouble that is called fonts ...

@TrueBrain TrueBrain reopened this Jan 13, 2021
@telk5093
Copy link
Contributor Author

Even though it is too sad that it's impossible to use all font, I can find what font is suitable with -dtruetype=2.
Thanks for your great effort 👍

@TrueBrain
Copy link
Member

No problem! If this is sufficient for you, I will be closing the ticket for real now :D Hopefully you can help the Korean community with some nice working fonts :D

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

Successfully merging a pull request may close this issue.

3 participants