From 1436bb1ed051a8d3fe5d82574d1ea4077401a806 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 24 Feb 2010 00:14:21 +0200 Subject: docview: Lets not hardcode the Arial font. --- docview/components/richtext/CanvasFontManager.pas | 35 ++++++----------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'docview') diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas index 86a52b9d..53fd1d34 100644 --- a/docview/components/richtext/CanvasFontManager.pas +++ b/docview/components/richtext/CanvasFontManager.pas @@ -540,14 +540,17 @@ begin FCanvas := Canvas; FWidget := AWidget; FLogicalFonts := TList.Create; - FCurrentFontSpec.FaceName := 'Arial'; - FCurrentFont := nil; - FAllowBitmapFonts := AllowBitmapFonts; + // get system default font spec // as default default ;) FPGuiFontToFontSpec( fpgApplication.DefaultFont, FDefaultFontSpec ); if FDefaultFontSpec.FaceName = '' then raise Exception.Create('For some reason we could not create a FDefaultFontSpec instance'); + + // FCurrentFontSpec.FaceName := 'Arial'; + FCurrentFontSpec.FaceName := FDefaultFontSpec.FaceName; + FCurrentFont := nil; + FAllowBitmapFonts := AllowBitmapFonts; end; // Destructor @@ -935,7 +938,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 @@ -978,17 +981,7 @@ begin // allocate memory for storing the char widths GetMem( FCurrentFont.pCharWidthArray, sizeof( TCharWidthArray ) ); - //if not GpiQueryWidthTable( FCanvas.Handle, - // 0, 256, - // FCurrentFont.pCharWidthArray^[ #0 ] ) then - //begin - // raise Exception.Create( 'Error getting character width table: ' - // + 'GpiQueryWidthTable error ' - // + IntToStr( WinGetLastError( AppHandle ) ) ); - //end; - - // Convert all widths to positive! - // For unknown reason, sometimes GPI returns negative values... + for TheChar := #0 to #255 do begin FCurrentFont.pCharWidthArray^[ TheChar ] := Abs( FCurrentFont.pCharWidthArray^[ TheChar ] ); @@ -1003,19 +996,9 @@ begin // For bitmap fonts, multiply by 256 manually for TheChar := #0 to #255 do begin - FCurrentFont.pCharWidthArray^[ TheChar ] := - FCurrentFont.pCharWidthArray^[ TheChar ] - * FontWidthPrecisionFactor; + FCurrentFont.pCharWidthArray^[ TheChar ] := FCurrentFont.pCharWidthArray^[ TheChar ]; end; end; - - //GpiQueryFontMetrics( FCanvas.Handle, - // sizeof( fm ), - // fm ); - //FCurrentFont.lMaxbaseLineExt := fm.lMaxbaselineExt; - //FCurrentFont.lAveCharWidth := fm.lAveCharWidth; - //FCurrentFont.lMaxCharInc := fm.lMaxCharInc; - //FCurrentFont.lMaxDescender := fm.lMaxDescender; end; procedure TCanvasFontManager.EnsureMetricsLoaded; -- cgit v1.2.3-70-g09d2