Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualAressera

Posted 29 January 2013 - 08:50 PM

Yes, that's what I'd like to do, I'm just having trouble with the "somehow mapping that font back to a font file" part. Since the font files aren't guaranteed to be named with any convention I can't assume that they'll even contain the font name in their filenames. I know my current solution isn't ideal, that's why I'm asking for ideas.

 

Here is the basic interface for my font management system. Currently it caches the available font files behind the scenes (slow!) in a hash map internally so that the user can get the file containing the font with the given name. In general use (as part of a game's GUI) this won't be a huge issue because the game will just bundle the necessary font file with the game itself at a known path, however I still need to be able to access commonly available fonts (with fallbacks in case of failure) so that I can have a good default font for the rendered GUI elements if none is provided by the game.

FontManager fonts;
FontInfo fontInfo; // contains path to font file.

// Get a font file path for the given font family/style name
fonts.getFont( "times new roman", // font family name
               "" // optional font face name (i.e. bold, italic)
                &fontInfo );

// Get a sensible default system font file.
fonts.getDefaultFont( &fontInfo );

#1Aressera

Posted 29 January 2013 - 08:49 PM

Yes, that's what I'd like to do, I'm just having trouble with the "somehow mapping that font back to a font file" part. Since the font files aren't guaranteed to be named with any convention I can't assume that they'll even contain the font name in their filenames. I know my current solution isn't ideal, that's why I'm asking for ideas.

 

Here is the basic interface for my font management system. Currently it caches the available font files behind the scenes (slow!) in a hash map internally so that the user can get the file containing the font with the given name. In general use (as part of a game's GUI) this won't be a huge issue because the game will just bundle the necessary font file with the game itself at a known path, however I still need to be able to access commonly available fonts (with fallbacks in case of failure) so that I can have a good default font for the rendered GUI elements if none is provided by the game.

FontManager fonts;
FontInfo fontInfo; // contains path to font file.

// Get a font file path for the given font family/style name
fonts.getFont( "times new roman", // font family name
               "" // optional font face name (i.e. bold, italic)
                &fontInfo );

// Get the default system font file.
fonts.getDefaultFont( &fontInfo );

PARTNERS