How can we calculate x-height of a font (typeface) without needing .NET 3.0 or later (for example I would like to avoid System.Windows.Media
namespace).
views:
33answers:
4Are you looking for this: Font.Height or Perhaps this: How to: Obtain Font Metrics
Or are you looking for a way to calculate the height of a text rendered with a font? In that case you can use the TextRenderer class with the MeasureText function. This is available from .NET 2.0.
If you may use the System.Drawing
namespace, you might want to use the Graphics.MeasureString()
method. Otherwise, do as Josh says, perhaps.
Your question might not be detailed enough for further assistance.
EDIT #1
The Graphics.MeasureString()
method's return type is a System.Drawing.SizeF
. This SizeF
class provides three properties which among them you have these two:
If this is not what you want, them I don't get your point. If it is so, I'm sorry.
I hope this helps anyway! =)
Although your question clearly states x-height, all the answers talk about height, which is not at all the same thing. MeasureString
and MeasureCharacterRanges
don't provide x-height.
Anyway, my answer would be: no, x-height is not available (in any way) in .Net 2.0.