mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-04 13:57:15 +01:00
LazUtils: Allow hints to reveal a bug in TFreeTypeGlyph. Formatting.
git-svn-id: trunk@63130 -
This commit is contained in:
parent
77a9fd307d
commit
8946cd3dd1
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user