View Issue Details

IDProjectCategoryView StatusLast Update
0017694LazarusIDEpublic2016-05-30 05:21
ReporterindianajonesAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.9.29 (SVN)Product Build 
Target VersionFixed in Version0.9.31 (SVN) 
Summary0017694: Changing font size problem
DescriptionReproducing the error.

1. Environment / Options
2. Under the Display option, change the Default editor font size
3. Changing font size effecting the "Editor font height" which is different than the font size.
Additional InformationUbuntu 10.04
GTK2 2.30.2
FPC 2.4.0 - Lazarus 0.9.29 SVN 27034
TagsNo tags attached.
Fixed in Revision32150
LazTarget1.0
WidgetsetGTK 2
Attached Files
  • editorfontsize.diff (15,756 bytes)
    Index: debugger/assemblerdlg.pp
    ===================================================================
    --- debugger/assemblerdlg.pp	(revision 31909)
    +++ debugger/assemblerdlg.pp	(working copy)
    @@ -215,7 +215,7 @@
     
       Caption := lisDisAssAssembler;
     
    -  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
    +  pbAsm.Font.Size := EditorOpts.EditorFontSize;
       pbAsm.Font.Name := EditorOpts.EditorFont;
       Caption := lisMenuViewAssembler;
       CopyToClipboard.Caption := lisDbgAsmCopyToClipboard;
    Index: ide/editoroptions.pp
    ===================================================================
    --- ide/editoroptions.pp	(revision 31909)
    +++ ide/editoroptions.pp	(working copy)
    @@ -957,7 +957,7 @@
         FGutterSeparatorIndex: Integer;
         fRightMargin: Integer;
         fEditorFont:  String;
    -    fEditorFontHeight: Integer;
    +    fEditorFontSize:   Integer;
         fExtraCharSpacing: Integer;
         fExtraLineSpacing: Integer;
         fDisableAntialiasing: Boolean;
    @@ -1092,8 +1092,8 @@
         property RightMargin: Integer
           read fRightMargin write fRightMargin default 80;
         property EditorFont: String read fEditorFont write fEditorFont;
    -    property EditorFontHeight: Integer
    -      read fEditorFontHeight write FEditorFontHeight;
    +    property EditorFontSize: Integer
    +      read fEditorFontSize write fEditorFontSize;
         property ExtraCharSpacing: Integer
           read fExtraCharSpacing write fExtraCharSpacing default 0;
         property ExtraLineSpacing: Integer
    @@ -1254,6 +1254,16 @@
     var
       DefaultColorSchemeName: String;
     
    +function FontHeightToSize(Height: Integer): Integer;
    +var
    +  AFont: TFont;
    +begin
    +  AFont := TFont.Create;
    +  AFont.Height := Height;
    +  Result := AFont.Size;
    +  AFont.Free;
    +end;
    +
     { TSynEditMouseActionKeyCmdHelper }
     
     function TSynEditMouseActionKeyCmdHelper.GetOptionKeyCmd: TSynEditorCommand;
    @@ -3047,7 +3057,7 @@
     
       // Display options
       fEditorFont := SynDefaultFontName;
    -  fEditorFontHeight := SynDefaultFontHeight;
    +  fEditorFontSize := FontHeightToSize(SynDefaultFontHeight);
       fDisableAntialiasing := DefaultEditorDisableAntiAliasing;
     
       // Key Mappings
    @@ -3092,6 +3102,7 @@
       i: Integer;
       SynEditOpt2: TSynEditorOption2;
       FileVersion: LongInt;
    +  FontHeight: Integer;
     
     begin
       try
    @@ -3199,10 +3210,21 @@
           XMLConfig.GetValue('EditorOptions/Display/RightMargin', 80);
         fEditorFont  :=
           XMLConfig.GetValue('EditorOptions/Display/EditorFont', SynDefaultFontName);
    -    fEditorFontHeight :=
    +    // Try old EditorFontHeight first.
    +    FontHeight :=
           XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',
           SynDefaultFontHeight);
    -    RepairEditorFontHeight(fEditorFontHeight);
    +    if FontHeight = SynDefaultFontHeight then
    +    begin
    +      fEditorFontSize :=
    +        XMLConfig.GetValue('EditorOptions/Display/EditorFontSize',
    +        FontHeightToSize(SynDefaultFontHeight));
    +    end
    +    else
    +    begin
    +      RepairEditorFontHeight(FontHeight);
    +      fEditorFontSize := FontHeightToSize(FontHeight);
    +    end;
         fExtraCharSpacing :=
           XMLConfig.GetValue('EditorOptions/Display/ExtraCharSpacing', 0);
         fExtraLineSpacing :=
    @@ -3391,8 +3413,9 @@
           fRightMargin, 80);
         XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFont',
           fEditorFont, SynDefaultFontName);
    -    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontHeight'
    -      ,fEditorFontHeight, SynDefaultFontHeight);
    +    XMLConfig.DeleteValue('EditorOptions/Display/EditorFontHeight'); // unused old value
    +    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontSize'
    +      ,fEditorFontSize, FontHeightToSize(SynDefaultFontHeight));
         XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraCharSpacing'
           ,fExtraCharSpacing, 0);
         XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraLineSpacing'
    @@ -3921,7 +3944,7 @@
     
     procedure TEditorOptions.ApplyFontSettingsTo(ASynEdit: TSynEdit);
     begin
    -  ASynEdit.Font.Height := fEditorFontHeight;// set height before name for XLFD !
    +  ASynEdit.Font.Size := fEditorFontSize;// set size before name for XLFD !
       ASynEdit.Font.Name := fEditorFont;
       if fDisableAntialiasing then
         ASynEdit.Font.Quality := fqNonAntialiased
    Index: ide/lazarusidestrconsts.pas
    ===================================================================
    --- ide/lazarusidestrconsts.pas	(revision 31909)
    +++ ide/lazarusidestrconsts.pas	(working copy)
    @@ -1425,7 +1425,7 @@
       dlgGutterColor = 'Gutter Color';
       dlgEditorFont = 'Editor font';
       dlgDefaultEditorFont='Default editor font';
    -  dlgEditorFontHeight = 'Editor font height';
    +  dlgEditorFontSize = 'Editor font size';
       dlgExtraCharSpacing = 'Extra char spacing';
       dlgExtraLineSpacing = 'Extra line spacing';
       dlgDisableAntialiasing = 'Disable anti-aliasing';
    Index: ide/sourceeditor.pp
    ===================================================================
    --- ide/sourceeditor.pp	(revision 31909)
    +++ ide/sourceeditor.pp	(working copy)
    @@ -1728,7 +1728,7 @@
         if (Editor<>nil) then
           Font := Editor.Font
         else begin
    -      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name for XLFD !
    +      Font.Size:=EditorOpts.EditorFontSize; // set Size before name for XLFD !
           Font.Name:=EditorOpts.EditorFont;
         end;
         Font.Style:=[];
    @@ -1763,7 +1763,7 @@
         if (Editor<>nil) then
           Font:=Editor.Font
         else begin
    -      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name of XLFD !
    +      Font.Size:=EditorOpts.EditorFontSize; // set Size before name of XLFD !
           Font.Name:=EditorOpts.EditorFont;
         end;
         Font.Style:=[];
    Index: ide/frames/editor_display_options.pas
    ===================================================================
    --- ide/frames/editor_display_options.pas	(revision 31909)
    +++ ide/frames/editor_display_options.pas	(working copy)
    @@ -39,8 +39,8 @@
         EditorFontButton: TButton;
         EditorFontComboBox: TComboBox;
         EditorFontGroupBox: TGroupBox;
    -    EditorFontHeightComboBox: TComboBox;
    -    EditorFontHeightLabel: TLabel;
    +    EditorFontSizeSpinEdit: TSpinEdit;
    +    EditorFontSizeLabel: TLabel;
         ExtraCharSpacingComboBox: TComboBox;
         ExtraCharSpacingLabel: TLabel;
         ExtraLineSpacingComboBox: TComboBox;
    @@ -58,6 +58,7 @@
         VisibleRightMarginCheckBox: TCheckBox;
         procedure EditorFontButtonClick(Sender: TObject);
         procedure EditorFontComboBoxEditingDone(Sender: TObject);
    +    procedure EditorFontSizeSpinEditChange(Sender: TObject);
         procedure ComboboxOnExit(Sender: TObject);
         procedure ComboBoxOnKeyDown(Sender: TObject; var Key: Word;
           Shift: TShiftState);
    @@ -96,7 +97,7 @@
             PreviewEdits[a].Font.Assign(TFontDialog(Sender).Font);
     
       SetComboBoxText(EditorFontComboBox, DisplayPreview.Font.Name,cstCaseInsensitive);
    -  SetComboBoxText(EditorFontHeightComboBox, IntToStr(DisplayPreview.Font.Height),cstCaseInsensitive);
    +  EditorFontSizeSpinEdit.Value := DisplayPreview.Font.Size;
     end;
     
     function TEditorDisplayOptionsFrame.DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
    @@ -108,16 +109,13 @@
     procedure TEditorDisplayOptionsFrame.EditorFontButtonClick(Sender: TObject);
     var
       FontDialog: TFontDialog;
    -  NewHeight: LongInt;
     begin
       FontDialog := TFontDialog.Create(nil);
       try
         with FontDialog do
         begin
           Font.Name := EditorFontComboBox.Text;
    -      NewHeight := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
    -      RepairEditorFontHeight(NewHeight);
    -      Font.Height := NewHeight;
    +      Font.Size := EditorFontSizeSpinEdit.Value;
           Options := Options + [fdApplyButton];
           OnApplyClicked := @FontDialogApplyClicked;
           if Execute then
    @@ -138,21 +136,21 @@
             PreviewEdits[i].Font.Name := EditorFontComboBox.Text;
     end;
     
    +procedure TEditorDisplayOptionsFrame.EditorFontSizeSpinEditChange(Sender: TObject);
    +var
    +  NewVal, a: Integer;
    +begin
    +  NewVal := EditorFontSizeSpinEdit.Value;
    +  with GeneralPage do
    +    for a := Low(PreviewEdits) to High(PreviewEdits) do
    +      if PreviewEdits[a] <> nil then
    +        PreviewEdits[a].Font.Size := NewVal;
    +end;
    +
     procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
     var
       NewVal, a: Integer;
     begin
    -  if Sender = EditorFontHeightComboBox then
    -  begin
    -    NewVal := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
    -    RepairEditorFontHeight(NewVal);
    -    SetComboBoxText(EditorFontHeightComboBox, IntToStr(NewVal),cstCaseInsensitive);
    -    with GeneralPage do
    -      for a := Low(PreviewEdits) to High(PreviewEdits) do
    -        if PreviewEdits[a] <> nil then
    -          PreviewEdits[a].Font.Height := NewVal;
    -  end
    -  else
       if Sender = ExtraCharSpacingComboBox then
       begin
         NewVal := StrToIntDef(ExtraCharSpacingComboBox.Text, DisplayPreview.ExtraCharSpacing);
    @@ -296,7 +294,7 @@
       GutterSeparatorIndexLabel.Caption := dlgGutterSeparatorIndex;
       RightMarginLabel.Caption := dlgRightMargin;
       EditorFontGroupBox.Caption := dlgDefaultEditorFont;
    -  EditorFontHeightLabel.Caption := dlgEditorFontHeight;
    +  EditorFontSizeLabel.Caption := dlgEditorFontSize;
       ExtraCharSpacingLabel.Caption := dlgExtraCharSpacing;
       ExtraLineSpacingLabel.Caption := dlgExtraLineSpacing;
       DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
    @@ -320,7 +318,7 @@
         VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
         SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin),cstCaseInsensitive);
         SetComboBoxText(EditorFontComboBox, EditorFont,cstCaseInsensitive);
    -    SetComboBoxText(EditorFontHeightComboBox, IntToStr(EditorFontHeight),cstCaseInsensitive);
    +    EditorFontSizeSpinEdit.Value := EditorFontSize;
         SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing),cstCaseInsensitive);
         SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing),cstCaseInsensitive);
         DisableAntialiasingCheckBox.Checked := DisableAntialiasing;
    @@ -342,7 +340,7 @@
         VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
         RightMargin := StrToIntDef(RightMarginComboBox.Text, 80);
         EditorFont := EditorFontComboBox.Text;
    -    EditorFontHeight := StrToIntDef(EditorFontHeightComboBox.Text, EditorFontHeight);
    +    EditorFontSize := EditorFontSizeSpinEdit.Value;
         ExtraCharSpacing := StrToIntDef(ExtraCharSpacingComboBox.Text, ExtraCharSpacing);
         ExtraLineSpacing := StrToIntDef(ExtraLineSpacingComboBox.Text, ExtraLineSpacing);
         DisableAntialiasing := DisableAntialiasingCheckBox.Checked;
    Index: ide/frames/editor_display_options.lfm
    ===================================================================
    --- ide/frames/editor_display_options.lfm	(revision 31909)
    +++ ide/frames/editor_display_options.lfm	(working copy)
    @@ -167,27 +167,27 @@
       object EditorFontGroupBox: TGroupBox[1]
         AnchorSideRight.Side = asrBottom
         Left = 0
    -    Height = 105
    -    Top = 128
    +    Height = 133
    +    Top = 162
         Width = 501
         Align = alTop
         AutoSize = True
         BorderSpacing.Top = 6
         Caption = 'EditorFontGroupBox'
    -    ClientHeight = 87
    +    ClientHeight = 111
         ClientWidth = 497
         TabOrder = 1
    -    object EditorFontHeightLabel: TLabel
    -      AnchorSideLeft.Control = EditorFontHeightComboBox
    +    object EditorFontSizeLabel: TLabel
    +      AnchorSideLeft.Control = EditorFontSizeSpinEdit
           AnchorSideLeft.Side = asrBottom
    -      AnchorSideTop.Control = EditorFontHeightComboBox
    +      AnchorSideTop.Control = EditorFontSizeSpinEdit
           AnchorSideTop.Side = asrCenter
    -      Left = 112
    -      Height = 14
    -      Top = 36
    -      Width = 107
    +      Left = 62
    +      Height = 22
    +      Top = 44
    +      Width = 136
           BorderSpacing.Around = 6
    -      Caption = 'EditorFontHeightLabel'
    +      Caption = 'EditorFontSizeLabel'
           ParentColor = False
         end
         object ExtraLineSpacingLabel: TLabel
    @@ -195,10 +195,10 @@
           AnchorSideLeft.Side = asrBottom
           AnchorSideTop.Control = ExtraLineSpacingComboBox
           AnchorSideTop.Side = asrCenter
    -      Left = 351
    -      Height = 14
    -      Top = 36
    -      Width = 108
    +      Left = 330
    +      Height = 22
    +      Top = 44
    +      Width = 155
           BorderSpacing.Around = 6
           Caption = 'ExtraLineSpacingLabel'
           ParentColor = False
    @@ -208,10 +208,10 @@
           AnchorSideLeft.Side = asrBottom
           AnchorSideTop.Control = ExtraCharSpacingComboBox
           AnchorSideTop.Side = asrCenter
    -      Left = 351
    -      Height = 14
    -      Top = 63
    -      Width = 112
    +      Left = 330
    +      Height = 22
    +      Top = 79
    +      Width = 157
           BorderSpacing.Around = 6
           Caption = 'ExtraCharSpacingLabel'
           ParentColor = False
    @@ -221,13 +221,13 @@
           AnchorSideTop.Control = EditorFontGroupBox
           AnchorSideRight.Control = EditorFontButton
           Left = 6
    -      Height = 21
    +      Height = 29
           Top = 6
           Width = 460
           Anchors = [akTop, akLeft, akRight]
           BorderSpacing.Left = 6
           BorderSpacing.Top = 6
    -      ItemHeight = 13
    +      ItemHeight = 21
           OnEditingDone = EditorFontComboBoxEditingDone
           TabOrder = 0
           Text = 'EditorFontComboBox'
    @@ -239,7 +239,7 @@
           AnchorSideBottom.Control = EditorFontComboBox
           AnchorSideBottom.Side = asrBottom
           Left = 466
    -      Height = 21
    +      Height = 29
           Top = 6
           Width = 25
           Anchors = [akTop, akRight, akBottom]
    @@ -248,44 +248,32 @@
           OnClick = EditorFontButtonClick
           TabOrder = 1
         end
    -    object EditorFontHeightComboBox: TComboBox
    +    object EditorFontSizeSpinEdit: TSpinEdit
           AnchorSideLeft.Control = EditorFontGroupBox
           AnchorSideTop.Control = EditorFontComboBox
           AnchorSideTop.Side = asrBottom
           Left = 6
    -      Height = 21
    -      Top = 33
    -      Width = 100
    +      Height = 29
    +      Top = 41
    +      Width = 50
           BorderSpacing.Around = 6
    -      ItemHeight = 13
    -      Items.Strings = (
    -        '10'
    -        '11'
    -        '12'
    -        '13'
    -        '14'
    -        '15'
    -        '16'
    -        '17'
    -        '18'
    -      )
    -      OnChange = ComboboxOnChange
    -      OnExit = ComboboxOnExit
    -      OnKeyDown = ComboBoxOnKeyDown
    +      MinValue = 5
    +      OnChange = EditorFontSizeSpinEditChange
           TabOrder = 2
    +      Value = 5
         end
         object ExtraLineSpacingComboBox: TComboBox
    -      AnchorSideLeft.Control = EditorFontHeightLabel
    +      AnchorSideLeft.Control = EditorFontSizeLabel
           AnchorSideLeft.Side = asrBottom
           AnchorSideTop.Control = EditorFontComboBox
           AnchorSideTop.Side = asrBottom
    -      Left = 245
    -      Height = 21
    -      Top = 33
    +      Left = 224
    +      Height = 29
    +      Top = 41
           Width = 100
           BorderSpacing.Left = 20
           BorderSpacing.Around = 6
    -      ItemHeight = 13
    +      ItemHeight = 21
           Items.Strings = (
             '0'
             '1'
    @@ -300,12 +288,12 @@
           AnchorSideLeft.Control = ExtraLineSpacingComboBox
           AnchorSideTop.Control = ExtraLineSpacingComboBox
           AnchorSideTop.Side = asrBottom
    -      Left = 245
    -      Height = 21
    -      Top = 60
    +      Left = 224
    +      Height = 29
    +      Top = 76
           Width = 100
           BorderSpacing.Bottom = 6
    -      ItemHeight = 13
    +      ItemHeight = 21
           Items.Strings = (
             '0'
             '1'
    @@ -318,12 +306,12 @@
         end
         object DisableAntialiasingCheckBox: TCheckBox
           AnchorSideLeft.Control = EditorFontGroupBox
    -      AnchorSideTop.Control = EditorFontHeightComboBox
    +      AnchorSideTop.Control = EditorFontSizeSpinEdit
           AnchorSideTop.Side = asrBottom
           Left = 6
    -      Height = 21
    -      Top = 60
    -      Width = 153
    +      Height = 29
    +      Top = 76
    +      Width = 223
           Anchors = [akTop, akLeft, akBottom]
           BorderSpacing.Around = 6
           Caption = 'DisableAntialiasingCheckBox'
    
    editorfontsize.diff (15,756 bytes)
  • convert_size_sample.tar.bz2 (1,915 bytes)
  • editorfontsize2.diff (19,231 bytes)
    Index: components/synedit/synedit.pp
    ===================================================================
    --- components/synedit/synedit.pp	(revision 32083)
    +++ components/synedit/synedit.pp	(working copy)
    @@ -98,6 +98,7 @@
       // SynDefaultFont is determined in InitSynDefaultFont()
       SynDefaultFontName:    String       = '';
       SynDefaultFontHeight:  Integer      = 13;
    +  SynDefaultFontSize:    Integer      = 10;
       SynDefaultFontPitch:   TFontPitch   = fpFixed;
       SynDefaultFontQuality: TFontQuality = fqNonAntialiased;
     
    Index: debugger/assemblerdlg.pp
    ===================================================================
    --- debugger/assemblerdlg.pp	(revision 32083)
    +++ debugger/assemblerdlg.pp	(working copy)
    @@ -217,7 +217,7 @@
       Caption := lisDisAssAssembler;
     
       EditorOpts.AddHandlerAfterWrite(@DoEditorOptsChanged);
    -  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
    +  pbAsm.Font.Size := EditorOpts.EditorFontSize;
       pbAsm.Font.Name := EditorOpts.EditorFont;
       Caption := lisMenuViewAssembler;
       CopyToClipboard.Caption := lisDbgAsmCopyToClipboard;
    @@ -679,7 +679,7 @@
     var
       TM: TTextMetric;
     begin
    -  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
    +  pbAsm.Font.Size := EditorOpts.EditorFontSize;
       pbAsm.Font.Name := EditorOpts.EditorFont;
       if EditorOpts.DisableAntialiasing then
         pbAsm.Font.Quality := fqNonAntialiased
    Index: ide/editoroptions.pp
    ===================================================================
    --- ide/editoroptions.pp	(revision 32083)
    +++ ide/editoroptions.pp	(working copy)
    @@ -957,7 +957,7 @@
         FGutterSeparatorIndex: Integer;
         fRightMargin: Integer;
         fEditorFont:  String;
    -    fEditorFontHeight: Integer;
    +    fEditorFontSize:   Integer;
         fExtraCharSpacing: Integer;
         fExtraLineSpacing: Integer;
         fDisableAntialiasing: Boolean;
    @@ -1092,8 +1092,8 @@
         property RightMargin: Integer
           read fRightMargin write fRightMargin default 80;
         property EditorFont: String read fEditorFont write fEditorFont;
    -    property EditorFontHeight: Integer
    -      read fEditorFontHeight write FEditorFontHeight;
    +    property EditorFontSize: Integer
    +      read fEditorFontSize write fEditorFontSize;
         property ExtraCharSpacing: Integer
           read fExtraCharSpacing write fExtraCharSpacing default 0;
         property ExtraLineSpacing: Integer
    @@ -1210,7 +1210,7 @@
     function StrToLazSyntaxHighlighter(const s: String): TLazSyntaxHighlighter;
     function ExtensionToLazSyntaxHighlighter(Ext: String): TLazSyntaxHighlighter;
     function FilenameToLazSyntaxHighlighter(Filename: String): TLazSyntaxHighlighter;
    -procedure RepairEditorFontHeight(var FontHeight: integer);
    +procedure RepairEditorFontSize(var FontSize: integer);
     
     function BuildBorlandDCIFile(ACustomSynAutoComplete: TCustomSynAutoComplete): Boolean;
     function ColorSchemeFactory: TColorSchemeFactory;
    @@ -1254,6 +1254,16 @@
     var
       DefaultColorSchemeName: String;
     
    +function FontHeightToSize(Height: Integer): Integer;
    +var
    +  AFont: TFont;
    +begin
    +  AFont := TFont.Create;
    +  AFont.Height := Height;
    +  Result := AFont.Size;
    +  AFont.Free;
    +end;
    +
     { TSynEditMouseActionKeyCmdHelper }
     
     function TSynEditMouseActionKeyCmdHelper.GetOptionKeyCmd: TSynEditorCommand;
    @@ -1268,11 +1278,11 @@
     end;
     
     
    -procedure RepairEditorFontHeight(var FontHeight: integer);
    +procedure RepairEditorFontSize(var FontSize: integer);
     begin
    -  if ((FontHeight>=0) and (FontHeight<=5))
    -  or ((FontHeight<0) and (FontHeight>=-5)) then
    -    FontHeight := SynDefaultFontHeight;
    +  if ((FontSize>=0) and (FontSize<=5))
    +  or ((FontSize<0) and (FontSize>=-5)) then
    +    FontSize := SynDefaultFontSize;
     end;
     
     function StrToLazSyntaxHighlighter(const s: String): TLazSyntaxHighlighter;
    @@ -3047,7 +3057,7 @@
     
       // Display options
       fEditorFont := SynDefaultFontName;
    -  fEditorFontHeight := SynDefaultFontHeight;
    +  fEditorFontSize := SynDefaultFontSize;
       fDisableAntialiasing := DefaultEditorDisableAntiAliasing;
     
       // Key Mappings
    @@ -3092,6 +3102,7 @@
       i: Integer;
       SynEditOpt2: TSynEditorOption2;
       FileVersion: LongInt;
    +  FontHeight: Integer;
     
     begin
       try
    @@ -3199,10 +3210,21 @@
           XMLConfig.GetValue('EditorOptions/Display/RightMargin', 80);
         fEditorFont  :=
           XMLConfig.GetValue('EditorOptions/Display/EditorFont', SynDefaultFontName);
    -    fEditorFontHeight :=
    +    // Try old EditorFontHeight first.
    +    FontHeight :=
           XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',
           SynDefaultFontHeight);
    -    RepairEditorFontHeight(fEditorFontHeight);
    +    if FontHeight = SynDefaultFontHeight then
    +    begin
    +      fEditorFontSize :=
    +        XMLConfig.GetValue('EditorOptions/Display/EditorFontSize',
    +        SynDefaultFontSize);
    +    end
    +    else
    +    begin
    +      fEditorFontSize := FontHeightToSize(FontHeight);
    +    end;
    +    RepairEditorFontSize(fEditorFontSize);
         fExtraCharSpacing :=
           XMLConfig.GetValue('EditorOptions/Display/ExtraCharSpacing', 0);
         fExtraLineSpacing :=
    @@ -3391,8 +3413,9 @@
           fRightMargin, 80);
         XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFont',
           fEditorFont, SynDefaultFontName);
    -    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontHeight'
    -      ,fEditorFontHeight, SynDefaultFontHeight);
    +    XMLConfig.DeleteValue('EditorOptions/Display/EditorFontHeight'); // unused old value
    +    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontSize'
    +      ,fEditorFontSize, SynDefaultFontSize);
         XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraCharSpacing'
           ,fExtraCharSpacing, 0);
         XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraLineSpacing'
    @@ -3922,7 +3945,7 @@
     
     procedure TEditorOptions.ApplyFontSettingsTo(ASynEdit: TSynEdit);
     begin
    -  ASynEdit.Font.Height := fEditorFontHeight;// set height before name for XLFD !
    +  ASynEdit.Font.Size := fEditorFontSize;// set size before name for XLFD !
       ASynEdit.Font.Name := fEditorFont;
       if fDisableAntialiasing then
         ASynEdit.Font.Quality := fqNonAntialiased
    Index: ide/lazarusidestrconsts.pas
    ===================================================================
    --- ide/lazarusidestrconsts.pas	(revision 32083)
    +++ ide/lazarusidestrconsts.pas	(working copy)
    @@ -1427,7 +1427,7 @@
       dlgGutterColor = 'Gutter Color';
       dlgEditorFont = 'Editor font';
       dlgDefaultEditorFont='Default editor font';
    -  dlgEditorFontHeight = 'Editor font height';
    +  dlgEditorFontSize = 'Editor font size';
       dlgExtraCharSpacing = 'Extra char spacing';
       dlgExtraLineSpacing = 'Extra line spacing';
       dlgDisableAntialiasing = 'Disable anti-aliasing';
    Index: ide/sourceeditor.pp
    ===================================================================
    --- ide/sourceeditor.pp	(revision 32083)
    +++ ide/sourceeditor.pp	(working copy)
    @@ -1728,7 +1728,7 @@
         if (Editor<>nil) then
           Font := Editor.Font
         else begin
    -      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name for XLFD !
    +      Font.Size:=EditorOpts.EditorFontSize; // set Size before name for XLFD !
           Font.Name:=EditorOpts.EditorFont;
         end;
         Font.Style:=[];
    @@ -1763,7 +1763,7 @@
         if (Editor<>nil) then
           Font:=Editor.Font
         else begin
    -      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name of XLFD !
    +      Font.Size:=EditorOpts.EditorFontSize; // set Size before name of XLFD !
           Font.Name:=EditorOpts.EditorFont;
         end;
         Font.Style:=[];
    Index: ide/frames/editor_display_options.pas
    ===================================================================
    --- ide/frames/editor_display_options.pas	(revision 32083)
    +++ ide/frames/editor_display_options.pas	(working copy)
    @@ -39,8 +39,8 @@
         EditorFontButton: TButton;
         EditorFontComboBox: TComboBox;
         EditorFontGroupBox: TGroupBox;
    -    EditorFontHeightComboBox: TComboBox;
    -    EditorFontHeightLabel: TLabel;
    +    EditorFontSizeSpinEdit: TSpinEdit;
    +    EditorFontSizeLabel: TLabel;
         ExtraCharSpacingComboBox: TComboBox;
         ExtraCharSpacingLabel: TLabel;
         ExtraLineSpacingComboBox: TComboBox;
    @@ -58,6 +58,7 @@
         VisibleRightMarginCheckBox: TCheckBox;
         procedure EditorFontButtonClick(Sender: TObject);
         procedure EditorFontComboBoxEditingDone(Sender: TObject);
    +    procedure EditorFontSizeSpinEditChange(Sender: TObject);
         procedure ComboboxOnExit(Sender: TObject);
         procedure ComboBoxOnKeyDown(Sender: TObject; var Key: Word;
           Shift: TShiftState);
    @@ -69,7 +70,9 @@
         procedure ShowLineNumbersCheckBoxClick(Sender: TObject);
       private
         FDialog: TAbstractOptionsEditorDialog;
    +    function FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
         function GeneralPage: TEditorGeneralOptionsFrame; inline;
    +    procedure SetEditorFontSizeSpinEditValue(FontSize: Integer);
     
         procedure FontDialogApplyClicked(Sender: TObject);
         function DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
    @@ -86,6 +89,18 @@
     
     {$R *.lfm}
     
    +uses
    +  LCLIntf;
    +
    +function TEditorDisplayOptionsFrame.FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
    +var
    +  tm: TTextMetric;
    +begin
    +  DisplayPreview.Canvas.Font.Assign(DisplayPreview.Font);
    +  LCLIntf.GetTextMetrics(DisplayPreview.Canvas.Handle, tm);
    +  Result := -(NegativeSize + MulDiv(tm.tmInternalLeading, 72, DisplayPreview.Font.PixelsPerInch));
    +end;
    +
     procedure TEditorDisplayOptionsFrame.FontDialogApplyClicked(Sender: TObject);
     var
       a: Integer;
    @@ -96,7 +111,7 @@
             PreviewEdits[a].Font.Assign(TFontDialog(Sender).Font);
     
       SetComboBoxText(EditorFontComboBox, DisplayPreview.Font.Name,cstCaseInsensitive);
    -  SetComboBoxText(EditorFontHeightComboBox, IntToStr(DisplayPreview.Font.Height),cstCaseInsensitive);
    +  SetEditorFontSizeSpinEditValue(DisplayPreview.Font.Size);
     end;
     
     function TEditorDisplayOptionsFrame.DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
    @@ -108,16 +123,20 @@
     procedure TEditorDisplayOptionsFrame.EditorFontButtonClick(Sender: TObject);
     var
       FontDialog: TFontDialog;
    -  NewHeight: LongInt;
    +  CurFontSize: Integer;
     begin
       FontDialog := TFontDialog.Create(nil);
       try
         with FontDialog do
         begin
           Font.Name := EditorFontComboBox.Text;
    -      NewHeight := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
    -      RepairEditorFontHeight(NewHeight);
    -      Font.Height := NewHeight;
    +      CurFontSize := EditorFontSizeSpinEdit.Value;
    +      if CurFontSize < 0 then
    +      begin
    +        CurFontSize := FontSizeNegativeToPositive(CurFontSize);
    +        RepairEditorFontSize(CurFontSize);
    +      end;
    +      Font.Size := CurFontSize;
           Options := Options + [fdApplyButton];
           OnApplyClicked := @FontDialogApplyClicked;
           if Execute then
    @@ -138,21 +157,21 @@
             PreviewEdits[i].Font.Name := EditorFontComboBox.Text;
     end;
     
    +procedure TEditorDisplayOptionsFrame.EditorFontSizeSpinEditChange(Sender: TObject);
    +var
    +  NewVal, a: Integer;
    +begin
    +  NewVal := EditorFontSizeSpinEdit.Value;
    +  with GeneralPage do
    +    for a := Low(PreviewEdits) to High(PreviewEdits) do
    +      if PreviewEdits[a] <> nil then
    +        PreviewEdits[a].Font.Size := NewVal;
    +end;
    +
     procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
     var
       NewVal, a: Integer;
     begin
    -  if Sender = EditorFontHeightComboBox then
    -  begin
    -    NewVal := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
    -    RepairEditorFontHeight(NewVal);
    -    SetComboBoxText(EditorFontHeightComboBox, IntToStr(NewVal),cstCaseInsensitive);
    -    with GeneralPage do
    -      for a := Low(PreviewEdits) to High(PreviewEdits) do
    -        if PreviewEdits[a] <> nil then
    -          PreviewEdits[a].Font.Height := NewVal;
    -  end
    -  else
       if Sender = ExtraCharSpacingComboBox then
       begin
         NewVal := StrToIntDef(ExtraCharSpacingComboBox.Text, DisplayPreview.ExtraCharSpacing);
    @@ -277,6 +296,15 @@
       Result := TEditorGeneralOptionsFrame(FDialog.FindEditor(TEditorGeneralOptionsFrame));
     end;
     
    +procedure TEditorDisplayOptionsFrame.SetEditorFontSizeSpinEditValue(FontSize: Integer);
    +begin
    +  if FontSize < 0 then
    +    EditorFontSizeSpinEdit.MinValue := -100
    +  else
    +    EditorFontSizeSpinEdit.MinValue := 5;
    +  EditorFontSizeSpinEdit.Value := FontSize;
    +end;
    +
     function TEditorDisplayOptionsFrame.GetTitle: String;
     begin
       Result := dlgEdDisplay;
    @@ -296,7 +324,7 @@
       GutterSeparatorIndexLabel.Caption := dlgGutterSeparatorIndex;
       RightMarginLabel.Caption := dlgRightMargin;
       EditorFontGroupBox.Caption := dlgDefaultEditorFont;
    -  EditorFontHeightLabel.Caption := dlgEditorFontHeight;
    +  EditorFontSizeLabel.Caption := dlgEditorFontSize;
       ExtraCharSpacingLabel.Caption := dlgExtraCharSpacing;
       ExtraLineSpacingLabel.Caption := dlgExtraLineSpacing;
       DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
    @@ -320,7 +348,7 @@
         VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
         SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin),cstCaseInsensitive);
         SetComboBoxText(EditorFontComboBox, EditorFont,cstCaseInsensitive);
    -    SetComboBoxText(EditorFontHeightComboBox, IntToStr(EditorFontHeight),cstCaseInsensitive);
    +    SetEditorFontSizeSpinEditValue(EditorFontSize);
         SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing),cstCaseInsensitive);
         SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing),cstCaseInsensitive);
         DisableAntialiasingCheckBox.Checked := DisableAntialiasing;
    @@ -342,7 +370,7 @@
         VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
         RightMargin := StrToIntDef(RightMarginComboBox.Text, 80);
         EditorFont := EditorFontComboBox.Text;
    -    EditorFontHeight := StrToIntDef(EditorFontHeightComboBox.Text, EditorFontHeight);
    +    EditorFontSize := EditorFontSizeSpinEdit.Value;
         ExtraCharSpacing := StrToIntDef(ExtraCharSpacingComboBox.Text, ExtraCharSpacing);
         ExtraLineSpacing := StrToIntDef(ExtraLineSpacingComboBox.Text, ExtraLineSpacing);
         DisableAntialiasing := DisableAntialiasingCheckBox.Checked;
    Index: ide/frames/editor_display_options.lfm
    ===================================================================
    --- ide/frames/editor_display_options.lfm	(revision 32083)
    +++ ide/frames/editor_display_options.lfm	(working copy)
    @@ -167,27 +167,27 @@
       object EditorFontGroupBox: TGroupBox[1]
         AnchorSideRight.Side = asrBottom
         Left = 0
    -    Height = 105
    -    Top = 128
    +    Height = 133
    +    Top = 162
         Width = 501
         Align = alTop
         AutoSize = True
         BorderSpacing.Top = 6
         Caption = 'EditorFontGroupBox'
    -    ClientHeight = 87
    +    ClientHeight = 111
         ClientWidth = 497
         TabOrder = 1
    -    object EditorFontHeightLabel: TLabel
    -      AnchorSideLeft.Control = EditorFontHeightComboBox
    +    object EditorFontSizeLabel: TLabel
    +      AnchorSideLeft.Control = EditorFontSizeSpinEdit
           AnchorSideLeft.Side = asrBottom
    -      AnchorSideTop.Control = EditorFontHeightComboBox
    +      AnchorSideTop.Control = EditorFontSizeSpinEdit
           AnchorSideTop.Side = asrCenter
    -      Left = 112
    -      Height = 14
    -      Top = 36
    -      Width = 107
    +      Left = 62
    +      Height = 22
    +      Top = 44
    +      Width = 136
           BorderSpacing.Around = 6
    -      Caption = 'EditorFontHeightLabel'
    +      Caption = 'EditorFontSizeLabel'
           ParentColor = False
         end
         object ExtraLineSpacingLabel: TLabel
    @@ -195,10 +195,10 @@
           AnchorSideLeft.Side = asrBottom
           AnchorSideTop.Control = ExtraLineSpacingComboBox
           AnchorSideTop.Side = asrCenter
    -      Left = 351
    -      Height = 14
    -      Top = 36
    -      Width = 108
    +      Left = 330
    +      Height = 22
    +      Top = 44
    +      Width = 155
           BorderSpacing.Around = 6
           Caption = 'ExtraLineSpacingLabel'
           ParentColor = False
    @@ -208,10 +208,10 @@
           AnchorSideLeft.Side = asrBottom
           AnchorSideTop.Control = ExtraCharSpacingComboBox
           AnchorSideTop.Side = asrCenter
    -      Left = 351
    -      Height = 14
    -      Top = 63
    -      Width = 112
    +      Left = 330
    +      Height = 22
    +      Top = 79
    +      Width = 157
           BorderSpacing.Around = 6
           Caption = 'ExtraCharSpacingLabel'
           ParentColor = False
    @@ -221,13 +221,13 @@
           AnchorSideTop.Control = EditorFontGroupBox
           AnchorSideRight.Control = EditorFontButton
           Left = 6
    -      Height = 21
    +      Height = 29
           Top = 6
           Width = 460
           Anchors = [akTop, akLeft, akRight]
           BorderSpacing.Left = 6
           BorderSpacing.Top = 6
    -      ItemHeight = 13
    +      ItemHeight = 21
           OnEditingDone = EditorFontComboBoxEditingDone
           TabOrder = 0
           Text = 'EditorFontComboBox'
    @@ -239,7 +239,7 @@
           AnchorSideBottom.Control = EditorFontComboBox
           AnchorSideBottom.Side = asrBottom
           Left = 466
    -      Height = 21
    +      Height = 29
           Top = 6
           Width = 25
           Anchors = [akTop, akRight, akBottom]
    @@ -248,44 +248,30 @@
           OnClick = EditorFontButtonClick
           TabOrder = 1
         end
    -    object EditorFontHeightComboBox: TComboBox
    +    object EditorFontSizeSpinEdit: TSpinEdit
           AnchorSideLeft.Control = EditorFontGroupBox
           AnchorSideTop.Control = EditorFontComboBox
           AnchorSideTop.Side = asrBottom
           Left = 6
    -      Height = 21
    -      Top = 33
    -      Width = 100
    +      Height = 29
    +      Top = 41
    +      Width = 50
           BorderSpacing.Around = 6
    -      ItemHeight = 13
    -      Items.Strings = (
    -        '10'
    -        '11'
    -        '12'
    -        '13'
    -        '14'
    -        '15'
    -        '16'
    -        '17'
    -        '18'
    -      )
    -      OnChange = ComboboxOnChange
    -      OnExit = ComboboxOnExit
    -      OnKeyDown = ComboBoxOnKeyDown
    +      OnChange = EditorFontSizeSpinEditChange
           TabOrder = 2
         end
         object ExtraLineSpacingComboBox: TComboBox
    -      AnchorSideLeft.Control = EditorFontHeightLabel
    +      AnchorSideLeft.Control = EditorFontSizeLabel
           AnchorSideLeft.Side = asrBottom
           AnchorSideTop.Control = EditorFontComboBox
           AnchorSideTop.Side = asrBottom
    -      Left = 245
    -      Height = 21
    -      Top = 33
    +      Left = 224
    +      Height = 29
    +      Top = 41
           Width = 100
           BorderSpacing.Left = 20
           BorderSpacing.Around = 6
    -      ItemHeight = 13
    +      ItemHeight = 21
           Items.Strings = (
             '0'
             '1'
    @@ -300,12 +286,12 @@
           AnchorSideLeft.Control = ExtraLineSpacingComboBox
           AnchorSideTop.Control = ExtraLineSpacingComboBox
           AnchorSideTop.Side = asrBottom
    -      Left = 245
    -      Height = 21
    -      Top = 60
    +      Left = 224
    +      Height = 29
    +      Top = 76
           Width = 100
           BorderSpacing.Bottom = 6
    -      ItemHeight = 13
    +      ItemHeight = 21
           Items.Strings = (
             '0'
             '1'
    @@ -318,12 +304,12 @@
         end
         object DisableAntialiasingCheckBox: TCheckBox
           AnchorSideLeft.Control = EditorFontGroupBox
    -      AnchorSideTop.Control = EditorFontHeightComboBox
    +      AnchorSideTop.Control = EditorFontSizeSpinEdit
           AnchorSideTop.Side = asrBottom
           Left = 6
    -      Height = 21
    -      Top = 60
    -      Width = 153
    +      Height = 29
    +      Top = 76
    +      Width = 223
           Anchors = [akTop, akLeft, akBottom]
           BorderSpacing.Around = 6
           Caption = 'DisableAntialiasingCheckBox'
    
    editorfontsize2.diff (19,231 bytes)
  • editorfontsize3.diff (18,153 bytes)
    Index: components/synedit/synedit.pp
    ===================================================================
    --- components/synedit/synedit.pp	(revision 32127)
    +++ components/synedit/synedit.pp	(working copy)
    @@ -98,6 +98,7 @@
       // SynDefaultFont is determined in InitSynDefaultFont()
       SynDefaultFontName:    String       = '';
       SynDefaultFontHeight:  Integer      = 13;
    +  SynDefaultFontSize:    Integer      = 10;
       SynDefaultFontPitch:   TFontPitch   = fpFixed;
       SynDefaultFontQuality: TFontQuality = fqNonAntialiased;
     
    Index: debugger/assemblerdlg.pp
    ===================================================================
    --- debugger/assemblerdlg.pp	(revision 32127)
    +++ debugger/assemblerdlg.pp	(working copy)
    @@ -217,7 +217,7 @@
       Caption := lisDisAssAssembler;
     
       EditorOpts.AddHandlerAfterWrite(@DoEditorOptsChanged);
    -  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
    +  pbAsm.Font.Size := EditorOpts.EditorFontSize;
       pbAsm.Font.Name := EditorOpts.EditorFont;
       Caption := lisMenuViewAssembler;
       CopyToClipboard.Caption := lisDbgAsmCopyToClipboard;
    @@ -679,7 +679,7 @@
     var
       TM: TTextMetric;
     begin
    -  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
    +  pbAsm.Font.Size := EditorOpts.EditorFontSize;
       pbAsm.Font.Name := EditorOpts.EditorFont;
       if EditorOpts.DisableAntialiasing then
         pbAsm.Font.Quality := fqNonAntialiased
    Index: ide/editoroptions.pp
    ===================================================================
    --- ide/editoroptions.pp	(revision 32127)
    +++ ide/editoroptions.pp	(working copy)
    @@ -570,13 +570,15 @@
         );
     
     const
    -  EditorOptsFormatVersion = 7;
    +  EditorOptsFormatVersion = 8;
       { * Changes in Version 6:
            - ColorSchemes now have a Global settings part.
              Language specific changes must save UseSchemeGlobals=False (Default is true)
              Since Version 5 did not have this setting, in Version 5 the default is false.
         * Changes in Version 7:
              DisableAntialiasing default true to false
    +    * Changes in Version 8:
    +         Replaced EditorFontHeight with EditorFontSize.
       }
     
       LazSyntaxHighlighterClasses: array[TLazSyntaxHighlighter] of
    @@ -615,6 +617,8 @@
                                                       + [eoHalfPageScroll];
       SynEditDefaultOptions2 = SYNEDIT_DEFAULT_OPTIONS2;
     
    +  EditorOptionsMinimumFontSize = 5;
    +
     type
       { TEditOptLanguageInfo stores lazarus IDE additional information
         of a highlighter, such as samplesource, which sample lines are special
    @@ -957,7 +961,7 @@
         FGutterSeparatorIndex: Integer;
         fRightMargin: Integer;
         fEditorFont:  String;
    -    fEditorFontHeight: Integer;
    +    fEditorFontSize:   Integer;
         fExtraCharSpacing: Integer;
         fExtraLineSpacing: Integer;
         fDisableAntialiasing: Boolean;
    @@ -1092,8 +1096,8 @@
         property RightMargin: Integer
           read fRightMargin write fRightMargin default 80;
         property EditorFont: String read fEditorFont write fEditorFont;
    -    property EditorFontHeight: Integer
    -      read fEditorFontHeight write FEditorFontHeight;
    +    property EditorFontSize: Integer
    +      read fEditorFontSize write fEditorFontSize;
         property ExtraCharSpacing: Integer
           read fExtraCharSpacing write fExtraCharSpacing default 0;
         property ExtraLineSpacing: Integer
    @@ -1210,7 +1214,7 @@
     function StrToLazSyntaxHighlighter(const s: String): TLazSyntaxHighlighter;
     function ExtensionToLazSyntaxHighlighter(Ext: String): TLazSyntaxHighlighter;
     function FilenameToLazSyntaxHighlighter(Filename: String): TLazSyntaxHighlighter;
    -procedure RepairEditorFontHeight(var FontHeight: integer);
    +procedure RepairEditorFontSize(var FontSize: integer);
     
     function BuildBorlandDCIFile(ACustomSynAutoComplete: TCustomSynAutoComplete): Boolean;
     function ColorSchemeFactory: TColorSchemeFactory;
    @@ -1254,6 +1258,16 @@
     var
       DefaultColorSchemeName: String;
     
    +function FontHeightToSize(Height: Integer): Integer;
    +var
    +  AFont: TFont;
    +begin
    +  AFont := TFont.Create;
    +  AFont.Height := Height;
    +  Result := AFont.Size;
    +  AFont.Free;
    +end;
    +
     { TSynEditMouseActionKeyCmdHelper }
     
     function TSynEditMouseActionKeyCmdHelper.GetOptionKeyCmd: TSynEditorCommand;
    @@ -1268,11 +1282,11 @@
     end;
     
     
    -procedure RepairEditorFontHeight(var FontHeight: integer);
    +procedure RepairEditorFontSize(var FontSize: integer);
     begin
    -  if ((FontHeight>=0) and (FontHeight<=5))
    -  or ((FontHeight<0) and (FontHeight>=-5)) then
    -    FontHeight := SynDefaultFontHeight;
    +  if ((FontSize>=0) and (FontSize<=EditorOptionsMinimumFontSize))
    +  or ((FontSize<0) and (FontSize>=-EditorOptionsMinimumFontSize)) then
    +    FontSize := SynDefaultFontSize;
     end;
     
     function StrToLazSyntaxHighlighter(const s: String): TLazSyntaxHighlighter;
    @@ -3047,7 +3061,7 @@
     
       // Display options
       fEditorFont := SynDefaultFontName;
    -  fEditorFontHeight := SynDefaultFontHeight;
    +  fEditorFontSize := SynDefaultFontSize;
       fDisableAntialiasing := DefaultEditorDisableAntiAliasing;
     
       // Key Mappings
    @@ -3199,10 +3213,17 @@
           XMLConfig.GetValue('EditorOptions/Display/RightMargin', 80);
         fEditorFont  :=
           XMLConfig.GetValue('EditorOptions/Display/EditorFont', SynDefaultFontName);
    -    fEditorFontHeight :=
    -      XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',
    -      SynDefaultFontHeight);
    -    RepairEditorFontHeight(fEditorFontHeight);
    +    if FileVersion < 8 then begin
    +      fEditorFontSize :=
    +        XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',
    +        SynDefaultFontHeight);
    +      fEditorFontSize := FontHeightToSize(fEditorFontSize);
    +    end else begin
    +      fEditorFontSize :=
    +        XMLConfig.GetValue('EditorOptions/Display/EditorFontSize',
    +        SynDefaultFontSize);
    +    end;
    +    RepairEditorFontSize(fEditorFontSize);
         fExtraCharSpacing :=
           XMLConfig.GetValue('EditorOptions/Display/ExtraCharSpacing', 0);
         fExtraLineSpacing :=
    @@ -3391,8 +3412,9 @@
           fRightMargin, 80);
         XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFont',
           fEditorFont, SynDefaultFontName);
    -    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontHeight'
    -      ,fEditorFontHeight, SynDefaultFontHeight);
    +    XMLConfig.DeleteValue('EditorOptions/Display/EditorFontHeight'); // unused old value
    +    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontSize'
    +      ,fEditorFontSize, SynDefaultFontSize);
         XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraCharSpacing'
           ,fExtraCharSpacing, 0);
         XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraLineSpacing'
    @@ -3922,7 +3944,7 @@
     
     procedure TEditorOptions.ApplyFontSettingsTo(ASynEdit: TSynEdit);
     begin
    -  ASynEdit.Font.Height := fEditorFontHeight;// set height before name for XLFD !
    +  ASynEdit.Font.Size := fEditorFontSize;// set size before name for XLFD !
       ASynEdit.Font.Name := fEditorFont;
       if fDisableAntialiasing then
         ASynEdit.Font.Quality := fqNonAntialiased
    Index: ide/lazarusidestrconsts.pas
    ===================================================================
    --- ide/lazarusidestrconsts.pas	(revision 32127)
    +++ ide/lazarusidestrconsts.pas	(working copy)
    @@ -1427,7 +1427,7 @@
       dlgGutterColor = 'Gutter Color';
       dlgEditorFont = 'Editor font';
       dlgDefaultEditorFont='Default editor font';
    -  dlgEditorFontHeight = 'Editor font height';
    +  dlgEditorFontSize = 'Editor font size';
       dlgExtraCharSpacing = 'Extra char spacing';
       dlgExtraLineSpacing = 'Extra line spacing';
       dlgDisableAntialiasing = 'Disable anti-aliasing';
    Index: ide/sourceeditor.pp
    ===================================================================
    --- ide/sourceeditor.pp	(revision 32127)
    +++ ide/sourceeditor.pp	(working copy)
    @@ -1728,7 +1728,7 @@
         if (Editor<>nil) then
           Font := Editor.Font
         else begin
    -      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name for XLFD !
    +      Font.Size:=EditorOpts.EditorFontSize; // set Size before name for XLFD !
           Font.Name:=EditorOpts.EditorFont;
         end;
         Font.Style:=[];
    @@ -1763,7 +1763,7 @@
         if (Editor<>nil) then
           Font:=Editor.Font
         else begin
    -      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name of XLFD !
    +      Font.Size:=EditorOpts.EditorFontSize; // set Size before name of XLFD !
           Font.Name:=EditorOpts.EditorFont;
         end;
         Font.Style:=[];
    Index: ide/frames/editor_display_options.pas
    ===================================================================
    --- ide/frames/editor_display_options.pas	(revision 32127)
    +++ ide/frames/editor_display_options.pas	(working copy)
    @@ -39,8 +39,8 @@
         EditorFontButton: TButton;
         EditorFontComboBox: TComboBox;
         EditorFontGroupBox: TGroupBox;
    -    EditorFontHeightComboBox: TComboBox;
    -    EditorFontHeightLabel: TLabel;
    +    EditorFontSizeSpinEdit: TSpinEdit;
    +    EditorFontSizeLabel: TLabel;
         ExtraCharSpacingComboBox: TComboBox;
         ExtraCharSpacingLabel: TLabel;
         ExtraLineSpacingComboBox: TComboBox;
    @@ -58,6 +58,7 @@
         VisibleRightMarginCheckBox: TCheckBox;
         procedure EditorFontButtonClick(Sender: TObject);
         procedure EditorFontComboBoxEditingDone(Sender: TObject);
    +    procedure EditorFontSizeSpinEditChange(Sender: TObject);
         procedure ComboboxOnExit(Sender: TObject);
         procedure ComboBoxOnKeyDown(Sender: TObject; var Key: Word;
           Shift: TShiftState);
    @@ -69,7 +70,10 @@
         procedure ShowLineNumbersCheckBoxClick(Sender: TObject);
       private
         FDialog: TAbstractOptionsEditorDialog;
    +    FUpdatingFontSizeRange: Boolean;
    +    function FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
         function GeneralPage: TEditorGeneralOptionsFrame; inline;
    +    procedure SetEditorFontSizeSpinEditValue(FontSize: Integer);
     
         procedure FontDialogApplyClicked(Sender: TObject);
         function DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
    @@ -86,6 +90,20 @@
     
     {$R *.lfm}
     
    +uses
    +  LCLIntf;
    +
    +function TEditorDisplayOptionsFrame.FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
    +var
    +  tm: TTextMetric;
    +begin
    +  DisplayPreview.Canvas.Font.Assign(DisplayPreview.Font);
    +  if LCLIntf.GetTextMetrics(DisplayPreview.Canvas.Handle, tm) then
    +    Result := -(NegativeSize + MulDiv(tm.tmInternalLeading, 72, DisplayPreview.Font.PixelsPerInch))
    +  else
    +    Result := -NegativeSize;
    +end;
    +
     procedure TEditorDisplayOptionsFrame.FontDialogApplyClicked(Sender: TObject);
     var
       a: Integer;
    @@ -96,7 +114,7 @@
             PreviewEdits[a].Font.Assign(TFontDialog(Sender).Font);
     
       SetComboBoxText(EditorFontComboBox, DisplayPreview.Font.Name,cstCaseInsensitive);
    -  SetComboBoxText(EditorFontHeightComboBox, IntToStr(DisplayPreview.Font.Height),cstCaseInsensitive);
    +  SetEditorFontSizeSpinEditValue(DisplayPreview.Font.Size);
     end;
     
     function TEditorDisplayOptionsFrame.DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
    @@ -108,16 +126,20 @@
     procedure TEditorDisplayOptionsFrame.EditorFontButtonClick(Sender: TObject);
     var
       FontDialog: TFontDialog;
    -  NewHeight: LongInt;
    +  CurFontSize: Integer;
     begin
       FontDialog := TFontDialog.Create(nil);
       try
         with FontDialog do
         begin
           Font.Name := EditorFontComboBox.Text;
    -      NewHeight := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
    -      RepairEditorFontHeight(NewHeight);
    -      Font.Height := NewHeight;
    +      CurFontSize := EditorFontSizeSpinEdit.Value;
    +      if CurFontSize < 0 then
    +      begin
    +        CurFontSize := FontSizeNegativeToPositive(CurFontSize);
    +        RepairEditorFontSize(CurFontSize);
    +      end;
    +      Font.Size := CurFontSize;
           Options := Options + [fdApplyButton];
           OnApplyClicked := @FontDialogApplyClicked;
           if Execute then
    @@ -138,21 +160,32 @@
             PreviewEdits[i].Font.Name := EditorFontComboBox.Text;
     end;
     
    -procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
    +procedure TEditorDisplayOptionsFrame.EditorFontSizeSpinEditChange(Sender: TObject);
     var
       NewVal, a: Integer;
     begin
    -  if Sender = EditorFontHeightComboBox then
    +  NewVal := EditorFontSizeSpinEdit.Value;
    +  if (NewVal < 0) and (NewVal > -EditorOptionsMinimumFontSize) then
       begin
    -    NewVal := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
    -    RepairEditorFontHeight(NewVal);
    -    SetComboBoxText(EditorFontHeightComboBox, IntToStr(NewVal),cstCaseInsensitive);
    +    // Skip to minimum positive value. Will trigger OnChange again.
    +    SetEditorFontSizeSpinEditValue(EditorOptionsMinimumFontSize);
    +  end
    +  else
    +  begin
    +    if (NewVal > 0) and not FUpdatingFontSizeRange then
    +      EditorFontSizeSpinEdit.MinValue := EditorOptionsMinimumFontSize;
    +
         with GeneralPage do
           for a := Low(PreviewEdits) to High(PreviewEdits) do
             if PreviewEdits[a] <> nil then
    -          PreviewEdits[a].Font.Height := NewVal;
    -  end
    -  else
    +          PreviewEdits[a].Font.Size := NewVal;
    +  end;
    +end;
    +
    +procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
    +var
    +  NewVal, a: Integer;
    +begin
       if Sender = ExtraCharSpacingComboBox then
       begin
         NewVal := StrToIntDef(ExtraCharSpacingComboBox.Text, DisplayPreview.ExtraCharSpacing);
    @@ -277,6 +310,17 @@
       Result := TEditorGeneralOptionsFrame(FDialog.FindEditor(TEditorGeneralOptionsFrame));
     end;
     
    +procedure TEditorDisplayOptionsFrame.SetEditorFontSizeSpinEditValue(FontSize: Integer);
    +begin
    +  FUpdatingFontSizeRange := True;
    +  if FontSize < 0 then
    +    EditorFontSizeSpinEdit.MinValue := -EditorFontSizeSpinEdit.MaxValue
    +  else
    +    EditorFontSizeSpinEdit.MinValue := EditorOptionsMinimumFontSize;
    +  FUpdatingFontSizeRange := False;
    +  EditorFontSizeSpinEdit.Value := FontSize;
    +end;
    +
     function TEditorDisplayOptionsFrame.GetTitle: String;
     begin
       Result := dlgEdDisplay;
    @@ -287,6 +331,7 @@
       // Prevent the caret from moving
       DisplayPreview.RegisterMouseActionSearchHandler(@DoSynEditMouse);
       FDialog := ADialog;
    +  FUpdatingFontSizeRange := False;
     
       MarginAndGutterGroupBox.Caption := dlgMarginGutter;
       VisibleRightMarginCheckBox.Caption := dlgVisibleRightMargin;
    @@ -296,7 +341,7 @@
       GutterSeparatorIndexLabel.Caption := dlgGutterSeparatorIndex;
       RightMarginLabel.Caption := dlgRightMargin;
       EditorFontGroupBox.Caption := dlgDefaultEditorFont;
    -  EditorFontHeightLabel.Caption := dlgEditorFontHeight;
    +  EditorFontSizeLabel.Caption := dlgEditorFontSize;
       ExtraCharSpacingLabel.Caption := dlgExtraCharSpacing;
       ExtraLineSpacingLabel.Caption := dlgExtraLineSpacing;
       DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
    @@ -320,7 +365,7 @@
         VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
         SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin),cstCaseInsensitive);
         SetComboBoxText(EditorFontComboBox, EditorFont,cstCaseInsensitive);
    -    SetComboBoxText(EditorFontHeightComboBox, IntToStr(EditorFontHeight),cstCaseInsensitive);
    +    SetEditorFontSizeSpinEditValue(EditorFontSize);
         SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing),cstCaseInsensitive);
         SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing),cstCaseInsensitive);
         DisableAntialiasingCheckBox.Checked := DisableAntialiasing;
    @@ -342,7 +387,7 @@
         VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
         RightMargin := StrToIntDef(RightMarginComboBox.Text, 80);
         EditorFont := EditorFontComboBox.Text;
    -    EditorFontHeight := StrToIntDef(EditorFontHeightComboBox.Text, EditorFontHeight);
    +    EditorFontSize := EditorFontSizeSpinEdit.Value;
         ExtraCharSpacing := StrToIntDef(ExtraCharSpacingComboBox.Text, ExtraCharSpacing);
         ExtraLineSpacing := StrToIntDef(ExtraLineSpacingComboBox.Text, ExtraLineSpacing);
         DisableAntialiasing := DisableAntialiasingCheckBox.Checked;
    Index: ide/frames/editor_display_options.lfm
    ===================================================================
    --- ide/frames/editor_display_options.lfm	(revision 32127)
    +++ ide/frames/editor_display_options.lfm	(working copy)
    @@ -177,17 +177,17 @@
         ClientHeight = 87
         ClientWidth = 497
         TabOrder = 1
    -    object EditorFontHeightLabel: TLabel
    -      AnchorSideLeft.Control = EditorFontHeightComboBox
    +    object EditorFontSizeLabel: TLabel
    +      AnchorSideLeft.Control = EditorFontSizeSpinEdit
           AnchorSideLeft.Side = asrBottom
    -      AnchorSideTop.Control = EditorFontHeightComboBox
    +      AnchorSideTop.Control = EditorFontSizeSpinEdit
           AnchorSideTop.Side = asrCenter
           Left = 112
           Height = 14
           Top = 36
           Width = 107
           BorderSpacing.Around = 6
    -      Caption = 'EditorFontHeightLabel'
    +      Caption = 'EditorFontSizeLabel'
           ParentColor = False
         end
         object ExtraLineSpacingLabel: TLabel
    @@ -248,34 +248,20 @@
           OnClick = EditorFontButtonClick
           TabOrder = 1
         end
    -    object EditorFontHeightComboBox: TComboBox
    +    object EditorFontSizeSpinEdit: TSpinEdit
           AnchorSideLeft.Control = EditorFontGroupBox
           AnchorSideTop.Control = EditorFontComboBox
           AnchorSideTop.Side = asrBottom
           Left = 6
    -      Height = 21
    -      Top = 33
    -      Width = 100
    +      Height = 29
    +      Top = 41
    +      Width = 50
           BorderSpacing.Around = 6
    -      ItemHeight = 13
    -      Items.Strings = (
    -        '10'
    -        '11'
    -        '12'
    -        '13'
    -        '14'
    -        '15'
    -        '16'
    -        '17'
    -        '18'
    -      )
    -      OnChange = ComboboxOnChange
    -      OnExit = ComboboxOnExit
    -      OnKeyDown = ComboBoxOnKeyDown
    +      OnChange = EditorFontSizeSpinEditChange
           TabOrder = 2
         end
         object ExtraLineSpacingComboBox: TComboBox
    -      AnchorSideLeft.Control = EditorFontHeightLabel
    +      AnchorSideLeft.Control = EditorFontSizeLabel
           AnchorSideLeft.Side = asrBottom
           AnchorSideTop.Control = EditorFontComboBox
           AnchorSideTop.Side = asrBottom
    @@ -318,7 +304,7 @@
         end
         object DisableAntialiasingCheckBox: TCheckBox
           AnchorSideLeft.Control = EditorFontGroupBox
    -      AnchorSideTop.Control = EditorFontHeightComboBox
    +      AnchorSideTop.Control = EditorFontSizeSpinEdit
           AnchorSideTop.Side = asrBottom
           Left = 6
           Height = 21
    
    editorfontsize3.diff (18,153 bytes)

