Jump to content

everybyte2

Members
  • Content Count

    7
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by everybyte2


  1. Webinar demo creates a PDF from a bitmap of the control, as a result PDF does not scale well.

     

    With a fix in Skia I do create scalable PDFs on Windows (where Printer canvas is available),

    but this solution is not portable, at least for Android.

    • Like 1

  2. Thanks for a quick reply!

     

    The problem of rendering to a different canvas (rather than default) is an FMX problem, not Skia problem.

    The TTextLayout derivative is bound to the default canvas when created and knows nothing about some other canvas type.

     

    I created a workaround which works on Windows, other platforms are untested:

     

    type
      TTextLayoutX = class(TTextLayout);

    procedure TSkTextLayout.DoDrawLayout(const ACanvas: TCanvas);
    var
      layoutClass: TTextLayoutClass;
      layout: TTextlayout;
    begin
      if (ACanvas is TSkCanvasCustom) and Assigned(TSkCanvasCustom(ACanvas).Surface) then
        DoDrawLayout(TSkCanvasCustom(ACanvas).Surface.Canvas)
      else begin                                                                    //
    {$REGION 'A-Dato workaround for printing (on GDI+)'}
        layoutClass := TTextLayoutManager.TextLayoutByCanvas(ACanvas.ClassType);
        if (layoutClass <> nil) then begin
          layout := layoutClass.Create;
          layout.TopLeft := TopLeft;
          layout.MaxSize := MaxSize;
          layout.Text := Text;
          layout.Padding := Padding;
          layout.WordWrap := WordWrap;
          layout.HorizontalAlign := HorizontalAlign;
          layout.VerticalAlign := VerticalAlign;
          //layout.VerticalAlign := TTextAlign.Trailing;    //too low
          layout.Color := Color;
          layout.Font := Font;
          layout.Opacity := Opacity;
          layout.RightToLeft := RightToLeft;
          TTextLayoutX(layout).DoDrawLayout(ACanvas);
        end;
    {$ENDREGION}
      end;
    end;

     


  3. A second question about printing:

     

    Skia has an example of rendering to a PDF canvas, but this canvas is of a  TskCanvas  class

    and thus not compatible with FMX adapter class TSkCanvasCustom  (which uses TskCanvas internally).

    Is there an easy way to create TSkCanvasCustom from a given TskCanvas instance?


  4. Has anybody tried to do printing of an control ?

     

    The TextLayout is bound to TSkCanvasCustom for display but the printing goes to GDI+ canvas,

    which custom TextLayout knows nothing about. As a result all text is missing in the printout.

×