FMX Application with Delphi 10.2

FMX Application with Delphi 10.2

We would print on Printer.Canvas some Wingdings chars but all solutions found on Internet are not helping us.

In a recent (2016) Stack Overflow post someone suggested this example code

Canvas.Font.Name := 'Wingdings';
Canvas.Font.Charset := SYMBOL_CHARSET;
for i := 128 to 128 + 21 do
Canvas.TextOut(0, 20 * (i - 128), AnsiChar(i));

that we are not able to use since the lack of Charset property and textout method (using FillText does not print the expected Wingdings symbol, maybe for the lack of proper charset or maybe for some unicode conversion problem that we had to consider?).

Thanks for your help!


Comments

  1. Wingdings?? Really. Why would you expect the printer to know about that?

    What glyphs are you trying to produce anyway?

    ReplyDelete
  2. Uhm.. David, basically it was only an idea to "refresh" some reports with smilies or so.. but I think you are right, actually It can turn to be simply a wrong one ;)

    ReplyDelete
  3. Marco Cirinei You can draw a glyph for that I suspect

    ReplyDelete
  4. This will draw on form canvas.
    procedure TForm17.Button3Click(Sender: TObject);
    var
    i: Integer;
    ARect: TRectF;
    s: string;
    begin
    // draws on form canvas
    Canvas.Font.Family := 'Wingdings';
    Canvas.Fill.Color := clablack;// uses System.UIConsts
    ARect.Top := 10;
    ARect.Left := 10;
    ARect.Width := 1000;
    ARect.Height := 1000;
    for i := 128 to 128 + 21 do
    s := s + Char(i);
    Canvas.BeginScene;
    Canvas.FillText(ARect, s, false, 1, [], TTextAlign.Leading, TTextAlign.Leading);
    Canvas.EndScene;
    end;

    ReplyDelete
  5. Hard to see that drawing survive a paint cycle, not to mention it having little chance of making it to the printer.....

    ReplyDelete
  6. @Marco Cinirei:

    I had a similar problem in a VCL application where the wrong Wingdings symbols where produced.

    I wanted to output the Windings glyphs by index number. The easiest way to accomplish that is by using the ANSI version of Textout(), after having selected the Wingdings font. But please note that this method is Windows specific.


    VAR a:Ansichar; b:Ansistring;
    ...
    a:=Ansichar(indexnumber);
    b:=a;
    Windows.TextOutA(canvas.handle, X,Y, pansichar(b), length(b));



    ReplyDelete
  7. Arthur Hoornweg Pointless to assign to a heap allocated string here. This is better:

    var
    a: AnsiChar;
    ...
    a := AnsiChar(GlyphIndex);
    Windows.TextOutA(canvas.handle, X, Y, @a, 1);

    ReplyDelete

Post a Comment