You are not logged in.
Pages: 1
Hi;
I am working on text alignment (left, right, center etc). You can download sample application from here.
I can not succeed on getting exact text width. Depending on font size, real text width differs from VCLCanvas.TextExtent().cx result.
If you try different font sizes (12, 14, 16, 18, 20, 22 etc.) by changing xFontSize constant, you will see strange results.
Thanks for your help. Best Regards...
Offline
TextExtent calls in fact the Windows API, so I don't know what you state what "real text width differs from TextExtent result".
Individual character positioning is not handled as in Windows, so it may differ if you enlarge the character spacing and kerning.
What is wrong? The text in the PDF? How does it be "wrong"? With which fonts and character sets?
If you can write some sample code to reproduce the problem, it would be easier to guess what's up.
Thanks!
Offline
You can download the test application from here (I updated the demo just now). What I do is:
Get the text width by TextExtent (for ex. to variable TxtWidth)
Calculate the text's left value by removing TxtWidth from rectangle's right side
Draw bounding rectangle for testing. I expect that text will fit in the bounding rectangle but the text always overflows bounding rectangle
Overflow amount depends on text content (not character count) and font (in demo app I used Times New Roman and Arial)
Last edited by fkaynakli (2011-09-03 14:31:30)
Offline
AFAIK your sample code mix both TPdfCanvas and TCanvas methods, i.e. the Canvas and VCLCanvas.
The VCLCanvas will use Kerning for its font rendering, whereas Canvas won't.
If you use only one class of methods, the width will be consistent.
So IMHO there is no bug.
I recommend only use VCLCanvas, which will allow you more easier TCanvas access, with metafile rendering, and such.
Offline
I mixed of them for two reasons:
I have to use CMYK colors and transparent PNG. Is it possible to use these with VCLCanvas?
I don't have to use kerning. If I can get unicode text width by PdfCanvas, it is enaugh for me.
Offline
Pages: 1