Skip to content

Commit

Permalink
[Controls] Fix wrong size of TSkLabel with AutoSize and Align=None #273
Browse files Browse the repository at this point in the history
Co-Authored-By: Paulo César Botelho Barbosa <16469061+paulocesarbot@users.noreply.github.com>
  • Loading branch information
viniciusfbb and paulocesarbot committed Oct 23, 2023
1 parent 628bf71 commit cb00373
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Source/FMX/FMX.Skia.Canvas.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3262,11 +3262,13 @@ procedure TSkTextLayout.UpdateParagraph;
end;

procedure ParagraphLayout(const AParagraph: ISkParagraph; AMaxWidth: Single);
const
MaxLayoutWidth = High(Integer) - High(Word);
begin
if CompareValue(AMaxWidth, 0, TEpsilon.Position) = GreaterThanValue then
begin
// The SkParagraph.Layout calls a floor for the MaxWidth, so we should ceil it to force the original AMaxWidth
AParagraph.Layout(Ceil(AMaxWidth + TEpsilon.Matrix));
AParagraph.Layout(Min(Ceil(AMaxWidth + TEpsilon.Matrix), MaxLayoutWidth));
end
else
AParagraph.Layout(0);
Expand Down
4 changes: 3 additions & 1 deletion Source/FMX/FMX.Skia.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5913,11 +5913,13 @@ procedure TSkLabel.ParagraphLayout(AMaxWidth: Single);
AParagraph.Layout(Result);
end;

const
MaxLayoutWidth = High(Integer) - High(Word);
var
LMaxWidthUsed: Single;
LParagraph: ISkParagraph;
begin
AMaxWidth := Max(AMaxWidth, 0);
AMaxWidth := EnsureRange(AMaxWidth, 0, MaxLayoutWidth);
if not SameValue(FParagraphLayoutWidth, AMaxWidth, TEpsilon.Position) then
begin
LParagraph := Paragraph;
Expand Down
4 changes: 3 additions & 1 deletion Source/VCL/Vcl.Skia.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6069,11 +6069,13 @@ procedure TSkLabel.ParagraphLayout(AMaxWidth: Single);
AParagraph.Layout(Result);
end;

const
MaxLayoutWidth = High(Integer) - High(Word);
var
LMaxWidthUsed: Single;
LParagraph: ISkParagraph;
begin
AMaxWidth := Max(AMaxWidth, 0);
AMaxWidth := EnsureRange(AMaxWidth, 0, MaxLayoutWidth);
if not SameValue(FParagraphLayoutWidth, AMaxWidth, TEpsilon.Position) then
begin
LParagraph := Paragraph;
Expand Down

0 comments on commit cb00373

Please sign in to comment.