diff --git a/Source/Engine/Render2D/Font.h b/Source/Engine/Render2D/Font.h index ada57ca9d..b3ddd25f8 100644 --- a/Source/Engine/Render2D/Font.h +++ b/Source/Engine/Render2D/Font.h @@ -10,7 +10,6 @@ #include "TextLayoutOptions.h" class FontAsset; -struct FontTextureAtlasSlot; struct FontCharacterEntry; // The default DPI that engine is using diff --git a/Source/Engine/Render2D/FontAsset.h b/Source/Engine/Render2D/FontAsset.h index c8bcf435c..0a5c67255 100644 --- a/Source/Engine/Render2D/FontAsset.h +++ b/Source/Engine/Render2D/FontAsset.h @@ -7,116 +7,12 @@ #include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Core/Math/Vector2.h" +#include "Engine/Render2D/FontCharacterEntry.h" class Font; class FontManager; -struct FontTextureAtlasSlot; typedef struct FT_FaceRec_* FT_Face; -// Font glyph metrics: -// -// xmin xmax -// | | -// |<-------- width -------->| -// | | -// | +-------------------------+----------------- ymax -// | | ggggggggg ggggg | ^ ^ -// | | g:::::::::ggg::::g | | | -// | | g:::::::::::::::::g | | | -// | | g::::::ggggg::::::gg | | | -// | | g:::::g g:::::g | | | -// offsetX -|-------->| g:::::g g:::::g | offsetY | -// | | g:::::g g:::::g | | | -// | | g::::::g g:::::g | | | -// | | g:::::::ggggg:::::g | | | -// | | g::::::::::::::::g | | height -// | | gg::::::::::::::g | | | -// baseline ---*---------|---- gggggggg::::::g-----*-------- | -// / | | g:::::g | | -// origin | | gggggg g:::::g | | -// | | g:::::gg gg:::::g | | -// | | g::::::ggg:::::::g | | -// | | gg:::::::::::::g | | -// | | ggg::::::ggg | | -// | | gggggg | v -// | +-------------------------+----------------- ymin -// | | -// |------------- advanceX ----------->| - -/// -/// The cached font character entry (read for rendering and further processing). -/// -API_STRUCT(NoDefault) struct FLAXENGINE_API FontCharacterEntry -{ - DECLARE_SCRIPTING_TYPE_MINIMAL(FontCharacterEntry); - - /// - /// The character represented by this entry. - /// - API_FIELD() Char Character; - - /// - /// True if entry is valid, otherwise false. - /// - API_FIELD() bool IsValid = false; - - /// - /// The index to a specific texture in the font cache. - /// - API_FIELD() byte TextureIndex; - - /// - /// The left bearing expressed in integer pixels. - /// - API_FIELD() int16 OffsetX; - - /// - /// The top bearing expressed in integer pixels. - /// - API_FIELD() int16 OffsetY; - - /// - /// The amount to advance in X before drawing the next character in a string. - /// - API_FIELD() int16 AdvanceX; - - /// - /// The distance from baseline to glyph top most point. - /// - API_FIELD() int16 BearingY; - - /// - /// The height in pixels of the glyph. - /// - API_FIELD() int16 Height; - - /// - /// The start location of the character in the texture (in texture coordinates space). - /// - API_FIELD() Float2 UV; - - /// - /// The size the character in the texture (in texture coordinates space). - /// - API_FIELD() Float2 UVSize; - - /// - /// The slot in texture atlas, containing the pixel data of the glyph. - /// - API_FIELD() const FontTextureAtlasSlot* Slot; - - /// - /// The owner font. - /// - API_FIELD() const class Font* Font; -}; - -template<> -struct TIsPODType -{ - enum { Value = true }; -}; - /// /// The font hinting used when rendering characters. /// diff --git a/Source/Engine/Render2D/FontCharacterEntry.h b/Source/Engine/Render2D/FontCharacterEntry.h new file mode 100644 index 000000000..f73099beb --- /dev/null +++ b/Source/Engine/Render2D/FontCharacterEntry.h @@ -0,0 +1,109 @@ +// Copyright (c) Wojciech Figat. All rights reserved. + +#pragma once + +#include "Engine/Core/Math/Vector2.h" + +// Font glyph metrics: +// +// xmin xmax +// | | +// |<-------- width -------->| +// | | +// | +-------------------------+----------------- ymax +// | | ggggggggg ggggg | ^ ^ +// | | g:::::::::ggg::::g | | | +// | | g:::::::::::::::::g | | | +// | | g::::::ggggg::::::gg | | | +// | | g:::::g g:::::g | | | +// offsetX -|-------->| g:::::g g:::::g | offsetY | +// | | g:::::g g:::::g | | | +// | | g::::::g g:::::g | | | +// | | g:::::::ggggg:::::g | | | +// | | g::::::::::::::::g | | height +// | | gg::::::::::::::g | | | +// baseline ---*---------|---- gggggggg::::::g-----*-------- | +// / | | g:::::g | | +// origin | | gggggg g:::::g | | +// | | g:::::gg gg:::::g | | +// | | g::::::ggg:::::::g | | +// | | gg:::::::::::::g | | +// | | ggg::::::ggg | | +// | | gggggg | v +// | +-------------------------+----------------- ymin +// | | +// |------------- advanceX ----------->| + +/// +/// The cached font character entry (read for rendering and further processing). +/// +API_STRUCT(NoDefault) struct FLAXENGINE_API FontCharacterEntry +{ + DECLARE_SCRIPTING_TYPE_MINIMAL(FontCharacterEntry); + + /// + /// The character represented by this entry. + /// + API_FIELD() Char Character; + + /// + /// True if entry is valid, otherwise false. + /// + API_FIELD() bool IsValid = false; + + /// + /// The index to a specific texture in the font cache. + /// + API_FIELD() byte TextureIndex; + + /// + /// The left bearing expressed in integer pixels. + /// + API_FIELD() int16 OffsetX; + + /// + /// The top bearing expressed in integer pixels. + /// + API_FIELD() int16 OffsetY; + + /// + /// The amount to advance in X before drawing the next character in a string. + /// + API_FIELD() int16 AdvanceX; + + /// + /// The distance from baseline to glyph top most point. + /// + API_FIELD() int16 BearingY; + + /// + /// The height in pixels of the glyph. + /// + API_FIELD() int16 Height; + + /// + /// The start location of the character in the texture (in texture coordinates space). + /// + API_FIELD() Float2 UV; + + /// + /// The size the character in the texture (in texture coordinates space). + /// + API_FIELD() Float2 UVSize; + + /// + /// The slot in texture atlas, containing the pixel data of the glyph. + /// + API_FIELD() const struct FontTextureAtlasSlot* Slot; + + /// + /// The owner font. + /// + API_FIELD() const class Font* Font; +}; + +template<> +struct TIsPODType +{ + enum { Value = true }; +};