[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IGraphicsInfo.GetDigitWidth

GetDigitWidth Method

GetDigitWidth(TextFormatInfo)

Gets the maximum width of the digits 0 through 9, in device-independent pixels. Useful formulas for wrapping a native implementation that returns pixels:

[Device independent pixel] = Pixel / [DPI Scale]

[DPI Scale] = DPI / 96.

Declaration
double GetDigitWidth(TextFormatInfo textFormat)
Function GetDigitWidth(textFormat As TextFormatInfo) As Double
Parameters
Type Name Description
TextFormatInfo textFormat

The text format used to measure the digits.

Returns
Type Description
double

The maximum width of the digits 0 through 9, in device-independent pixels.

Examples
class CustomGraphicsInfo : IGraphicsInfo
{
    public double GetDigitWidth(TextFormatInfo textFormat)
    {
        if ("Calibri" == textFormat.FontFamily)
        {
            return 8 * textFormat.FontSize / 11;
        }
        return 7 * textFormat.FontSize / 11;
    }
}
IGraphicsInfo graphicsInfo = new CustomGraphicsInfo();
TextFormatInfo textFormat = new TextFormatInfo();
textFormat.FontFamily = "Calibri";
textFormat.FontSize = 11;
double digitWidth = graphicsInfo.GetDigitWidth(textFormat);