private GetFontData ( |
||
hdc | ||
dwTable | uint | |
dwOffset | uint | |
lpvBuffer | [ | |
cbData | uint | |
Résultat | uint |
/// <summary> /// Gets font metric data for a TrueType font or TrueType collection. /// </summary> /// <returns></returns> public byte[] GetFontData() { if (data == null) { try { // Check if this is a TrueType font collection uint ttcfTag = TableNames.ToUint(TableNames.Ttcf); uint ttcfSize = LibWrapper.GetFontData(dc.Handle, ttcfTag, 0, null, 0); if (ttcfSize != 0 && ttcfSize != 0xFFFFFFFF) { data = ReadFontFromCollection(); } else { data = ReadFont(); } } catch (Exception e) { throw new Exception( String.Format("Failed to load data for font {0}", FaceName), e); } } return(data); }
private byte[] ReadTableData(string tableName) { uint tag = TableNames.ToUint(tableName); uint size = LibWrapper.GetFontData(dc.Handle, tag, 0, null, 0); byte[] data = new byte[size]; uint rv = LibWrapper.GetFontData(dc.Handle, tag, 0, data, (uint)data.Length); if (rv == GdiFontMetrics.GDI_ERROR) { throw new Exception("Failed to retrieve table " + tableName); } return(data); }
private byte[] ReadFont() { uint bufferSize = LibWrapper.GetFontData(dc.Handle, 0, 0, null, 0); if (bufferSize == 0xFFFFFFFF) { throw new InvalidOperationException("No font selected into device context"); } byte[] buffer = new byte[bufferSize]; uint rv = LibWrapper.GetFontData(dc.Handle, 0, 0, buffer, bufferSize); if (rv == GDI_ERROR) { throw new Exception("Failed to retrieve table data for font " + FaceName); } return(buffer); }