2016-05-24 10 views
2

Nicht sicher, ob ich hier etwas verpasse, aber kannst du in Firemonkey TCanvas Schriftfarbe einstellen?Schriftfarbe in FMX einstellen TCanvas

Ich sehe etwas vorzuschlagen dies nicht in der folgenden Eigenschaft:

Canvas.Font. ???? 

Jede Hilfe wäre toll

Danke,

+0

Set 'Canvas.Fill.Color'? – RepeatUntil

+0

@RepeatUntil: Ja, [Canvas.Fill'] (http://docwiki.embarcadero.com/Libraries/en/FMX.Graphics.TCanvas.Fill) ist die richtige Eigenschaft, die verwendet werden soll, zB beim Aufruf von [Canvas .FillText() '] (http://docwiki.embarcadero.com/Libraries/en/FMX.Graphics.TCanvas.FillText). –

Antwort

3

Testen Sie diesen Code. Legen Sie ein Bild auf das Formular und eine Schaltfläche.

procedure TForm1.Button1Click(Sender: TObject); 
var 
    b:TBitmap; 
    f:TFont; 
begin 
    b:=TBitmap.Create; 
    f:=TFont.Create; 
    try 
    f.Family:='Arial'; 
    f.Size:=20; 
    f.Style:=[TFontStyle.fsBold]; 
    b.Width:=200; 
    b.Height:=200; 
    b.Canvas.BeginScene; 
    b.Canvas.Fill.Color:=TAlphaColorRec.red; 
    b.Canvas.Font.Assign(f); 
    b.Canvas.FillText(TRectF.Create(0,0,100,100),'AAA',False,1,[TFillTextFlag.RightToLeft], TTextAlign.Leading,TTextAlign.Center); 
    b.Canvas.EndScene; 
    image1.Bitmap:=b; 
    finally 
    b.Free; 
    f.Free; 
    end; 
end;