Beispiel #1
0
        public void PrepareStringForRenderVx(RenderVxFormattedString renderVx, char[] text, int startAt, int len)
        {
            //1. update some props..
            //2. update current type face
            UpdateGlyphLayoutSettings();
            Typeface typeface = _currentTypeface;// _glyphPathBuilder.Typeface;

            _glyphLayout.Typeface = typeface;
            _glyphLayout.Layout(text, startAt, len);
            //
            //3. scale from design unit to specific font size
            _outputPxScaledGlyphPlans.Clear();
            _pxScaleEngine.Layout(_glyphLayout.ResultUnscaledGlyphPositions, _outputPxScaledGlyphPlans);
            TextPrinterHelper.CopyGlyphPlans(renderVx, _outputUnscaledGlyphPlans, this._currentFontSizePxScale);
        }
Beispiel #2
0
        public void Draw()
        {
            PxScaledGlyphPlanList            glyphPlans = _line._glyphPlans;
            List <UserCodePointToGlyphIndex> userCharToGlyphIndexMap = _line._userCodePointToGlyphIndexMap;

            if (_line.ContentChanged)
            {
                //TODO: or font face/font-size change
                //re-calculate
                char[] textBuffer = _line._charBuffer.ToArray();
                glyphPlans.Clear();
                userCharToGlyphIndexMap.Clear();
                //read glyph plan and userCharToGlyphIndexMap

                _printer.GenerateGlyphPlan(textBuffer, 0, textBuffer.Length, glyphPlans, userCharToGlyphIndexMap);


                _line.ContentChanged = false;
            }

            if (glyphPlans.Count > 0)
            {
                _printer.DrawFromGlyphPlans(glyphPlans, X, Y);
                //draw caret
                //not blink in this version
                int caret_index = _line.CaretCharIndex;
                //find caret pos based on glyph plan
                //TODO: check when do gsub (glyph number may not match with user char number)

                if (caret_index == 0)
                {
                    _printer.DrawCaret(X, this.Y);
                }
                else
                {
                    //UserCodePointToGlyphIndex map = userCharToGlyphIndexMap[caret_index - 1];
                    //GlyphPlan p = glyphPlans[map.glyphIndexListOffset_plus1 + map.len - 2];
                    //_printer.DrawCaret(X + (p.ExactX + p.AdvanceX), this.Y);
                }
            }
            else
            {
                _printer.DrawCaret(X, this.Y);
            }
        }