Пример #1
0
        public void Draw()
        {
            GlyphPlanList glyphPlans = _line._glyphPlans;
            List <UserCharToGlyphIndexMap> userCharToGlyphIndexMap = _line._userCharToGlyphMap;

            if (_line.ContentChanged)
            {
                //re-calculate
                char[] textBuffer = _line._charBuffer.ToArray();
                glyphPlans.Clear();

                userCharToGlyphIndexMap.Clear();

                //read glyph plan and userCharToGlyphIndexMap

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


                toPxScale            = _printer.Typeface.CalculateScaleToPixelFromPointSize(_printer.FontSizeInPoints);
                _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
                {
                    UserCharToGlyphIndexMap map = userCharToGlyphIndexMap[caret_index - 1];
                    GlyphPlan p = glyphPlans[map.glyphIndexListOffset_plus1 + map.len - 2];
                    _printer.DrawCaret(X + p.ExactRight, this.Y);
                }
            }
            else
            {
                _printer.DrawCaret(X, this.Y);
            }
        }
Пример #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);
            }
        }