using System; namespace FastReport.Fonts { /// /// IndexToLocation table /// public class IndexToLocationClass : TrueTypeTable { private ushort[] shortIndexToLocation = null; private uint[] longIndexToLocation = null; internal ushort[] Short { get { return shortIndexToLocation; } } internal uint[] Long { get { return longIndexToLocation; } } internal void LoadIndexToLocation(FontStream stream, FontHeaderClass font_header) { int count; stream.Seek(this.Offset, System.IO.SeekOrigin.Begin); switch (font_header.indexToLocFormat) { case FontHeaderClass.IndexToLoc.ShortType: count = (int)this.Length / 2; shortIndexToLocation = new ushort[count]; for (int i = 0; i < count; i++) { shortIndexToLocation[i] = stream.ReadUInt16(); } break; case FontHeaderClass.IndexToLoc.LongType: count = (int)this.Length / 4; longIndexToLocation = new uint[count]; for (int j = 0; j < count; j++) { longIndexToLocation[j] = stream.ReadUInt32(); } break; default: throw new Exception("Unsupported Index to Location format"); } } public ushort GetGlyph(ushort i2l_idx, FontHeaderClass font_header, out uint location) { location = 0; ushort length = 0; switch (font_header.indexToLocFormat) { case FontHeaderClass.IndexToLoc.ShortType: if (i2l_idx >= shortIndexToLocation.Length) { location = 0; break; } location = (uint)(2 * shortIndexToLocation[i2l_idx]); length = (ushort)(2 * (shortIndexToLocation[i2l_idx + 1] - shortIndexToLocation[i2l_idx])); break; case FontHeaderClass.IndexToLoc.LongType: if (i2l_idx >= longIndexToLocation.Length - 1) { break; } location = longIndexToLocation[i2l_idx]; length = (ushort)(longIndexToLocation[i2l_idx + 1] - longIndexToLocation[i2l_idx]); break; } return length; } //internal override uint Save(FontStream font, uint offset) //// internal override uint Save(IntPtr src, IntPtr dst, uint offset) //{ // this.Offset = offset; // return base.Save(font, offset); //} public IndexToLocationClass(TrueTypeTable src) : base(src) { } } }