From 10b29bd17948e67f28d8756a22e19495555e9cb4 Mon Sep 17 00:00:00 2001 From: macpgmr Date: Thu, 30 Dec 2010 20:09:28 +0000 Subject: [PATCH] Added support to DfmToLfm for font substitution git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1412 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/xdev_toolkit/dfmtolfm.ini | 18 ++++++++++++++++-- components/xdev_toolkit/dfmtolfm.pas | 20 +++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/components/xdev_toolkit/dfmtolfm.ini b/components/xdev_toolkit/dfmtolfm.ini index 658cc85c0..6a5d0bdb9 100644 --- a/components/xdev_toolkit/dfmtolfm.ini +++ b/components/xdev_toolkit/dfmtolfm.ini @@ -1,8 +1,8 @@ - ; DfmToLfm program configuration file. ; Be sure to add "=" after each key you add. The key's value can be omitted ; as it has no meaning to DfmToLfm. + ; DfmToLfm deletes these .dfm properties when creating .lfm file. ; Note: If no class is specified, deletes that property from all classes. @@ -124,6 +124,20 @@ TOvcTCIcon= TFrameViewer= THTMLViewer= + +; List of fonts to substitute with the -s switch (for example, fonts +; that don't exist on non-Windows platforms). +; Useful links: +; http://www.angelfire.com/al4/rcollins/style/fonts.html +; http://dustinbrewer.com/popular-fonts-with-their-mac-osx-windows-and-linux-equivalents/ +; http://mondaybynoon.com/2007/04/02/linux-font-equivalents-to-popular-web-typefaces/ + +[FontSubstitutes] +MS Sans Serif=Arial +MS Serif=Times New Roman +System=Arial + + ; These controls cannot receive focus on Mac, so with -m switch ; add TabStop = False so tabbing skips over them. @@ -132,6 +146,6 @@ TButton= TBitBtn= TComboBox= TCheckBox= +TRadioGroup= ;TListBox= -;TRadioGroup diff --git a/components/xdev_toolkit/dfmtolfm.pas b/components/xdev_toolkit/dfmtolfm.pas index 7a9967dea..c6bf564c7 100644 --- a/components/xdev_toolkit/dfmtolfm.pas +++ b/components/xdev_toolkit/dfmtolfm.pas @@ -60,6 +60,7 @@ var MatchFound : TFilenameCaseMatch; {$ENDIF} FontSwitch : Integer; + SubstFonts : Boolean; MacSwitch : Boolean; CfgFileObj : TMemIniFile; DfmFileName : string; @@ -88,12 +89,14 @@ begin begin WriteLn(ProgramName, ', version ', ProgramVersion, ' - converts a Delphi form file to a Lazarus form file.'); - WriteLn('Usage: ', ProgramName, ' filename', DfmFileExt, ' [-p|-d][-m]'); + WriteLn('Usage: ', ProgramName, ' filename', DfmFileExt, + ' [-p|-d][-s][-m]'); WriteLn('Switches:'); WriteLn(' -p Add parent''s font to controls with no font ', '(useful with Windows).'); WriteLn(' -d Delete font name from controls ', '(useful with GTK and GTK2).'); + WriteLn(' -s Substitute font names.'); WriteLn(' -m Mac prettifier.'); WriteLn('Looks for configuration data in file ', CfgFileName); Halt; @@ -105,6 +108,7 @@ begin FontSwitch := UseParentFont else if FindCmdLineSwitch('d', ['-'], True) then FontSwitch := DeleteFontName; + SubstFonts := FindCmdLineSwitch('s', ['-'], True); MacSwitch := FindCmdLineSwitch('m', ['-'], True); {Load configuration file} @@ -301,6 +305,20 @@ begin end *) + else if SubstFonts and + SameText('font.name', Copy(StripStr, 1, 9)) then + begin + StripStr := Copy(InStr, Pos('=', InStr)+3, MaxInt); {Name after quote} + Delete(StripStr, Length(StripStr), 1); {Delete closing quote} + if CfgFileObj.ValueExists('FontSubstitutes', StripStr) then + WriteLn(LfmFileVar, + Copy(InStr, 1, Succ(Pos('=', InStr))), '''', + CfgFileObj.ReadString('FontSubstitutes', StripStr, 'Arial'), + '''') + else + WriteLn(LfmFileVar, InStr); + end + else if MacSwitch and (StackLevel > 1) and (SameText('TButton', StackRec[StackLevel].ClassName) or