#1 PDF Engine » SetWordSpace in SynPdf.pas » 2013-03-05 16:47:53

ElFab
Replies: 1

Hi,

I detect a problem when SetWordSpace is called in function TextOut in SynPdf.pas (line 8908).
After WordSpace is set, it's set to all following elements.

to fix this :

if Canvas.fUseSetTextJustification and (nspace>0) and ((W-measW)>(nspace*2)) then
        // we should have had a SetTextJustification() call -> modify word space
        with Canvas do
          SetWordSpace(((W-measW) * fscaleX)/nspace)
      else begin
        Canvas.SetWordSpace(0);
        // check if DX[] width differs from PDF width
        nspace := 0;
        hscale := (W*100) / measW;

I add SetWordSpace(0) in else condition.


and in SetWordSpace function :

procedure TPdfCanvas.SetWordSpace(wordSpace: Single);
begin
  //if FPage.WordSpace=wordSpace then Exit;
  FPage.SetWordSpace(wordSpace);
  if FContents<>nil then
    FContents.Writer.AddWithSpace(wordSpace).Add('Tw'#10);
end;

If you have a better solution...

Fabien.

#2 PDF Engine » Problem with font style is underline » 2013-03-05 13:13:23

ElFab
Replies: 1

Hi,

I use your library to export Fast-Report report and it it works well.
But, there is one problem when underline is affect to font.style.

in procedure DrawLine in SynPdf.pas, WithClip variable is set to False, but never reset to his old value.
After this, nothing is drawn.

I propose to fix as Below :

procedure DrawLine(var P: TPoint; aH: Single);
var
  tmp: TPdfEnumStatePen;
  BakWithCli: Boolean;
  BakbOpaque: boolean;
begin
  BakWithCli := WithClip;
  BakbOpaque := bOpaque;
  try
    WithClip := False;
    bOpaque := False;

    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
        Canvas.MoveToI(P.X,(P.Y-(H-aH)));
        Canvas.LineToI(P.X+W+wW,(P.Y-(H-aH)));
      end else begin
        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;
    end;

  finally
    WithClip := BakWithCli;
    bOpaque := BakbOpaque;
  end;
end;

Fabien.

Board footer

Powered by FluxBB