LuciadCPillar 2024.1.06
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
luciad::Fonts Class Referencefinal

This class allows you to register custom fonts. More...

#include <luciad/text/Fonts.h>

Static Public Member Functions

static std::vector< size_t > getSupportedFontSizes (const std::string &fontName)
 This function is used to see which font sizes are supported by a bitmap font. More...
 
static void registerFont (const FontConfig &fontConfig)
 Registers an additional font that can be used in alongside the default ones, for example for use in a TextStyle. More...
 
static void registerFont (const std::string &fontName, const std::string &fontPath)
 Registers an additional font that can be used in alongside the default ones, for example for use in a TextStyle. More...
 

Detailed Description

This class allows you to register custom fonts.

By default, the following fonts are supported:

Font Name Font
Arial Liberation Sans Serif
Arial Narrow Liberation Sans Narrow
Arial Black Archivo Black
Bitstream Vera Sans Bistream Vera Sans
Calibri Open Sans
Console Inconsolata
Noto Sans Noto Sans
Times New Roman Liberation Serif

For international language support, the Noto font from Google was added. As the Noto font is very extensive, only a small subset of fonts is available. List of currently supported alphabets in the Noto font:

  • Arabic
  • Armenian
  • Cyrillic
  • Devanagari
  • Georgian
  • Greek
  • Gujarati
  • Gurmukhi
  • Hangul (Koran)
  • Han
  • Hebrew
  • Hiragana
  • Kannada
  • Katakana
  • Laotian
  • Latin
  • Malayalam
  • Oriya
  • Tamil
  • Telugu
  • Thai

Note that these are all vector fonts, so for these default fonts any font size can be used.

You can register additional fonts using the luciad::Fonts::registerFont function.

Since
2024.1

Member Function Documentation

◆ getSupportedFontSizes()

static std::vector< size_t > luciad::Fonts::getSupportedFontSizes ( const std::string &  fontName)
static

This function is used to see which font sizes are supported by a bitmap font.

Not necessary for vector fonts, also known as outline fonts, since they can scale to any size. For these fonts, and empty list is returned.

Parameters
fontNameidentifier of the font.
Returns
A list of support font sizes. For vector fonts an empty list is returned.
Exceptions
luciad::InvalidArgumentExceptionwhen the font is not registered.

◆ registerFont() [1/2]

static void luciad::Fonts::registerFont ( const FontConfig fontConfig)
static

Registers an additional font that can be used in alongside the default ones, for example for use in a TextStyle.

Using a font name that is already in use overwrites it, this includes the fonts available by default.

Node: registering bitmap fonts instead of vector fonts is supported, but it may have downsides:

  • not all font sizes are supported. Using an unsupported size when using bitmap fonts will result in an exception
  • HiDPI support for bitmap fonts is limited: text quality may be lower than the quality when using vector fonts
Parameters
fontConfigthe configuration of the font
Exceptions
luciad::InvalidArgumentExceptionwhen one of the paths is invalid.

◆ registerFont() [2/2]

static void luciad::Fonts::registerFont ( const std::string &  fontName,
const std::string &  fontPath 
)
static

Registers an additional font that can be used in alongside the default ones, for example for use in a TextStyle.

Using a font name that is already in use overwrites it, this includes the fonts available by default.

Node: registering bitmap fonts instead of vector fonts is supported, but it may have downsides:

  • not all font sizes are supported. Using an unsupported size when using bitmap fonts will result in an exception
  • HiDPI support for bitmap fonts is limited: text quality may be lower than the quality when using vector fonts
Parameters
fontNameidentifier of the font.
fontPaththe path to the font file.
Exceptions
luciad::InvalidArgumentExceptionwhen the path is invalid.