Unit for font int TextObject

Hello,

I try set the size of text on TextObject and found property "Unit".

But font have the same size for all units. How can I use this parameter? Because the 20 millimeters is not same as 20 Inches, but in label (20 x 20 mm) text looks same with 20 mm or 20 Inch.

I use the FastReport default designer ver. 2019.4.0


BR

Peter Stellmach

Comments

  • Hello!

    The Unit property within the TextObject.Font property is a standard property of System.Drawing.Font.Unit (GraphicsUnit: Point, Millimetre, Inch, Pixel). When editing in the Properties Inspector or during rendering, FastReport uses font size in points (Font.SizeInPoints / GraphicsUnit.Point, 1 point = 1/72 of an inch); therefore, changing only the Unit property in Font does not scale the visual size of the text as expected (or the default Point constructor is reset).

    To specify the exact physical font size in millimetres in C# code, convert the millimetres to points (1 mm = 72f / 25.4f ≈ 2.8346 pt):

    float sizeMm = 20f;
    textObject.Font = new Font(‘Arial’, sizeMm * 72f / 25.4f, FontStyle.Regular);
    

    The size of the TextObject itself (Bounds, Width, Height) in the report is always specified in screen pixels (96 DPI: 1 mm = 3.78f px, see Units.Millimetres)

This discussion has been closed.