I'm trying to draw an font icon on a canvas. I'm using the Ionicons font. All I get is a rectangle on the screen.
var
  x1, y1: integer;
  xChr: WideChar;
begin
  x1 := 10;
  y1 := 10;
  fMaleIcon := $f202;
  fFemailIcon := $f25d;
  if xRep.Male then
    xChr := Char(fMaleIcon)
  else
    xChr := Char(fFemaleIcon);
  xCanvas.TextOut(x1, y1, xChr);
end;
What am I doing wrong?
Thanks - Steve
The empty rectangle means that the font you are using does not contain glyphs for those characters. You must use a font that does.
Your code is rather convoluted. I'd write it like this:
var
  xChr: Char;
begin
  if xRep.Male then
    xChr := #$f202;
  else
    xChr := #$f25d;
  xCanvas.TextOut(10, 10, xChr);
end;
Or perhaps:
const
  GenderChars: array [Boolean] of Char = (#$f25d, #$f202);
....
xCanvas.TextOut(10, 10, GenderChars[xRep.Male]);
You might like to declare an enumerated type to hold your gender information, rather than a Boolean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With