Beispiel #1
0
        public VertexStore CreateVxs(char[] buffer, double x = 0, double y = 0)
        {
            int j        = buffer.Length;
            int buffsize = j * 2;

            //get kerning list

            ProperGlyph[] properGlyphs = new ProperGlyph[buffsize];
            currentFont.GetGlyphPos(buffer, 0, buffsize, properGlyphs);
            VertexStore resultVxs = new VertexStore();


            double xpos = x;

            for (int i = 0; i < buffsize; ++i)
            {
                uint codepoint = properGlyphs[i].codepoint;
                if (codepoint == 0)
                {
                    break;
                }
                //-------------------------------------------------------------
                FontGlyph glyph = this.currentFont.GetGlyphByIndex(codepoint);
                var       left  = glyph.exportGlyph.img_horiBearingX;
                //--------------------------------------------------------
                VertexStore vxs1 = Agg.Transform.Affine.TranslateToVxs(
                    glyph.flattenVxs,
                    (float)(xpos),
                    (float)(y));
                //--------------------------------------------------------
                resultVxs.AddSubVertices(vxs1);


                int w = (glyph.exportGlyph.advanceX) >> 6;
                xpos += (w);
                //-------------------------------------------------------------
            }
            return(resultVxs);
        }
Beispiel #2
0
        public void Print(PixelFarm.Drawing.Color color, char[] buffer, int start, int len, double x, double y)
        {
            if (this.currentFont.IsAtlasFont)
            {
                //temp hard-code here!
                PixelFarm.Agg.Fonts.GdiTextureFont textureFont = (PixelFarm.Agg.Fonts.GdiTextureFont)currentFont;
                var srcAndDestList = textureFont.GetGlyphPos(buffer, start, len, (int)x, (int)y);
                //***
                canvas2d.DrawGlyphImages(color, textureFont.BmpBoard, srcAndDestList);
            }
            else
            {
                int j        = len;
                int buffsize = j * 2;
                //get kerning list
                if (properGlyphs == null)
                {
                    properGlyphs = new ProperGlyph[buffsize];
                    currentFont.GetGlyphPos(buffer, start, buffsize, properGlyphs);
                }

                double xpos = x;
                for (int i = 0; i < buffsize; ++i)
                {
                    uint codepoint = properGlyphs[i].codepoint;
                    if (codepoint == 0)
                    {
                        break;
                    }

                    //-------------------------------------------------------------
                    FontGlyph glyph = this.currentFont.GetGlyphByIndex(codepoint);
                    //glyph image32
                    //-------------------------------------------------------------
                    GLBitmap bmp  = new GLBitmap(new LazyAggBitmapBufferProvider(glyph.glyphImage32));
                    var      left = glyph.exportGlyph.img_horiBearingX;
                    this.canvas2d.DrawImage(bmp,
                                            (float)(xpos + (left >> 6)),
                                            (float)(y + (glyph.exportGlyph.bboxYmin >> 6)));

                    int w = (glyph.exportGlyph.advanceX) >> 6;
                    xpos += (w);

                    bmp.Dispose(); //temp here
                    //-------------------------------------------------------------
                }
            }
        }