Font sizes are broken #22

Open
opened 2014-03-29 20:01:24 +00:00 by Ancurio · 4 comments
Ancurio commented 2014-03-29 20:01:24 +00:00 (Migrated from github.com)

Yep.

https://github.com/Ancurio/mkxp/blob/dev/src/font.cpp#L119:

// FIXME 0.9 is guesswork at this point
font = TTF_OpenFontRW(ops, 1, (float) size * .90);

this mostly works when substituting the compiled-in Liberation Sans for Arial, at the default size of 22, but is otherwise horribly broken. I have tried to determine the font scaling factors for both SDL_TTF and RMXP (using the char '_'), using the resulting ratio to compensate for the difference, but it turns out the ratio is different for each font; at the moment I'm just at an dead end. I'm not even sure how RMXP does font rendering (I'd guess DirectWrite??) RMXP uses GDI for font rendering. There must be something like a hint hidden in the metadata on how to scale fonts correctly.

Yep. https://github.com/Ancurio/mkxp/blob/dev/src/font.cpp#L119: ``` // FIXME 0.9 is guesswork at this point font = TTF_OpenFontRW(ops, 1, (float) size * .90); ``` this mostly works when substituting the compiled-in Liberation Sans for Arial, at the default size of 22, but is otherwise horribly broken. I have tried to determine the font scaling factors for both SDL_TTF and RMXP (using the char '_'), using the resulting ratio to compensate for the difference, but it turns out the ratio is different for each font; at the moment I'm just at an dead end. ~~I'm not even sure how RMXP does font rendering (I'd guess DirectWrite??)~~ RMXP uses GDI for font rendering. There must be something like a hint hidden in the metadata on how to scale fonts correctly.
cremno commented 2014-04-09 22:17:45 +00:00 (Migrated from github.com)

The good old GDI: CreateFontIndirect and GetGlyphOutline. DirectWrite is only available on Vista and newer.

The good old GDI: [CreateFontIndirect](http://msdn.microsoft.com/en-us/library/windows/desktop/dd183500%28v=vs.85%29.aspx) and [GetGlyphOutline](http://msdn.microsoft.com/en-us/library/windows/desktop/dd144891%28v=vs.85%29.aspx). DirectWrite is only available on Vista and newer.
chosenofbear commented 2015-06-17 14:50:43 +00:00 (Migrated from github.com)

Is RM's font size by pixel and SDL_TTF's by point?

Is RM's font size by pixel and SDL_TTF's by point?
Ancurio commented 2015-06-17 14:57:04 +00:00 (Migrated from github.com)

SDL_ttf is point size, based on 72DPI.

SDL_ttf is point size, based on 72DPI.
chosenofbear commented 2015-06-19 02:28:51 +00:00 (Migrated from github.com)

I changed the scaling factor from 0.9 to 1. When mkxp displays Chinese font SimHei, the size is exactly the same as rmxp. But somehow I am not able to test English fonts. For example, if I put arial.ttf in Fonts folder, and add a line Font.default_name = (["Arial"]), it does not use that font at all.

I changed the scaling factor from 0.9 to 1. When mkxp displays Chinese font SimHei, the size is exactly the same as rmxp. But somehow I am not able to test English fonts. For example, if I put arial.ttf in Fonts folder, and add a line Font.default_name = (["Arial"]), it does not use that font at all.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: MapleShrine/mkxp#22
No description provided.