Exemplo n.º 1
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
                    //-------------------------------------------------------------
                }
            }
        }