From 8946cd3dd1e64302d627c3098a5f29d20671eef4 Mon Sep 17 00:00:00 2001 From: juha Date: Sat, 9 May 2020 18:34:49 +0000 Subject: [PATCH] LazUtils: Allow hints to reveal a bug in TFreeTypeGlyph. Formatting. git-svn-id: trunk@63130 - --- components/lazutils/easylazfreetype.pas | 26 +++++++++++++------------ components/lazutils/ttraster.pas | 12 ++++++++---- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/components/lazutils/easylazfreetype.pas b/components/lazutils/easylazfreetype.pas index e9ef1eecc1..488627faa8 100644 --- a/components/lazutils/easylazfreetype.pas +++ b/components/lazutils/easylazfreetype.pas @@ -727,14 +727,14 @@ begin f := TFreeTypeFont(Afont); if ftaTop in AAlign then - y += AFont.Ascent + y += AFont.Ascent else if ftaVerticalCenter in AALign then - y += AFont.Ascent - AFont.LineFullHeight*0.5 + y += AFont.Ascent - AFont.LineFullHeight*0.5 else if ftaBottom in AAlign then - y += AFont.Ascent - AFont.LineFullHeight; + y += AFont.Ascent - AFont.LineFullHeight; if ftaCenter in AAlign then - x -= f.CharWidthFromGlyph(AGlyph)*0.5 + x -= f.CharWidthFromGlyph(AGlyph)*0.5 else if ftaRight in AAlign then x -= f.CharWidthFromGlyph(AGlyph); @@ -743,10 +743,9 @@ end; { TFreeTypeGlyph } -{$push} -{$hints off} function TFreeTypeGlyph.GetBounds: TRect; -var metrics: TT_Glyph_Metrics; +var + metrics: TT_Glyph_Metrics; begin TT_Get_Glyph_Metrics(FGlyphData, metrics); with metrics.bbox do @@ -755,21 +754,24 @@ begin end; function TFreeTypeGlyph.GetAdvance: single; -var metrics: TT_Glyph_Metrics; +var + metrics: TT_Glyph_Metrics; begin TT_Get_Glyph_Metrics(FGlyphData, metrics); result := metrics.advance/64; end; function TFreeTypeGlyph.GetBoundsWithOffset(x, y: single): TRect; -var metrics: TT_Glyph_Metrics; +var + metrics: TT_Glyph_Metrics; begin TT_Get_Glyph_Metrics(FGlyphData, metrics); with metrics.bbox do - result := rect(IncludeFullGrainMin(xMin+round(x*64),64) div 64,IncludeFullGrainMin(-yMax+round(y*64),64) div 64, - (IncludeFullGrainMax(xMax+round(x*64),64)+1) div 64,(IncludeFullGrainMax(-yMin+round(y*64),64)+1) div 64); + result := rect(IncludeFullGrainMin(xMin+round(x*64), 64) div 64, + IncludeFullGrainMin(-yMax+round(y*64),64) div 64, + (IncludeFullGrainMax(xMax+round(x*64), 64)+1) div 64, + (IncludeFullGrainMax(-yMin+round(y*64),64)+1) div 64); end; -{$pop} constructor TFreeTypeGlyph.Create(AFont: TFreeTypeFont; AIndex: integer); begin diff --git a/components/lazutils/ttraster.pas b/components/lazutils/ttraster.pas index 3295c75a48..9a62b365ee 100644 --- a/components/lazutils/ttraster.pas +++ b/components/lazutils/ttraster.pas @@ -243,8 +243,10 @@ function IncludeFullGrainMin(minValue: integer; Grain: integer): integer; begin if minValue mod Grain <> 0 then begin - if minValue > 0 then result := minValue - (minValue mod Grain) - else result := minValue - (Grain - (-minValue) mod Grain); + if minValue > 0 then + result := minValue - (minValue mod Grain) + else + result := minValue - (Grain - (-minValue) mod Grain); end else result := minValue; end; @@ -253,8 +255,10 @@ function IncludeFullGrainMax(maxValue: integer; Grain: integer): integer; begin if maxValue mod Grain <> Grain-1 then begin - if maxValue > 0 then result := maxValue + (Grain-1 - (maxValue mod Grain)) - else result := maxValue + (((-maxValue) mod Grain) - 1); + if maxValue > 0 then + result := maxValue + (Grain-1 - (maxValue mod Grain)) + else + result := maxValue + (((-maxValue) mod Grain) - 1); end else result := maxValue;