5,379
社区成员
发帖
与我相关
我的任务
分享
procedure DrawColorText(aCanvas: TCanvas; const x, y: Integer; const Texts: array of string; const Colors: array of TColor; const FontStyles: array of TFontStyles);var
w, i: Integer;
begin
w := 0;
for i := Low(Texts) to High(Texts) do
begin
aCanvas.Font.Style := FontStyles[i];
aCanvas.Font.Color := Colors[i];
aCanvas.TextOut(x + w, y, Texts[i]);
w := w + aCanvas.TextWidth(Texts[i]);
end;
end;
//测试代码
DrawColorText(
Canvas,
100, 100,
['测试', '颜色', '字符串', '程序示例'],
[clBlack, clRed, clBlack, clBlue],
[[],[fsBold],[],[]]);