Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[imstb_truetype] Request on Upgrade to latest version #5075

Closed
Jony01 opened this issue Mar 4, 2022 · 2 comments
Closed

[imstb_truetype] Request on Upgrade to latest version #5075

Jony01 opened this issue Mar 4, 2022 · 2 comments

Comments

@Jony01
Copy link

Jony01 commented Mar 4, 2022

My Issue:
I found on Ubuntu font "/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf" NotoColorEmoji.zip. When I try to initialize the font by function stbtt_InitFont. InitFunction ends inside stbtt__find_table, which return 0 and disallow initialization of the font.

To Reproduce:
Run test and see it is uninitializabled font.

TEST_CASE("Initialize NotoColorEmoji") {
    std::string font_path = "NotoColorEmoji.ttf";
    FILE *file = fopen(font_path.c_str(), "rb");
    REQUIRE(file != nullptr);
    // find size of file
    REQUIRE(fseek(file, 0L, SEEK_END) == 0);
    size_t size = ftell(file);
    REQUIRE(size != 0);
    rewind(file);
    std::vector<unsigned char> buffer(size);
    size_t count_loaded_bytes = fread((void *) &buffer.front(), 1, size, file);
    REQUIRE(count_loaded_bytes == size);
    int font_offset = stbtt_GetFontOffsetForIndex(buffer.data(), 0);
    REQUIRE(font_offset >= 0);
    stbtt_fontinfo font_info;
    CHECK(stbtt_InitFont(&font_info, buffer.data(), font_offset) != 0); 
}

New version of stb_truetype
I checked that latest version v1.26 of stb_truetype [link] can initialize this font.

ImGui version of file imstb_truetype.h is v1.20 (contain imgui modifications).

@quetzalsly
Copy link

I hope all of the stb libs get updated, theres been lots of changes to them and imgui last updated them 8 months ago.

ocornut added a commit that referenced this issue Mar 13, 2022
(our STBRP__CDECL change was merged)
ocornut added a commit that referenced this issue Mar 13, 2022
(Our pageup/pagedown PR was merged, so this is essentially a no-op)
@ocornut
Copy link
Owner

ocornut commented Mar 13, 2022

I have now updated all STB libs, however I can't seem to load my copy of NotoColorEmoji.ttf with stb_truetype 1.26 still.

@ocornut ocornut closed this as completed Mar 13, 2022
sergeyn pushed a commit to sergeyn/imgui that referenced this issue Mar 19, 2022
sergeyn pushed a commit to sergeyn/imgui that referenced this issue Mar 19, 2022
(Our pageup/pagedown PR was merged, so this is essentially a no-op)
ocornut added a commit that referenced this issue Mar 29, 2022
…ggering debuggers). (#5139, #5075)

Amend 0cff5ac (mislabeled as stb_textedit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants