Hey all!
I am trying to align a multiline text properly. Therefore i create my
font like this and set it to my painter:
font = g_outputDoc->CreateFont(fontName, isBold, isItalic, false,
new PdfIdentityEncoding(0, 0xffff, true), true);
font->SetFontSize(fontSize);
g_painter.SetFont(font);
After that i measure the text width of every line of the text i want to
draw like this:
double imposedPdf::measureText(const wchar_t* text) {
PoDoFo::PdfString pdfText(text);
return g_painter.GetFont()->GetFontMetrics()->StringWidth(pdfText);
}
(the pdf string constructor is used because if found something in the
mail archive which suggested that this is better...)
It returns a reasonable value (for example "11" is double the width of
"1" etc.)
My program will then draw text to a specific position like this:
PoDoFo::PdfRect textRect(mmToPdfUnits(x), mmToPdfUnits(y),
mmToPdfUnits(width), mmToPdfUnits(height));
PoDoFo::PdfString pdfText(text);
g_painter.DrawMultiLineText(
textRect,
pdfText,
textAlign,
vertiAlign,
false);
This results in the text being in the pdf with the corret font/fontsize,
BUT it is monospaced and its therefore wider then the suggested value of
the "StringWidth" function.
So in the end my texts placement is wrong, because i calculated the
placement depending on the widest line of the text i want to draw...
Any ideas why my fonts are all drawn monospaced? (and no: i didnt just
use monospaced fonts :D i tried about 50 different fonts, all with the
same issue)
Greetings,
Dennis Voss
--
dots <http://www.dots.de/en/>
Dennis Voss
dots Software GmbH
Schlesische Str. 27, 10997 Berlin, Germany
Tel: +49 (0)30 695 799-47
Fax: +49 (0)30 695 799-55
dennis.v...@dots.de <mailto:dennis.v...@dots.de>
http://www.dots.de <http://www.dots.de/>
Amtsgericht Berlin Charlottenburg HRB 65201
Geschäftsführer: Olaf Lorenz
Follow us on: Twitter <http://www.dots.de/?id=twitter> Youtube
<http://www.dots.de/?id=youtube> Xing <http://www.dots.de/?id=xing>
------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users