Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb_font_desc.h
1 // ================================================================================
2 // == This file is a part of Turbo Badger. (C) 2011-2014, Emil SegerÃ¥s ==
3 // == See tb_core.h for more information. ==
4 // ================================================================================
5 
6 #ifndef TB_FONT_DESC_H
7 #define TB_FONT_DESC_H
8 
9 #include "tb_types.h"
10 #include "tb_id.h"
11 
12 namespace tb {
13 
19 {
20 public:
29  void SetID(const TBID &id) { m_id = id; }
30 
32  TBID GetID() const { return m_id; }
33 
40  TBID GetFontFaceID() const { return m_id + m_packed_init; }
41 
42  void SetSize(uint32_t size) { m_packed.size = MIN(size, 0x8000u); }
43  uint32_t GetSize() const { return m_packed.size; }
44 
45  //not connected to anything yet
46  //void SetBold(bool bold) { m_packed.bold = bold; }
47  //bool GetBold() const { return m_packed.bold; }
48 
49  //not connected to anything yet
50  //void SetItalic(bool italic) { m_packed.italic = italic; }
51  //bool GetItalic() const { return m_packed.italic; }
52 
53  // ask the font renderer to outline the font
54  void SetOutline(bool outline) { m_packed.outline = outline; }
55  bool GetOutline() const { return m_packed.outline; }
56 
57  TBFontDescription() : m_packed_init(0) {}
58  TBFontDescription(const TBFontDescription &src) { m_packed_init = src.m_packed_init; m_id = src.m_id; }
59  const TBFontDescription& operator = (const TBFontDescription &src) { m_packed_init = src.m_packed_init; m_id = src.m_id; return *this; }
60  bool operator == (const TBFontDescription &fd) const { return m_packed_init == fd.m_packed_init && m_id == fd.m_id; }
61  bool operator != (const TBFontDescription &fd) const { return !(*this == fd); }
62 private:
63  TBID m_id;
64  union {
65  struct {
66  uint32_t size : 15;
67  uint32_t italic : 1;
68  uint32_t bold : 1;
69  uint32_t outline : 1;
70  } m_packed;
71  uint32_t m_packed_init;
72  };
73 };
74 
75 } // namespace tb
76 
77 #endif // TB_FONT_DESC_H
TBID GetFontFaceID() const
Get the TBID for the TBFontFace that matches this font description.
Definition: tb_font_desc.h:40
TBID GetID() const
Get the TBID for the font name (See SetID).
Definition: tb_font_desc.h:32
TBID is a wrapper for a uint32_t to be used as ID.
Definition: tb_id.h:18
void SetID(const TBID &id)
Set the font ID of the font to use.
Definition: tb_font_desc.h:29
TBFontDescription describes a font.
Definition: tb_font_desc.h:18