// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Types/BaseTypes.h"
class Font;
class FontAsset;
class FontTextureAtlas;
struct FontCharacterEntry;
typedef struct FT_LibraryRec_* FT_Library;
///
/// Fonts management and character atlases management utility service.
///
class FLAXENGINE_API FontManager
{
public:
///
/// The global characters font scale factor. Used to upscale characters on high-DPI monitors.
///
static float FontScale;
///
/// Gets the FreeType library.
///
/// The library.
static FT_Library GetLibrary();
///
/// Gets the texture atlas.
///
/// The atlas index.
/// The texture atlas.
static FontTextureAtlas* GetAtlas(int32 index);
///
/// Adds character from given font to the cache.
///
/// The font to create character entry for it.
/// The character to add.
/// The created character entry.
/// True if cannot add new character entry to the font cache, otherwise false.
static bool AddNewEntry(Font* font, Char c, FontCharacterEntry& entry);
///
/// Invalidates the cached dynamic font character. Can be used to reload font characters after changing font asset options.
///
/// The font character entry.
static void Invalidate(FontCharacterEntry& entry);
///
/// Flushes all font atlases.
///
static void Flush();
// Ensure that atlas with given index has been created
static void EnsureAtlasCreated(int32 index);
///
/// Determines whether one or more font atlases is dirty.
///
/// true if one or more font atlases is dirty; otherwise, false.
static bool IsDirty();
///
/// Determines whether all atlases has been synced with the GPU memory and data is up to date.
///
/// true if all atlases has been synced with the GPU memory and data is up to date; otherwise, false.
static bool HasDataSyncWithGPU();
};