private Head(BinaryReader input) { var version = input.ReadUInt32(); // 0x00010000 for version 1.0. var fontRevision = input.ReadUInt32(); var checkSumAdjustment = input.ReadUInt32(); var magicNumber = input.ReadUInt32(); if (magicNumber != 0x5F0F3CF5) { throw new NRasterizerException("Invalid magic number!" + magicNumber.ToString("x")); } var flags = input.ReadUInt16(); _unitsPerEm = input.ReadUInt16(); // valid is 16 to 16384 var created = input.ReadUInt64(); // International date (8-byte field). (?) var modified = input.ReadUInt64(); // bounding box for all glyphs _bounds = BoundsReader.ReadFrom(input); var macStyle = input.ReadUInt16(); var lowestRecPPEM = input.ReadUInt16(); var fontDirectionHint = input.ReadInt16(); _indexToLocFormat = input.ReadInt16(); // 0 for 16-bit offsets, 1 for 32-bit. var glyphDataFormat = input.ReadInt16(); // 0 }
internal static List <Glyph> From(TableEntry table, GlyphLocations locations) { var glyphCount = locations.GlyphCount; var glyphs = new List <Glyph>(glyphCount); var compositeGlyphs = new List <CompositeGlyph>(glyphCount); for (int i = 0; i < glyphCount; i++) { var input = table.GetDataReader(); input.BaseStream.Seek(locations.Offsets[i], SeekOrigin.Current); var length = locations.Offsets[i + 1] - locations.Offsets[i]; if (length > 0) { var contoursCount = input.ReadInt16(); var bounds = BoundsReader.ReadFrom(input); if (contoursCount >= 0) { glyphs.Add(ReadSimpleGlyph(input, contoursCount, bounds)); } else { compositeGlyphs.Add(ReadCompositeGlyph(input, -contoursCount, bounds, glyphs)); glyphs.Add(null); } } else { glyphs.Add(Glyph.Empty); } } // Flatten all composites int c = 0; for (int i = 0; i < glyphs.Count; i++) { if (glyphs[i] == null) { glyphs[i] = compositeGlyphs[c].Flatten(glyphs); c++; } } return(glyphs); }