allegro_flare icon indicating copy to clipboard operation
allegro_flare copied to clipboard

Resolve Design Concern About Using Different Fonts

Open MarkOates opened this issue 3 years ago • 2 comments

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
  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 avatar Jun 22 '22 17:06 MarkOates

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

MarkOates avatar Jun 26 '22 02:06 MarkOates

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 avatar Jul 07 '22 20:07 MarkOates

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.

MarkOates avatar Sep 19 '23 18:09 MarkOates