예제 #1
0
        public static GlyphTable Load(FontReader reader)
        {
            uint[] locations           = reader.GetTable <IndexLocationTable>().GlyphOffsets;
            Bounds fallbackEmptyBounds = reader.GetTable <HeadTable>().Bounds;

            using (BinaryReader binaryReader = reader.GetReaderAtTablePosition(TableName))
            {
                return(Load(binaryReader, locations, fallbackEmptyBounds));
            }
        }
        public static HorizontalMetricsTable Load(FontReader reader)
        {
            // you should load all dependent tables prior to manipulating the reader
            HorizontalHeadTable headTable    = reader.GetTable <HorizontalHeadTable>();
            MaximumProfileTable profileTable = reader.GetTable <MaximumProfileTable>();

            // Move to start of table
            using BigEndianBinaryReader binaryReader = reader.GetReaderAtTablePosition(TableName);
            return(Load(binaryReader, headTable.NumberOfHMetrics, profileTable.GlyphCount));
        }
예제 #3
0
        public static IndexLocationTable Load(FontReader reader)
        {
            var head = reader.GetTable <HeadTable>();
            var maxp = reader.GetTable <MaximumProfileTable>();

            // must not get a binary reader untill all depended data is retrieved in case they need to use the stream
            using (var binaryReader = reader.GetReaderAtTablePosition(TableName))
            {
                return(Load(binaryReader, maxp.GlyphCount, head.IndexLocationFormat));
            }
        }
예제 #4
0
        public static GlyphTable Load(FontReader reader)
        {
            var locations = reader.GetTable <IndexLocationTable>().GlyphOffsets;

            using (var binaryReader = reader.GetReaderAtTablePosition(TableName))
            {
                return(Load(binaryReader, locations));
            }
        }
        public void GlyphsCount_WithWoffFormat_EqualsTtf()
        {
            var        fontReaderWoff = new FontReader(TestFonts.OpensSansWoff1Data());
            GlyphTable glyphsWoff     = fontReaderWoff.GetTable <GlyphTable>();
            var        fontReaderTtf  = new FontReader(TestFonts.OpenSansTtfData());
            GlyphTable glyphsTtf      = fontReaderTtf.GetTable <GlyphTable>();

            Assert.Equal(glyphsTtf.GlyphCount, glyphsWoff.GlyphCount);
        }
예제 #6
0
        public static IndexLocationTable Load(FontReader reader)
        {
            HeadTable head = reader.GetTable <HeadTable>();

            if (head == null)
            {
                throw new InvalidFontTableException("Unable to find table", "head");
            }

            MaximumProfileTable maxp = reader.GetTable <MaximumProfileTable>();

            // must not get a binary reader untill all depended data is retrieved in case they need to use the stream
            using (BinaryReader binaryReader = reader.TryGetReaderAtTablePosition(TableName))
            {
                if (binaryReader == null)
                {
                    return(null);
                }

                return(Load(binaryReader, maxp.GlyphCount, head.IndexLocationFormat));
            }
        }
예제 #7
0
        public void ReadCMapTable()
        {
            BinaryWriter writer = new BinaryWriter();

            writer.WriteTrueTypeFileHeader(new TableHeader("cmap", 0, 0, 20));

            writer.WriteCMapTable(new[] {
                new SixLabors.Fonts.Tables.General.CMap.Format0SubTable(0, WellKnownIds.PlatformIDs.Macintosh, 1, new byte[] { 2, 9 })
            });

            FontReader reader = new FontReader(writer.GetStream());
            CMapTable  cmap   = reader.GetTable <CMapTable>();

            Assert.NotNull(cmap);
        }
예제 #8
0
        public void ShouldReturnTableValues()
        {
            var writer = new BigEndianBinaryWriter();

            writer.WriteTrueTypeFileHeader();
            writer.WriteColrTable(new[]
            {
                new ColrGlyphRecord
                {
                    Glyph  = 1,
                    Layers =
                    {
                        new ColrLayerRecord {
                            Glyph = 10, Pallete = 1
                        },
                        new ColrLayerRecord {
                            Glyph = 11, Pallete = 2
                        }
                    }
                },
                new ColrGlyphRecord
                {
                    Glyph  = 2,
                    Layers =
                    {
                        new ColrLayerRecord {
                            Glyph = 12, Pallete = 1
                        },
                        new ColrLayerRecord {
                            Glyph = 13, Pallete = 2
                        }
                    }
                }
            });

            using (System.IO.Stream stream = TestFonts.TwemojiMozillaData())
            {
                var       reader = new FontReader(stream);
                ColrTable tbl    = reader.GetTable <ColrTable>();

                System.Span <Fonts.Tables.General.Colr.LayerRecord> layers = tbl.GetLayers(15);
                Assert.Equal(2, layers.Length);
            }
        }