simongeilfus / Cinder-ImGui

Dear ImGui Renderer/Wrapper for Cinder
153 stars 96 forks source link

Multiple glyph ranges are not supported by a single font #69

Open totalgee opened 6 years ago

totalgee commented 6 years ago

If you try to specify multiple glyph ranges, you only get the first one.

For example:

    // In setup():
    auto robo = getAssetPath("Roboto-Medium.ttf");
    auto const firstArrow = L'←';
    auto const lastArrow = L'↓';
    auto options = ui::Options()
        .fonts({ { robo, 16.0f } }, false)
        .fontGlyphRanges(robo.stem().string(), { 0x20, 0xff, firstArrow, lastArrow, 0 });

    // ... more setup of options ...

    ui::initialize(options);

Then, later in the GUI drawing code, try to draw using a mixture of characters from both glyph ranges (here, the arrows will show the "missing" symbol). For example:

    if (ui::MenuItem(u8"Move up (shift-↑)")) {
        // blah
    }
totalgee commented 6 years ago

By the way, the "Roboto-Medium" font referenced in my code above doesn't actually include those arrow keys glyphs ;-), but that doesn't change the underlying problem here...as long as you specify multiple ranges, you'll still see the problem -- the only glyphs "available" are those in the first range pair in the fontGlyphRanges() call. You could (for example) request the ASCII number range, then the upper- and lower-case alphabet ranges, but (with the bug) you'd only have glyphs available for the numbers (0x30-0x39):

    auto options = ui::Options()
        .fonts({ { robo, 16.0f } }, false)
        .fontGlyphRanges(robo.stem().string(), { 0x30, 0x39, 0x41, 0x5a, 0x61, 0x7a, 0 });