BestSizeEstimator.GetFontToFitBounds(String, BrickStyle, RectangleF, ReportUnit) Method
Gets the font with which the specified text fits the specified boundaries.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.1.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
public static DXFont GetFontToFitBounds(
string text,
BrickStyle style,
RectangleF bounds,
ReportUnit reportUnit
)
Parameters
Name | Type | Description |
---|---|---|
text | String | A string that specifies the text used in calculations. |
style | BrickStyle | A BrickStyle object that specifies a drawing style. |
bounds | RectangleF | A RectangleF structure specifying the initial boundaries which the text should fit. |
reportUnit | ReportUnit | A ReportUnit enumeration value that specifies the system of measurement. |
Returns
Type | Description |
---|---|
DXFont | An optimal font. |
Remarks
The GetFontToFitBounds
method allows you to calculate an optimal font for the specified text to occupy the entire specified area.
The code snippet below demonstrates how to use this method to draw a LabelBrick with maximum possible text size.
using DevExpress.XtraReports.UI;
using DevExpress.Drawing;
// Prepare for creating a document.
printingSystem.Begin();
BrickGraphics gr = printingSystem.Graph;
gr.Modifier = BrickModifier.Detail;
// Create a new brick instance and specify its settings.
LabelBrick brick = new LabelBrick();
brick.Text = "Some text";
brick.Rect = new RectangleF(0, 0, 200, 100);
DXFont font = BestSizeEstimator.GetFontToFitBounds(brick.Text, brick.Style, brick.Rect, ReportUnit.Pixels);
brick.Style.Font = font;
gr.DrawBrick(brick);
// Finish creating the document.
printingSystem.End();
To perform the opposite operation (that is get the boundaries to fit the specified text), call the BestSizeEstimator.GetBoundsToFitText method.