Esempio n. 1
0
        // 'compressed_ttf_data' still owned by caller. Compress with binary_to_compressed_c.cpp
        unsafe ImFont AddFontFromMemoryCompressedTTF(byte *compressed_ttf_data, uint compressed_ttf_size, float size_pixels, ImFontConfig font_cfg_template = null, char[] glyph_ranges = null)
        {
            uint buf_decompressed_size = STB.stb_decompress_length(compressed_ttf_data);

            //unsigned char* buf_decompressed_data = (unsigned char*)ImGui::MemAlloc(buf_decompressed_size);
            byte[] _buf_decompressed_data = new byte[buf_decompressed_size];

            fixed(byte *buf_decompressed_data = _buf_decompressed_data)
            {
                STB.stb_decompress(buf_decompressed_data, compressed_ttf_data, compressed_ttf_size);

                ImFontConfig font_cfg = font_cfg_template ?? new ImFontConfig();

                System.Diagnostics.Debug.Assert(font_cfg.FontData == null);
                font_cfg.FontDataOwnedByAtlas = true;
                return(AddFontFromMemoryTTF(_buf_decompressed_data, (int)buf_decompressed_size, size_pixels, font_cfg_template, glyph_ranges));
            }
        }
Esempio n. 2
0
        internal ImFont AddFontDefault(float fontSize = 13f, ImFontConfig font_cfg_template = null)
        {
            ImFontConfig font_cfg = font_cfg_template ?? new ImFontConfig();// font_cfg_template != null ? *font_cfg_template : ImFontConfig();

            if (font_cfg_template == null)
            {
                font_cfg.OversampleH = font_cfg.OversampleV = 2;
                font_cfg.PixelSnapH  = true;
            }
            if (font_cfg.Name == null)
            {
                font_cfg.Name = "<default>";
            }

            var    ttf_compressed_base85 = STB.GetDefaultCompressedFontDataTTFBase85();
            ImFont font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, fontSize, font_cfg, GetGlyphRangesDefault());

            return(font);
        }