使用带有字体真棒图标的TDirect2DCanvas

时间:2019-02-11 20:29:17

标签: delphi gdi direct2d

我正在用Delphi XE 10.2编写一个使用 Direct2D canvas Font Awesome图标的应用程序。 GDI画布正确显示,而Direct2d画布显示字母数字字符,但不显示图标(Hexcode> = $ f000)。将在其位置显示经典矩形。 有人可以告诉我原因吗? 谢谢,恩佐

这是我的代码:

procedure TForm1.Button2Click(Sender: TObject);
var
  D2DCanvas: TDirect2DCanvas;
  Ch: Char;
begin
  Ch := Char($F4BA);
  Canvas.Font.Assign(Self.Font);
  Canvas.Font.Name := 'Font Awesome 5 Free Solid';
  Canvas.Font.Color := clHotLight;

  D2DCanvas := TDirect2DCanvas.Create(Canvas, Rect(0, 0, Width, Height));
  try
    D2DCanvas.Font.Assign(Self.Font);
    D2DCanvas.Font.Name := 'Font Awesome 5 Free Solid';
    D2DCanvas.Font.Color := clHotLight;
    D2DCanvas.BeginDraw;
    try
      D2DCanvas.TextOut(10, 50,  '(Direct2D): ' + Ch);
    finally
      D2DCanvas.EndDraw;
    end;
  finally
    D2DCanvas.Free;
  end;
  Canvas.TextOut(10, 150, '(GDI): ' + Ch);
end;

with this result

0 个答案:

没有答案