Relationships

related to 0014357 closedMartin Friebe Buggy font size selection in Environment Options / Editor / Display 
related to 0018795 resolvedZeljan Rikalo GetEditorControlSettings is buggy 
related to 0030085 assignedMartin Friebe Source Editor font size - Pixels vs Point size 

Activities

Martin Friebe

2010-10-31 02:43

manager   ~0042467

I just tested this, and can't reproduce. Yes there is a font height, and a font size.

The field (drop-down) on the display page is labelled "height" and changes the height.

If you use the font-dialog you will be ask for "Size" (at least win32 and gtk2, may be different per OS?). If you click OK, your Size is converted into a "Height" and the resulting Height used (w32 and gtk2).

So everything works ok? If not please specify more exactly in which order you change which of the "size"/"height" settings, and where it goes wrong or what should be changed?

Gerard V

2011-02-21 19:53

reporter   ~0046175

IIRC, TFont.Size is the size in points, TFont.Height is the height in pixels resulting from Font.Size X Pixels per inch / Screen resolution in ppi.
Setting the font size with the font dialog works fine, and the font heigth is then set to the new height, but the reverse doesen't work.
IMHO, the height is irrelevant, and it's confusing to let the user edit something if it's not going to work.
Maybe the best would be to show a lookup combo with all the monospace fonts + another lookup with their respective size (not height), or even better, show only the font name and size with labels and let the user select the font via the dialog. And you still can apply the changes without closing the dialog and see the results in the underlying demo synedit.

