OpenTTD Source: src/fontcache.cpp File Reference

OpenTTD Source 12.2

Data Structures | Macros | Functions | Variables
fontcache.cpp File Reference
`#include "stdafx.h"`
`#include "fontcache.h"`
`#include "fontcache_internal.h"`
`#include "fontdetection.h"`
`#include "blitter/factory.hpp"`
`#include "core/math_func.hpp"`
`#include "core/smallmap_type.hpp"`
`#include "strings_func.h"`
`#include "zoom_type.h"`
`#include "gfx_layout.h"`
`#include "zoom_func.h"`
`#include "fileio_func.h"`
`#include "table/sprites.h"`
`#include "table/control_codes.h"`
`#include "table/unicode.h"`
`#include "safeguards.h"`
`#include <ft2build.h>`
`#include <FT_FREETYPE_H>`
`#include <FT_GLYPH_H>`
`#include <FT_TRUETYPE_TABLES_H>`

Go to the source code of this file.

## Data Structures
class | SpriteFontCache
| Font cache for fonts that are based on a freetype font. More...
class | FreeTypeFontCache
| Font cache for fonts that are based on a freetype font. More...

## Macros
#define | CPSET { 0, 0, 0, 0, 1 }
#define | CP___ { 0, 0, 0, 0, 0 }

## Functions
int | GetCharacterHeight (FontSize size)
| Get height of a character for a given font size. More...
static bool | GetFontAAState (FontSize size, bool check_blitter=true)
static void | LoadFreeTypeFont (FontSize fs)
| Loads the freetype font. More...
void | InitFreeType (bool monospace)
| (Re)initialize the freetype related things, i.e. More...
void | UninitFreeType ()
| Free everything allocated w.r.t. More...
bool | HasAntialiasedFonts ()
| Should any of the active fonts be anti-aliased? More...

## Variables
static const int | ASCII_LETTERSTART = 32
| First printable ASCII letter.
static const int | _default_font_height [FS_END] = {10, 6, 18, 10}
| Default heights for the different sizes of fonts.
static const int | _default_font_ascender [FS_END] = { 8, 5, 15, 8}
FreeTypeSettings | _freetype
FT_Library | _library = nullptr

## Detailed Description

Cache for characters from fonts.

Definition in file fontcache.cpp.

## Function Documentation

## ◆ GetCharacterHeight()

int GetCharacterHeight | ( | FontSize | size | ) |

Get height of a character for a given font size.

Parameters

  size | Font size to get height of

Returns
  Height of characters in the given font (pixels)

Definition at line 69 of file fontcache.cpp.

References FontCache::Get(), and FontCache::GetHeight().

Referenced by NWidgetResizeBase::SetMinimalSize(), and NWidgetResizeBase::SetMinimalTextLines().

## ◆ HasAntialiasedFonts()

bool HasAntialiasedFonts | ( |  | ) |

Should any of the active fonts be anti-aliased?

Returns
  True if any of the loaded fonts want anti-aliased drawing.

Definition at line 721 of file fontcache.cpp.

References FS_BEGIN.

## ◆ InitFreeType()

void InitFreeType | ( | bool | monospace | ) |

(Re)initialize the freetype related things, i.e.

load the non-sprite fonts.

Parameters

  monospace | Whether to initialise the monospace or regular fonts.

Definition at line 681 of file fontcache.cpp.

References FS_BEGIN.

Referenced by MissingGlyphSearcher::FindMissingGlyphs(), and SetFallbackFont().

## ◆ LoadFreeTypeFont()

static void LoadFreeTypeFont | ( | FontSize | fs | ) |
| static

Loads the freetype font.

First type to load the fontname as if it were a path. If that fails, try to resolve the filename of the font using fontconfig, where the format is 'font family name' or 'font family name, font style'.

Parameters

  fs | The font size to load.

Definition at line 482 of file fontcache.cpp.

References settings.

## ◆ UninitFreeType()

void UninitFreeType | ( |  | ) |

Free everything allocated w.r.t.

fonts.

Definition at line 704 of file fontcache.cpp.

References FS_BEGIN.