Skip to main content

TdxSpreadSheetCustomFont.Size Property

Specifies the font size.

Declaration

property Size: Integer read; write;

Property Value

Type
Integer

Remarks

Use this property to specify the point size of the font. If the value is negative, the internal leading that appears at the top of each line of text is included. If the value is positive, the Size property represents the height of the characters but not the internal leading.

To determine the size of the font in pixels, use the Height property instead. You can obtain the value of the Size property from the Height in pixels by using this formula:

Font.Size = -Font.Height * 72/Font.PixelsPerInch

When the Size property has a positive value, the Height property has a negative value. When the Height property has a positive value, the Size property has a negative value.

The following code example applies incrementing sizes to the A1:A5 cell range:

var
  ATableView: TdxSpreadSheetTableView;
  ACell: TdxSpreadSheetCell;
  AFont: TdxSpreadSheetCellFont;
  I, ASize: Integer;
//...
  ATableView := TdxSpreadSheetTableView(dxSpreadSheet1.ActiveSheet);
  for I := 0 to 4 do
    begin
      ACell := ATableView.CreateCell(I, 0);
      ASize := (I + 2) * 5;
      ACell.AsText := 'Font Size = ' + IntToStr(ASize);
      AFont := ACell.Style.Font;
      AFont.Size := ASize;
    end;

To allow an end-user to change font size in the currently selected cells, you can link the ChangeFontSize, DecreaseFontSize and IncreaseFontSize commands to elements of your UI.

See Also