Clarification on realFontSize and UNorm/SNorm/Relative coordinate systems

Jan 23, 2015 at 1:00 PM

I'm not quite sure what value you are supposed to use for the realFontSize parameter of the respective DrawString overloads.

Let's say I have TextFontRenderer created with an "Arial" font and font-size 12. It looks fine when using absolute coordinates, but what am I supposed to pass for realFontSize if I want to use another coordinate system to render the text without any stretching?

I tried to simply pass the FontSize property of the TextFontRenderer instance but that's obviously wrong and even after some experimenting I haven't quite figured it out.

Jan 27, 2015 at 7:47 AM

realFontSize is supposed to be the font size in the target coordinate system.
One problem with UNorm and SNorm coordinate systems is that their aspect ratio (which is constantly 1) does not always match the viewport's aspect ratio. Therefore, these coordinate systems should only be used for text if you have a quadratic viewport.
In this case you can calculate the realFontSize as
realFontSize = textBlock.FontSize / viewport.Width = textBlock.FontSize / viewport.Height; // (for UNorm) 
realFontSize = 2 * textBlock.FontSize / viewport.Width = 2 * textBlock.FontSize / viewport.Height; // (for SNorm)
Marked as answer by bomsel1234 on 1/27/2015 at 3:07 AM
Jan 27, 2015 at 11:07 AM
ah alright, thanks! very pleased with the library btw :)