Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
525 stars 137 forks source link

Font sizes are broken #22

Open Ancurio opened 10 years ago

Ancurio commented 10 years ago

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 SDLTTF 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 10 years ago

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

chosenofbear commented 9 years ago

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

Ancurio commented 9 years ago

SDL_ttf is point size, based on 72DPI.

chosenofbear commented 9 years ago

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.