diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2010-02-24 00:15:28 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2010-02-24 00:15:28 +0200 |
commit | b885dfc74dbb4870b3936d0e643c278e7d10bc53 (patch) | |
tree | 149c5e500379c88e1e24aceb08f0be6f7ba5aa21 | |
parent | 1436bb1ed051a8d3fe5d82574d1ea4077401a806 (diff) | |
download | fpGUI-b885dfc74dbb4870b3936d0e643c278e7d10bc53.tar.xz |
docview: This drastically improved text width calculations.
Due to this change the text wrapping has also improved a lot. Still
not 100% but much better than before.
-rw-r--r-- | docview/components/richtext/CanvasFontManager.pas | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas index 53fd1d34..c182ba91 100644 --- a/docview/components/richtext/CanvasFontManager.pas +++ b/docview/components/richtext/CanvasFontManager.pas @@ -1011,12 +1011,16 @@ begin end; function TCanvasFontManager.CharWidth( const C: Char ): longint; +var + f: TfpgFont; begin - EnsureMetricsLoaded; - Result := FCurrentFont.pCharWidthArray^[ C ]; - { TODO -ograemeg -chard-coded result : This is a temporary hard-code } -// result := fpgApplication.DefaultFont.TextWidth(C); - Result := FCurrentFont.lAveCharWidth; +// EnsureMetricsLoaded; +// Result := FCurrentFont.pCharWidthArray^[ C ]; + + { TODO -ograeme : This needs improvement: what about font attributes, and performance. } + f := fpgGetFont(FCurrentFont.FaceName + '-' + IntToStr(FCurrentFont.PointSize)); + Result := f.TextWidth(C); + f.Free; end; function TCanvasFontManager.AverageCharWidth: longint; |