Does anyone know how to print text in FMX (Delphi 11.3) that includes emojis (I guess I really mean full UTF8)?
Using a string (with appropriate values) in VCL I can do
myString := ‘GoobledygookĀā😊’ + #$1F600;
Printer.Canvas.TextOut(10,10, myString);
and it prints with UTF8 characters (like A with a macron) and emojis.
I can’t work out how to do it in FMX.
My closest attempt is
Printer.Canvas.FillText(RectF(10, 10, Printer.PageWidth, 50), myString, False, 1, [], TTextAlign.Leading, TTextAlign.Leading)
which prints the text and special characters, but the emojis show as a square box (undefined character I guess). Probably because they aren’t defined in the font.
The same as near as I can tell - Arial
VCL:
Printer.Canvas.Font.Name := ‘Arial’
FMX:
Printer.Canvas.Font.Family := ‘Arial’
I’ve tried other fonts (like Verdana) and the text and non-latin characters change (possibly also the emojis), but still no joy. I also tried not specifying a font at all (default).
Maybe the VCL is irrelevant (I was mainly using it to test that I could print an emoji). My issue is how to print an emoji in FMX on Windows (I’ll look at the other platforms later).
Fairly simple, combo to select printer, then a label and memo (for testing display) and a button to do it.
The label and memo both display correctly (with the emojis in colour), while the showmessage is also correct (with black and white emojis).
procedure TForm1.Button1Click(Sender : TObject);
var
myString : string;
begin
{ Set the default DPI for the printer. The SelectDPI routine defaults
to the closest available resolution as reported by the driver. }