Commit da1e9bb5 authored by Juha Manninen's avatar Juha Manninen
Browse files

LazUtils: Initialize LazFreeType variables. Prevent range errors. Issue...

LazUtils: Initialize LazFreeType variables. Prevent range errors. Issue #37033, patch from circular.

git-svn-id: trunk@63134 -
parent e3a0380e
......@@ -747,30 +747,37 @@ function TFreeTypeGlyph.GetBounds: TRect;
var
metrics: TT_Glyph_Metrics;
begin
TT_Get_Glyph_Metrics(FGlyphData, metrics);
with metrics.bbox do
result := rect(IncludeFullGrainMin(xMin,64) div 64,IncludeFullGrainMin(-yMax,64) div 64,
(IncludeFullGrainMax(xMax,64)+1) div 64,(IncludeFullGrainMax(-yMin,64)+1) div 64);
if TT_Get_Glyph_Metrics(FGlyphData, metrics) = TT_Err_Ok then
with metrics.bbox do
result := rect(IncludeFullGrainMin(xMin,64) div 64,IncludeFullGrainMin(-yMax,64) div 64,
(IncludeFullGrainMax(xMax,64)+1) div 64,(IncludeFullGrainMax(-yMin,64)+1) div 64)
else
result := TRect.Empty;
end;
function TFreeTypeGlyph.GetAdvance: single;
var
metrics: TT_Glyph_Metrics;
begin
TT_Get_Glyph_Metrics(FGlyphData, metrics);
result := metrics.advance/64;
if TT_Get_Glyph_Metrics(FGlyphData, metrics) = TT_Err_Ok then
result := metrics.advance/64
else
result := 0;
end;
function TFreeTypeGlyph.GetBoundsWithOffset(x, y: single): TRect;
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);
if TT_Get_Glyph_Metrics(FGlyphData, metrics) = TT_Err_Ok then
begin
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);
end else
result := TRect.Empty;
end;
constructor TFreeTypeGlyph.Create(AFont: TFreeTypeFont; AIndex: integer);
......
......@@ -254,13 +254,13 @@ const
(* Get a glyph's metrics *)
(* *)
function TT_Get_Glyph_Metrics( _glyph : TT_Glyph;
var gmetrics : TT_Glyph_Metrics ) : TT_Error;
out gmetrics : TT_Glyph_Metrics ) : TT_Error;
(*****************************************************************)
(* Get a glyph's big metrics *)
(* *)
function TT_Get_Glyph_Big_Metrics( _glyph : TT_Glyph;
var gmetrics : TT_Big_Glyph_Metrics
out gmetrics : TT_Big_Glyph_Metrics
) : TT_Error;
(*****************************************************************)
......@@ -1027,7 +1027,7 @@ uses
(* *)
(* *)
function TT_Get_Glyph_Metrics( _glyph : TT_Glyph;
var gmetrics : TT_Glyph_Metrics ) : TT_Error;
out gmetrics : TT_Glyph_Metrics ) : TT_Error;
var
glyph : PGlyph;
begin
......@@ -1041,14 +1041,17 @@ uses
TT_Get_Glyph_Metrics := TT_Err_Ok;
end
else
TT_Get_Glyph_Metrics := TT_Err_Invalid_Glyph_Handle;
begin
fillchar(gmetrics, sizeof(gmetrics), 0);
TT_Get_Glyph_Metrics := TT_Err_Invalid_Glyph_Handle;
end;
end;
(*****************************************************************)
(* Get a glyph's big metrics *)
(* *)
function TT_Get_Glyph_Big_Metrics( _glyph : TT_Glyph;
var gmetrics : TT_Big_Glyph_Metrics
out gmetrics : TT_Big_Glyph_Metrics
) : TT_Error;
var
glyph : PGlyph;
......@@ -1060,7 +1063,10 @@ uses
TT_Get_Glyph_Big_Metrics := TT_Err_Ok;
end
else
TT_Get_Glyph_Big_Metrics := TT_Err_Invalid_Glyph_Handle;
begin
fillchar(gmetrics, sizeof(gmetrics), 0);
TT_Get_Glyph_Big_Metrics := TT_Err_Invalid_Glyph_Handle;
end;
end;
(*****************************************************************)
......@@ -1345,6 +1351,15 @@ uses
n : Int;
begin
if out.n_points-nbPhantomPoints <= 0 then
with bbox do
begin
xMin := 0;
xMax := 0;
yMin := 0;
yMax := 0;
end
else
with bbox do
begin
xMin := $7FFFFFFF;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment