internal static void MeasureCharWidths(IntPtr hFont, out int[] charWidths, out NativeTextWin32.FontABC[] abcSizes) { //only in ascii range //current version charWidths = new int[MAX_CODEPOINT_NO + 1]; // MyWin32.SelectObject(win32MemDc.DC, hFont); unsafe { //see: https://msdn.microsoft.com/en-us/library/ms404377(v=vs.110).aspx //A code page contains 256 code points and is zero-based. //In most code pages, code points 0 through 127 represent the ASCII character set, //and code points 128 through 255 differ significantly between code pages abcSizes = new NativeTextWin32.FontABC[MAX_CODEPOINT_NO + 1]; fixed(NativeTextWin32.FontABC *abc = abcSizes) { NativeTextWin32.GetCharABCWidths(win32MemDc.DC, (uint)0, (uint)MAX_CODEPOINT_NO, abc); } for (int i = 0; i < (MAX_CODEPOINT_NO + 1); ++i) { charWidths[i] = abcSizes[i].Sum; } } }
internal static void MeasureCharWidths(IntPtr hFont, out int[] charWidths, out NativeTextWin32.FontABC[] abcSizes) { //only in ascii range //current version charWidths = new int[MAX_CODEPOINT_NO + 1]; // MyWin32.SelectObject(win32MemDc.DC, hFont); unsafe { //see: https://msdn.microsoft.com/en-us/library/ms404377(v=vs.110).aspx //A code page contains 256 code points and is zero-based. //In most code pages, code points 0 through 127 represent the ASCII character set, //and code points 128 through 255 differ significantly between code pages abcSizes = new NativeTextWin32.FontABC[MAX_CODEPOINT_NO + 1]; fixed (NativeTextWin32.FontABC* abc = abcSizes) { NativeTextWin32.GetCharABCWidths(win32MemDc.DC, (uint)0, (uint)MAX_CODEPOINT_NO, abc); } for (int i = 0; i < (MAX_CODEPOINT_NO + 1); ++i) { charWidths[i] = abcSizes[i].Sum; } } }