Hello, I would like to determine the height of a text for a given font. For
most fonts the GetAscentPoint and GetDescentPoint return a correct value but
for some fonts it just returns 0. Eg: Myriad Pro Bold Condensed (otf font
installed by installing Adobe photoshop) returns 0 However:Myriad Pro Regular
does return a value. This is my test code: static void Main(string[] args)
{
GetTextHeight("Arial"); //this returns values
GetTextHeight("Myriad Pro Bold Condensed"); //this does not return any values
Console.Read();
}
private static void GetTextHeight(string systemFont)
{
int totalfonts = FontFactory.RegisterDirectory("C:\\WINDOWS\\Fonts");
iTextSharp.text.Font Myriad = FontFactory.GetFont(systemFont, 14);
BaseFont basefont = Myriad.GetCalculatedBaseFont(false);
float heightOfText = basefont.GetAscentPoint("SampleText", 14) -
basefont.GetDescentPoint("SampleText", 14);
Console.WriteLine("Height of the `{0}` Text Is {1}", systemFont, heightOfText);
}
--> output: Height of the `Arial` Text Is 12,964
Height of the `Myriad Pro Bold Condensed` Text Is 0 Thanks !! Wim
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php