Handmade Hero » Forums » Code » DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
current_mood
Anders
17 posts

Professional (non-game)developer living in Stockholm, Sweden. Born '84. Gamer since five years of age, computer nerd since six.

#21466 DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
4 weeks ago Edited by Anders on Aug. 19, 2019, 10:13 a.m.

Hello, I've just finished with day 180, but my debug cycle count texts aren't rendered like they are in Casey's video. I've verified it's not a code error, because I built it once with Casey's source code to verify I hadn't messed something up, and I get the exact same results then.

Basically, it's the formatting of text into columns that's different, and the font itself looks a bit weird too.

Which leaves the underlying platform. Is this perhaps because I run on Win 10 now and the video was made on Win 7? If anyone can shed some light on this issue I'd be very grateful. I'd like to understand it. :)

This is what it looks like:

mrmixer
Simon Anciaux
661 posts
#21469 DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
3 weeks, 6 days ago

I ran day 180 from Casey and it works on Windows 7 and Windows 10 (text is aligned properly). I used the hhas from "handmade_hero_legacy_art.zip" v0_hhas. Have you tried using those hhas ?

Otherwise it's most likely that you've got a bug in the text layout function. It looks like you're not advancing properly after each character, or that you're not using the right size to advance (e.g. if you scaled the font you need to scaled the advance too).

Your font doesn't look like the one Casey is using. That might also be a problem if you are using graphics from one font with metrics from another one (or there is a problem with how handmade hero handle the metrics, that just work with certain fonts ?).
current_mood
Anders
17 posts

Professional (non-game)developer living in Stockholm, Sweden. Born '84. Gamer since five years of age, computer nerd since six.

#21475 DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
3 weeks, 6 days ago Edited by Anders on Aug. 20, 2019, 12:02 p.m.

Hm, interesting. Thanks for letting me know.

The weird part though is that I compiled Casey's code as well and got the same thing. Now that I think about it however, I never re-ran the test_asset_builder using Casey's compiled code, I only used his handmade.exe with MY hha's. So it could indeed be a bug in my version of the test_asset_builder...

I'll try that, and if that doesn't change anything I'll try with those hha's you mentioned.

Cheers


UPDATE

Ok, so, this is somewhat interesting. First I reran the test_asset_builder.exe on my machine, compiled using Casey's source code. Using win32_handmade.exe compiled using Casey's source code. And I got the same problem as before.

But when I dropped those hha's you linked into the directory instead, it worked! Everything looked ok with those.

So now the question is: why does the test_asset_builder.exe (both mine and Casey's version) create weird hha's when run on my machine?
current_mood
Anders
17 posts

Professional (non-game)developer living in Stockholm, Sweden. Born '84. Gamer since five years of age, computer nerd since six.

#21476 DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
3 weeks, 6 days ago Edited by Anders on Aug. 20, 2019, 12:44 p.m.

Alright, I found out why this happened.

I did not have liberation mono in my Fonts folder. *facepalm*

I guess CreateFontA grabs the closest thing, or some default Font, instead.
mmozeiko
Mārtiņš Možeiko
1971 posts / 1 project
#21480 DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
3 weeks, 5 days ago Edited by Mārtiņš Možeiko on Aug. 20, 2019, 6:32 p.m.

No need to guess. CreateFont documentation clearly states:

Because available fonts can vary from system to system, do not assume that the selected font is always the same as the requested font. For example, if you request a font named Palatino, but no such font is available on the system, the font mapper will substitute a font that has similar attributes but a different name.


Also here: Font Substitution

If font looks wrong on screen that means there are some bugs in HH code that does not do measurements generic enough. They seem to work for font Casey chose, but they calculations are not universal enough for other fonts.
current_mood
Anders
17 posts

Professional (non-game)developer living in Stockholm, Sweden. Born '84. Gamer since five years of age, computer nerd since six.

#21491 DEBUGOverlay & DEBUGTextLine (day 180) and Windows 10
3 weeks, 5 days ago

Very true mmozeiko!

Thanks for the information :)