allegroflare / allegro_flare

Application toolkit for Allegro 5
https://clubcatt.com/allegroflare
MIT License
35 stars 6 forks source link

Add UnicodeFontViewer #219

Closed MarkOates closed 2 years ago

MarkOates commented 2 years ago

Problem

Several examples (FontAwesomeExample, FontBravuraExample) need to display unicode characters and there is a class in those examples that should be extracted.

Solution

Extract the UnicodeFontViewer from the example programs and replace the example program usage with the new viewer.

Notes

Here's the UnicodeFontViewer in action:

unicode-viewer

A few tweaks were added to the initial class that was extracted, but a few more would be worth adding eventually:

Here's an example where the Bravura font characters draw on top of the numbers: AllegroFlare_UnicodeFontViewerTestWithAllegroRende

...this particular typeface uses glyph in a way that is different from typical word typography (it's anchor points are used to position glyphs on a music staff).

In situations like this, the user might prefer to view the glyphs such that they can see the full glyph. Adding a toggleable option to view the glyphs positioned differently in the grid might be nice. One of the toggleable options might have the glyph completely centered - could use al_get_ustr_dimensions() and get the data needed to render the glyph centered in its grid cell.