2011-08-09 00:09

 

editorfontsize.diff (15,756 bytes)
Index: debugger/assemblerdlg.pp
===================================================================
--- debugger/assemblerdlg.pp	(revision 31909)
+++ debugger/assemblerdlg.pp	(working copy)
@@ -215,7 +215,7 @@
 
   Caption := lisDisAssAssembler;
 
-  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
+  pbAsm.Font.Size := EditorOpts.EditorFontSize;
   pbAsm.Font.Name := EditorOpts.EditorFont;
   Caption := lisMenuViewAssembler;
   CopyToClipboard.Caption := lisDbgAsmCopyToClipboard;
Index: ide/editoroptions.pp
===================================================================
--- ide/editoroptions.pp	(revision 31909)
+++ ide/editoroptions.pp	(working copy)
@@ -957,7 +957,7 @@
     FGutterSeparatorIndex: Integer;
     fRightMargin: Integer;
     fEditorFont:  String;
-    fEditorFontHeight: Integer;
+    fEditorFontSize:   Integer;
     fExtraCharSpacing: Integer;
     fExtraLineSpacing: Integer;
     fDisableAntialiasing: Boolean;
@@ -1092,8 +1092,8 @@
     property RightMargin: Integer
       read fRightMargin write fRightMargin default 80;
     property EditorFont: String read fEditorFont write fEditorFont;
-    property EditorFontHeight: Integer
-      read fEditorFontHeight write FEditorFontHeight;
+    property EditorFontSize: Integer
+      read fEditorFontSize write fEditorFontSize;
     property ExtraCharSpacing: Integer
       read fExtraCharSpacing write fExtraCharSpacing default 0;
     property ExtraLineSpacing: Integer
@@ -1254,6 +1254,16 @@
 var
   DefaultColorSchemeName: String;
 
+function FontHeightToSize(Height: Integer): Integer;
+var
+  AFont: TFont;
+begin
+  AFont := TFont.Create;
+  AFont.Height := Height;
+  Result := AFont.Size;
+  AFont.Free;
+end;
+
 { TSynEditMouseActionKeyCmdHelper }
 
 function TSynEditMouseActionKeyCmdHelper.GetOptionKeyCmd: TSynEditorCommand;
@@ -3047,7 +3057,7 @@
 
   // Display options
   fEditorFont := SynDefaultFontName;
-  fEditorFontHeight := SynDefaultFontHeight;
+  fEditorFontSize := FontHeightToSize(SynDefaultFontHeight);
   fDisableAntialiasing := DefaultEditorDisableAntiAliasing;
 
   // Key Mappings
@@ -3092,6 +3102,7 @@
   i: Integer;
   SynEditOpt2: TSynEditorOption2;
   FileVersion: LongInt;
+  FontHeight: Integer;
 
 begin
   try
@@ -3199,10 +3210,21 @@
       XMLConfig.GetValue('EditorOptions/Display/RightMargin', 80);
     fEditorFont  :=
       XMLConfig.GetValue('EditorOptions/Display/EditorFont', SynDefaultFontName);
-    fEditorFontHeight :=
+    // Try old EditorFontHeight first.
+    FontHeight :=
       XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',
       SynDefaultFontHeight);
-    RepairEditorFontHeight(fEditorFontHeight);
+    if FontHeight = SynDefaultFontHeight then
+    begin
+      fEditorFontSize :=
+        XMLConfig.GetValue('EditorOptions/Display/EditorFontSize',
+        FontHeightToSize(SynDefaultFontHeight));
+    end
+    else
+    begin
+      RepairEditorFontHeight(FontHeight);
+      fEditorFontSize := FontHeightToSize(FontHeight);
+    end;
     fExtraCharSpacing :=
       XMLConfig.GetValue('EditorOptions/Display/ExtraCharSpacing', 0);
     fExtraLineSpacing :=
@@ -3391,8 +3413,9 @@
       fRightMargin, 80);
     XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFont',
       fEditorFont, SynDefaultFontName);
-    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontHeight'
-      ,fEditorFontHeight, SynDefaultFontHeight);
+    XMLConfig.DeleteValue('EditorOptions/Display/EditorFontHeight'); // unused old value
+    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontSize'
+      ,fEditorFontSize, FontHeightToSize(SynDefaultFontHeight));
     XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraCharSpacing'
       ,fExtraCharSpacing, 0);
     XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraLineSpacing'
@@ -3921,7 +3944,7 @@
 
 procedure TEditorOptions.ApplyFontSettingsTo(ASynEdit: TSynEdit);
 begin
-  ASynEdit.Font.Height := fEditorFontHeight;// set height before name for XLFD !
+  ASynEdit.Font.Size := fEditorFontSize;// set size before name for XLFD !
   ASynEdit.Font.Name := fEditorFont;
   if fDisableAntialiasing then
     ASynEdit.Font.Quality := fqNonAntialiased
Index: ide/lazarusidestrconsts.pas
===================================================================
--- ide/lazarusidestrconsts.pas	(revision 31909)
+++ ide/lazarusidestrconsts.pas	(working copy)
@@ -1425,7 +1425,7 @@
   dlgGutterColor = 'Gutter Color';
   dlgEditorFont = 'Editor font';
   dlgDefaultEditorFont='Default editor font';
-  dlgEditorFontHeight = 'Editor font height';
+  dlgEditorFontSize = 'Editor font size';
   dlgExtraCharSpacing = 'Extra char spacing';
   dlgExtraLineSpacing = 'Extra line spacing';
   dlgDisableAntialiasing = 'Disable anti-aliasing';
Index: ide/sourceeditor.pp
===================================================================
--- ide/sourceeditor.pp	(revision 31909)
+++ ide/sourceeditor.pp	(working copy)
@@ -1728,7 +1728,7 @@
     if (Editor<>nil) then
       Font := Editor.Font
     else begin
-      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name for XLFD !
+      Font.Size:=EditorOpts.EditorFontSize; // set Size before name for XLFD !
       Font.Name:=EditorOpts.EditorFont;
     end;
     Font.Style:=[];
@@ -1763,7 +1763,7 @@
     if (Editor<>nil) then
       Font:=Editor.Font
     else begin
-      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name of XLFD !
+      Font.Size:=EditorOpts.EditorFontSize; // set Size before name of XLFD !
       Font.Name:=EditorOpts.EditorFont;
     end;
     Font.Style:=[];
Index: ide/frames/editor_display_options.pas
===================================================================
--- ide/frames/editor_display_options.pas	(revision 31909)
+++ ide/frames/editor_display_options.pas	(working copy)
@@ -39,8 +39,8 @@
     EditorFontButton: TButton;
     EditorFontComboBox: TComboBox;
     EditorFontGroupBox: TGroupBox;
-    EditorFontHeightComboBox: TComboBox;
-    EditorFontHeightLabel: TLabel;
+    EditorFontSizeSpinEdit: TSpinEdit;
+    EditorFontSizeLabel: TLabel;
     ExtraCharSpacingComboBox: TComboBox;
     ExtraCharSpacingLabel: TLabel;
     ExtraLineSpacingComboBox: TComboBox;
@@ -58,6 +58,7 @@
     VisibleRightMarginCheckBox: TCheckBox;
     procedure EditorFontButtonClick(Sender: TObject);
     procedure EditorFontComboBoxEditingDone(Sender: TObject);
+    procedure EditorFontSizeSpinEditChange(Sender: TObject);
     procedure ComboboxOnExit(Sender: TObject);
     procedure ComboBoxOnKeyDown(Sender: TObject; var Key: Word;
       Shift: TShiftState);
@@ -96,7 +97,7 @@
         PreviewEdits[a].Font.Assign(TFontDialog(Sender).Font);
 
   SetComboBoxText(EditorFontComboBox, DisplayPreview.Font.Name,cstCaseInsensitive);
-  SetComboBoxText(EditorFontHeightComboBox, IntToStr(DisplayPreview.Font.Height),cstCaseInsensitive);
+  EditorFontSizeSpinEdit.Value := DisplayPreview.Font.Size;
 end;
 
 function TEditorDisplayOptionsFrame.DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
@@ -108,16 +109,13 @@
 procedure TEditorDisplayOptionsFrame.EditorFontButtonClick(Sender: TObject);
 var
   FontDialog: TFontDialog;
-  NewHeight: LongInt;
 begin
   FontDialog := TFontDialog.Create(nil);
   try
     with FontDialog do
     begin
       Font.Name := EditorFontComboBox.Text;
-      NewHeight := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
-      RepairEditorFontHeight(NewHeight);
-      Font.Height := NewHeight;
+      Font.Size := EditorFontSizeSpinEdit.Value;
       Options := Options + [fdApplyButton];
       OnApplyClicked := @FontDialogApplyClicked;
       if Execute then
@@ -138,21 +136,21 @@
         PreviewEdits[i].Font.Name := EditorFontComboBox.Text;
 end;
 
+procedure TEditorDisplayOptionsFrame.EditorFontSizeSpinEditChange(Sender: TObject);
+var
+  NewVal, a: Integer;
+begin
+  NewVal := EditorFontSizeSpinEdit.Value;
+  with GeneralPage do
+    for a := Low(PreviewEdits) to High(PreviewEdits) do
+      if PreviewEdits[a] <> nil then
+        PreviewEdits[a].Font.Size := NewVal;
+end;
+
 procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
 var
   NewVal, a: Integer;
 begin
-  if Sender = EditorFontHeightComboBox then
-  begin
-    NewVal := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
-    RepairEditorFontHeight(NewVal);
-    SetComboBoxText(EditorFontHeightComboBox, IntToStr(NewVal),cstCaseInsensitive);
-    with GeneralPage do
-      for a := Low(PreviewEdits) to High(PreviewEdits) do
-        if PreviewEdits[a] <> nil then
-          PreviewEdits[a].Font.Height := NewVal;
-  end
-  else
   if Sender = ExtraCharSpacingComboBox then
   begin
     NewVal := StrToIntDef(ExtraCharSpacingComboBox.Text, DisplayPreview.ExtraCharSpacing);
@@ -296,7 +294,7 @@
   GutterSeparatorIndexLabel.Caption := dlgGutterSeparatorIndex;
   RightMarginLabel.Caption := dlgRightMargin;
   EditorFontGroupBox.Caption := dlgDefaultEditorFont;
-  EditorFontHeightLabel.Caption := dlgEditorFontHeight;
+  EditorFontSizeLabel.Caption := dlgEditorFontSize;
   ExtraCharSpacingLabel.Caption := dlgExtraCharSpacing;
   ExtraLineSpacingLabel.Caption := dlgExtraLineSpacing;
   DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
@@ -320,7 +318,7 @@
     VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
     SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin),cstCaseInsensitive);
     SetComboBoxText(EditorFontComboBox, EditorFont,cstCaseInsensitive);
-    SetComboBoxText(EditorFontHeightComboBox, IntToStr(EditorFontHeight),cstCaseInsensitive);
+    EditorFontSizeSpinEdit.Value := EditorFontSize;
     SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing),cstCaseInsensitive);
     SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing),cstCaseInsensitive);
     DisableAntialiasingCheckBox.Checked := DisableAntialiasing;
@@ -342,7 +340,7 @@
     VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
     RightMargin := StrToIntDef(RightMarginComboBox.Text, 80);
     EditorFont := EditorFontComboBox.Text;
-    EditorFontHeight := StrToIntDef(EditorFontHeightComboBox.Text, EditorFontHeight);
+    EditorFontSize := EditorFontSizeSpinEdit.Value;
     ExtraCharSpacing := StrToIntDef(ExtraCharSpacingComboBox.Text, ExtraCharSpacing);
     ExtraLineSpacing := StrToIntDef(ExtraLineSpacingComboBox.Text, ExtraLineSpacing);
     DisableAntialiasing := DisableAntialiasingCheckBox.Checked;
Index: ide/frames/editor_display_options.lfm
===================================================================
--- ide/frames/editor_display_options.lfm	(revision 31909)
+++ ide/frames/editor_display_options.lfm	(working copy)
@@ -167,27 +167,27 @@
   object EditorFontGroupBox: TGroupBox[1]
     AnchorSideRight.Side = asrBottom
     Left = 0
-    Height = 105
-    Top = 128
+    Height = 133
+    Top = 162
     Width = 501
     Align = alTop
     AutoSize = True
     BorderSpacing.Top = 6
     Caption = 'EditorFontGroupBox'
-    ClientHeight = 87
+    ClientHeight = 111
     ClientWidth = 497
     TabOrder = 1
-    object EditorFontHeightLabel: TLabel
-      AnchorSideLeft.Control = EditorFontHeightComboBox
+    object EditorFontSizeLabel: TLabel
+      AnchorSideLeft.Control = EditorFontSizeSpinEdit
       AnchorSideLeft.Side = asrBottom
-      AnchorSideTop.Control = EditorFontHeightComboBox
+      AnchorSideTop.Control = EditorFontSizeSpinEdit
       AnchorSideTop.Side = asrCenter
-      Left = 112
-      Height = 14
-      Top = 36
-      Width = 107
+      Left = 62
+      Height = 22
+      Top = 44
+      Width = 136
       BorderSpacing.Around = 6
-      Caption = 'EditorFontHeightLabel'
+      Caption = 'EditorFontSizeLabel'
       ParentColor = False
     end
     object ExtraLineSpacingLabel: TLabel
@@ -195,10 +195,10 @@
       AnchorSideLeft.Side = asrBottom
       AnchorSideTop.Control = ExtraLineSpacingComboBox
       AnchorSideTop.Side = asrCenter
-      Left = 351
-      Height = 14
-      Top = 36
-      Width = 108
+      Left = 330
+      Height = 22
+      Top = 44
+      Width = 155
       BorderSpacing.Around = 6
       Caption = 'ExtraLineSpacingLabel'
       ParentColor = False
@@ -208,10 +208,10 @@
       AnchorSideLeft.Side = asrBottom
       AnchorSideTop.Control = ExtraCharSpacingComboBox
       AnchorSideTop.Side = asrCenter
-      Left = 351
-      Height = 14
-      Top = 63
-      Width = 112
+      Left = 330
+      Height = 22
+      Top = 79
+      Width = 157
       BorderSpacing.Around = 6
       Caption = 'ExtraCharSpacingLabel'
       ParentColor = False
@@ -221,13 +221,13 @@
       AnchorSideTop.Control = EditorFontGroupBox
       AnchorSideRight.Control = EditorFontButton
       Left = 6
-      Height = 21
+      Height = 29
       Top = 6
       Width = 460
       Anchors = [akTop, akLeft, akRight]
       BorderSpacing.Left = 6
       BorderSpacing.Top = 6
-      ItemHeight = 13
+      ItemHeight = 21
       OnEditingDone = EditorFontComboBoxEditingDone
       TabOrder = 0
       Text = 'EditorFontComboBox'
@@ -239,7 +239,7 @@
       AnchorSideBottom.Control = EditorFontComboBox
       AnchorSideBottom.Side = asrBottom
       Left = 466
-      Height = 21
+      Height = 29
       Top = 6
       Width = 25
       Anchors = [akTop, akRight, akBottom]
@@ -248,44 +248,32 @@
       OnClick = EditorFontButtonClick
       TabOrder = 1
     end
-    object EditorFontHeightComboBox: TComboBox
+    object EditorFontSizeSpinEdit: TSpinEdit
       AnchorSideLeft.Control = EditorFontGroupBox
       AnchorSideTop.Control = EditorFontComboBox
       AnchorSideTop.Side = asrBottom
       Left = 6
-      Height = 21
-      Top = 33
-      Width = 100
+      Height = 29
+      Top = 41
+      Width = 50
       BorderSpacing.Around = 6
-      ItemHeight = 13
-      Items.Strings = (
-        '10'
-        '11'
-        '12'
-        '13'
-        '14'
-        '15'
-        '16'
-        '17'
-        '18'
-      )
-      OnChange = ComboboxOnChange
-      OnExit = ComboboxOnExit
-      OnKeyDown = ComboBoxOnKeyDown
+      MinValue = 5
+      OnChange = EditorFontSizeSpinEditChange
       TabOrder = 2
+      Value = 5
     end
     object ExtraLineSpacingComboBox: TComboBox
-      AnchorSideLeft.Control = EditorFontHeightLabel
+      AnchorSideLeft.Control = EditorFontSizeLabel
       AnchorSideLeft.Side = asrBottom
       AnchorSideTop.Control = EditorFontComboBox
       AnchorSideTop.Side = asrBottom
-      Left = 245
-      Height = 21
-      Top = 33
+      Left = 224
+      Height = 29
+      Top = 41
       Width = 100
       BorderSpacing.Left = 20
       BorderSpacing.Around = 6
-      ItemHeight = 13
+      ItemHeight = 21
       Items.Strings = (
         '0'
         '1'
@@ -300,12 +288,12 @@
       AnchorSideLeft.Control = ExtraLineSpacingComboBox
       AnchorSideTop.Control = ExtraLineSpacingComboBox
       AnchorSideTop.Side = asrBottom
-      Left = 245
-      Height = 21
-      Top = 60
+      Left = 224
+      Height = 29
+      Top = 76
       Width = 100
       BorderSpacing.Bottom = 6
-      ItemHeight = 13
+      ItemHeight = 21
       Items.Strings = (
         '0'
         '1'
@@ -318,12 +306,12 @@
     end
     object DisableAntialiasingCheckBox: TCheckBox
       AnchorSideLeft.Control = EditorFontGroupBox
-      AnchorSideTop.Control = EditorFontHeightComboBox
+      AnchorSideTop.Control = EditorFontSizeSpinEdit
       AnchorSideTop.Side = asrBottom
       Left = 6
-      Height = 21
-      Top = 60
-      Width = 153
+      Height = 29
+      Top = 76
+      Width = 223
       Anchors = [akTop, akLeft, akBottom]
       BorderSpacing.Around = 6
       Caption = 'DisableAntialiasingCheckBox'
editorfontsize.diff (15,756 bytes)

cobines

2011-08-09 00:12

reporter   ~0050623

Attached a patch that changes EditorFontHeight combobox to EditorFontSize spinedit. Value in spinedit is now the same as in the font chooser dialog.
Old configuration EditorFontHeight (negative) in editoroptions.xml is converted to EditorFontSize.
Tested on Windows native, Linux Gtk2, Linux Qt.

Zaher Dirkey

2011-08-09 00:23

reporter   ~0050624

I do not think FontHeightToSize take the right way to calc the size from height

cobines

2011-08-09 12:06

reporter   ~0050632

Last edited: 2011-08-09 13:04

I can't use TFont.SetSize() like that? Do I need to somehow "load" the font first? It seems to work OK. What is the correct procedure?

[edit]
I think it is correct.
http://support.microsoft.com/kb/74299
http://support.microsoft.com/kb/32667

Zaher Dirkey

2011-08-09 14:27

reporter   ~0050642

@cobines in FontHeightToSize you created a TFont and freed it just for calc the size from height, it is not good way, ask LCL developer for the right solution.

cobines

2011-08-09 16:21

reporter   ~0050650

Don't mix correctness and performance please.
If in the future calculations in TFont change or become widgetset dependent the code won't have to change, so I don't want to have direct calculations in two places. Besides, the code that uses FontHeightToSize is not performance critical. If someone has "right" solution please share or comment.

Martin Friebe

2011-08-25 18:54

manager   ~0051121

just wondering: Will this not introduce a new problem.

The issue is/was that the user gets different values for the font's size/height.

But any user currently having a positive height, will now get a negative size => which still differs from the value the user has in the font dialog.

I agree, the improvement is there, as any new user, selecting a font size from the dialog, will not have the issue (and people who intentionally set a negative value themself are not the issue, they made their own choice)

Just thinking, it would be better, if the conversion could be done so that always a positive size is returned? (unless this has other side effects?)

Martin Friebe

2011-08-25 18:57

manager   ~0051122

Last edited: 2011-08-25 19:27

Just tested the patch, due to the new font size field only allowing sizes greater than 5, it does break.

My EditorFontHeight is 13, so the conversion is negative, and the edit shows "5" which is wrong.


Edit:
It will also break for new installations, since
  SynDefaultFontHeight: Integer = 13;

maybe this can be replaced by a Size too?


Edit 2:
if the new FontSize is loaded from xml, then there is no equivalent to RepairEditorFontHeight. The FontSize is not checked against values that are to small?

cobines

2011-08-26 03:26

reporter   ~0051148

Last edited: 2011-08-26 05:38

I did it assuming Size is always > 0, yes, so it is wrong.

To convert negative Size to positive Size we need InternalLeading measure of the font converted to Points. It is implemented on LCLWin32 but for example it isn't on LCLQT, LCLGTK2, so it is impossible to convert. Maybe it is Windows only.

Incidently, I found there is no difference in font size on LCLQT and LCLGTK2 if I set Size=X and Size=-X and the same is true for Height. Maybe because there is no InternalLeading implemented on such platforms it is just omitted therefore negative value has the same effect as positive.
I think to be able to consistently convert between negative and positive we need some widgetset-dependent function that includes or excludes InternalLeading on platforms where it is implemented and does nothing (but change sign) where it is implemented.

I will make a new patch that allows setting negative Font.Size, add SynDefaultFontSize=10pt and add RepairEditorFontSize.

[edit]
I have attached sample application that converts negative<->positive FontSize. Choose negative font size in the spin box and compare visually font sizes. On platforms where InternalLeading is not implemented its value is simply zero therefore Font.Size=X and Font.Size=-X look the same. I tested on LCLWin32 and LCLQT,LCLGTK2 on Linux.

2011-08-26 05:38

 

convert_size_sample.tar.bz2 (1,915 bytes)

2011-08-28 14:11

 

editorfontsize2.diff (19,231 bytes)
Index: components/synedit/synedit.pp
===================================================================
--- components/synedit/synedit.pp	(revision 32083)
+++ components/synedit/synedit.pp	(working copy)
@@ -98,6 +98,7 @@
   // SynDefaultFont is determined in InitSynDefaultFont()
   SynDefaultFontName:    String       = '';
   SynDefaultFontHeight:  Integer      = 13;
+  SynDefaultFontSize:    Integer      = 10;
   SynDefaultFontPitch:   TFontPitch   = fpFixed;
   SynDefaultFontQuality: TFontQuality = fqNonAntialiased;
 
Index: debugger/assemblerdlg.pp
===================================================================
--- debugger/assemblerdlg.pp	(revision 32083)
+++ debugger/assemblerdlg.pp	(working copy)
@@ -217,7 +217,7 @@
   Caption := lisDisAssAssembler;
 
   EditorOpts.AddHandlerAfterWrite(@DoEditorOptsChanged);
-  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
+  pbAsm.Font.Size := EditorOpts.EditorFontSize;
   pbAsm.Font.Name := EditorOpts.EditorFont;
   Caption := lisMenuViewAssembler;
   CopyToClipboard.Caption := lisDbgAsmCopyToClipboard;
@@ -679,7 +679,7 @@
 var
   TM: TTextMetric;
 begin
-  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
+  pbAsm.Font.Size := EditorOpts.EditorFontSize;
   pbAsm.Font.Name := EditorOpts.EditorFont;
   if EditorOpts.DisableAntialiasing then
     pbAsm.Font.Quality := fqNonAntialiased
Index: ide/editoroptions.pp
===================================================================
--- ide/editoroptions.pp	(revision 32083)
+++ ide/editoroptions.pp	(working copy)
@@ -957,7 +957,7 @@
     FGutterSeparatorIndex: Integer;
     fRightMargin: Integer;
     fEditorFont:  String;
-    fEditorFontHeight: Integer;
+    fEditorFontSize:   Integer;
     fExtraCharSpacing: Integer;
     fExtraLineSpacing: Integer;
     fDisableAntialiasing: Boolean;
@@ -1092,8 +1092,8 @@
     property RightMargin: Integer
       read fRightMargin write fRightMargin default 80;
     property EditorFont: String read fEditorFont write fEditorFont;
-    property EditorFontHeight: Integer
-      read fEditorFontHeight write FEditorFontHeight;
+    property EditorFontSize: Integer
+      read fEditorFontSize write fEditorFontSize;
     property ExtraCharSpacing: Integer
       read fExtraCharSpacing write fExtraCharSpacing default 0;
     property ExtraLineSpacing: Integer
@@ -1210,7 +1210,7 @@
 function StrToLazSyntaxHighlighter(const s: String): TLazSyntaxHighlighter;
 function ExtensionToLazSyntaxHighlighter(Ext: String): TLazSyntaxHighlighter;
 function FilenameToLazSyntaxHighlighter(Filename: String): TLazSyntaxHighlighter;
-procedure RepairEditorFontHeight(var FontHeight: integer);
+procedure RepairEditorFontSize(var FontSize: integer);
 
 function BuildBorlandDCIFile(ACustomSynAutoComplete: TCustomSynAutoComplete): Boolean;
 function ColorSchemeFactory: TColorSchemeFactory;
@@ -1254,6 +1254,16 @@
 var
   DefaultColorSchemeName: String;
 
+function FontHeightToSize(Height: Integer): Integer;
+var
+  AFont: TFont;
+begin
+  AFont := TFont.Create;
+  AFont.Height := Height;
+  Result := AFont.Size;
+  AFont.Free;
+end;
+
 { TSynEditMouseActionKeyCmdHelper }
 
 function TSynEditMouseActionKeyCmdHelper.GetOptionKeyCmd: TSynEditorCommand;
@@ -1268,11 +1278,11 @@
 end;
 
 
-procedure RepairEditorFontHeight(var FontHeight: integer);
+procedure RepairEditorFontSize(var FontSize: integer);
 begin
-  if ((FontHeight>=0) and (FontHeight<=5))
-  or ((FontHeight<0) and (FontHeight>=-5)) then
-    FontHeight := SynDefaultFontHeight;
+  if ((FontSize>=0) and (FontSize<=5))
+  or ((FontSize<0) and (FontSize>=-5)) then
+    FontSize := SynDefaultFontSize;
 end;
 
 function StrToLazSyntaxHighlighter(const s: String): TLazSyntaxHighlighter;
@@ -3047,7 +3057,7 @@
 
   // Display options
   fEditorFont := SynDefaultFontName;
-  fEditorFontHeight := SynDefaultFontHeight;
+  fEditorFontSize := SynDefaultFontSize;
   fDisableAntialiasing := DefaultEditorDisableAntiAliasing;
 
   // Key Mappings
@@ -3092,6 +3102,7 @@
   i: Integer;
   SynEditOpt2: TSynEditorOption2;
   FileVersion: LongInt;
+  FontHeight: Integer;
 
 begin
   try
@@ -3199,10 +3210,21 @@
       XMLConfig.GetValue('EditorOptions/Display/RightMargin', 80);
     fEditorFont  :=
       XMLConfig.GetValue('EditorOptions/Display/EditorFont', SynDefaultFontName);
-    fEditorFontHeight :=
+    // Try old EditorFontHeight first.
+    FontHeight :=
       XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',
       SynDefaultFontHeight);
-    RepairEditorFontHeight(fEditorFontHeight);
+    if FontHeight = SynDefaultFontHeight then
+    begin
+      fEditorFontSize :=
+        XMLConfig.GetValue('EditorOptions/Display/EditorFontSize',
+        SynDefaultFontSize);
+    end
+    else
+    begin
+      fEditorFontSize := FontHeightToSize(FontHeight);
+    end;
+    RepairEditorFontSize(fEditorFontSize);
     fExtraCharSpacing :=
       XMLConfig.GetValue('EditorOptions/Display/ExtraCharSpacing', 0);
     fExtraLineSpacing :=
@@ -3391,8 +3413,9 @@
       fRightMargin, 80);
     XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFont',
       fEditorFont, SynDefaultFontName);
-    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontHeight'
-      ,fEditorFontHeight, SynDefaultFontHeight);
+    XMLConfig.DeleteValue('EditorOptions/Display/EditorFontHeight'); // unused old value
+    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontSize'
+      ,fEditorFontSize, SynDefaultFontSize);
     XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraCharSpacing'
       ,fExtraCharSpacing, 0);
     XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraLineSpacing'
@@ -3922,7 +3945,7 @@
 
 procedure TEditorOptions.ApplyFontSettingsTo(ASynEdit: TSynEdit);
 begin
-  ASynEdit.Font.Height := fEditorFontHeight;// set height before name for XLFD !
+  ASynEdit.Font.Size := fEditorFontSize;// set size before name for XLFD !
   ASynEdit.Font.Name := fEditorFont;
   if fDisableAntialiasing then
     ASynEdit.Font.Quality := fqNonAntialiased
Index: ide/lazarusidestrconsts.pas
===================================================================
--- ide/lazarusidestrconsts.pas	(revision 32083)
+++ ide/lazarusidestrconsts.pas	(working copy)
@@ -1427,7 +1427,7 @@
   dlgGutterColor = 'Gutter Color';
   dlgEditorFont = 'Editor font';
   dlgDefaultEditorFont='Default editor font';
-  dlgEditorFontHeight = 'Editor font height';
+  dlgEditorFontSize = 'Editor font size';
   dlgExtraCharSpacing = 'Extra char spacing';
   dlgExtraLineSpacing = 'Extra line spacing';
   dlgDisableAntialiasing = 'Disable anti-aliasing';
Index: ide/sourceeditor.pp
===================================================================
--- ide/sourceeditor.pp	(revision 32083)
+++ ide/sourceeditor.pp	(working copy)
@@ -1728,7 +1728,7 @@
     if (Editor<>nil) then
       Font := Editor.Font
     else begin
-      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name for XLFD !
+      Font.Size:=EditorOpts.EditorFontSize; // set Size before name for XLFD !
       Font.Name:=EditorOpts.EditorFont;
     end;
     Font.Style:=[];
@@ -1763,7 +1763,7 @@
     if (Editor<>nil) then
       Font:=Editor.Font
     else begin
-      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name of XLFD !
+      Font.Size:=EditorOpts.EditorFontSize; // set Size before name of XLFD !
       Font.Name:=EditorOpts.EditorFont;
     end;
     Font.Style:=[];
Index: ide/frames/editor_display_options.pas
===================================================================
--- ide/frames/editor_display_options.pas	(revision 32083)
+++ ide/frames/editor_display_options.pas	(working copy)
@@ -39,8 +39,8 @@
     EditorFontButton: TButton;
     EditorFontComboBox: TComboBox;
     EditorFontGroupBox: TGroupBox;
-    EditorFontHeightComboBox: TComboBox;
-    EditorFontHeightLabel: TLabel;
+    EditorFontSizeSpinEdit: TSpinEdit;
+    EditorFontSizeLabel: TLabel;
     ExtraCharSpacingComboBox: TComboBox;
     ExtraCharSpacingLabel: TLabel;
     ExtraLineSpacingComboBox: TComboBox;
@@ -58,6 +58,7 @@
     VisibleRightMarginCheckBox: TCheckBox;
     procedure EditorFontButtonClick(Sender: TObject);
     procedure EditorFontComboBoxEditingDone(Sender: TObject);
+    procedure EditorFontSizeSpinEditChange(Sender: TObject);
     procedure ComboboxOnExit(Sender: TObject);
     procedure ComboBoxOnKeyDown(Sender: TObject; var Key: Word;
       Shift: TShiftState);
@@ -69,7 +70,9 @@
     procedure ShowLineNumbersCheckBoxClick(Sender: TObject);
   private
     FDialog: TAbstractOptionsEditorDialog;
+    function FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
     function GeneralPage: TEditorGeneralOptionsFrame; inline;
+    procedure SetEditorFontSizeSpinEditValue(FontSize: Integer);
 
     procedure FontDialogApplyClicked(Sender: TObject);
     function DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
@@ -86,6 +89,18 @@
 
 {$R *.lfm}
 
+uses
+  LCLIntf;
+
+function TEditorDisplayOptionsFrame.FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
+var
+  tm: TTextMetric;
+begin
+  DisplayPreview.Canvas.Font.Assign(DisplayPreview.Font);
+  LCLIntf.GetTextMetrics(DisplayPreview.Canvas.Handle, tm);
+  Result := -(NegativeSize + MulDiv(tm.tmInternalLeading, 72, DisplayPreview.Font.PixelsPerInch));
+end;
+
 procedure TEditorDisplayOptionsFrame.FontDialogApplyClicked(Sender: TObject);
 var
   a: Integer;
@@ -96,7 +111,7 @@
         PreviewEdits[a].Font.Assign(TFontDialog(Sender).Font);
 
   SetComboBoxText(EditorFontComboBox, DisplayPreview.Font.Name,cstCaseInsensitive);
-  SetComboBoxText(EditorFontHeightComboBox, IntToStr(DisplayPreview.Font.Height),cstCaseInsensitive);
+  SetEditorFontSizeSpinEditValue(DisplayPreview.Font.Size);
 end;
 
 function TEditorDisplayOptionsFrame.DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
@@ -108,16 +123,20 @@
 procedure TEditorDisplayOptionsFrame.EditorFontButtonClick(Sender: TObject);
 var
   FontDialog: TFontDialog;
-  NewHeight: LongInt;
+  CurFontSize: Integer;
 begin
   FontDialog := TFontDialog.Create(nil);
   try
     with FontDialog do
     begin
       Font.Name := EditorFontComboBox.Text;
-      NewHeight := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
-      RepairEditorFontHeight(NewHeight);
-      Font.Height := NewHeight;
+      CurFontSize := EditorFontSizeSpinEdit.Value;
+      if CurFontSize < 0 then
+      begin
+        CurFontSize := FontSizeNegativeToPositive(CurFontSize);
+        RepairEditorFontSize(CurFontSize);
+      end;
+      Font.Size := CurFontSize;
       Options := Options + [fdApplyButton];
       OnApplyClicked := @FontDialogApplyClicked;
       if Execute then
@@ -138,21 +157,21 @@
         PreviewEdits[i].Font.Name := EditorFontComboBox.Text;
 end;
 
+procedure TEditorDisplayOptionsFrame.EditorFontSizeSpinEditChange(Sender: TObject);
+var
+  NewVal, a: Integer;
+begin
+  NewVal := EditorFontSizeSpinEdit.Value;
+  with GeneralPage do
+    for a := Low(PreviewEdits) to High(PreviewEdits) do
+      if PreviewEdits[a] <> nil then
+        PreviewEdits[a].Font.Size := NewVal;
+end;
+
 procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
 var
   NewVal, a: Integer;
 begin
-  if Sender = EditorFontHeightComboBox then
-  begin
-    NewVal := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
-    RepairEditorFontHeight(NewVal);
-    SetComboBoxText(EditorFontHeightComboBox, IntToStr(NewVal),cstCaseInsensitive);
-    with GeneralPage do
-      for a := Low(PreviewEdits) to High(PreviewEdits) do
-        if PreviewEdits[a] <> nil then
-          PreviewEdits[a].Font.Height := NewVal;
-  end
-  else
   if Sender = ExtraCharSpacingComboBox then
   begin
     NewVal := StrToIntDef(ExtraCharSpacingComboBox.Text, DisplayPreview.ExtraCharSpacing);
