Cogs.Core
Classes | Public Member Functions | Public Attributes | List of all members
Cogs::Core::Font Struct Reference

Font resources are used to render text with a specific font and size. More...

#include <Font.h>

Inheritance diagram for Cogs::Core::Font:
Cogs::Core::ResourceBase

Classes

struct  BakedCharacter
 Defines a quad with locations in screen space defined by [x0, y0] and [x1, y1]. More...
 
struct  Character
 Defines a single character from a font resource. More...
 

Public Member Functions

 Font ()=default
 Default construct a new Font resource.
 
 Font (Font &&other) noexcept=default
 Move construct Font from other.
 
Fontoperator= (Font &&other) noexcept=default
 Move assign Font from other.
 
- Public Member Functions inherited from Cogs::Core::ResourceBase
 ResourceBase ()=default
 Constructs a new resource base.
 
 ResourceBase (const ResourceBase &other)=delete
 Disable trivial copies of resources.
 
ResourceBaseoperator= (const ResourceBase &other)=delete
 Disable copy-assignment of resources.
 
 ResourceBase (ResourceBase &&other)
 Move constructs a resource base from other.
 
ResourceBaseoperator= (ResourceBase &&other)
 Move assign the resource from the given ResourceBase other.
 
 ~ResourceBase ()
 Destructs the resource.
 
void setInitialized ()
 
void setChanged ()
 
bool hasChanged () const
 
void setLoading ()
 
void setLoaded ()
 
void setFailedLoad ()
 
void setActive ()
 
void setResident ()
 
void setProxy ()
 
void setKeepStorage ()
 
bool isInitialized () const
 
bool isLoaded () const
 
bool isActive () const
 
bool isResident () const
 
bool isDependency () const
 
bool isDeleted () const
 
bool isOrphaned () const
 
bool isProxy () const
 
bool hasFailedLoad () const
 
bool hasFailedActivation () const
 
bool keepStorage () const
 
void setType (ResourceTypes type)
 Set the type enumeration of the resource.
 
ResourceTypes getType () const
 Gets the type enumeration of the resource.
 
void setId (ResourceId resourceId)
 Set the resource id of the resource.
 
ResourceId getId () const
 Get the resource id of this instance.
 
void setFlag (ResourceFlags flags)
 Set the given resource flag.
 
void setFlags (ResourceFlags flags)
 
void unsetFlag (ResourceFlags flag)
 Unset the given flag.
 
bool isSet (ResourceFlags flag) const
 Check if the given flag is currently set.
 
ResourceFlags getFlags () const
 Get the current flags of the resource.
 
void attachResource (RenderResource *attachment)
 Attach the given GPU resource to the resource.
 
bool hasAttachedResource () const
 Check if the resource has an attachment.
 
RenderResourcegetAttachedResource () const
 Get the attached resource.
 
void setOwner (IResourceManager *owner)
 Sets the owner of this resource instance.
 
IResourceManagergetOwner () const
 
void setName (const StringView &name)
 Set the user friendly name of the resource.
 
StringView getName () const
 Get the name of the resource.
 
void setSource (const StringView &source)
 
StringView getSource () const
 
void increment ()
 Increments the reference count of the resource.
 
void decrement ()
 Decrement the reference count of the resource.
 
uint32_t referenceCount () const
 Get the current reference count.
 
void incrementGeneration ()
 Increment the generation count.
 
uint32_t getGeneration () const
 Get the generation count.
 
void setSlot (uint32_t slot)
 Sets the slot at which the resource is internally tracked.
 
uint32_t getSlot () const
 Gets the slot where the resource is tracked internally.
 

Public Attributes

std::vector< Charactercharacters
 Contains all available characters in the font, defining their locations in the cached bitmap.
 
float size = 16.0f
 Desired font size given in pixels.
 
float ascent = 12.0f
 Font ascent given in pixels.
 
float descent = 12.0f
 Font descent given in pixels.
 
int bitmapSize = 512
 Bitmap font size in pixels. The font cache bitmap will be bitmapSize * bitmapSize * 4 bytes.
 
bool sdf = false
 If the font is generated as a distance field.
 
std::vector< uint8_t > bitmap
 Bitmap font data storage.
 
TextureHandle texture = TextureHandle::NoHandle
 Handle to the texture used to hold the bitmap font data.
 

Additional Inherited Members

- Static Public Attributes inherited from Cogs::Core::ResourceBase
static const uint32_t NoAttachment = 0xFFFFFFFF
 Constant used to signal no attachment.
 

Detailed Description

Font resources are used to render text with a specific font and size.

Fonts are loaded from system fonts or user-provided TrueType font files.

A single font instance has a size specified at creation time, due to how fonts are cached in bitmaps by the FontManager, and as such cannot be shared between instances of text wanting to render with different sizes.

Font resource instances are loaded, processed and activated by the FontManager.

Definition at line 21 of file Font.h.

Member Data Documentation

◆ ascent

float Cogs::Core::Font::ascent = 12.0f

Font ascent given in pixels.

Definition at line 69 of file Font.h.

◆ bitmap

std::vector<uint8_t> Cogs::Core::Font::bitmap

Bitmap font data storage.

Definition at line 81 of file Font.h.

◆ bitmapSize

int Cogs::Core::Font::bitmapSize = 512

Bitmap font size in pixels. The font cache bitmap will be bitmapSize * bitmapSize * 4 bytes.

Definition at line 75 of file Font.h.

◆ characters

std::vector<Character> Cogs::Core::Font::characters

Contains all available characters in the font, defining their locations in the cached bitmap.

Definition at line 63 of file Font.h.

◆ descent

float Cogs::Core::Font::descent = 12.0f

Font descent given in pixels.

Definition at line 72 of file Font.h.

◆ sdf

bool Cogs::Core::Font::sdf = false

If the font is generated as a distance field.

Definition at line 78 of file Font.h.

◆ size

float Cogs::Core::Font::size = 16.0f

Desired font size given in pixels.

Definition at line 66 of file Font.h.

◆ texture

TextureHandle Cogs::Core::Font::texture = TextureHandle::NoHandle

Handle to the texture used to hold the bitmap font data.

Definition at line 84 of file Font.h.


The documentation for this struct was generated from the following file: