allegroflare / allegro_flare

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

Resolve Design Concern About Using Different Fonts #201

Closed MarkOates closed 1 year ago

MarkOates commented 2 years ago

Right now, there isn't a clear strategy on how to customize fonts in the different Elements. Specifically, Elements/Stopwatch and Elements/Text, both of which require you to pass in a FontBin but not let you define a font (which is selected internally).

Here are a few possible options:

1) Pass in two arguments, font_identifier, and font_size <-- 🌟 Update: this option is preferred 2) Pass in a single argument, font_data_str, which is a single string in the format "[font-name] [font-size]". This is the current way a FontBin references and loads the resource. 3) Create a new Font object in AllegroFlare, and, pass it into the Element. This would leave open the decision: a) Font will have a FontBin injected into it. b) Font will not have a FontBin injected, but rather a component would join the two together, perhaps the Element. 4) There's some kind of global font registry where { identifier, ALLEGRO_FONT } can be initially loaded and then referenced by an identifier. This would be accessible globally, and, breaks the design for using a global resource. The constant injection of FontBin across a bunch of stuff is what this is meant to fix. Maybe the registry can be included in a Framework... but then again, that's what FontBin is.

MarkOates commented 2 years ago

Consider adding a FontKit which would have predefined named font styles like "title", "header1", "paragraph", etc.

MarkOates commented 2 years ago

Another way to look at this is to consider in what kinds of scenarios you might need the different arrangements?

For example, you might have a component that internally relies on the FontBin, but is not intended to have customized fonts.

MarkOates commented 1 year ago

After using the components for awhile now, the solution is relatively simple, option 1:

Pass in two arguments, font_identifier, and font_size

This allows the user to customize the typeface and the size, controlling each independently, without any additional requirements. For the Elements/Stopwatch example, there are now several other components, some screens like TitleScreen for example, that allow you to customize individual typefaces and sizes.

If any extra required "management strategy" or whatever is needed, that can be added as another layer up. The minimum pieces are the font_identifier, font_size, and font_bin.

The (Elements/Stopwatch and Elements/Text) classes should be updated so the have the font_identifier and font_size options.