FifeGUI 0.3.0
A C++ GUI library designed for games.
fcn::font::FontLoader Class Reference

#include <fontloader.hpp>

Static Public Member Functions

static std::filesystem::path findFontFile (std::string const &fontName, std::vector< std::filesystem::path > const &searchPaths={})
static std::vector< std::filesystem::path > getDefaultSearchPaths ()
static std::shared_ptr< FontloadFont (Graphics &graphics, std::string const &fontName, int size, std::vector< std::filesystem::path > const &searchPaths={})

Detailed Description

Helper class for searching and loading fonts.

This provides the same functionality as the previous free functions but grouped inside an exported class to improve encapsulation and allow stateful extensions in the future.

Definition at line 27 of file fontloader.hpp.

Member Function Documentation

◆ findFontFile()

std::filesystem::path fcn::font::FontLoader::findFontFile ( std::string const & fontName,
std::vector< std::filesystem::path > const & searchPaths = {} )
static

Find a font file by name searching the provided paths.

Parameters
fontNameFont family or filename to search for.
searchPathsOptional list of paths to search. If empty the default search paths are used.
Returns
Path to the found font file or empty path when not found.

Definition at line 113 of file fontloader.cpp.

References getDefaultSearchPaths().

Referenced by loadFont().

◆ getDefaultSearchPaths()

std::vector< std::filesystem::path > fcn::font::FontLoader::getDefaultSearchPaths ( )
static

Returns default search paths used when locating font files on the current platform.

Definition at line 78 of file fontloader.cpp.

Referenced by findFontFile().

◆ loadFont()

std::shared_ptr< Font > fcn::font::FontLoader::loadFont ( Graphics & graphics,
std::string const & fontName,
int size,
std::vector< std::filesystem::path > const & searchPaths = {} )
static

Load a Font object for the given font name and size using the provided Graphics implementation.

Parameters
graphicsGraphics instance used for creating font resources.
fontNameFont family or filename.
sizeRequested font size in points.
searchPathsOptional search paths for locating font files.
Returns
Shared pointer to a Font instance or nullptr on failure.

Definition at line 146 of file fontloader.cpp.

References fcn::Graphics::createFont(), and findFontFile().


The documentation for this class was generated from the following files: