Flood.GUI.GlyphManager.TryGetGlyphImage C# (CSharp) Method

TryGetGlyphImage() public method

public TryGetGlyphImage ( Font font, int codepoint, SubTexture &texture, ResourceHandle &material ) : bool
font Font
codepoint int
texture SubTexture
material ResourceHandle
return bool
        public bool TryGetGlyphImage(Font font, int codepoint, out SubTexture texture, out ResourceHandle<Material> material)
        {
            material = textMaterial;

            var glyphId = new GlyphId(font, codepoint);
            if (glyphSubTextures.TryGetValue(glyphId, out texture))
                return true;

            var nativeFont = font.EngineFont.Resolve();
            var imageHandle = nativeFont.CreateGlyphImage(codepoint, font.Size);

            if (imageHandle.Id == ResourceHandle<Resource>.Invalid)
                return false;

            if (!textureAtlas.AddImage(imageHandle))
            {
                throw new Exception("Atlas full");
            }

            if (!textureAtlas.GetImageSubTexture(imageHandle, out texture))
                return false;

            glyphSubTextures.Add(glyphId, texture);

            return true;
        }