@@ -277,6 +296,15 @@
   Result := TEditorGeneralOptionsFrame(FDialog.FindEditor(TEditorGeneralOptionsFrame));
 end;
 
+procedure TEditorDisplayOptionsFrame.SetEditorFontSizeSpinEditValue(FontSize: Integer);
+begin
+  if FontSize < 0 then
+    EditorFontSizeSpinEdit.MinValue := -100
+  else
+    EditorFontSizeSpinEdit.MinValue := 5;
+  EditorFontSizeSpinEdit.Value := FontSize;
+end;
+
 function TEditorDisplayOptionsFrame.GetTitle: String;
 begin
   Result := dlgEdDisplay;
@@ -296,7 +324,7 @@
   GutterSeparatorIndexLabel.Caption := dlgGutterSeparatorIndex;
   RightMarginLabel.Caption := dlgRightMargin;
   EditorFontGroupBox.Caption := dlgDefaultEditorFont;
-  EditorFontHeightLabel.Caption := dlgEditorFontHeight;
+  EditorFontSizeLabel.Caption := dlgEditorFontSize;
   ExtraCharSpacingLabel.Caption := dlgExtraCharSpacing;
   ExtraLineSpacingLabel.Caption := dlgExtraLineSpacing;
   DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
@@ -320,7 +348,7 @@
     VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
     SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin),cstCaseInsensitive);
     SetComboBoxText(EditorFontComboBox, EditorFont,cstCaseInsensitive);
-    SetComboBoxText(EditorFontHeightComboBox, IntToStr(EditorFontHeight),cstCaseInsensitive);
+    SetEditorFontSizeSpinEditValue(EditorFontSize);
     SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing),cstCaseInsensitive);
     SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing),cstCaseInsensitive);
     DisableAntialiasingCheckBox.Checked := DisableAntialiasing;
@@ -342,7 +370,7 @@
     VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
     RightMargin := StrToIntDef(RightMarginComboBox.Text, 80);
     EditorFont := EditorFontComboBox.Text;
-    EditorFontHeight := StrToIntDef(EditorFontHeightComboBox.Text, EditorFontHeight);
+    EditorFontSize := EditorFontSizeSpinEdit.Value;
     ExtraCharSpacing := StrToIntDef(ExtraCharSpacingComboBox.Text, ExtraCharSpacing);
     ExtraLineSpacing := StrToIntDef(ExtraLineSpacingComboBox.Text, ExtraLineSpacing);
     DisableAntialiasing := DisableAntialiasingCheckBox.Checked;
Index: ide/frames/editor_display_options.lfm
===================================================================
--- ide/frames/editor_display_options.lfm	(revision 32083)
+++ ide/frames/editor_display_options.lfm	(working copy)
@@ -167,27 +167,27 @@
   object EditorFontGroupBox: TGroupBox[1]
     AnchorSideRight.Side = asrBottom
     Left = 0
-    Height = 105
-    Top = 128
+    Height = 133
+    Top = 162
     Width = 501
     Align = alTop
     AutoSize = True
     BorderSpacing.Top = 6
     Caption = 'EditorFontGroupBox'
-    ClientHeight = 87
+    ClientHeight = 111
     ClientWidth = 497
     TabOrder = 1
-    object EditorFontHeightLabel: TLabel
-      AnchorSideLeft.Control = EditorFontHeightComboBox
+    object EditorFontSizeLabel: TLabel
+      AnchorSideLeft.Control = EditorFontSizeSpinEdit
       AnchorSideLeft.Side = asrBottom
-      AnchorSideTop.Control = EditorFontHeightComboBox
+      AnchorSideTop.Control = EditorFontSizeSpinEdit
       AnchorSideTop.Side = asrCenter
-      Left = 112
-      Height = 14
-      Top = 36
-      Width = 107
+      Left = 62
+      Height = 22
+      Top = 44
+      Width = 136
       BorderSpacing.Around = 6
-      Caption = 'EditorFontHeightLabel'
+      Caption = 'EditorFontSizeLabel'
       ParentColor = False
     end
     object ExtraLineSpacingLabel: TLabel
@@ -195,10 +195,10 @@
       AnchorSideLeft.Side = asrBottom
       AnchorSideTop.Control = ExtraLineSpacingComboBox
       AnchorSideTop.Side = asrCenter
-      Left = 351
-      Height = 14
-      Top = 36
-      Width = 108
+      Left = 330
+      Height = 22
+      Top = 44
+      Width = 155
       BorderSpacing.Around = 6
       Caption = 'ExtraLineSpacingLabel'
       ParentColor = False
@@ -208,10 +208,10 @@
       AnchorSideLeft.Side = asrBottom
       AnchorSideTop.Control = ExtraCharSpacingComboBox
       AnchorSideTop.Side = asrCenter
-      Left = 351
-      Height = 14
-      Top = 63
-      Width = 112
+      Left = 330
+      Height = 22
+      Top = 79
+      Width = 157
       BorderSpacing.Around = 6
       Caption = 'ExtraCharSpacingLabel'
       ParentColor = False
@@ -221,13 +221,13 @@
       AnchorSideTop.Control = EditorFontGroupBox
       AnchorSideRight.Control = EditorFontButton
       Left = 6
-      Height = 21
+      Height = 29
       Top = 6
       Width = 460
       Anchors = [akTop, akLeft, akRight]
       BorderSpacing.Left = 6
       BorderSpacing.Top = 6
-      ItemHeight = 13
+      ItemHeight = 21
       OnEditingDone = EditorFontComboBoxEditingDone
       TabOrder = 0
       Text = 'EditorFontComboBox'
@@ -239,7 +239,7 @@
       AnchorSideBottom.Control = EditorFontComboBox
       AnchorSideBottom.Side = asrBottom
       Left = 466
-      Height = 21
+      Height = 29
       Top = 6
       Width = 25
       Anchors = [akTop, akRight, akBottom]
@@ -248,44 +248,30 @@
       OnClick = EditorFontButtonClick
       TabOrder = 1
     end
-    object EditorFontHeightComboBox: TComboBox
+    object EditorFontSizeSpinEdit: TSpinEdit
       AnchorSideLeft.Control = EditorFontGroupBox
       AnchorSideTop.Control = EditorFontComboBox
       AnchorSideTop.Side = asrBottom
       Left = 6
-      Height = 21
-      Top = 33
-      Width = 100
+      Height = 29
+      Top = 41
+      Width = 50
       BorderSpacing.Around = 6
-      ItemHeight = 13
-      Items.Strings = (
-        '10'
-        '11'
-        '12'
-        '13'
-        '14'
-        '15'
-        '16'
-        '17'
-        '18'
-      )
-      OnChange = ComboboxOnChange
-      OnExit = ComboboxOnExit
-      OnKeyDown = ComboBoxOnKeyDown
+      OnChange = EditorFontSizeSpinEditChange
       TabOrder = 2
     end
     object ExtraLineSpacingComboBox: TComboBox
-      AnchorSideLeft.Control = EditorFontHeightLabel
+      AnchorSideLeft.Control = EditorFontSizeLabel
       AnchorSideLeft.Side = asrBottom
       AnchorSideTop.Control = EditorFontComboBox
       AnchorSideTop.Side = asrBottom
-      Left = 245
-      Height = 21
-      Top = 33
+      Left = 224
+      Height = 29
+      Top = 41
       Width = 100
       BorderSpacing.Left = 20
       BorderSpacing.Around = 6
-      ItemHeight = 13
+      ItemHeight = 21
       Items.Strings = (
         '0'
         '1'
@@ -300,12 +286,12 @@
       AnchorSideLeft.Control = ExtraLineSpacingComboBox
       AnchorSideTop.Control = ExtraLineSpacingComboBox
       AnchorSideTop.Side = asrBottom
-      Left = 245
-      Height = 21
-      Top = 60
+      Left = 224
+      Height = 29
+      Top = 76
       Width = 100
       BorderSpacing.Bottom = 6
-      ItemHeight = 13
+      ItemHeight = 21
       Items.Strings = (
         '0'
         '1'
@@ -318,12 +304,12 @@
     end
     object DisableAntialiasingCheckBox: TCheckBox
       AnchorSideLeft.Control = EditorFontGroupBox
-      AnchorSideTop.Control = EditorFontHeightComboBox
+      AnchorSideTop.Control = EditorFontSizeSpinEdit
       AnchorSideTop.Side = asrBottom
       Left = 6
-      Height = 21
-      Top = 60
-      Width = 153
+      Height = 29
+      Top = 76
+      Width = 223
       Anchors = [akTop, akLeft, akBottom]
       BorderSpacing.Around = 6
       Caption = 'DisableAntialiasingCheckBox'
editorfontsize2.diff (19,231 bytes)

2011-08-31 05:23

 

editorfontsize3.diff (18,153 bytes)
Index: components/synedit/synedit.pp
===================================================================
--- components/synedit/synedit.pp	(revision 32127)
+++ components/synedit/synedit.pp	(working copy)
@@ -98,6 +98,7 @@
   // SynDefaultFont is determined in InitSynDefaultFont()
   SynDefaultFontName:    String       = '';
   SynDefaultFontHeight:  Integer      = 13;
+  SynDefaultFontSize:    Integer      = 10;
   SynDefaultFontPitch:   TFontPitch   = fpFixed;
   SynDefaultFontQuality: TFontQuality = fqNonAntialiased;
 
Index: debugger/assemblerdlg.pp
===================================================================
--- debugger/assemblerdlg.pp	(revision 32127)
+++ debugger/assemblerdlg.pp	(working copy)
@@ -217,7 +217,7 @@
   Caption := lisDisAssAssembler;
 
   EditorOpts.AddHandlerAfterWrite(@DoEditorOptsChanged);
-  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
+  pbAsm.Font.Size := EditorOpts.EditorFontSize;
   pbAsm.Font.Name := EditorOpts.EditorFont;
   Caption := lisMenuViewAssembler;
   CopyToClipboard.Caption := lisDbgAsmCopyToClipboard;
@@ -679,7 +679,7 @@
 var
   TM: TTextMetric;
 begin
-  pbAsm.Font.Height := EditorOpts.EditorFontHeight;
+  pbAsm.Font.Size := EditorOpts.EditorFontSize;
   pbAsm.Font.Name := EditorOpts.EditorFont;
   if EditorOpts.DisableAntialiasing then
     pbAsm.Font.Quality := fqNonAntialiased
Index: ide/editoroptions.pp
===================================================================
--- ide/editoroptions.pp	(revision 32127)
+++ ide/editoroptions.pp	(working copy)
@@ -570,13 +570,15 @@
     );
 
 const
-  EditorOptsFormatVersion = 7;
+  EditorOptsFormatVersion = 8;
   { * Changes in Version 6:
        - ColorSchemes now have a Global settings part.
          Language specific changes must save UseSchemeGlobals=False (Default is true)
          Since Version 5 did not have this setting, in Version 5 the default is false.
     * Changes in Version 7:
          DisableAntialiasing default true to false
+    * Changes in Version 8:
+         Replaced EditorFontHeight with EditorFontSize.
   }
 
   LazSyntaxHighlighterClasses: array[TLazSyntaxHighlighter] of
@@ -615,6 +617,8 @@
                                                   + [eoHalfPageScroll];
   SynEditDefaultOptions2 = SYNEDIT_DEFAULT_OPTIONS2;
 
+  EditorOptionsMinimumFontSize = 5;
+
 type
   { TEditOptLanguageInfo stores lazarus IDE additional information
     of a highlighter, such as samplesource, which sample lines are special
@@ -957,7 +961,7 @@
     FGutterSeparatorIndex: Integer;
     fRightMargin: Integer;
     fEditorFont:  String;
-    fEditorFontHeight: Integer;
+    fEditorFontSize:   Integer;
     fExtraCharSpacing: Integer;
     fExtraLineSpacing: Integer;
     fDisableAntialiasing: Boolean;
@@ -1092,8 +1096,8 @@
     property RightMargin: Integer
       read fRightMargin write fRightMargin default 80;
     property EditorFont: String read fEditorFont write fEditorFont;
-    property EditorFontHeight: Integer
-      read fEditorFontHeight write FEditorFontHeight;
+    property EditorFontSize: Integer
+      read fEditorFontSize write fEditorFontSize;
     property ExtraCharSpacing: Integer
       read fExtraCharSpacing write fExtraCharSpacing default 0;
     property ExtraLineSpacing: Integer
@@ -1210,7 +1214,7 @@
 function StrToLazSyntaxHighlighter(const s: String): TLazSyntaxHighlighter;
 function ExtensionToLazSyntaxHighlighter(Ext: String): TLazSyntaxHighlighter;
 function FilenameToLazSyntaxHighlighter(Filename: String): TLazSyntaxHighlighter;
-procedure RepairEditorFontHeight(var FontHeight: integer);
+procedure RepairEditorFontSize(var FontSize: integer);
 
 function BuildBorlandDCIFile(ACustomSynAutoComplete: TCustomSynAutoComplete): Boolean;
 function ColorSchemeFactory: TColorSchemeFactory;
@@ -1254,6 +1258,16 @@
 var
   DefaultColorSchemeName: String;
 
+function FontHeightToSize(Height: Integer): Integer;
+var
+  AFont: TFont;
+begin
+  AFont := TFont.Create;
+  AFont.Height := Height;
+  Result := AFont.Size;
+  AFont.Free;
+end;
+
 { TSynEditMouseActionKeyCmdHelper }
 
 function TSynEditMouseActionKeyCmdHelper.GetOptionKeyCmd: TSynEditorCommand;
@@ -1268,11 +1282,11 @@
 end;
 
 
-procedure RepairEditorFontHeight(var FontHeight: integer);
+procedure RepairEditorFontSize(var FontSize: integer);
 begin
-  if ((FontHeight>=0) and (FontHeight<=5))
-  or ((FontHeight<0) and (FontHeight>=-5)) then
-    FontHeight := SynDefaultFontHeight;
+  if ((FontSize>=0) and (FontSize<=EditorOptionsMinimumFontSize))
+  or ((FontSize<0) and (FontSize>=-EditorOptionsMinimumFontSize)) then
+    FontSize := SynDefaultFontSize;
 end;
 
 function StrToLazSyntaxHighlighter(const s: String): TLazSyntaxHighlighter;
@@ -3047,7 +3061,7 @@
 
   // Display options
   fEditorFont := SynDefaultFontName;
-  fEditorFontHeight := SynDefaultFontHeight;
+  fEditorFontSize := SynDefaultFontSize;
   fDisableAntialiasing := DefaultEditorDisableAntiAliasing;
 
   // Key Mappings
@@ -3199,10 +3213,17 @@
       XMLConfig.GetValue('EditorOptions/Display/RightMargin', 80);
     fEditorFont  :=
       XMLConfig.GetValue('EditorOptions/Display/EditorFont', SynDefaultFontName);
-    fEditorFontHeight :=
-      XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',
-      SynDefaultFontHeight);
-    RepairEditorFontHeight(fEditorFontHeight);
+    if FileVersion < 8 then begin
+      fEditorFontSize :=
+        XMLConfig.GetValue('EditorOptions/Display/EditorFontHeight',
+        SynDefaultFontHeight);
+      fEditorFontSize := FontHeightToSize(fEditorFontSize);
+    end else begin
+      fEditorFontSize :=
+        XMLConfig.GetValue('EditorOptions/Display/EditorFontSize',
+        SynDefaultFontSize);
+    end;
+    RepairEditorFontSize(fEditorFontSize);
     fExtraCharSpacing :=
       XMLConfig.GetValue('EditorOptions/Display/ExtraCharSpacing', 0);
     fExtraLineSpacing :=
@@ -3391,8 +3412,9 @@
       fRightMargin, 80);
     XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFont',
       fEditorFont, SynDefaultFontName);
