diff --git a/components/synedit/Source/SynEdit.pas b/components/synedit/Source/SynEdit.pas index 1bc2d541..7a12598e 100644 --- a/components/synedit/Source/SynEdit.pas +++ b/components/synedit/Source/SynEdit.pas @@ -2834,7 +2834,7 @@ begin for i := 1 to Length(S) do begin inc(j); - CountOfAvgGlyphs := Ceil(fTextDrawer.TextWidth(S[i]) / fCharWidth); + CountOfAvgGlyphs := Ceil(fTextDrawer.TextWidth(S[i]) / Max(fCharWidth,1)); if j + CountOfAvgGlyphs > Length(Result) then SetLength(Result, Length(Result) + 128); diff --git a/components/synedit/Source/SynTextDrawer.pas b/components/synedit/Source/SynTextDrawer.pas index 52ba92a5..f6497eee 100644 --- a/components/synedit/Source/SynTextDrawer.pas +++ b/components/synedit/Source/SynTextDrawer.pas @@ -935,8 +935,12 @@ procedure TheTextDrawer.ExtTextOut(X, Y: Integer; Options: TTextOutOptions; end; begin - InitETODist(GetCharWidth); - AdjustLastCharWidthAndRect; + try + InitETODist(GetCharWidth); + AdjustLastCharWidthAndRect; + except + // Suppress error in threaded applications + end; UniversalExtTextOut(FDC, X, Y, Options, ARect, Text, Length, FETODist); end;