SynEdit: Avoid crash with corrupt font-data. (Bug #12563). This is a fix for the crash, rendering of a none-renderable font is a welcome side-effect.

git-svn-id: trunk@17513 -
This commit is contained in:
martin 2008-11-22 13:41:02 +00:00
parent 7dfb9415a6
commit ff7e434cf4

View File

@ -71,7 +71,7 @@ interface
uses
{$IFDEF SYN_LAZARUS}
LCLProc, LCLType, LCLIntf, GraphType,
LCLProc, LCLType, LCLIntf, GraphType, SynEditMiscProcs,
{$ELSE}
Windows,
{$ENDIF}
@ -663,6 +663,12 @@ begin
// Result(CharWidth)
with ABC do
Result := abcA + Integer(abcB) + abcC + TM.tmOverhang;
{$IFDEF SYN_LAZARUS}
// SynEdit would crash if a (defect) font returns 0.
if Result <= 0 then result := TM.tmAveCharWidth + Max(TM.tmOverhang,0);
if Result <= 0 then result := 1 + CharHeight * 8 div 10;
{$ENDIF}
// pCharHeight
if Assigned(pCharHeight) then
pCharHeight^ := Abs(TM.tmHeight) {+ TM.tmInternalLeading};