Reputation: 121
I have a multi device application with fmx. On Form1 there is only a TPaintBox named pbox. In pboxPaint I do all drawing. With Bitmaps it functions better and faster than exspected! (Good for game developers, more advertising would help to kick off older bad working solutions). But with Canvas.FillText there are several errors.
Horizontal alignment is wrong. TTextAlign.Leading aligns text to the right and TTextAlign.Trailing aligns text to the left. Center is ok. Vertical alignment works as exspected.
The text 'Hello Peter Kloß!' appears as '!Hello Peter Kloß'. That is surprising! The '!' comes first, then the rest of the text. Perhaps I would understand it when the text comes like '!ßolK reteP olleH'. Several tests with some other constellations: ABC! * -> * !ABC || A.B.C -> A.B.C || A.BC! 0 -> A.BC! 0
[TFillTextFlag.RightToLeft] is the only selectable flag. What sense does it have?
SAMPLE CODE
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Objects, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs;
type
TForm1 = class(TForm)
pbox: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure pboxPaint(Sender: TObject; Canvas: TCanvas);
procedure TForm1.pboxPaint(Sender: TObject; Canvas: TCanvas);
begin
Canvas.Fill.Color := TAlphaColors.Red;
mRect := TRectF.Create(form1.ClientRect);
Canvas.FillText(mRect, 'Hello Peter Kloß!', false, 0.5,
[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Leading);
end;
ENVIRONMENT
Delphi Community Edition 10.3.3
Windows 10
Upvotes: 1
Views: 296
Reputation: 21045
In Fmx
horizontal and vertical alignment operate with the same constants but in horizontal resp. vertical direction and for horizontal alignment taking in consideration also the reading order.
a. If reading order is []
(meaning LeftToRight
), then horizontal alignment TTextAlign.Leading
means that the text is placed at the left edge. If horizontal alignment is TextAlign.Trailing
, then the text is placed at the right edge.
b. If reading order is [TFillTextFlag.RightToLeft]
then the meaning of those flags are reversed.
When reading order is RTL, it is clear that sentense punctuation is to the left of the text. The program can however not know whether the text is already RTL or LTR.
The only reading order constant needed is [TFillTextFlag.RightToLeft], as the opposite can be indicated as []
.
Especially point 2 could be discussed, but Stack Overflow is not the right place for such a discussion.
Upvotes: 2