Example #1
0
        private static async Task <IList <string> > GetTableNameAsync(FontReader reader, uint offset)
        {
            await reader.SeekAsync(offset);

            await reader.SkipAsync(2); //version

            var nameRecordCount = await reader.ReadUInt16BEAsync();

            ushort storageOffset = await reader.ReadUInt16BEAsync();

            var items = new List <string>();

            for (int i = 0; i < nameRecordCount; i++)
            {
                var platformID = await reader.ReadUInt16BEAsync();

                var encodingID = await reader.ReadUInt16BEAsync();

                var languageID = await reader.ReadUInt16BEAsync();

                var nameID = await reader.ReadUInt16BEAsync();

                var length = await reader.ReadUInt16BEAsync();

                var stringOffset   = (ushort)(await reader.ReadUInt16BEAsync() + storageOffset);
                var actualPosition = reader.BaseStream.Position;
                if (nameID != NameID.Family)
                {
                    continue;
                }
                var data = await ExtractStringFromNameRecordAsync(reader,
                                                                  offset,
                                                                  stringOffset,
                                                                  length,
                                                                  platformID,
                                                                  encodingID);

                reader.BaseStream.Seek(actualPosition, SeekOrigin.Begin);
                items.Add(data);
            }
            return(items);
        }
Example #2
0
        public static async Task <List <string> > GetFontFamilyAsync(FontReader reader)
        {
            var sfntVersion = await reader.ReadUInt32BEAsync();

            FontCheck.ValidateSfntVersion(sfntVersion);
            var tableCount = await reader.ReadUInt16BEAsync();

            await reader.SkipAsync(6);

            var offsetItems = new List <uint>();

            for (var i = 0; i < tableCount; i++)
            {
                var tagByte = await reader.ReadBytesAsync(4);

                var checksum = await reader.ReadUInt32BEAsync();

                var offset = await reader.ReadUInt32BEAsync();

                var length = await reader.ReadUInt32BEAsync();

                var tag = FontCheck.ConvertToTagName(tagByte);
                if (tag != Tables.NAME)
                {
                    continue;
                }
                offsetItems.Add(offset);
            }
            var items = new List <string>();

            foreach (var item in offsetItems)
            {
                items.AddRange(await GetTableNameAsync(reader, item));
            }

            return(items);
        }