Archive Browser
Download GetTextMetricsDemo.zip, last updated 09/07/2016 (10.51 KB)
Download- md5: 5716cc483e334071b2334c8ae92e076f
- sha1: 2c94d15164e3498d892843eaf8b78d77dd3ba8c7
- sha256: 3bf039f038a478d5f31aca3e1ca634739e4343a84de89ab73ff6c2f33653f9c2
using System;
using System.Runtime.InteropServices;
// Retrieving font and text metrics using C#
// http://www.cyotek.com/blog/retrieving-font-and-text-metrics-using-csharp
// Copyright © 2016 Cyotek Ltd. All Rights Reserved.
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
namespace GetTextMetricsDemo
{
internal static class NativeMethods
{
#region Externals
[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool DeleteObject(IntPtr hObject);
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
public static extern bool GetTextMetrics(IntPtr hdc, out TEXTMETRICW lptm);
[DllImport("gdi32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiObj);
#endregion
#region Nested type: TEXTMETRICW
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TEXTMETRICW
{
public int tmHeight;
public int tmAscent;
public int tmDescent;
public int tmInternalLeading;
public int tmExternalLeading;
public int tmAveCharWidth;
public int tmMaxCharWidth;
public int tmWeight;
public int tmOverhang;
public int tmDigitizedAspectX;
public int tmDigitizedAspectY;
public ushort tmFirstChar;
public ushort tmLastChar;
public ushort tmDefaultChar;
public ushort tmBreakChar;
public byte tmItalic;
public byte tmUnderlined;
public byte tmStruckOut;
public byte tmPitchAndFamily;
public byte tmCharSet;
}
#endregion
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate