OpenTTD Source 20241224-master-gf74b0cf984
|
Cache for characters from fonts. More...
#include "stdafx.h"
#include "fontcache.h"
#include "fontdetection.h"
#include "blitter/factory.hpp"
#include "gfx_layout.h"
#include "fontcache/spritefontcache.h"
#include "openttd.h"
#include "settings_func.h"
#include "strings_func.h"
#include "viewport_func.h"
#include "window_func.h"
#include "fileio_func.h"
#include "safeguards.h"
Go to the source code of this file.
Functions | |
int | GetCharacterHeight (FontSize size) |
Get height of a character for a given font size. | |
bool | GetFontAAState () |
void | SetFont (FontSize fontsize, const std::string &font, uint size) |
void | LoadFreeTypeFont (FontSize fs) |
Loads the freetype font. | |
void | UninitFreeType () |
Free everything allocated w.r.t. | |
static bool | IsDefaultFont (const FontCacheSubSetting &setting) |
Test if a font setting uses the default font. | |
uint | GetFontCacheFontSize (FontSize fs) |
Get the scalable font size to use for a FontSize. | |
static std::string | GetDefaultTruetypeFont (FontSize fs) |
Get name of default font file for a given font size. | |
static std::string | GetDefaultTruetypeFontFile (FontSize fs) |
Get path of default font file for a given font size. | |
std::string | GetFontCacheFontName (FontSize fs) |
Get font to use for a given font size. | |
void | InitFontCache (bool monospace) |
(Re)initialize the font cache related things, i.e. | |
void | UninitFontCache () |
Free everything allocated w.r.t. | |
Variables | |
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} |
FontCacheSettings | _fcsettings |
Cache for characters from fonts.
Definition in file fontcache.cpp.
int GetCharacterHeight | ( | FontSize | size | ) |
Get height of a character for a given font size.
size | Font size to get height of |
Definition at line 77 of file fontcache.cpp.
References FontCache::Get(), and FontCache::GetHeight().
Referenced by CargoesField::CargoClickedAt(), CargoesField::CargoLabelClickedAt(), CheckClickOnViewportSign(), TextfileWindow::CheckHyperlinkClick(), CargoesField::Draw(), StationViewWindow::DrawAcceptedCargo(), TownAuthorityWindow::DrawActions(), DrawAircraftDetails(), DrawAircraftPurchaseInfo(), TimetableWindow::DrawArrivalDeparturePanel(), DrawButtonDropdown(), StationViewWindow::DrawCargoRatings(), DrawCategories(), DrawCategory(), DrawCharCentered(), NetworkClientListWindow::DrawCompany(), CompanyInfrastructureWindow::DrawCountLine(), NetworkContentListWindow::DrawDetails(), FramerateWindow::DrawElementTimesColumn(), DrawEngineList(), StationViewWindow::DrawEntries(), DrawFrame(), BaseGraphWindow::DrawGraph(), SmallMapWindow::DrawIndustryNames(), IndustryViewWindow::DrawInfo(), GoalListWindow::DrawListColumn(), NetworkContentListWindow::DrawMatrix(), DrawOrderString(), TownAuthorityWindow::DrawRatings(), DrawRoadVehDetails(), NetworkGameWindow::DrawServerLine(), SettingEntry::DrawSetting(), SettingsPage::DrawSetting(), DrawShipDetails(), DrawSliderWidget(), DrawSmallOrderList(), DrawString(), TimetableWindow::DrawSummaryPanel(), TimetableWindow::DrawTimetablePanel(), SmallMapWindow::DrawTowns(), DrawTrainDetails(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehiclePurchaseInfo(), DrawVehicleRefitWindow(), CheatWindow::DrawWidget(), SelectCompanyLiveryWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), EnginePreviewWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), FramerateWindow::DrawWidget(), FrametimeGraphWindow::DrawWidget(), GSConfigWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), BaseGraphWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), PerformanceLeagueWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), LandInfoWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), BaseNetworkContentDownloadStatusWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), NewGRFWindow::DrawWidget(), SavePresetWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), ScriptListWindow::DrawWidget(), ScriptSettingsWindow::DrawWidget(), GameSettingsWindow::DrawWidget(), SignListWindow::DrawWidget(), SmallMapWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), StatusBarWindow::DrawWidget(), StoryBookWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), TextfileWindow::DrawWidget(), ScenarioEditorToolbarWindow::DrawWidget(), TownViewWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), VehicleDetailsWindow::DrawWidget(), VehicleViewWindow::DrawWidget(), DrawYearCategory(), DrawYearColumn(), StoryBookWindow::EnsureStoryPageElementLayout(), GetAutoPlacePosition(), TownViewWindow::GetDesiredInfoHeight(), GetEngineListHeight(), StoryBookWindow::GetHeadHeight(), SmallMapWindow::GetLegendHeight(), SmallMapWindow::GetPositionOnLegend(), VehicleDetailsWindow::GetRoadVehDetailsHeight(), GetTotalCategoriesHeight(), GetVehicleListHeight(), LocalGetWindowPlacement(), ViewportSign::MarkDirty(), NetworkDrawChatMessage(), NetworkReInitChatBoxSize(), FramerateWindow::OnClick(), BaseGraphWindow::OnClick(), MusicTrackSelectionWindow::OnClick(), StationViewWindow::OnClick(), TownAuthorityWindow::OnClick(), IConsoleWindow::OnInit(), PaymentRatesGraphWindow::OnInit(), IndustryProductionGraphWindow::OnInit(), BuildIndustryWindow::OnInit(), IndustryViewWindow::OnInit(), IndustryCargoesWindow::OnInit(), SmallMapWindow::OnInit(), BuildAirportWindow::OnPaint(), ReplaceVehicleWindow::OnPaint(), BuildVehicleWindow::OnPaint(), HighScoreWindow::OnPaint(), GameSettingsWindow::OnPaint(), FramerateWindow::OnResize(), TextfileWindow::ReflowContent(), NWidgetResizeBase::SetMinimalSize(), NWidgetResizeBase::SetMinimalTextLines(), NWidgetBackground::SetupSmallestSize(), StationsWndShowStationRating(), NWidgetResizeBase::UpdateMultilineWidgetSize(), AIConfigWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), BuildVehicleWindow::UpdateWidgetSize(), CheatWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), SelectCompanyLiveryWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), EnginePreviewWindow::UpdateWidgetSize(), SaveLoadWindow::UpdateWidgetSize(), FramerateWindow::UpdateWidgetSize(), GSConfigWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), PaymentRatesGraphWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), PerformanceLeagueWindow::UpdateWidgetSize(), ScriptLeagueWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), AboutWindow::UpdateWidgetSize(), NetworkContentListWindow::UpdateWidgetSize(), BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(), NetworkGameWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), NewGRFInspectWindow::UpdateWidgetSize(), SpriteAlignerWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), SavePresetWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), PickerWindow::UpdateWidgetSize(), ScriptListWindow::UpdateWidgetSize(), ScriptSettingsWindow::UpdateWidgetSize(), ScriptDebugWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), SignListWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), StationViewWindow::UpdateWidgetSize(), StoryBookWindow::UpdateWidgetSize(), SubsidyListWindow::UpdateWidgetSize(), TextfileWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), RefitWindow::UpdateWidgetSize(), VehicleDetailsWindow::UpdateWidgetSize(), VehicleViewWindow::UpdateWidgetSize(), and ViewportAddString().
|
static |
Get name of default font file for a given font size.
fs | Font size. |
Definition at line 174 of file fontcache.cpp.
References FS_LARGE, FS_MONO, FS_NORMAL, and FS_SMALL.
Referenced by GetDefaultTruetypeFontFile().
|
static |
Get path of default font file for a given font size.
fs | Font size. |
Definition at line 191 of file fontcache.cpp.
References BASESET_DIR, FioFindFullPath(), and GetDefaultTruetypeFont().
Referenced by GetFontCacheFontName().
bool GetFontAAState | ( | ) |
Definition at line 93 of file fontcache.cpp.
std::string GetFontCacheFontName | ( | FontSize | fs | ) |
Get font to use for a given font size.
fs | Font size. |
Definition at line 206 of file fontcache.cpp.
References GetDefaultTruetypeFontFile(), GetFontCacheSubSetting(), FontCacheSettings::prefer_sprite, and settings.
Referenced by LoadCoreTextFont(), LoadFreeTypeFont(), and LoadWin32Font().
uint GetFontCacheFontSize | ( | FontSize | fs | ) |
Get the scalable font size to use for a FontSize.
fs | FontSize to get the scalable font size for. |
Definition at line 162 of file fontcache.cpp.
References GetFontCacheSubSetting(), IsDefaultFont(), and FontCacheSubSetting::size.
Referenced by LoadCoreTextFont(), LoadFreeTypeFont(), and LoadWin32Font().
void InitFontCache | ( | bool | monospace | ) |
(Re)initialize the font cache related things, i.e.
load the non-sprite fonts.
monospace | Whether to initialise the monospace or regular fonts. |
Definition at line 218 of file fontcache.cpp.
References FS_BEGIN, FS_MONO, FontCache::Get(), FontCache::HasParent(), LoadCoreTextFont(), LoadFreeTypeFont(), and LoadWin32Font().
Referenced by CheckForMissingGlyphs(), MissingGlyphSearcher::FindMissingGlyphs(), GameOptionsWindow::OnClick(), openttd_main(), and SetFallbackFont().
|
static |
Test if a font setting uses the default font.
Definition at line 152 of file fontcache.cpp.
References FontCacheSubSetting::font, and FontCacheSubSetting::os_handle.
Referenced by GetFontCacheFontSize().
|
extern |
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'.
fs | The font size to load. |
Definition at line 159 of file freetypefontcache.cpp.
References BASE_DIR, Debug, FioFindFullPath(), GetFontByFaceName(), GetFontCacheFontName(), GetFontCacheFontSize(), GetFontCacheSubSetting(), and settings.
Referenced by InitFontCache().
void SetFont | ( | FontSize | fontsize, |
const std::string & | font, | ||
uint | size | ||
) |
Definition at line 101 of file fontcache.cpp.
void UninitFontCache | ( | ) |
Free everything allocated w.r.t.
fonts.
Definition at line 241 of file fontcache.cpp.
References FS_BEGIN, FontCache::Get(), FontCache::HasParent(), and UninitFreeType().
Referenced by ShutdownGame().
|
extern |
Free everything allocated w.r.t.
freetype.
Definition at line 303 of file freetypefontcache.cpp.
Referenced by UninitFontCache().
|
static |
Definition at line 27 of file fontcache.cpp.
|
static |
Default heights for the different sizes of fonts.
Definition at line 26 of file fontcache.cpp.
FontCacheSettings _fcsettings |
Definition at line 29 of file fontcache.cpp.