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
This commit is contained in:
macpgmr
2010-12-30 20:09:28 +00:00
parent 055525bdff
commit 10b29bd179
2 changed files with 35 additions and 3 deletions

View File

@ -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

View File

@ -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