[DllImport("gdi32.dll", EntryPoint = "GetCharABCWidthsW", SetLastError = true)]
static extern unsafe bool GetCharABCWidths(IntPtr hdc, uint uFirstChar,
uint uLastChar, ABC* lpabc);
[StructLayout(LayoutKind.Sequential)]
public struct ABC
{
public int abcA;
public uint abcB;
public int abcC;
public override string ToString()
{
return string.Format("A={0}, B={1}, C={2}", abcA, abcB, abcC);
}
}
None.
The following managed wrapper can be used to get the width of a single character.
public unsafe ABC GetCharABCWidth(char ch)
{
ABC[] abc = new ABC[1];
fixed (ABC* ar = abc)
{
if (!GetCharABCWidths(hdc, (uint)ch, (uint)ch, ar))
{
int err = Marshal.GetLastWin32Error();
throw new Exception("GetCharABCWidthsW failed with code "+err.ToString());
}
}
return abc[0];
}
Please add some!
Do you know one? Please contribute it!