Re: [Podofo-users] font metrics StringWidth() differs from actually width of drawn string

2016-12-01 Thread dennis

Hey,

the version is 0.9.4 sorry, i just assumed that if not said specifically 
everybody would default to the latest release :-)


Thank you for your answer. I will take a look at PdfEncodingFactory. In 
another program that uses 0.9.3 PoDoFo it works fine with the posted 
code. no monospace, no problems.



greetings

Dennis


Am 01.12.2016 um 13:59 schrieb zyx:

On Thu, 2016-12-01 at 11:48 +0100, dennis wrote:

font = g_outputDoc->CreateFont(fontName, isBold, isItalic, false,
new PdfIdentityEncoding(0, 0x, true), true);

Hi,
I wouldn't be surprised if it's due to the PdfIdentityEncoding() use
(which you actually leak; consider using PdfEncodingFactory members).


double imposedPdf::measureText(const wchar_t* text) {
 PoDoFo::PdfString pdfText(text);

Another thing, at least from my past experience, when using wchar_t and
PdfString, I'd rather use PdfString::setFromWchar_t() method, to make
sure the value is wchar_t, not any other PdfString() constructor. It
depends on the actual system for which you compile, though.

By the way, mentioning your PoDoFo version would be also a good idea.
Bye,
zyx



--

dots 

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 
http://www.dots.de 

Amtsgericht Berlin Charlottenburg HRB 65201
Geschäftsführer: Olaf Lorenz

Follow us on: 	Twitter  	Youtube 
 	Xing 


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] font metrics StringWidth() differs from actually width of drawn string

2016-12-01 Thread zyx
On Thu, 2016-12-01 at 11:48 +0100, dennis wrote:
> font = g_outputDoc->CreateFont(fontName, isBold, isItalic, false,
> new PdfIdentityEncoding(0, 0x, true), true);

Hi,
I wouldn't be surprised if it's due to the PdfIdentityEncoding() use
(which you actually leak; consider using PdfEncodingFactory members).

> double imposedPdf::measureText(const wchar_t* text) {
>PoDoFo::PdfString pdfText(text);

Another thing, at least from my past experience, when using wchar_t and
PdfString, I'd rather use PdfString::setFromWchar_t() method, to make
sure the value is wchar_t, not any other PdfString() constructor. It
depends on the actual system for which you compile, though.

By the way, mentioning your PoDoFo version would be also a good idea.
Bye,
zyx

-- 
http://www.litePDF.cz i...@litepdf.cz

--
___
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


[Podofo-users] font metrics StringWidth() differs from actually width of drawn string

2016-12-01 Thread dennis

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, 0x, 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 

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 
http://www.dots.de 

Amtsgericht Berlin Charlottenburg HRB 65201
Geschäftsführer: Olaf Lorenz

Follow us on: 	Twitter  	Youtube 
 	Xing 


--
___
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users