FlowArithmeticCalculator 1.0.0
Flow Arithmetic Calculator
Loading...
Searching...
No Matches
gui::renderer::FontManager Class Reference

Utility class that holds static font instances and handles scaling them on window resizes. More...

#include <FontManager.h>

+ Collaboration diagram for gui::renderer::FontManager:

Static Public Member Functions

static void recalculateFontSizes (float aspectX, float aspectY, float xScale, float yScale)
 Recalculates the font sizes.
 
static const SkFont & getFontForVariant (const business_logic::components::UIText::Variant &variant)
 Gets the font for the given variant.
 

Static Public Attributes

static SkPaint textFontFillPaint
 The paint for the text font fill.
 
static SkPaint textFontStrokePaint
 The paint for the text font stroke.
 
static SkFont menuChoiceFont
 The font for the menu choice font.
 
static SkFont menuHeadlineFont
 The font for the menu headline font.
 
static SkFont menuCaptionFont
 The font for the menu caption font.
 
static SkFont captionFont
 The font for the caption font.
 

Static Private Attributes

static sk_sp< SkTypeface > typeface
 The typeface for the text font.
 
static sk_sp< SkFontMgr > fontMgr
 The font manager.
 

Detailed Description

Utility class that holds static font instances and handles scaling them on window resizes.

Definition at line 38 of file FontManager.h.

Member Function Documentation

◆ getFontForVariant()

const SkFont & gui::renderer::FontManager::getFontForVariant ( const business_logic::components::UIText::Variant variant)
static

Gets the font for the given variant.

Parameters
variantThe variant of the label
Returns
The font for the given variant

Definition at line 89 of file FontManager.cpp.

References business_logic::components::UIText::Caption, captionFont, business_logic::components::UIText::Choice, business_logic::components::UIText::Headline, business_logic::components::UIText::MenuCaption, menuCaptionFont, menuChoiceFont, and menuHeadlineFont.

Referenced by gui::elements::SkiaBaseBlockRenderer::render().

+ Here is the caller graph for this function:

◆ recalculateFontSizes()

void gui::renderer::FontManager::recalculateFontSizes ( float  aspectX,
float  aspectY,
float  xScale,
float  yScale 
)
static

Recalculates the font sizes.

This method adapts the font sizes by multiplying them by the a scale factor.

The scale factor is calculated according to the following formula:

scaling = min(aspectX, aspectY) * min(xScale, yScale)

Parameters
aspectXThe aspect ratio of the window width to the base width (constants::FONT_ASPECT_BASE_WINDOW_WIDTH)
aspectYThe aspect ratio of the window height to the base height (constants::FONT_ASPECT_BASE_WINDOW_HEIGHT)
xScaleThe scale factor for the X axis
yScaleThe scale factor for the Y axis

Definition at line 77 of file FontManager.cpp.

References gui::constants::CAPTION_FONT_SIZE_BASE, captionFont, gui::constants::MENU_CAPTION_FONT_SIZE_BASE, gui::constants::MENU_CHOICE_FONT_SIZE_BASE, gui::constants::MENU_HEADLINE_FONT_SIZE_BASE, menuCaptionFont, menuChoiceFont, and menuHeadlineFont.

Referenced by gui::renderer::SkiaRendererImpl::handleWindowResized().

+ Here is the caller graph for this function:

Member Data Documentation

◆ captionFont

SkFont gui::renderer::FontManager::captionFont
static
Initial value:
= [] {
SkFont font;
font.setSubpixel(true);
font.setTypeface(FontManager::typeface);
return font;
}()
static sk_sp< SkTypeface > typeface
The typeface for the text font.
constexpr int CAPTION_FONT_SIZE_BASE
Definition constants.h:10

The font for the caption font.

Definition at line 68 of file FontManager.h.

Referenced by getFontForVariant(), recalculateFontSizes(), and gui::elements::SkiaBaseBlockRenderer::renderValueAboveBlock().

◆ fontMgr

sk_sp< SkFontMgr > gui::renderer::FontManager::fontMgr
staticprivate
Initial value:
=
SkFontMgr_New_FontConfig(nullptr, SkFontScanner_Make_FreeType())

The font manager.

Definition at line 105 of file FontManager.h.

◆ menuCaptionFont

SkFont gui::renderer::FontManager::menuCaptionFont
static
Initial value:
= [] {
SkFont font;
font.setSubpixel(true);
font.setTypeface(FontManager::typeface);
return font;
}()
constexpr int MENU_CAPTION_FONT_SIZE_BASE
Definition constants.h:9

The font for the menu caption font.

Definition at line 63 of file FontManager.h.

Referenced by getFontForVariant(), and recalculateFontSizes().

◆ menuChoiceFont

SkFont gui::renderer::FontManager::menuChoiceFont
static
Initial value:
= [] {
SkFont font;
font.setSubpixel(true);
font.setTypeface(FontManager::typeface);
return font;
}()
constexpr int MENU_CHOICE_FONT_SIZE_BASE
Definition constants.h:11

The font for the menu choice font.

Definition at line 53 of file FontManager.h.

Referenced by getFontForVariant(), and recalculateFontSizes().

◆ menuHeadlineFont

SkFont gui::renderer::FontManager::menuHeadlineFont
static
Initial value:
= [] {
SkFont font;
font.setSubpixel(true);
font.setTypeface(FontManager::typeface);
font.setEmbolden(true);
return font;
}()
constexpr int MENU_HEADLINE_FONT_SIZE_BASE
Definition constants.h:8

The font for the menu headline font.

Definition at line 58 of file FontManager.h.

Referenced by getFontForVariant(), and recalculateFontSizes().

◆ textFontFillPaint

SkPaint gui::renderer::FontManager::textFontFillPaint
static
Initial value:
= [] {
SkPaint paint;
paint.setColor(colors::TEXT_COLOR);
paint.setStyle(SkPaint::kFill_Style);
paint.setAntiAlias(true);
return paint;
}()
const SkColor TEXT_COLOR
Definition colors.cpp:27

The paint for the text font fill.

Definition at line 43 of file FontManager.h.

Referenced by gui::elements::SkiaBaseBlockRenderer::renderValueAboveBlock().

◆ textFontStrokePaint

SkPaint gui::renderer::FontManager::textFontStrokePaint
static
Initial value:
= [] {
SkPaint paint;
paint.setColor(colors::TEXT_OUTLINE_COLOR);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(4);
paint.setAntiAlias(true);
return paint;
}()
const SkColor TEXT_OUTLINE_COLOR
Definition colors.cpp:30

The paint for the text font stroke.

Definition at line 48 of file FontManager.h.

◆ typeface

sk_sp< SkTypeface > gui::renderer::FontManager::typeface
staticprivate
Initial value:
=
fontMgr->legacyMakeTypeface(nullptr, SkFontStyle::Normal())
static sk_sp< SkFontMgr > fontMgr
The font manager.

The typeface for the text font.

Definition at line 100 of file FontManager.h.


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