Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
Font.h
Go to the documentation of this file.
1
2/*
3 ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
4 ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
5 █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
6 ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
7 ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
8 ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
9 /vvvvvvvvvvvvvvvvvvv \=========================================,
10 `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
11 Katana Engine \/ © 2012 - Shuriken Studios LLC
12 http://www.shurikenstudios.com
13*/
14
15#pragma once
16
17namespace KatanaEngine
18{
20 class Font : public Resource
21 {
22
23 public:
24
25 Font() { }
26 virtual ~Font() { al_destroy_font(m_pFont); }
27
32 static void SetLoadSize(const int size, const bool restore = false);
33
38 static void SetCharacterRange(const int rangeCount, int ranges[]);
39
44 virtual bool Load(const std::string &path, ResourceManager *pManager);
45
48 virtual int GetLineHeight() const { return al_get_font_line_height(m_pFont); }
49
53 virtual int GetTextWidth(const char *text) const { return al_get_text_width(m_pFont, text); }
54
58 virtual bool IsCloneable() const { return false; }
59
62 virtual ALLEGRO_FONT *GetAllegroFont() const { return m_pFont; }
63
64
65 private:
66
67 static int s_fontSize;
68 static int s_restoreSize;
69
70 static bool s_alAddonInitialized;
71
72 static int s_rangeCount;
73 static int *s_ranges;
74
75 ALLEGRO_FONT *m_pFont = nullptr;
76
77 };
78}
Represents a font or true-type font.
Definition Font.h:21
virtual int GetTextWidth(const char *text) const
Gets the width in pixels of the specified string.
Definition Font.h:53
static void SetCharacterRange(const int rangeCount, int ranges[])
Sets which characters to use when using a bitmap as a font.
Definition Font.cpp:33
virtual ~Font()
Definition Font.h:26
static void SetLoadSize(const int size, const bool restore=false)
Specifies the size of the font when loaded.
Definition Font.cpp:26
virtual ALLEGRO_FONT * GetAllegroFont() const
Get the allegro font representation of the texture.
Definition Font.h:62
virtual bool IsCloneable() const
Used to determine if the font is cloneable.
Definition Font.h:58
virtual int GetLineHeight() const
Gets the line height of the font in pixels.
Definition Font.h:48
virtual bool Load(const std::string &path, ResourceManager *pManager)
Load the desired font into memory.
Definition Font.cpp:39
Base class for all resource types to be managed by the ResourceManager class.
Definition Resource.h:23
Loads and manages the lifespan of objects from external files.
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition Animation.cpp:18