#1 Re: PDF Engine » TPdfDocumentGDI : problem with vertical text alignment » 2013-08-28 08:10:09

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.

#2 Re: PDF Engine » TPdfDocumentGDI : problem with vertical text alignment » 2013-08-27 18:13:54

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.

#3 Re: PDF Engine » TPdfDocumentGDI : problem with vertical text alignment » 2013-08-27 10:46:27

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).

#4 Re: PDF Engine » TPdfDocumentGDI : problem with vertical text alignment » 2013-08-23 12:19:05

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.

#5 Re: PDF Engine » TPdfDocumentGDI : problem with vertical text alignment » 2013-08-23 10:23:04

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)

#6 Re: PDF Engine » TPdfDocumentGDI : problem with vertical text alignment » 2013-08-22 12:50:51

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...

#7 PDF Engine » TPdfDocumentGDI : problem with vertical text alignment » 2013-08-22 11:23:44

ddemars
Replies: 9

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.

Board footer

Powered by FluxBB