From 9d9a86d39d3f22ea6db81729c1efc60ef55e0b83 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Fri, 6 Aug 2010 17:05:02 +0200 Subject: docview: Fixed mono font screwup when scrolling large tables. When scrolling pages that contain large tables of source code examples using mono fonts, it changed no non-mono fonts. This is now finally fixed! --- docview/components/richtext/CanvasFontManager.pas | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'docview/components') diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas index 8a15e914..7996c16d 100644 --- a/docview/components/richtext/CanvasFontManager.pas +++ b/docview/components/richtext/CanvasFontManager.pas @@ -924,11 +924,15 @@ var lDefaultFontSpec: TFontSpec; begin ProfileEvent('DEBUG: TCanvasFontManager.SetFont >>>>'); - if (FCurrentFontSpec.FaceName = FontSpec.FaceName) and - (FCurrentFontSpec.PointSize = FontSpec.PointSize) and - (FCurrentFontSpec.Attributes = FontSpec.Attributes) then - // same font - exit; + // we don't need this any more, because we check FCurrentFont <> Font further down + // We also make sure we always set Canvas.Font - this fixes large display of Grids or Sample Code in Courier New font + //if (FCurrentFontSpec.FaceName = FontSpec.FaceName) and + // (FCurrentFontSpec.PointSize = FontSpec.PointSize) and + // (FCurrentFontSpec.Attributes = FontSpec.Attributes) then + // //same font + //begin + // exit; + //end; Font := GetFont( FontSpec ); @@ -937,7 +941,7 @@ ProfileEvent('DEBUG: TCanvasFontManager.SetFont >>>>'); // ack! Pfffbt! Couldn't find the font. // Try to get the default font -// writeln('---------- here goes nothing -------------'); + //writeln('---------- here goes nothing -------------'); Font := GetFont( FDefaultFontSpec ); if Font = nil then begin @@ -948,7 +952,7 @@ ProfileEvent('DEBUG: TCanvasFontManager.SetFont >>>>'); FPGuiFontToFontSpec( fpgApplication.DefaultFont, lDefaultFontSpec ); Font := GetFont( lDefaultFontSpec ); if Font = nil then - // Jimminy! We can't even get the default system font + // WTF! We can't even get the default system font raise Exception.Create( 'Could not access default font ' + 'in place of ' + FontSpec.FaceName @@ -960,7 +964,8 @@ ProfileEvent('DEBUG: TCanvasFontManager.SetFont >>>>'); SelectFont( Font, 1 ); FCurrentFontSpec := FontSpec; - FCurrentFont.Free; + if FCurrentFont <> Font then + FCurrentFont.Free; FCurrentFont := Font; ProfileEvent('DEBUG: TCanvasFontManager.SetFont <<<<'); end; -- cgit v1.2.3-70-g09d2