libosmscout 0.1
Loading...
Searching...
No Matches
osmscout::FontNameResolution Class Referencefinal

Answers what a configured font name names: a font family to look up, or the face that a font file holds. More...

#include <FontNameResolution.h>

Classes

struct  Result
 What a configured font name names. More...
 

Public Member Functions

 FontNameResolution ()=delete
 

Static Public Member Functions

static bool CanReadFamilyFromFile ()
 Whether this build can read the family name out of a font file.
 
static bool ReadFamilyFromFile (const std::string &fontFile, std::string &family, std::string &error)
 Read the family name stored in a font file.
 
static Result Resolve (const std::string &configuredName)
 Resolve a configured font name to the face it names.
 

Detailed Description

Answers what a configured font name names: a font family to look up, or the face that a font file holds.

A render parameter carries one font name, and a caller may configure a family name ("Liberation Sans") or the path of a font file. A backend whose text stack resolves a font by family has to serve the face the file holds and make that file resolvable to its stack, while a backend that loads a font file directly wants the path. This is the one place that decision is taken, so that every backend and both build systems agree on it.

Constructor & Destructor Documentation

◆ FontNameResolution()

osmscout::FontNameResolution::FontNameResolution ( )
delete

Member Function Documentation

◆ CanReadFamilyFromFile()

bool osmscout::FontNameResolution::CanReadFamilyFromFile ( )
static

Whether this build can read the family name out of a font file.

Without the ability to read a font file, a configured file is still recognised, but the family it holds cannot be named.

Referenced by Resolve().

◆ ReadFamilyFromFile()

bool osmscout::FontNameResolution::ReadFamilyFromFile ( const std::string &  fontFile,
std::string &  family,
std::string &  error 
)
static

Read the family name stored in a font file.

Parameters
fontFilepath to a font file
familyset to the family name stored in the file on success
errorset to a description of what went wrong on failure
Returns
true on success, false on failure

Referenced by Resolve().

◆ Resolve()

FontNameResolution::Result osmscout::FontNameResolution::Resolve ( const std::string &  configuredName)
static

Resolve a configured font name to the face it names.

A name that is an existing font file is read for the family it holds, so that an interface resolving by family serves that face; the file is reported as well, so that a caller can make it resolvable to its text stack. Any other name is passed on unchanged.

Parameters
configuredNamefont name as the render parameter carries it
Returns
the name to hand a family-resolving interface and the font file it names, if any

References CanReadFamilyFromFile(), osmscout::Log::Error(), osmscout::FontNameResolution::Result::fontFile, osmscout::FontNameResolution::Result::fontName, osmscout::log, ReadFamilyFromFile(), and osmscout::Log::Warn().


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