PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
Xgraphics.MeasureString() ignores spaces? http://forum.pdfsharp.com/viewtopic.php?f=2&t=3826 |
Page 1 of 1 |
Author: | Maarten [ Wed Aug 15, 2018 12:29 pm ] |
Post subject: | Xgraphics.MeasureString() ignores spaces? |
Using the size = MeasureString(txt,font) function I notice a trailing space is ignored. Both txt = "1234567890" and txt = "1234567890 " give me the same value of size.width Do I overlook something or is this know behavior? Best regards, Maarten |
Author: | Thomas Hoevel [ Wed Aug 15, 2018 1:54 pm ] |
Post subject: | Re: Xgraphics.MeasureString() ignores spaces? |
This is the known behavior. Trailing spaces have no impact on the output in PDF. Spaces in the middle of the string are measured as they have impact on the result. Here's a trick that determines the width of a blank: https://github.com/empira/PDFsharp/blob ... ter.cs#L81 Code: _spaceWidth = _gfx.MeasureString("x x", value).Width;
_spaceWidth -= _gfx.MeasureString("xx", value).Width; |
Author: | Maarten [ Thu Aug 16, 2018 11:37 am ] |
Post subject: | Re: Xgraphics.MeasureString() ignores spaces? |
Thanks for the quick responds. I use the space width calculation routine as mentioned. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |