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

Summary: TFont in Tee.Format.pas does not handle negative Size
Product: TeeGrid for Delphi Reporter: dean.mustakinov
Component: GridAssignee: david berneda <david>
Status: RESOLVED FIXED    
Severity: major CC: marc
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

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.