summaryrefslogtreecommitdiff
path: root/docview/components/richtext
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-09-01 10:30:16 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-09-01 10:30:16 +0200
commite068b9b8d3d85d39ba0ab7bc81d5bae6db74b300 (patch)
tree395a4d16d9e1a308f5b95a186b9ba563c8b91259 /docview/components/richtext
parent4565b938528740ad354890c2a9ca2f9d197b748b (diff)
downloadfpGUI-e068b9b8d3d85d39ba0ab7bc81d5bae6db74b300.tar.xz
docview: Replaced hard-coded font values with constants.
A reference to a default font or fixed font are now the same throughout docview. If you change one, you change them all.
Diffstat (limited to 'docview/components/richtext')
-rw-r--r--docview/components/richtext/CanvasFontManager.pas23
-rw-r--r--docview/components/richtext/RichTextStyleUnit.pas42
2 files changed, 34 insertions, 31 deletions
diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas
index cfdb4924..ed3abf08 100644
--- a/docview/components/richtext/CanvasFontManager.pas
+++ b/docview/components/richtext/CanvasFontManager.pas
@@ -15,12 +15,16 @@ Const
// This defines the fraction of a pixel that
// font character widths will be given in
FontWidthPrecisionFactor = 1; // 256 seems to be specific to OS/2 API
- DefaultTopicFont = 'Sans';
+ DefaultTopicFontName = 'Arial';
DefaultTopicFontSize = '10';
- DefaultTopicFixedFont = 'Courier New';
+ DefaultTopicFixedFontName = 'Courier New';
DefaultTopicFixedFontSize = '10';
+ DefaultTopicFont = DefaultTopicFontName + '-' + DefaultTopicFontSize;
+ DefaultTopicFixedFont = DefaultTopicFixedFontName + '-' + DefaultTopicFixedFontSize;
+
+
Type
{Standard Font types}
TFontType=(ftBitmap,ftOutline);
@@ -146,6 +150,7 @@ uses
,ACLStringUtility
,nvUtilities
,fpg_stringutils
+ ,SettingsUnit
;
@@ -345,13 +350,13 @@ end;
procedure GetDefaultFonts;
begin
// courier new is common and reasonably nice
- DefaultOutlineFixedFace := FindFaceName( 'Courier New' );
+ DefaultOutlineFixedFace := FindFaceName( DefaultTopicFixedFontName );
if DefaultOutlineFixedFace = nil then
begin
DefaultOutlineFixedFace := GetFirstOutlineFace( true ); // first fixed outline face
end;
- DefaultOutlineProportionalFace := FindFaceName( DefaultTopicFont );
+ DefaultOutlineProportionalFace := FindFaceName( DefaultTopicFontName );
if DefaultOutlineProportionalFace = nil then
begin
DefaultOutlineProportionalFace := GetFirstOutlineFace( false ); // first prop outline face
@@ -455,17 +460,17 @@ end;
function SubstituteBitmapFontToOutline( const FaceName: string ): string;
begin
if StringsSame( FaceName, 'Helv' ) then
- result := DefaultTopicFont
+ result := DefaultTopicFontName
else if StringsSame( FaceName, 'Helvetica' ) then
- result := DefaultTopicFont
+ result := DefaultTopicFontName
else if StringsSame( FaceName, 'Tms Rmn' ) then
result := 'Times New Roman'
else if StringsSame( FaceName, 'System Proportional' ) then
- result := DefaultTopicFont
+ result := DefaultTopicFontName
else if StringsSame( FaceName, 'System Monospaced' ) then
- result := DefaultTopicFixedFont
+ result := DefaultTopicFixedFontName
else if StringsSame( FaceName, 'System VIO' ) then
- result := DefaultTopicFixedFont
+ result := DefaultTopicFixedFontName
else
result := FaceName; // no substitution
end;
diff --git a/docview/components/richtext/RichTextStyleUnit.pas b/docview/components/richtext/RichTextStyleUnit.pas
index 782889bd..cfdde684 100644
--- a/docview/components/richtext/RichTextStyleUnit.pas
+++ b/docview/components/richtext/RichTextStyleUnit.pas
@@ -61,8 +61,7 @@ type
function GetMargin_Top: longint;
Procedure SetMargin_Top( NewValue: longint );
Procedure SetupComponent;
- Procedure AssignFont( Var Font: TfpgFont;
- NewFont: TfpgFont );
+ Procedure AssignFont(var AFont: TfpgFont; NewFont: TfpgFont);
// Hide properties...
property Name;
@@ -131,6 +130,7 @@ uses
SysUtils,
ACLStringUtility
,nvUtilities
+ ,SettingsUnit
// , ACLProfile
;
@@ -320,11 +320,11 @@ end;
function GetDefaultStyle( const Settings: TRichTextSettings ): TTextDrawStyle;
begin
FillChar(Result, SizeOf(TTextDrawStyle), 0);
- FPGuiFontToFontSpec( Settings.FNormalFont, Result.Font );
- Result.Alignment := Settings.FDefaultAlignment;
- Result.Wrap := Settings.FDefaultWrap;
- Result.Color := Settings.FDefaultColor;
- Result.BackgroundColor := Settings.FDefaultBackgroundColor;
+ FPGuiFontToFontSpec( Settings.NormalFont, Result.Font );
+ Result.Alignment := Settings.DefaultAlignment;
+ Result.Wrap := Settings.DefaultWrap;
+ Result.Color := Settings.DefaultColor;
+ Result.BackgroundColor := Settings.DefaultBackgroundColor;
Result.LeftMargin := Settings.Margins.Left;
Result.RightMargin := Settings.Margins.Right;
end;
@@ -334,11 +334,11 @@ Procedure TRichTextSettings.SetupComponent;
begin
Name := 'RichTextSettings';
- FNormalFont := fpgGetFont('Arial-10');
- FFixedFont := fpgGetFont('Courier New-10');
- FHeading1Font := fpgGetFont('Arial-20');
- FHeading2Font := fpgGetFont('Arial-14');
- FHeading3Font := fpgGetFont('Arial-10:bold');
+ FNormalFont := fpgGetFont(Settings.NormalFontDesc); // fpgGetFont(DefaultTopicFont);
+ FFixedFont := fpgGetFont(Settings.FixedFontDesc); // fpgGetFont(DefaultTopicFixedFont);
+ FHeading1Font := fpgGetFont(DefaultTopicFontName + '-20');
+ FHeading2Font := fpgGetFont(DefaultTopicFontName + '-14');
+ FHeading3Font := fpgGetFont(DefaultTopicFontName + '-10:bold');
FDefaultColor := clBlack;
FDefaultBackgroundColor := clWhite;
@@ -350,12 +350,12 @@ begin
FMarginSizeStyle := msMaximumCharWidth;
FMarginChar := Ord( ' ' );
- FMargins.Left := 0;
- FMargins.Right := 0;
- FMargins.Top := 0;
+ FMargins.Left := 0;
+ FMargins.Right := 0;
+ FMargins.Top := 0;
FMargins.Bottom := 0;
- FUpdateCount := 0;
+ FUpdateCount := 0;
FChangesPending := false;
end;
@@ -502,18 +502,16 @@ begin
Result := FontA.FontDesc = FontB.FontDesc;
end;
-Procedure TRichTextSettings.AssignFont( Var Font: TfpgFont;
- NewFont: TfpgFont );
+Procedure TRichTextSettings.AssignFont(var AFont: TfpgFont; NewFont: TfpgFont );
begin
If NewFont = Nil Then
NewFont := fpgApplication.DefaultFont;
- if FontSame( NewFont, Font ) then
+ if FontSame( NewFont, AFont ) then
exit; // no change
- Font.Free;
- Font := NewFont;
-// Font.Free;
+ AFont.Free;
+ AFont := NewFont;
Change;
End;