Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 2441 - TFont in Tee.Format.pas does not handle negative Size
Summary: TFont in Tee.Format.pas does not handle negative Size
Status: RESOLVED FIXED
Alias: None
Product: TeeGrid for Delphi
Classification: Unclassified
Component: Grid (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- major
Target Milestone: ---
Assignee: david berneda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-28 23:13 EDT by dean.mustakinov
Modified: 2021-09-15 07:05 EDT (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dean.mustakinov 2021-06-28 23:13:38 EDT
VCL TFont uses negative Size to specify that internal leading on top of each line of text is included in Size.
TeeGrid assigns Self.Font.Size to Tee.Format.TFont.DefaultSize when ParentFont = true.
If parent uses negative Size then Tee.Format.TFont does not work correctly.

I have made a simple workaround for this in Tee.Format.pas:
-added public function to convert between negative and positive Size
class function TFont.GetTeeFontSize(const AWinFontSize: Single): Single; // DM CHANGE
begin
  if AWinFontSize >= 0 then result := AWinFontSize
  else result := Abs(AWinFontSize) * 0.9; // approximately font size - internal leading
end;

-changed following methods to use the GetTeeFontSize when setting internal font size:
Constructor TFont.Create(const AChanged: TNotifyEvent);
begin
  inherited;

  FName:=DefaultName;

  DefaultStyle:=[];

  FBrush:=TBrush.Create(AChanged);
  FBrush.InitColor(TColors.Black);

  FSize:=GetTeeFontSize(DefaultSize); // DM CHANGE
end;

procedure TFont.Assign(Source: TPersistent);
begin
  if Source is TFont then
  begin
    Brush:=TFont(Source).FBrush;
    FName:=TFont(Source).Name;
    FSize:=GetTeeFontSize(TFont(Source).FSize); // DM CHANGE
    FStyle:=TFont(Source).FStyle;
  end
  else
    inherited;
end;

function TFont.IsSizeStored: Boolean;
begin
  result:=GetTeeFontSize(FSize)<>GetTeeFontSize(DefaultSize); // DM CHANGE
end;

procedure TFont.SetSize(const Value: Single);
begin
  if FSize<>GetTeeFontSize(Value) then // DM CHANGE
  begin
    FSize:=GetTeeFontSize(Value); // DM CHANGE
    Changed;
  end;
end;
Comment 1 marc meumann 2021-09-15 07:05:55 EDT
Thank you Dean. Code included.