You are not logged in.
I'm evaluating SynPdf for use with my gmPrintsuite Reports (canvas based report engine)
I noticed a slight shift in vertical text position when using TPdfDocumentGDI
I wrote a small sample application that shows up the problem
https://www.dropbox.com/s/p6euugbvg19iv … synpdf.zip
will try to find out today where's the problem (maybe in my code ?).
it may take some time as I'm new to SynPDf, but it will be the occasion for me to learn about text metrics.
Last edited by ddemars (2013-08-22 11:24:58)
Offline
a version of synpdf.pas with my modifications :
https://www.dropbox.com/s/pgt3046dfkv9mz7/SynPdf.zip
...seems it fixes the problem (at least in the sample app) but not sure if done properly.
Will try it with my reports now...
Offline
enhanced tests application. TextOut samples with different alignments.
https://www.dropbox.com/s/458cye411nwbu … synpdf.zip
show a problem also with TA_BOTTOM (previously the sample app only checked the default TA_TOP)
Offline
the TA_BOTTOM problem seems due to this rule not respected :
(from http://msdn.microsoft.com/en-us/library … 85%29.aspx )
The text-alignment flags are not necessarily single bit flags and may be equal to zero. The flags must be examined in groups of related flags, as shown in the following list.
TA_LEFT, TA_RIGHT, and TA_CENTER
TA_BOTTOM, TA_TOP, and TA_BASELINE
TA_NOUPDATECP and TA_UPDATECP
To verify that a particular flag is set in the return value of this function:
Apply the bitwise OR operator to the flag and its related flags.
Apply the bitwise AND operator to the result and the return value.
Test for the equality of this result and the flag.
Offline
here's synpdf.pas with my latest fix suggestions :
https://www.dropbox.com/s/kvdraf29yqk71 … SynPdf.zip
(also fixed an issue with text rotation, issue visible when adding a font orientation in the test application).
Offline
Yes in my opinion.
As I'm not expert in this field, I took time to visually check my changes with the test application I wrote.
If the concept of the test app is valid : draw to canvas, then draw to PDF's VCLCanvas, expecting the same visual result, then my changes are OK.
that said, my tests are basic and does not cover strange cases seen in SynPDF code... ( (Canvas.FWorldFactorY) < 0 ?? )
so perharps more checks with EMF sample files are welcome...
here's latest version of my test app :
https://www.dropbox.com/s/f880hoacz0zlq … synpdf.zip
if you run it (with my modifications) you will see some issues with DrawLine (underlined text).
Need to check but I don't think the problem comes from my changes, but was a previous issue.
Offline
here's fix for Drawline in TPdfEnum.TextOut (underlined and striked text) :
procedure DrawLine(var P: TPoint; aH: Single);
var tmp: TPdfEnumStatePen;
begin
with DC[nDC] do begin
tmp := Pen;
pen.color := font.color;
pen.width := aSize / 15 / Canvas.GetWorldFactorX / Canvas.FDevScale;
pen.style := PS_SOLID;
pen.null := False;
NeedPen;
if font.spec.angle=0 then begin
// P = textout original coords
// (-W,-H) = delta to text start pos (at baseline)
// wW = text width
// aH = delta H for drawed line (from baseline)
Canvas.MoveToI(P.X -W,(P.Y-(H-aH))); // deltax := -W deltaY := (-H+aH)
Canvas.LineToI(P.X -W+wW,(P.Y-(H-aH)));// deltax := -W+wW deltaY := (-H+aH)
end else begin
// rotation pattern :
// rdx = deltax * acos + deltay * asin
// rdy = deltay * acos - deltax * asin
Canvas.MoveToI( P.X+( (-W) *acos +(-H+aH)*asin ),
P.Y+((-H+aH)*acos -(-W) *asin ) );
Canvas.LineToI( P.X+((-W+wW) *acos +(-H+aH)*asin ),
P.Y+((-H+aH) *acos -(-W+wW)*asin ) );
end;
Canvas.Stroke;
Pen := tmp;
NeedPen;
end;
end;
comments and redundant sign operators placed to ease the fix process. they can be removed.
Offline
We have included your patch proposal.
See http://synopse.info/fossil/info/7373ead175
Sounds fine for our own regression files.
Merci beaucoup!
Offline