-    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontHeight'
-      ,fEditorFontHeight, SynDefaultFontHeight);
+    XMLConfig.DeleteValue('EditorOptions/Display/EditorFontHeight'); // unused old value
+    XMLConfig.SetDeleteValue('EditorOptions/Display/EditorFontSize'
+      ,fEditorFontSize, SynDefaultFontSize);
     XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraCharSpacing'
       ,fExtraCharSpacing, 0);
     XMLConfig.SetDeleteValue('EditorOptions/Display/ExtraLineSpacing'
@@ -3922,7 +3944,7 @@
 
 procedure TEditorOptions.ApplyFontSettingsTo(ASynEdit: TSynEdit);
 begin
-  ASynEdit.Font.Height := fEditorFontHeight;// set height before name for XLFD !
+  ASynEdit.Font.Size := fEditorFontSize;// set size before name for XLFD !
   ASynEdit.Font.Name := fEditorFont;
   if fDisableAntialiasing then
     ASynEdit.Font.Quality := fqNonAntialiased
Index: ide/lazarusidestrconsts.pas
===================================================================
--- ide/lazarusidestrconsts.pas	(revision 32127)
+++ ide/lazarusidestrconsts.pas	(working copy)
@@ -1427,7 +1427,7 @@
   dlgGutterColor = 'Gutter Color';
   dlgEditorFont = 'Editor font';
   dlgDefaultEditorFont='Default editor font';
-  dlgEditorFontHeight = 'Editor font height';
+  dlgEditorFontSize = 'Editor font size';
   dlgExtraCharSpacing = 'Extra char spacing';
   dlgExtraLineSpacing = 'Extra line spacing';
   dlgDisableAntialiasing = 'Disable anti-aliasing';
Index: ide/sourceeditor.pp
===================================================================
--- ide/sourceeditor.pp	(revision 32127)
+++ ide/sourceeditor.pp	(working copy)
@@ -1728,7 +1728,7 @@
     if (Editor<>nil) then
       Font := Editor.Font
     else begin
-      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name for XLFD !
+      Font.Size:=EditorOpts.EditorFontSize; // set Size before name for XLFD !
       Font.Name:=EditorOpts.EditorFont;
     end;
     Font.Style:=[];
@@ -1763,7 +1763,7 @@
     if (Editor<>nil) then
       Font:=Editor.Font
     else begin
-      Font.Height:=EditorOpts.EditorFontHeight; // set Height before name of XLFD !
+      Font.Size:=EditorOpts.EditorFontSize; // set Size before name of XLFD !
       Font.Name:=EditorOpts.EditorFont;
     end;
     Font.Style:=[];
Index: ide/frames/editor_display_options.pas
===================================================================
--- ide/frames/editor_display_options.pas	(revision 32127)
+++ ide/frames/editor_display_options.pas	(working copy)
@@ -39,8 +39,8 @@
     EditorFontButton: TButton;
     EditorFontComboBox: TComboBox;
     EditorFontGroupBox: TGroupBox;
-    EditorFontHeightComboBox: TComboBox;
-    EditorFontHeightLabel: TLabel;
+    EditorFontSizeSpinEdit: TSpinEdit;
+    EditorFontSizeLabel: TLabel;
     ExtraCharSpacingComboBox: TComboBox;
     ExtraCharSpacingLabel: TLabel;
     ExtraLineSpacingComboBox: TComboBox;
@@ -58,6 +58,7 @@
     VisibleRightMarginCheckBox: TCheckBox;
     procedure EditorFontButtonClick(Sender: TObject);
     procedure EditorFontComboBoxEditingDone(Sender: TObject);
+    procedure EditorFontSizeSpinEditChange(Sender: TObject);
     procedure ComboboxOnExit(Sender: TObject);
     procedure ComboBoxOnKeyDown(Sender: TObject; var Key: Word;
       Shift: TShiftState);
@@ -69,7 +70,10 @@
     procedure ShowLineNumbersCheckBoxClick(Sender: TObject);
   private
     FDialog: TAbstractOptionsEditorDialog;
+    FUpdatingFontSizeRange: Boolean;
+    function FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
     function GeneralPage: TEditorGeneralOptionsFrame; inline;
+    procedure SetEditorFontSizeSpinEditValue(FontSize: Integer);
 
     procedure FontDialogApplyClicked(Sender: TObject);
     function DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
@@ -86,6 +90,20 @@
 
 {$R *.lfm}
 
+uses
+  LCLIntf;
+
+function TEditorDisplayOptionsFrame.FontSizeNegativeToPositive(NegativeSize: Integer): Integer;
+var
+  tm: TTextMetric;
+begin
+  DisplayPreview.Canvas.Font.Assign(DisplayPreview.Font);
+  if LCLIntf.GetTextMetrics(DisplayPreview.Canvas.Handle, tm) then
+    Result := -(NegativeSize + MulDiv(tm.tmInternalLeading, 72, DisplayPreview.Font.PixelsPerInch))
+  else
+    Result := -NegativeSize;
+end;
+
 procedure TEditorDisplayOptionsFrame.FontDialogApplyClicked(Sender: TObject);
 var
   a: Integer;
@@ -96,7 +114,7 @@
         PreviewEdits[a].Font.Assign(TFontDialog(Sender).Font);
 
   SetComboBoxText(EditorFontComboBox, DisplayPreview.Font.Name,cstCaseInsensitive);
-  SetComboBoxText(EditorFontHeightComboBox, IntToStr(DisplayPreview.Font.Height),cstCaseInsensitive);
+  SetEditorFontSizeSpinEditValue(DisplayPreview.Font.Size);
 end;
 
 function TEditorDisplayOptionsFrame.DoSynEditMouse(var AnInfo: TSynEditMouseActionInfo;
@@ -108,16 +126,20 @@
 procedure TEditorDisplayOptionsFrame.EditorFontButtonClick(Sender: TObject);
 var
   FontDialog: TFontDialog;
-  NewHeight: LongInt;
+  CurFontSize: Integer;
 begin
   FontDialog := TFontDialog.Create(nil);
   try
     with FontDialog do
     begin
       Font.Name := EditorFontComboBox.Text;
-      NewHeight := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
-      RepairEditorFontHeight(NewHeight);
-      Font.Height := NewHeight;
+      CurFontSize := EditorFontSizeSpinEdit.Value;
+      if CurFontSize < 0 then
+      begin
+        CurFontSize := FontSizeNegativeToPositive(CurFontSize);
+        RepairEditorFontSize(CurFontSize);
+      end;
+      Font.Size := CurFontSize;
       Options := Options + [fdApplyButton];
       OnApplyClicked := @FontDialogApplyClicked;
       if Execute then
@@ -138,21 +160,32 @@
         PreviewEdits[i].Font.Name := EditorFontComboBox.Text;
 end;
 
-procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
+procedure TEditorDisplayOptionsFrame.EditorFontSizeSpinEditChange(Sender: TObject);
 var
   NewVal, a: Integer;
 begin
-  if Sender = EditorFontHeightComboBox then
+  NewVal := EditorFontSizeSpinEdit.Value;
+  if (NewVal < 0) and (NewVal > -EditorOptionsMinimumFontSize) then
   begin
-    NewVal := StrToIntDef(EditorFontHeightComboBox.Text, DisplayPreview.Font.Height);
-    RepairEditorFontHeight(NewVal);
-    SetComboBoxText(EditorFontHeightComboBox, IntToStr(NewVal),cstCaseInsensitive);
+    // Skip to minimum positive value. Will trigger OnChange again.
+    SetEditorFontSizeSpinEditValue(EditorOptionsMinimumFontSize);
+  end
+  else
+  begin
+    if (NewVal > 0) and not FUpdatingFontSizeRange then
+      EditorFontSizeSpinEdit.MinValue := EditorOptionsMinimumFontSize;
+
     with GeneralPage do
       for a := Low(PreviewEdits) to High(PreviewEdits) do
         if PreviewEdits[a] <> nil then
-          PreviewEdits[a].Font.Height := NewVal;
-  end
-  else
+          PreviewEdits[a].Font.Size := NewVal;
+  end;
+end;
+
+procedure TEditorDisplayOptionsFrame.ComboboxOnExit(Sender: TObject);
+var
+  NewVal, a: Integer;
+begin
   if Sender = ExtraCharSpacingComboBox then
   begin
     NewVal := StrToIntDef(ExtraCharSpacingComboBox.Text, DisplayPreview.ExtraCharSpacing);
@@ -277,6 +310,17 @@
   Result := TEditorGeneralOptionsFrame(FDialog.FindEditor(TEditorGeneralOptionsFrame));
 end;
 
+procedure TEditorDisplayOptionsFrame.SetEditorFontSizeSpinEditValue(FontSize: Integer);
+begin
+  FUpdatingFontSizeRange := True;
+  if FontSize < 0 then
+    EditorFontSizeSpinEdit.MinValue := -EditorFontSizeSpinEdit.MaxValue
+  else
+    EditorFontSizeSpinEdit.MinValue := EditorOptionsMinimumFontSize;
+  FUpdatingFontSizeRange := False;
+  EditorFontSizeSpinEdit.Value := FontSize;
+end;
+
 function TEditorDisplayOptionsFrame.GetTitle: String;
 begin
   Result := dlgEdDisplay;
@@ -287,6 +331,7 @@
   // Prevent the caret from moving
   DisplayPreview.RegisterMouseActionSearchHandler(@DoSynEditMouse);
   FDialog := ADialog;
+  FUpdatingFontSizeRange := False;
 
   MarginAndGutterGroupBox.Caption := dlgMarginGutter;
   VisibleRightMarginCheckBox.Caption := dlgVisibleRightMargin;
@@ -296,7 +341,7 @@
   GutterSeparatorIndexLabel.Caption := dlgGutterSeparatorIndex;
   RightMarginLabel.Caption := dlgRightMargin;
   EditorFontGroupBox.Caption := dlgDefaultEditorFont;
-  EditorFontHeightLabel.Caption := dlgEditorFontHeight;
+  EditorFontSizeLabel.Caption := dlgEditorFontSize;
   ExtraCharSpacingLabel.Caption := dlgExtraCharSpacing;
   ExtraLineSpacingLabel.Caption := dlgExtraLineSpacing;
   DisableAntialiasingCheckBox.Caption := dlgDisableAntialiasing;
@@ -320,7 +365,7 @@
     VisibleRightMarginCheckBox.Checked := VisibleRightMargin;
     SetComboBoxText(RightMarginComboBox, IntToStr(RightMargin),cstCaseInsensitive);
     SetComboBoxText(EditorFontComboBox, EditorFont,cstCaseInsensitive);
-    SetComboBoxText(EditorFontHeightComboBox, IntToStr(EditorFontHeight),cstCaseInsensitive);
+    SetEditorFontSizeSpinEditValue(EditorFontSize);
     SetComboBoxText(ExtraCharSpacingComboBox, IntToStr(ExtraCharSpacing),cstCaseInsensitive);
     SetComboBoxText(ExtraLineSpacingComboBox, IntToStr(ExtraLineSpacing),cstCaseInsensitive);
     DisableAntialiasingCheckBox.Checked := DisableAntialiasing;
@@ -342,7 +387,7 @@
     VisibleRightMargin := VisibleRightMarginCheckBox.Checked;
     RightMargin := StrToIntDef(RightMarginComboBox.Text, 80);
     EditorFont := EditorFontComboBox.Text;
-    EditorFontHeight := StrToIntDef(EditorFontHeightComboBox.Text, EditorFontHeight);
+    EditorFontSize := EditorFontSizeSpinEdit.Value;
     ExtraCharSpacing := StrToIntDef(ExtraCharSpacingComboBox.Text, ExtraCharSpacing);
     ExtraLineSpacing := StrToIntDef(ExtraLineSpacingComboBox.Text, ExtraLineSpacing);
     DisableAntialiasing := DisableAntialiasingCheckBox.Checked;
Index: ide/frames/editor_display_options.lfm
===================================================================
--- ide/frames/editor_display_options.lfm	(revision 32127)
+++ ide/frames/editor_display_options.lfm	(working copy)
@@ -177,17 +177,17 @@
     ClientHeight = 87
     ClientWidth = 497
     TabOrder = 1
-    object EditorFontHeightLabel: TLabel
-      AnchorSideLeft.Control = EditorFontHeightComboBox
+    object EditorFontSizeLabel: TLabel
+      AnchorSideLeft.Control = EditorFontSizeSpinEdit
       AnchorSideLeft.Side = asrBottom
-      AnchorSideTop.Control = EditorFontHeightComboBox
+      AnchorSideTop.Control = EditorFontSizeSpinEdit
       AnchorSideTop.Side = asrCenter
       Left = 112
       Height = 14
       Top = 36
       Width = 107
       BorderSpacing.Around = 6
-      Caption = 'EditorFontHeightLabel'
+      Caption = 'EditorFontSizeLabel'
       ParentColor = False
     end
     object ExtraLineSpacingLabel: TLabel
@@ -248,34 +248,20 @@
       OnClick = EditorFontButtonClick
       TabOrder = 1
     end
-    object EditorFontHeightComboBox: TComboBox
+    object EditorFontSizeSpinEdit: TSpinEdit
       AnchorSideLeft.Control = EditorFontGroupBox
       AnchorSideTop.Control = EditorFontComboBox
       AnchorSideTop.Side = asrBottom
       Left = 6
-      Height = 21
-      Top = 33
-      Width = 100
+      Height = 29
+      Top = 41
+      Width = 50
       BorderSpacing.Around = 6
-      ItemHeight = 13
-      Items.Strings = (
-        '10'
-        '11'
-        '12'
-        '13'
-        '14'
-        '15'
-        '16'
-        '17'
-        '18'
-      )
-      OnChange = ComboboxOnChange
-      OnExit = ComboboxOnExit
-      OnKeyDown = ComboBoxOnKeyDown
+      OnChange = EditorFontSizeSpinEditChange
       TabOrder = 2
     end
     object ExtraLineSpacingComboBox: TComboBox
-      AnchorSideLeft.Control = EditorFontHeightLabel
+      AnchorSideLeft.Control = EditorFontSizeLabel
       AnchorSideLeft.Side = asrBottom
       AnchorSideTop.Control = EditorFontComboBox
       AnchorSideTop.Side = asrBottom
@@ -318,7 +304,7 @@
     end
     object DisableAntialiasingCheckBox: TCheckBox
       AnchorSideLeft.Control = EditorFontGroupBox
-      AnchorSideTop.Control = EditorFontHeightComboBox
+      AnchorSideTop.Control = EditorFontSizeSpinEdit
       AnchorSideTop.Side = asrBottom
       Left = 6
       Height = 21
editorfontsize3.diff (18,153 bytes)

Martin Friebe

2011-09-02 00:28

manager   ~0051370

Thanks to cobines for the patch.

Please test and close if ok

Issue History

Date Modified Username Field Change
2010-10-23 00:11 indianajones New Issue
2010-10-23 00:11 indianajones Widgetset => GTK 2
2010-10-23 02:07 Martin Friebe Status new => assigned
2010-10-23 02:07 Martin Friebe Assigned To => Martin Friebe
2010-10-23 02:08 Martin Friebe LazTarget => 1.2
2010-10-23 02:08 Martin Friebe Additional Information Updated
2010-10-31 02:43 Martin Friebe Note Added: 0042467
2010-10-31 02:43 Martin Friebe Status assigned => feedback
2011-02-21 17:03 Michael Van Canneyt Relationship added related to 0018795
2011-02-21 19:53 Gerard V Note Added: 0046175
2011-04-28 12:10 Martin Friebe Relationship added related to 0014357
2011-08-08 19:08 Martin Friebe Status feedback => assigned
2011-08-09 00:09 cobines File Added: editorfontsize.diff
2011-08-09 00:12 cobines Note Added: 0050623
2011-08-09 00:23 Zaher Dirkey Note Added: 0050624
2011-08-09 12:06 cobines Note Added: 0050632
2011-08-09 13:04 cobines Note Edited: 0050632
2011-08-09 14:27 Zaher Dirkey Note Added: 0050642
2011-08-09 16:21 cobines Note Added: 0050650
2011-08-25 18:54 Martin Friebe LazTarget 1.2 => 1.0
2011-08-25 18:54 Martin Friebe Note Added: 0051121
2011-08-25 18:54 Martin Friebe Status assigned => feedback
2011-08-25 18:57 Martin Friebe Note Added: 0051122
2011-08-25 19:15 Martin Friebe Note Edited: 0051122
2011-08-25 19:27 Martin Friebe Note Edited: 0051122
2011-08-26 03:26 cobines Note Added: 0051148
2011-08-26 05:38 cobines Note Edited: 0051148
2011-08-26 05:38 cobines File Added: convert_size_sample.tar.bz2
2011-08-28 14:11 cobines File Added: editorfontsize2.diff
2011-08-31 05:23 cobines File Added: editorfontsize3.diff
2011-09-02 00:28 Martin Friebe Fixed in Revision => 32150
2011-09-02 00:28 Martin Friebe Status feedback => resolved
2011-09-02 00:28 Martin Friebe Fixed in Version => 0.9.31 (SVN)
2011-09-02 00:28 Martin Friebe Resolution open => fixed
2011-09-02 00:28 Martin Friebe Note Added: 0051370
2011-09-02 00:29 Martin Friebe Target Version => 0.99.0
2016-05-30 05:21 Martin Friebe Relationship added related to 0030085