Esempio n. 1
0
        public void emit(render_container container, size_t start, size_t lines, float x, float y)
        {
            if (m_current_line != null)
            {
                // TODO: is there a sane way to allow an open line to be temporarily finalised and rolled back?
                m_current_line.align_text(this);
                m_current_line = null;
            }

            float base_y = (m_lines.size() > start) ? m_lines[start].yoffset() : 0.0f;

            for (size_t l = start; ((start + lines) > l) && (m_lines.size() > l); ++l)
            {
                var   line         = m_lines[l];
                float line_xoffset = line.xoffset(this);
                float char_y       = y + line.yoffset() - base_y;
                float char_height  = line.height();

                // emit every single character
                for (size_t i = 0; i < line.character_count(); i++)
                {
                    var ch = line.character(i);

                    // position this specific character correctly (TODO - this doesn't handle differently sized text (yet)
                    float char_x     = x + line_xoffset + ch.xoffset;
                    float char_width = ch.xwidth;

                    // render the background of the character (if present)
                    if (ch.style.bgcolor.a() != 0)
                    {
                        container.add_rect(char_x, char_y, char_x + char_width, char_y + char_height, ch.style.bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
                    }

                    // render the foreground
                    container.add_char(
                        char_x,
                        char_y,
                        char_height,
                        xscale() / yscale(),
                        ch.style.fgcolor,
                        font(),
                        (u16)ch.character);
                }
            }
        }
Esempio n. 2
0
File: text.cs Progetto: kwanboy/mcs
        //-------------------------------------------------
        //  emit
        //-------------------------------------------------
        public void emit(render_container container, float x, float y)
        {
            foreach (var line in m_lines)
            {
                float line_xoffset = line.xoffset();

                // emit every single character
                for (UInt32 i = 0; i < line.character_count(); i++)
                {
                    var ch = line.character(i);

                    // position this specific character correctly (TODO - this doesn't
                    // handle differently sized text (yet)
                    float char_x      = x + line_xoffset + ch.xoffset;
                    float char_y      = y + line.yoffset();
                    float char_width  = ch.xwidth;
                    float char_height = line.height();

                    // render the background of the character (if present)
                    if (ch.style.bgcolor.a() != 0)
                    {
                        container.add_rect(char_x, char_y, char_x + char_width, char_y + char_height, ch.style.bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
                    }

                    // render the foreground
                    container.add_char(
                        char_x,
                        char_y,
                        char_height,
                        xscale() / yscale(),
                        ch.style.fgcolor,
                        font(),
                        (UInt16)ch.character);
                }
            }
        }