OpenTTD: src/fontcache.cpp File Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Functions | Variables
fontcache.cpp File Reference

Cache for characters from fonts. More...

`#include "stdafx.h"`
`#include "fontcache.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 "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...
struct | FreeTypeFontCache::GlyphEntry
| Container for information about a glyph. 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.
static void | LoadFreeTypeFont (FontSize fs)
| Loads the freetype font.
static void * | AllocateFont (size_t size)
static bool | GetFontAAState (FontSize size)
void | InitFreeType (bool monospace)
| (Re)initialize the freetype related things, i.e.
void | UninitFreeType ()
| Free everything allocated w.r.t.

## Variables
static const int | ASCII_LETTERSTART = 32
| First printable ASCII letter.
static const int | MAX_FONT_SIZE = 72
| Maximum font size.
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}
FT_Library | _library = NULL
FreeTypeSettings | _freetype
static const byte | FACE_COLOUR = 1
static const byte | SHADOW_COLOUR = 2

## Detailed Description

Cache for characters from fonts.

Definition in file fontcache.cpp.

## Function Documentation

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 63 of file fontcache.cpp.

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

Referenced by BaseGraphWindow::DrawGraph(), NWidgetResizeBase::SetMinimalTextLines(), and StationsWndShowStationRating().

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 643 of file fontcache.cpp.

References FS_BEGIN, FS_MONO, FontCache::Get(), FontCache::HasParent(), and LoadFreeTypeFont().

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

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 324 of file fontcache.cpp.

References DEBUG, error(), FreeTypeSubSetting::font, FS_LARGE, FS_MONO, FS_NORMAL, FS_SMALL, GetFontByFaceName(), FreeTypeSettings::large, FreeTypeSettings::medium, FreeTypeSettings::mono, ShowInfoF(), FreeTypeSubSetting::size, FreeTypeSettings::small, and StrEmpty().

Referenced by InitFreeType().

void UninitFreeType | ( |  | ) |

Free everything allocated w.r.t.

fonts.

Definition at line 660 of file fontcache.cpp.

References FS_BEGIN, FontCache::Get(), and FontCache::HasParent().

Referenced by ShutdownGame().

## Variable Documentation

const int _default_font_height[FS_END] = {10, 6, 18, 10}
| static

Default heights for the different sizes of fonts.

Definition at line 33 of file fontcache.cpp.

Referenced by FreeTypeFontCache::FreeTypeFontCache().