Delphi-画一个Unicode字符? [英] Delphi - Draw a Unicode Character?
本文介绍了Delphi-画一个Unicode字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在画布上绘制字体图标.我正在使用 Ionicons 字体.我得到的只是屏幕上的一个矩形.
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;
我在做什么错了?
谢谢-史蒂夫
推荐答案
空白矩形表示您使用的字体不包含这些字符的字形.您必须使用可以的字体.
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;
或者也许:
const
GenderChars: array [Boolean] of Char = (#$f25d, #$f202);
....
xCanvas.TextOut(10, 10, GenderChars[xRep.Male]);
您可能想声明一个枚举类型来保存您的性别信息,而不是一个 Boolean
.
You might like to declare an enumerated type to hold your gender information, rather than a Boolean
.
这篇关于Delphi-画一个Unicode字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文