public void LoadSingleGlyphWithInt8Offset_signed_byte()
        {
            var writer = new BigEndianBinaryWriter();

            writer.WriteUInt16((ushort)CompositeGlyphFlags.ArgsAreXYValues); // signed byte
            writer.WriteUInt16(1);                                           // glyph id

            writer.WriteInt8(sbyte.MinValue + 1);                            // dx
            writer.WriteInt8(sbyte.MinValue + 2);                            // dy
            writer.GetReader();

            var bounds = new Bounds(0, 0, 100, 100);
            var glyph  = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds);

            var tbl = new GlyphTable(new[]
            {
                new SimpleGlyphLoader(bounds), // padding
                new SimpleGlyphLoader(new short[] { 20 }, new short[] { 21 }, new[] { true }, new ushort[] { 1 }, bounds, Array.Empty <byte>())
            });

            GlyphVector finalGlyph = glyph.CreateGlyph(tbl);

            Vector2 point = Assert.Single(finalGlyph.GetOutline().ControlPoints.ToArray());

            Assert.Equal(new Vector2(sbyte.MinValue + 1 + 20, sbyte.MinValue + 2 + 21), point);
        }
예제 #2
0
        public void CloneIsDeep()
        {
            // arrange
            Vector2[]    controlPoints = { new(1.0f), new(2.0f) };
            bool[]       onCurves      = { true, false };
            ushort[]     endPoints     = { 1, 2, 3 };
            var          bounds        = new Bounds(1.0f, 2.0f, 3.0f, 4.0f);
            var          glyphVector   = new GlyphVector(controlPoints, onCurves, endPoints, bounds, Array.Empty <byte>());
            GlyphOutline outline       = glyphVector.GetOutline();

            // act
            GlyphOutline clone = GlyphVector.DeepClone(glyphVector).GetOutline();

            // assert
            Assert.False(outline.ControlPoints.Equals(clone.ControlPoints));
            Assert.True(outline.ControlPoints.Span.SequenceEqual(clone.ControlPoints.Span));
            Assert.False(outline.OnCurves.Equals(clone.OnCurves));
            Assert.True(outline.OnCurves.Span.SequenceEqual(clone.OnCurves.Span));
            Assert.False(outline.EndPoints.Equals(clone.EndPoints));
            Assert.True(outline.EndPoints.Span.SequenceEqual(clone.EndPoints.Span));
        }
예제 #3
0
 public void DrawGlyphVector(GlyphVector g, float x, float y)
 {
     Fill(g.GetOutline(x, y));
 }
예제 #4
0
 /**
  * Renders the text of the specified
  * {@link GlyphVector} using
  * the <code>Graphics2D</code> context's rendering attributes.
  * The rendering attributes applied include the <code>Clip</code>,
  * <code>Transform</code>, <code>Paint</code>, and
  * <code>Composite</code> attributes.  The <code>GlyphVector</code>
  * specifies individual glyphs from a {@link Font}.
  * The <code>GlyphVector</code> can also contain the glyph positions.
  * This is the fastest way to render a Set of characters to the
  * screen.
  *
  * @param g the <code>GlyphVector</code> to be rendered
  * @param x the x position in user space where the glyphs should be
  *        rendered
  * @param y the y position in user space where the glyphs should be
  *        rendered
  *
  * @see java.awt.Font#CreateGlyphVector(FontRenderContext, char[])
  * @see java.awt.font.GlyphVector
  * @see #setPaint
  * @see java.awt.Graphics#setColor
  * @see #setTransform
  * @see #setComposite
  * @see #setClip(Shape)
  */
 public void DrawGlyphVector(GlyphVector g, float x, float y) {
     Shape glyphOutline = g.GetOutline(x, y);
     Fill(glyphOutline);
 }