示例#1
0
        public void FillTextRun(TextRun textRun, float x, float y)
        {
            //fill text run at spefic pos

            List <GlyphRun> glyphs = textRun._glyphs;
            int             j      = glyphs.Count;

            float scale = textRun.CalculateToPixelScaleFromPointSize(textRun.sizeInPoints);

            for (int i = 0; i < j; ++i)
            {
                //render each glyph
                GlyphRun run = glyphs[i];
                //
                fillShader.SetOffset(
                    x + run.OffsetX * scale,
                    y + run.OffsetY * scale);
                //
                fillShader.FillTriangles(
                    run.tessData,
                    run.nTessElements,
                    this.FillColor
                    );
            }
            fillShader.SetOffset(0, 0);
        }
示例#2
0
        public void FillTextRun(TextRun textRun, float x, float y)
        {
            //fill text run at spefic pos

            List <GlyphRun> glyphs = textRun._glyphs;
            int             j      = glyphs.Count;
            float           accX   = 0;
            float           accY   = 0;
            float           nx     = x;
            float           ny     = y;

            float pxscale = _textPrinter.Typeface.CalculateScaleToPixelFromPointSize(_textPrinter.FontSizeInPoints);


            for (int i = 0; i < j; ++i)
            {
                //render each glyph
                GlyphRun run = glyphs[i];

                Typography.TextLayout.UnscaledGlyphPlan plan = run.GlyphPlan;

                nx = x + accX + plan.OffsetX * pxscale;
                ny = y + accY + plan.OffsetY * pxscale;

                _fillShader.SetOffset(nx, ny);
                accX += (plan.AdvanceX * pxscale);


                _fillShader.FillTriangles(
                    run.tessData,
                    run.nTessElements,
                    this.FillColor
                    );
            }
            _fillShader.SetOffset(0, 0);
        }