Embed font for Android App Help #1100

Closed
opened 2017-04-13 15:37:47 +00:00 by vivienneanthony · 3 comments
vivienneanthony commented 2017-04-13 15:37:47 +00:00 (Migrated from github.com)

Hi,

I'm trying to add a embedded font to a Android app. I'm using the following code and output produced from the utility in extra font directory. It seg faults on the stack at "value_type &ImVector<ImFont *>::back() [T = ImFont *]: assertion "Size > 0" failed"

My thoughts immediately seems it's trying to push a font on a non-existent font table. I'm not sure.

Vivienne

//Configure Ranges
            static const ImWchar iconRanges[] = { 0xf000, 0xf3ff, 0 };
            static const ImWchar defaultranges[] = { 0x0020, 0x00FF, 0 };

            ImFontConfig config;
            config.MergeMode = true;
            config.OversampleH = 3;
            config.OversampleV = 1;
            config.GlyphExtraSpacing.x = 1.0f;

            // does not work if font provied by settings are all in merge mode, need one font already loaded
            io.Fonts->AddFontFromMemoryCompressedTTF(&fontawesome_webfont_compressed_data[0], fontawesome_webfont_compressed_size, 14, &config, iconRanges);
            io.Fonts->AddFontFromMemoryCompressedTTF(&Anonymous_Pro_compressed_data[0], Anonymous_Pro_compressed_size, 14, &config, defaultranges);
            io.Fonts->AddFontFromMemoryCompressedTTF(&UrhoCraz_Icons_Interface1_compressed_data[0], UrhoCraz_Icons_Interface1_compressed_size, 36, &config, defaultranges);
            io.Fonts->AddFontFromMemoryCompressedTTF(&BlueHighway_compressed_data[0], BlueHighway_compressed_size,36, &config, defaultranges);

      

and font```

#ifndef ImGuiEmbedFontAwesome
#define ImGuiEmbedFontAwesome
// File: 'fontawesome-webfont.ttf' (142072 bytes)
// Exported using binary_to_compressed_c.cpp
static const unsigned int fontawesome_webfont_compressed_size = 106033;
static const unsigned int fontawesome_webfont_compressed_data[106036/4] =
{
    0x0000bc57, 0x00000000, 0xf82a0200, 0x00000400, 0x00010033, 0x000e0000, 0x00030080, 0x54464660, 0x6f036a4d, 0x20118229, 0x2c0382ec, 0x4544471c,

.ignoring exta

Hi, I'm trying to add a embedded font to a Android app. I'm using the following code and output produced from the utility in extra font directory. It seg faults on the stack at "value_type &ImVector<ImFont *>::back() [T = ImFont *]: assertion "Size > 0" failed" My thoughts immediately seems it's trying to push a font on a non-existent font table. I'm not sure. Vivienne ``` //Configure Ranges static const ImWchar iconRanges[] = { 0xf000, 0xf3ff, 0 }; static const ImWchar defaultranges[] = { 0x0020, 0x00FF, 0 }; ImFontConfig config; config.MergeMode = true; config.OversampleH = 3; config.OversampleV = 1; config.GlyphExtraSpacing.x = 1.0f; // does not work if font provied by settings are all in merge mode, need one font already loaded io.Fonts->AddFontFromMemoryCompressedTTF(&fontawesome_webfont_compressed_data[0], fontawesome_webfont_compressed_size, 14, &config, iconRanges); io.Fonts->AddFontFromMemoryCompressedTTF(&Anonymous_Pro_compressed_data[0], Anonymous_Pro_compressed_size, 14, &config, defaultranges); io.Fonts->AddFontFromMemoryCompressedTTF(&UrhoCraz_Icons_Interface1_compressed_data[0], UrhoCraz_Icons_Interface1_compressed_size, 36, &config, defaultranges); io.Fonts->AddFontFromMemoryCompressedTTF(&BlueHighway_compressed_data[0], BlueHighway_compressed_size,36, &config, defaultranges); ``` and font``` ``` #ifndef ImGuiEmbedFontAwesome #define ImGuiEmbedFontAwesome // File: 'fontawesome-webfont.ttf' (142072 bytes) // Exported using binary_to_compressed_c.cpp static const unsigned int fontawesome_webfont_compressed_size = 106033; static const unsigned int fontawesome_webfont_compressed_data[106036/4] = { 0x0000bc57, 0x00000000, 0xf82a0200, 0x00000400, 0x00010033, 0x000e0000, 0x00030080, 0x54464660, 0x6f036a4d, 0x20118229, 0x2c0382ec, 0x4544471c, .ignoring exta ``` ```
vivienneanthony commented 2017-04-13 17:55:15 +00:00 (Migrated from github.com)

When I first add the default font. Theres no crash.

When I first add the default font. Theres no crash.
ocornut commented 2017-04-13 18:01:10 +00:00 (Migrated from github.com)

I will add a more explicit assertion, but if you set config.MergeMode = true; you need to have already added a font.

I will add a more explicit assertion, but if you set `config.MergeMode = true;` you need to have already added a font.
Kaldaien commented 2017-04-15 15:43:06 +00:00 (Migrated from github.com)

Thank you, I ran into this problem a while back too. That assertion is more helpful than you might think 👍

Thank you, I ran into this problem a while back too. That assertion is more helpful than you might think 👍
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#1100
No description provided.