Esempio n. 1
0
            public GlyphCache CacheGlyph(int glyph_code,
                                         int glyph_index,
                                         SimpleFont.GlyphDataType data_type,
                                         Rect bounds,
                                         double advance_x,
                                         double advance_y)
            {
                GlyphCache glyph;

                if (m_glyphs.TryGetValue(glyph_code, out glyph))
                {
                    // Already exists, do not overwrite
                    return(null);
                }

                glyph = new GlyphCache();

                glyph.glyph_index = glyph_index;
                glyph.data_type   = data_type;
                glyph.bounds      = bounds;
                glyph.advance_x   = advance_x;
                glyph.advance_y   = advance_y;

                m_glyphs.Add(glyph_code, glyph);

                return(glyph);
            }
Esempio n. 2
0
        public GlyphCache GetGlyph(int glyph_code)
        {
            Synchronize();

            GlyphCache gl = m_Fonts.FindGlyph(glyph_code);

            if (gl != null)
            {
                m_PrevGlyph = m_LastGlyph;

                return(m_LastGlyph = gl);
            }
            else
            {
                if (m_SimpleFont.PrepareGlyph(glyph_code))
                {
                    m_PrevGlyph = m_LastGlyph;
                    m_LastGlyph = m_Fonts.CacheGlyph(glyph_code,
                                                     m_SimpleFont.GlyphIndex,
                                                     m_SimpleFont.DataType,
                                                     m_SimpleFont.Bounds,
                                                     m_SimpleFont.AdvanceX,
                                                     m_SimpleFont.AdvanceY);
                    m_SimpleFont.WriteGlyphTo(m_LastGlyph);//.data);

                    return(m_LastGlyph);
                }
            }

            return(null);
        }
Esempio n. 3
0
        void Synchronize()
        {
            if (m_ChangeStamp != m_SimpleFont.ChangeStamp)
            {
                m_Fonts.SetCurrentFont(m_SimpleFont.Signature);
                m_ChangeStamp = m_SimpleFont.ChangeStamp;

                m_PrevGlyph = m_LastGlyph = null;
            }
        }
Esempio n. 4
0
        static TextRenderer()
        {
            textureAtlas = new TextureAtlas(512, PixelFormat.R8G8B8);
            glyphCache   = new GlyphCache();

            textMaterial = Material.Create(Allocator.GetHeap(), "TextMaterial");
            var mat = textMaterial.Resolve();

            mat.BackfaceCulling = false;
            mat.SetBlending(BlendSource.SourceAlpha, BlendDestination.InverseSourceAlpha);
            mat.SetShader("Text");
            mat.SetTexture(0, textureAtlas.AtlasImageHandle);
            mat.GetTextureUnit(0).WrapMode = TextureWrapMode.ClampToEdge;
        }