PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

PDFSharp: Precise height of text
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1231
Page 1 of 1

Author:  Chau [ Thu Jun 24, 2010 9:43 am ]
Post subject:  PDFSharp: Precise height of text

Is it possible to measure the actual height of a string and not the Glyph face height in the font?

I am currently testing using PdfSharp.Drawing.XGraphics.MeasureString("N", new XFont("Times New Roman", 10), which gives me a larger height than the height of the "N" printed.

Regards, Casper

Author:  Thomas Hoevel [ Thu Jun 24, 2010 11:24 am ]
Post subject:  Re: PDFSharp: Precise height of text

PDFsharp uses operating system functions to measure the strings.
And AFAIK what you want is not possible.

I think it's a feature and not a bug that either "N", "Ä", "y", "-", and "_" will return the same height.
That's not what you want, but that's what's normally needed.

Author:  Chau [ Thu Jun 24, 2010 11:34 am ]
Post subject:  Re: PDFSharp: Precise height of text

Thomas Hoevel wrote:
PDFsharp uses operating system functions to measure the strings.
And AFAIK what you want is not possible.

I think it's a feature and not a bug that either "N", "Ä", "y", "-", and "_" will return the same height.
That's not what you want, but that's what's normally needed.


Well - I thought so. But having two letters next to each other like "NN" and rotating one of the letters 180 degrees, the rotation around the center of the letter yields what percieves as a "translation" of the rotated letter.

Thanks for your quick response :)

Author:  Thomas Hoevel [ Thu Jun 24, 2010 12:08 pm ]
Post subject:  Re: PDFSharp: Precise height of text

If you want to make it work for "N" (but not for "n"), this could be solvable:
http://msdn.microsoft.com/en-us/library/ms533824(VS.85).aspx
http://msdn.microsoft.com/en-us/library/xwf9s90b.aspx

Maybe it's sufficient to shift the rotated text by the "descent", maybe it's more complicated.
Good luck!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/