Draw text as contour / draw text as outline

  • Hello,

    when text is printed as contour with the activated modes wpTextAsGlyphs, wpRenderTextInPathAsGlyph and this code:

    Code
        OldBkMode := SetBkMode(Canvas.Handle, TRANSPARENT);
        BeginPath(Canvas.Handle);
        Canvas.TextOut(X, Y, Text);
        EndPath(Canvas.Handle);
        StrokeAndFillPath(Canvas.Handle);
        SetBkMode(Canvas.Handle, OldBkMode);

    the glyphs are in the pdf source (Q 1 g 1 0 0 RG 20 w 1 J 1 j [] 0 d 1 0 0 1 0 0 cm q 0.064 0 0 0.064 192 -192 cm 1 0 0 rg 43 449 m 43 522 54 583 76 633 c 92 669 114 702 142 731 c 171 760 202 781 235 796 c 280 814 331 824 390 824 c ...) but nothing is shown in Acrobat.

    Is it possible to draw the contour of the characters?

    Regards,

    Thomas

    • Offizieller Beitrag

    From the quoted PS code I cannot see why it is not rendered. Maybe the "S" is missing at the end.

    You can use this utility function which requires a reference canvas:

    It is used like this:

    Code
    WPPDFPrinter1.Canvas.Brush.Color := clRed;
    WPPDFPrinter1.Canvas.Pen.Color := clYellow;
    WPPDFPrinter1.Canvas.Font.Size := 100;
    BeginPath(WPPDFPrinter1.Canvas.Handle);
    TextOutOutline(Canvas, WPPDFPrinter1.Canvas,  10, 10, 'Outline');
    EndPath(WPPDFPrinter1.Canvas.Handle);
    StrokeAndFillPath(WPPDFPrinter1.Canvas.Handle); 

    TextOutOutline Create the path data using a canvas which is not visible and then renders it to the wPDF Canvas.

    The code also skips the first part of the path data because it is usually only the bounding box of the output.

  • wpsupport 25. März 2022 um 08:12

    Hat den Titel des Themas von „Text as contour“ zu „Draw text as contour / draw text as outline“ geändert.