示例#1
0
        public override FontGlyph GetGlyphByIndex(uint glyphIndex)
        {
            FontGlyph glyph;
            //temp
            char c = (char)glyphIndex;

            if (!cachedGlyphs.TryGetValue(c, out glyph))
            {
                //create font glyph for this font size
                var         originalGlyph  = fontface.GetGlyphForCharacter(c);
                VertexStore characterGlyph = scaleTx.TransformToVxs(originalGlyph.originalVxs);
                glyph             = new FontGlyph();
                glyph.originalVxs = characterGlyph;
                //then flatten it
                characterGlyph    = curveFlattner.MakeVxs(characterGlyph);
                glyph.flattenVxs  = characterGlyph;
                glyph.horiz_adv_x = originalGlyph.horiz_adv_x;
                cachedGlyphs.Add(c, glyph);
            }
            return(glyph);
        }
示例#2
0
        public FontGlyph GetGlyphByIndex(uint glyphIndex)
        {
            FontGlyph glyph;

            //temp
            if (!cachedGlyphsByIndex.TryGetValue(glyphIndex, out glyph))
            {
                //create font glyph for this font size
                FontGlyph originalGlyph = fontface.GetGlyphByIndex((int)glyphIndex);

                VertexStore characterGlyph = new VertexStore();
                scaleTx.TransformToVxs(originalGlyph.originalVxs, characterGlyph);

                glyph             = new FontGlyph();
                glyph.originalVxs = characterGlyph;
                //then flatten it
                glyph.flattenVxs  = curveFlattner.MakeVxs(characterGlyph, new VertexStore());
                glyph.horiz_adv_x = originalGlyph.horiz_adv_x;
                cachedGlyphsByIndex.Add(glyphIndex, glyph);
            }
            return(glyph);
        }
示例#3
0
        public void MakeSmoothPath()
        {
            if (this.isValidSmooth)
            {
                return;
            }
            this.isValidSmooth = true;
            //--------
            if (contPoints.Count == 0)
            {
                return;
            }
            //return;
            //--------
            //lets smooth it
            //string str1 = dbugDumpPointsToString(contPoints);
            //string str2 = dbugDumpPointsToString2(contPoints);
            //var data2 = CurvePreprocess.RdpReduce(contPoints, 2);
            var data2 = contPoints;

            CubicBezier[] cubicBzs = CurveFit.Fit(data2, 8);
            //PathWriter pWriter = new PathWriter();
            //pWriter.StartFigure();

            //int j = cubicBzs.Length;
            //for (int i = 0; i < j; ++i)
            //{
            //    CubicBezier bz = cubicBzs[i];
            //    pWriter.MoveTo(bz.p0.x, bz.p0.y);
            //    pWriter.LineTo(bz.p0.x, bz.p0.y);

            //    pWriter.Curve4(bz.p1.x, bz.p1.y,
            //            bz.p2.x, bz.p2.y,
            //            bz.p3.x, bz.p3.y);
            //}
            //pWriter.CloseFigureCCW();
            vxs = new VertexStore();
            int j = cubicBzs.Length;

            //1.
            if (j > 0)
            {
                //1st
                CubicBezier bz0 = cubicBzs[0];
                vxs.AddMoveTo(bz0.p0.x, bz0.p0.y);
                vxs.AddLineTo(bz0.p0.x, bz0.p0.y);
                vxs.AddP3c(bz0.p1.x, bz0.p1.y);
                vxs.AddP3c(bz0.p2.x, bz0.p2.y);
                vxs.AddLineTo(bz0.p3.x, bz0.p3.y);
                //-------------------------------
                for (int i = 1; i < j; ++i) //start at 1
                {
                    CubicBezier bz = cubicBzs[i];
                    vxs.AddP3c(bz.p1.x, bz.p1.y);
                    vxs.AddP3c(bz.p2.x, bz.p2.y);
                    vxs.AddLineTo(bz.p3.x, bz.p3.y);
                }
                //-------------------------------
                //close
                vxs.AddLineTo(bz0.p0.x, bz0.p0.y);
            }
            vxs.AddCloseFigure();
            PixelFarm.Agg.VertexSource.CurveFlattener cflat = new PixelFarm.Agg.VertexSource.CurveFlattener();
            vxs = cflat.MakeVxs(vxs);
        }