Пример #1
0
        public void RenderText(string text)
        {
            //Application.GetInstance().DebugTimeToConsole("--> RenderText: " + text);

            // set paint
            //VG.vgSetPaint(mFont, VGPaintMode.VG_FILL_PATH);
            //VG.vgSetPaint(mFont, VGPaintMode.VG_STROKE_PATH | VGPaintMode.VG_FILL_PATH);

            // build kerning information
            var glyphIndices = new uint[text.Length];

            var adjustmentsX = new float[text.Length];
            var adjustmentsY = new float[text.Length];

            for (var i = 0; i < text.Length; ++i)
            {
                // find kerning relative to the characters couple
                var kerning = GetKerning(text[i], i < text.Length - 1 ? text[i + 1] : text[i]);

                // fill adjustments
                glyphIndices[i] = text[i];
                if (kerning != null)
                {
                    adjustmentsX[i] = kerning.mX;
                    adjustmentsY[i] = kerning.mY;
                }
                else
                {
                    adjustmentsX[i] = 0.0f;
                    adjustmentsY[i] = 0.0f;
                }
            }

            //Application.GetInstance().DebugTimeToConsole("RenderText:LoadGlyph");

            // draw glyphs
            VG.vgSeti(VGParamType.VG_RENDERING_QUALITY, (int)VGRenderingQuality.VG_RENDERING_QUALITY_BETTER);

            //VG.vgDrawGlyphs(mFont, text.Length, glyphIndices, adjustmentsX, adjustmentsY, VGPaintMode.VG_FILL_PATH, VGboolean.VG_FALSE);
            VG.vgDrawGlyphs(mFont, text.Length, glyphIndices, adjustmentsX, adjustmentsY, VGPaintMode.VG_FILL_PATH, VGboolean.VG_TRUE);
            //VG.vgDrawGlyphs(mFont, text.Length, glyphIndices, adjustmentsX, adjustmentsY, VGPaintMode.VG_FILL_PATH, VGboolean.VG_TRUE);

            //Application.GetInstance().DebugTimeToConsole("<-- RenderText");

            //float[] origin = { 0.0f, 0.0f };
            //VG.vgGetfv(VGParamType.VG_GLYPH_ORIGIN, 2, origin);
        }