public void LoadFont_WithWoff2Format()
        {
            Font font = new FontCollection().Add(TestFonts.OpensSansWoff2Data()).CreateFont(12);

            GlyphMetrics glyph = font.FontMetrics.GetGlyphMetrics(new CodePoint('A'), ColorFontSupport.None).First();
            var          r     = new GlyphRenderer();

            glyph.RenderTo(r, font.Size, System.Numerics.Vector2.Zero, new TextOptions(font));

            Assert.Equal(37, r.ControlPoints.Count);
            Assert.Single(r.GlyphKeys);
            Assert.Single(r.GlyphRects);
        }
Example #2
0
        public void LayoutWithLocation(string text, float x, float y, float expectedX, float expectedY)
        {
            FontCollection c    = new FontCollection();
            Font           font = c.Install(TestFonts.SimpleFontFileData()).CreateFont(12);

            int scaleFactor   = 72 * font.EmSize; // 72 * emSize means 1 point = 1px
            var glyphRenderer = new GlyphRenderer();
            var renderer      = new TextRenderer(glyphRenderer);

            renderer.RenderText(text, new RendererOptions(new Font(font, 1), 72 * font.EmSize, new PointF(x, y)));

            Assert.Equal(new PointF(expectedX, expectedY), glyphRenderer.GlyphRects[0].Location);
        }
Example #3
0
        public void LoadFontWoff()
        {
            IFontInstance font = FontInstance.LoadFont(TestFonts.SimpleFontFileWoffData());

            Assert.Equal("SixLaborsSampleAB regular", font.Description.FontName);
            Assert.Equal("Regular", font.Description.FontSubFamilyName);

            GlyphInstance glyph = font.GetGlyph('a');
            var           r     = new GlyphRenderer();

            glyph.RenderTo(r, 12, System.Numerics.Vector2.Zero, new System.Numerics.Vector2(72), 0);
            // the test font only has characters .notdef, 'a' & 'b' defined
            Assert.Equal(6, r.ControlPoints.Distinct().Count());
        }
        public void LoadFontWoff()
        {
            Font font = new FontCollection().Add(TestFonts.SimpleFontFileWoffData()).CreateFont(12);

            Assert.Equal("SixLaborsSampleAB regular", font.FontMetrics.Description.FontNameInvariantCulture);
            Assert.Equal("Regular", font.FontMetrics.Description.FontSubFamilyNameInvariantCulture);

            GlyphMetrics glyph = font.FontMetrics.GetGlyphMetrics(new CodePoint('a'), ColorFontSupport.None).First();
            var          r     = new GlyphRenderer();

            glyph.RenderTo(r, 12, System.Numerics.Vector2.Zero, new TextOptions(font));

            // the test font only has characters .notdef, 'a' & 'b' defined
            Assert.Equal(6, r.ControlPoints.Distinct().Count());
        }