[]
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.
double GetDigitWidth(TextFormatInfo textFormat)
Function GetDigitWidth(textFormat As TextFormatInfo) As Double
| Type | Name | Description |
|---|---|---|
| TextFormatInfo | textFormat | The text format used to measure the digits. |
| Type | Description |
|---|---|
| double | The maximum width of the digits 0 through 9, in device-independent pixels. |
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);