/// <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); }