Gorgon Game Engine
BitmapFont.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdint.h>
4 #include <Gorgon/Utils/Assert.h>
5 #include <map>
6 
7 #include "Font.h"
8 #include "Drawables.h"
9 #include "Bitmap.h"
10 #include "../Containers/Collection.h"
11 
12 namespace Gorgon { namespace Resource { class Font; } }
13 
14 
15 namespace Gorgon { namespace Graphics {
16 
17 
24  class BitmapFont : public GlyphRenderer, public BasicFont {
25  friend class Resource::Font;
26  public:
29  public:
31 
34 
37 
38  union {
39  const RectangularDrawable *image = nullptr;
40  int index; //for use in resource loading
41  };
42 
43  Geometry::Pointf offset;//update offset to be x and y as well as a seperate advance field
44  float advance;
45  };
46 
58  };
59 
63  All
64  };
65 
66 
68  struct ImportOptions {
70  bool pack = true,
71  float baseline = -1,
72  bool trim = true,
73  YesNoAuto converttoalpha = YesNoAuto::Yes,
74  bool prepare = true,
75  bool estimatebaseline = false,
76  bool automatickerning = true,
77  int spacing = -1
78  ) :
79  pack(pack),
81  trim(trim),
87  {
88  }
89 
92  bool pack = true;
93 
97  float baseline = -1;
98 
102  bool trim = true;
103 
110  YesNoAuto converttoalpha = YesNoAuto::Yes;
111 
113  bool prepare = true;
114 
118  bool estimatebaseline = false;
119 
121  bool automatickerning = true;
122 
127 
129  int spacing = -1;
130  };
131 
132  explicit BitmapFont(float baseline = 0) : BasicFont(dynamic_cast<GlyphRenderer &>(*this)), baseline(baseline) { }
133 
134  BitmapFont(const BitmapFont &) = delete;
135 
138  }
139 
140  BitmapFont(BitmapFont &&other);
141 
142  BitmapFont &operator =(const BitmapFont &) = delete;
143 
146  BitmapFont &operator =(BitmapFont &&other);
147 
149  destroylist.Destroy();
150  }
151 
154  void AddGlyph(Glyph glyph, const RectangularDrawable &bitmap, int baseline = 0) {
155  AddGlyph(glyph, bitmap, {0, this->baseline - baseline}, float(bitmap.GetWidth() + spacing));
156  }
157 
160  void AddGlyph(Glyph glyph, const RectangularDrawable &bitmap, Geometry::Pointf offset, float advance);
161 
164  void AssumeGlyph(Glyph glyph, const RectangularDrawable &bitmap, int baseline = 0) {
165  AddGlyph(glyph, bitmap, baseline);
166  destroylist.Push(bitmap);
167  }
168 
171  void AssumeGlyph(Glyph glyph, const RectangularDrawable &bitmap, Geometry::Pointf offset, float advance) {
172  AddGlyph(glyph, bitmap, offset, advance);
173  destroylist.Push(bitmap);
174  }
175 
176  virtual bool IsASCII() const override {
177  return isascii;
178  }
179 
180  void SetKerning(Glyph left, Glyph right, Geometry::Pointf kern) {
181  kerning[{left, right}] = kern;
182  }
183 
184  void SetKerning(Glyph left, Glyph right, float x) {
185  kerning[{left, right}] = {x, 0.f};
186  }
187 
194  void Pack(bool tight = false, DeleteConstants del = Owned);
195 
197  Graphics::Bitmap CreateAtlas(std::vector<Geometry::Bounds> &bounds, bool tight = false) const;
198 
199  using BasicFont::GetSize;
200 
201  virtual Geometry::Size GetSize(Glyph chr) const override;
202 
203  virtual void Render(Glyph chr, TextureTarget &target, Geometry::Pointf location, RGBAf color) const override;
204 
205  virtual bool IsFixedWidth() const override { return isfixedw; }
206 
207  virtual bool Exists(Glyph g) const override { return glyphmap.count(g) != 0; }
208 
209  virtual Geometry::Pointf KerningDistance(Glyph chr1, Glyph chr2) const override {
210  auto f = kerning.find({chr1, chr2});
211 
212  if(f != kerning.end())
213  return f->second;
214  else
215  return {0.f, 0.f};
216  }
217 
218  virtual float GetCursorAdvance(Glyph g) const override;
219 
220  virtual int GetEMSize() const override { return Exists(0x2004) ? GetSize(0x2004).Width : GetHeight(); }
221 
222  virtual int GetMaxWidth() const override { return maxwidth; }
223 
224  virtual int GetHeight() const override { return height; }
225 
226  virtual float GetBaseLine() const override { return baseline; }
227 
228  virtual float GetLineGap() const override { return linegap; }
229 
230  virtual int GetDigitWidth() const override { return digw; }
231 
232  virtual float GetLineThickness() const override { return (float)linethickness; }
233 
234  virtual int GetUnderlineOffset() const override { return underlinepos; }
235 
237  void SetHeight(int value) { height = value; }
238 
240  void SetMaxWidth(int value) { maxwidth = value; }
241 
245  void DetermineDimensions();
246 
248  void SetGlyphSpacing(int value) { spacing = value; }
249 
251  int GetGlyphSpacing() const { return spacing; }
252 
254  void SetLineThickness(int value) { linethickness = value; }
255 
257  void SetUnderlineOffset(int value) { underlinepos = value; }
258 
260  void SetBaseline(float value) { baseline = value; }
261 
263  void SetLineGap(float value) { linegap = value; }
264 
286  int ImportFolder(const std::string &path, ImportNamingTemplate naming = Automatic, Glyph start = 0,
287  std::string prefix = "", ImportOptions options = ImportOptions{});
288 
289 
306  int ImportAtlas(Bitmap &&bmp, Geometry::Size grid = {0, 0}, Glyph start = 0x20, bool expand = false, ImportOptions options = ImportOptions{});
307 
310  int ImportAtlas(const Bitmap &bmp, Geometry::Size grid = {0, 0}, Glyph start = 0x20, bool expand = false, ImportOptions options = ImportOptions{}) {
311  return ImportAtlas(bmp.Duplicate(), grid, start, expand, options);
312  }
313 
315  int ImportAtlas(const std::string &filename, Geometry::Size grid = {0, 0}, Glyph start = 0x20, bool expand = false, ImportOptions options = ImportOptions{}) {
316  Bitmap bmp;
317 
318  if(!bmp.Import(filename))
319  return 0;
320 
321  return ImportAtlas(std::move(bmp), grid, start, expand, options);
322  }
323 
333  void AutoKern(Byte opaquelevel = 64, int reduce = 1, int capitaloffset = -1);
334 
337  if(glyphmap.count(g))
338  return glyphmap.at(g).image;
339  else
340  return nullptr;
341  }
342 
344 
348  void Remove(Glyph g);
349 
352  auto it = destroylist.Find(img);
353 
354  if(it.IsValid()) {
355  destroylist.Remove(*it);
356 
357  return true;
358  }
359  else
360  return false;
361  }
362 
364  bool IsOwned(const RectangularDrawable &img) const {
365  auto it = destroylist.Find(img);
366 
367  return it.IsValid();
368  }
369 
372  void Adopt(const RectangularDrawable &img) {
373  destroylist.Add(img);
374  }
375 
378  virtual std::pair<int, int> GetLetterHeight(bool asciionly = false) const override;
379 
380 
381  virtual const GlyphRenderer &GetGlyphRenderer() const override {
382  return *this;
383  }
384 
385  std::map<Glyph, GlyphDescriptor>::iterator begin() {
386  return glyphmap.begin();
387  }
388 
389  std::map<Glyph, GlyphDescriptor>::iterator end() {
390  return glyphmap.end();
391  }
392 
393  std::map<Glyph, GlyphDescriptor>::const_iterator begin() const {
394  return glyphmap.begin();
395  }
396 
397  std::map<Glyph, GlyphDescriptor>::const_iterator end() const {
398  return glyphmap.end();
399  }
400 
401  protected:
402 
403  std::map<Glyph, GlyphDescriptor> glyphmap;
405 
406  struct gtog {
408  bool operator <(const gtog &other) const { if(left == other.left) return right < other.right; else return left < other.left; }
409  };
410 
411  std::map<gtog, Geometry::Pointf> kerning;
412 
413  int isfixedw = true;
414 
415  int maxwidth = 0;
416 
417  int height = 0;
418 
419  float baseline = 0;
420 
421  int digw = 0;
422 
423  bool isascii = true;
424 
425  int spacing = 0;
426 
427  int linethickness = 1;
428 
429  int underlinepos = 0;
430 
431  float linegap = 0;
432  };
433 
434 } }
Gorgon::Filesystem::Iterator::IsValid
bool IsValid() const
Checks whether the iterator is valid.
Definition: Iterator.h:146
Gorgon::Graphics::BitmapFont::AutoKern
void AutoKern(Byte opaquelevel=64, int reduce=1, int capitaloffset=-1)
Automatically calculates kerning distances between glyphs.
Definition: BitmapFont.cpp:756
Gorgon::Graphics::BitmapFont::gtog::operator<
bool operator<(const gtog &other) const
Definition: BitmapFont.h:408
Gorgon::Graphics::BitmapFont::ImportOptions::ImportOptions
ImportOptions(bool pack=true, float baseline=-1, bool trim=true, YesNoAuto converttoalpha=YesNoAuto::Yes, bool prepare=true, bool estimatebaseline=false, bool automatickerning=true, int spacing=-1)
Definition: BitmapFont.h:69
Gorgon::Geometry::basic_Bounds
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
Gorgon::swap
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
Gorgon::Graphics::BitmapFont::destroylist
Containers::Collection< const RectangularDrawable > destroylist
Definition: BitmapFont.h:404
Gorgon::Graphics::BitmapFont::kerning
std::map< gtog, Geometry::Pointf > kerning
Definition: BitmapFont.h:411
Gorgon::Graphics::RGBA
This class represents a color information.
Definition: Color.h:91
Gorgon::Graphics::BitmapFont::Render
virtual void Render(Glyph chr, TextureTarget &target, Geometry::Pointf location, RGBAf color) const override
This function should render the given character to the target at the specified location and color.
Definition: BitmapFont.cpp:74
Gorgon::String::From
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
Gorgon::Graphics::BitmapFont::CreateAtlas
Graphics::Bitmap CreateAtlas(std::vector< Geometry::Bounds > &bounds, bool tight=false) const
Performs packing without changing the font itself.
Definition: BitmapFont.cpp:956
Gorgon::Graphics::BitmapFont::GlyphDescriptor::advance
float advance
Definition: BitmapFont.h:44
Gorgon::Graphics::Bitmap::ForPixels
bool ForPixels(std::function< bool(int, int)> fn) const
Loops through all pixels of the image, giving coordinates to your function.
Definition: Bitmap.h:638
Gorgon::Graphics::internal::isspaced
bool isspaced(Glyph g)
Definition: Font.cpp:75
Gorgon::Graphics::Bitmap::Duplicate
Bitmap Duplicate() const
Duplicates this image.
Definition: Bitmap.h:117
Gorgon::Graphics::BitmapFont::DetermineDimensions
void DetermineDimensions()
Searches through the currently registered glyphs to determine dimensions.
Definition: BitmapFont.cpp:86
Gorgon::Graphics::BitmapFont::GlyphDescriptor::offset
Geometry::Pointf offset
Definition: BitmapFont.h:43
Gorgon::Graphics::BitmapFont::GlyphDescriptor::image
const RectangularDrawable * image
Definition: BitmapFont.h:39
Gorgon::Containers::Hashmap
This class is a reference based hashmap.
Definition: Hashmap.h:35
Gorgon::Graphics::BitmapFont::Release
bool Release(RectangularDrawable &img)
If the given resource is owned by this bitmap font, its ownership will be released.
Definition: BitmapFont.h:351
Gorgon::Graphics::GlyphRenderer::Prepare
virtual void Prepare(const std::string &) const
Notifies glyph renderer about a text to be rendered.
Definition: Font.h:143
Gorgon::Containers::Collection::Add
bool Add(T_ *Data)
Adds the given item to the end of the list if it is not already in the list.
Definition: Collection.h:248
Gorgon::Graphics::BitmapFont::baseline
float baseline
Definition: BitmapFont.h:419
Gorgon::Containers::Hashmap::Last
Iterator Last()
returns the iterator to the last item
Definition: Hashmap.h:430
Gorgon::Graphics::BitmapFont::ImportOptions::baseline
float baseline
Set baseline to specific height.
Definition: BitmapFont.h:97
Gorgon::Graphics::Bitmap::Zero
@ Zero
If there is transparency, transparent, otherwise black borders.
Definition: Bitmap.h:36
Gorgon::Graphics::BitmapFont::Owned
@ Owned
Definition: BitmapFont.h:62
Gorgon::Graphics::BitmapFont::IsASCII
virtual bool IsASCII() const override
This function should return true if this font renderer supports only 7-bit ASCII.
Definition: BitmapFont.h:176
Gorgon::Geometry::basic_Size::Height
T_ Height
Height of this size object.
Definition: Size.h:261
Gorgon::Graphics::BitmapFont::Pack
void Pack(bool tight=false, DeleteConstants del=Owned)
Converts individual glyphs to a single atlas.
Definition: BitmapFont.cpp:920
Drawables.h
Gorgon::Graphics::BitmapFont::SetLineGap
void SetLineGap(float value)
Changes the distance between two lines. Non-integer values are not recommended.
Definition: BitmapFont.h:263
Gorgon::Graphics::internal::isnewline
bool isnewline(Glyph g)
Definition: Font.cpp:79
Gorgon::Graphics::BitmapFont::Automatic
@ Automatic
Filenames will be examined to determine the template.
Definition: BitmapFont.h:50
Gorgon::Graphics::Bitmap::GetHeight
int GetHeight() const
Returns the height of the bitmap.
Definition: Bitmap.h:480
Gorgon::Graphics::BitmapFont::Exists
virtual bool Exists(Glyph g) const override
Returns true if the glyph exists.
Definition: BitmapFont.h:207
Gorgon::Graphics::BitmapFont::BitmapFont
BitmapFont(const BitmapFont &)=delete
Gorgon::Graphics::GlyphRenderer
Should be implemented by the systems aimed to render fonts on the screen.
Definition: Font.h:67
Gorgon::Graphics::BitmapFont::Hexadecimal
@ Hexadecimal
Hexadecimal code of the character is used as filename.
Definition: BitmapFont.h:57
Gorgon::Graphics::RGBAf
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
Gorgon::Graphics::BitmapFont::isfixedw
int isfixedw
Definition: BitmapFont.h:413
Gorgon::Graphics::Bitmap::GetMode
Graphics::ColorMode GetMode() const override
Returns the color mode of the image.
Definition: Bitmap.h:422
Gorgon::Containers::Hashmap::Add
void Add(const K_ &key, T_ &obj, bool deleteprev=false)
Adds the given item with the related key.
Definition: Hashmap.h:264
Gorgon::Graphics::BitmapFont::KerningDistance
virtual Geometry::Pointf KerningDistance(Glyph chr1, Glyph chr2) const override
This function should return the additional distance between given glyphs.
Definition: BitmapFont.h:209
Gorgon::Graphics::BitmapFont::ImportNamingTemplate
ImportNamingTemplate
Definition: BitmapFont.h:47
Gorgon::Graphics::BitmapFont::GlyphDescriptor::GlyphDescriptor
GlyphDescriptor(const RectangularDrawable &image, Geometry::Pointf offset, float advance)
Definition: BitmapFont.h:32
Gorgon::Graphics::BitmapFont::GlyphDescriptor::GlyphDescriptor
GlyphDescriptor()
Definition: BitmapFont.h:30
Gorgon::Filesystem::Join
std::string Join(std::string path1, const std::string &path2)
Joins two given paths or a path and filename.
Definition: Filesystem.h:154
Gorgon::Graphics::BitmapFont::end
std::map< Glyph, GlyphDescriptor >::const_iterator end() const
Definition: BitmapFont.h:397
Gorgon::Graphics::Bitmap::None
@ None
Atlas will be tight packed.
Definition: Bitmap.h:33
Gorgon::Graphics::RGBA::A
Byte A
Alpha channel.
Definition: Color.h:312
Font.h
Gorgon::Graphics::BitmapFont::Decimal
@ Decimal
Decimal code of the character is used as filename.
Definition: BitmapFont.h:55
Gorgon::Graphics::BitmapFont::ImportAtlas
int ImportAtlas(const std::string &filename, Geometry::Size grid={0, 0}, Glyph start=0x20, bool expand=false, ImportOptions options=ImportOptions{})
Imports the given file as atlas image. See ImportAtlas(Bitmap &&) for details.
Definition: BitmapFont.h:315
Gorgon::Graphics::BitmapFont::AddGlyph
void AddGlyph(Glyph glyph, const RectangularDrawable &bitmap, int baseline=0)
Adds a new glyph bitmap to the list.
Definition: BitmapFont.h:154
Gorgon::Graphics::BitmapFont::ImportOptions::converttoalpha
YesNoAuto converttoalpha
Whether to convert imported images to alpha only images.
Definition: BitmapFont.h:110
Gorgon::Graphics::internal::isspace
bool isspace(Glyph g)
Definition: Font.cpp:96
Gorgon::Graphics::BitmapFont::SetKerning
void SetKerning(Glyph left, Glyph right, float x)
Definition: BitmapFont.h:184
Gorgon::Geometry::basic_Margin::Top
T_ Top
Top margin.
Definition: Margin.h:170
Gorgon::Graphics::BitmapFont::ImportAtlas
int ImportAtlas(const Bitmap &bmp, Geometry::Size grid={0, 0}, Glyph start=0x20, bool expand=false, ImportOptions options=ImportOptions{})
Imports the given bitmap as atlas image.
Definition: BitmapFont.h:310
Gorgon::Graphics::BitmapFont::IsOwned
bool IsOwned(const RectangularDrawable &img) const
Returns if the given image is owned by this bitmap font.
Definition: BitmapFont.h:364
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Geometry::basic_Size
This class represents a 2D geometric size.
Definition: Size.h:23
Gorgon::Graphics::BitmapFont::SetUnderlineOffset
void SetUnderlineOffset(int value)
Changes the underline position to the specified value.
Definition: BitmapFont.h:257
Gorgon::Char
uint32_t Char
Definition: Types.h:46
Gorgon::Graphics::BitmapFont::~BitmapFont
~BitmapFont()
Definition: BitmapFont.h:148
Gorgon::Graphics::BitmapFont::GetSize
virtual Geometry::Size GetSize(const std::string &text) const override
Definition: Font.cpp:678
Gorgon::Graphics::BitmapFont::AssumeGlyph
void AssumeGlyph(Glyph glyph, const RectangularDrawable &bitmap, Geometry::Pointf offset, float advance)
Adds a new glyph bitmap to the list.
Definition: BitmapFont.h:171
Gorgon::YesNoAuto::No
@ No
Gorgon::Graphics::BitmapFont::gtog
Definition: BitmapFont.h:406
Gorgon::Graphics::BitmapFont::GetCursorAdvance
virtual float GetCursorAdvance(Glyph g) const override
This function should return the number of pixels the cursor should advance after this glyph.
Definition: BitmapFont.cpp:1066
Gorgon::Graphics::Bitmap::Trim
Geometry::Margin Trim(bool left, bool top, bool right, bool bottom)
Trims the empty parts of the image, alpha channel = 0 is used to determine empty portions.
Definition: Bitmap.cpp:541
Gorgon::Graphics::BitmapFont::height
int height
Definition: BitmapFont.h:417
Gorgon::Graphics::BitmapFont::digw
int digw
Definition: BitmapFont.h:421
Gorgon::Graphics::BitmapFont::ImportOptions::spacing
int spacing
Spaces between characters, -1 activates auto detection.
Definition: BitmapFont.h:129
Gorgon::Filesystem::GetExtension
std::string GetExtension(std::string path)
Returns the extension of the given path, also converts the extension to lower case.
Definition: Filesystem.cpp:140
Gorgon::Graphics::GetAlphaIndex
int GetAlphaIndex(ColorMode mode)
Returns the index of alpha channel. If alpha channel does not exists, this function returns -1.
Definition: Color.h:74
Gorgon::Graphics::BitmapFont::All
@ All
Definition: BitmapFont.h:63
Bitmap.h
Gorgon::Graphics::BitmapFont::ImportOptions
Use this structure to specify options for import operations.
Definition: BitmapFont.h:68
Gorgon::Graphics::BitmapFont::IsFixedWidth
virtual bool IsFixedWidth() const override
This function should return true if this font is fixed width.
Definition: BitmapFont.h:205
Gorgon::Graphics::BitmapFont::linegap
float linegap
Definition: BitmapFont.h:431
Gorgon::Containers::Collection
Collection is a container for reference typed objects.
Definition: Collection.h:21
Gorgon::Containers::Hashmap::GetSize
long GetSize() const
Returns the number of elements in the map.
Definition: Hashmap.h:380
Gorgon::Graphics::Glyph
Gorgon::Char Glyph
Glyph is a symbol for a character. In Gorgon, glyphs are UTF32 chars.
Definition: Font.h:15
Gorgon::Graphics::Bitmap
This object contains an bitmap image.
Definition: Bitmap.h:25
Gorgon::Graphics::BitmapFont::ImportAtlas
int ImportAtlas(Bitmap &&bmp, Geometry::Size grid={0, 0}, Glyph start=0x20, bool expand=false, ImportOptions options=ImportOptions{})
Imports the given bitmap as atlas image.
Definition: BitmapFont.cpp:477
Gorgon::Graphics::TextureImage
This is a solid texture based image class.
Definition: Texture.h:211
Gorgon::Filesystem::Iterator
This iterator allows iteration of directories.
Definition: Iterator.h:22
Gorgon::Graphics::Bitmap::Resize
void Resize(const Geometry::Size &size, Graphics::ColorMode mode=Graphics::ColorMode::RGBA)
Resizes the image to the given size and color mode.
Definition: Bitmap.h:264
Gorgon::Graphics::BitmapFont::operator=
BitmapFont & operator=(const BitmapFont &)=delete
Gorgon::Graphics::BitmapFont::SetHeight
void SetHeight(int value)
Changes the line height of the font. Adding glyphs may override this value.
Definition: BitmapFont.h:237
Gorgon::Graphics::BitmapFont::SetGlyphSpacing
void SetGlyphSpacing(int value)
Changes the spacing between glyphs.
Definition: BitmapFont.h:248
Gorgon::Graphics::BitmapFont::ImportFolder
int ImportFolder(const std::string &path, ImportNamingTemplate naming=Automatic, Glyph start=0, std::string prefix="", ImportOptions options=ImportOptions{})
Imports bitmap font images from a folder with the specified file naming template.
Definition: BitmapFont.cpp:122
Gorgon::Graphics::BitmapFont::GetMaxWidth
virtual int GetMaxWidth() const override
Returns the width of widest glyph.
Definition: BitmapFont.h:222
Gorgon::Graphics::TextureTarget
This interface defines a class that can be used as a common target for texture based drawing.
Definition: TextureTargets.h:12
Gorgon::Graphics::BitmapFont::maxwidth
int maxwidth
Definition: BitmapFont.h:415
Gorgon::Graphics::ColorMode::Alpha
@ Alpha
8bit alpha only color mode
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Graphics::BitmapFont::isascii
bool isascii
Definition: BitmapFont.h:423
Gorgon::Graphics::BitmapFont::Duplicate
BitmapFont Duplicate()
Definition: BitmapFont.h:136
Gorgon::Graphics::Bitmap::CreateLinearAtlas
std::vector< Geometry::Bounds > CreateLinearAtlas(Containers::Collection< const Bitmap > list, AtlasMargin margins=None)
Assumes all image heights are similar and all images have same color mode.
Definition: Bitmap.cpp:374
Gorgon::Graphics::BitmapFont::GetLineThickness
virtual float GetLineThickness() const override
Should return the average thickness of a line.
Definition: BitmapFont.h:232
Gorgon::Graphics::BitmapFont::GlyphDescriptor
to be used internally.
Definition: BitmapFont.h:28
Gorgon::Graphics::BitmapFont::begin
std::map< Glyph, GlyphDescriptor >::iterator begin()
Definition: BitmapFont.h:385
Gorgon::Byte
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
Gorgon::Graphics::BitmapFont::ImportOptions::trim
bool trim
Whether to trim whitespace around the glyphs.
Definition: BitmapFont.h:102
Gorgon::Graphics::BitmapFont::gtog::right
Glyph right
Definition: BitmapFont.h:407
Gorgon::Graphics::BasicFont
This is the basic font, performing the minimal amount of operations necessary to render text on the s...
Definition: Font.h:271
Gorgon::Graphics::RectangularDrawable::GetSize
const Geometry::Size GetSize() const
Returns the size of this object.
Definition: Drawables.h:443
Gorgon::Graphics::BitmapFont::GetDigitWidth
virtual int GetDigitWidth() const override
Width of a digit, if digits do not have the same width, maximum should be returned.
Definition: BitmapFont.h:230
Gorgon::UI::Graphics
@ Graphics
Definition: Template.h:164
Gorgon::Graphics::RectangularDrawable
Definition: Drawables.h:74
Gorgon::Graphics::BitmapFont::GetLetterHeight
virtual std::pair< int, int > GetLetterHeight(bool asciionly=false) const override
Definition: BitmapFont.cpp:997
Gorgon::Graphics::BasicFont::GetSize
virtual Geometry::Size GetSize(const std::string &text) const override
Returns the size of the given text.
Definition: Font.cpp:678
Gorgon::Graphics::BitmapFont::GetGlyphSpacing
int GetGlyphSpacing() const
Returns the spacing between glyphs.
Definition: BitmapFont.h:251
Gorgon::Graphics::BitmapFont::GetLineGap
virtual float GetLineGap() const override
This is the default distance between two consecutive lines.
Definition: BitmapFont.h:228
Gorgon::Geometry::basic_Size::Area
T_ Area() const
Returns the exact area of the rectangle has the size of this object.
Definition: Size.h:240
Gorgon::Graphics::Bitmap::Prepare
virtual void Prepare()
This function prepares image for drawing.
Definition: Bitmap.cpp:14
Gorgon::Graphics::BitmapFont::Adopt
void Adopt(const RectangularDrawable &img)
This will add the given image to the list of images that will be destroyed with this object.
Definition: BitmapFont.h:372
Gorgon::Graphics::BitmapFont
Bitmap fonts provide an easy way to render text on the screen.
Definition: BitmapFont.h:24
Gorgon::Graphics::BitmapFont::ImportOptions::automatickerningreduction
int automatickerningreduction
If automatic kerning is applied, this value will be used to reduce the kerning amount.
Definition: BitmapFont.h:126
Gorgon::Geometry::basic_Size::Width
T_ Width
Width of this size object.
Definition: Size.h:258
Gorgon::Graphics::BitmapFont::spacing
int spacing
Definition: BitmapFont.h:425
Gorgon::Graphics::BitmapFont::AssumeGlyph
void AssumeGlyph(Glyph glyph, const RectangularDrawable &bitmap, int baseline=0)
Adds a new glyph bitmap to the list.
Definition: BitmapFont.h:164
Gorgon::Graphics::BitmapFont::None
@ None
Definition: BitmapFont.h:61
Gorgon::Filesystem::IsFile
bool IsFile(const std::string &path)
Checks whether the given path is a file.
Definition: Linux.cpp:46
Gorgon::Graphics::Bitmap::GetWidth
int GetWidth() const
Returns the width of the bitmap.
Definition: Bitmap.h:476
Gorgon::Graphics::BitmapFont::GetImage
const RectangularDrawable * GetImage(Glyph g)
Returns the image that represents a glyph.
Definition: BitmapFont.h:336
Gorgon::Graphics::BitmapFont::GetEMSize
virtual int GetEMSize() const override
Returns the size of the EM dash.
Definition: BitmapFont.h:220
Gorgon::Graphics::BitmapFont::GetGlyphRenderer
virtual const GlyphRenderer & GetGlyphRenderer() const override
Returns the glyphrenderer that is used by this text renderer.
Definition: BitmapFont.h:381
Gorgon::Filesystem::Iterator::Next
bool Next()
Next path in the directory.
Definition: Linux.cpp:438
Gorgon::Graphics::RectangularDrawable::GetWidth
int GetWidth() const
Returns the width of the drawable.
Definition: Drawables.h:448
Gorgon::Graphics::BitmapFont::end
std::map< Glyph, GlyphDescriptor >::iterator end()
Definition: BitmapFont.h:389
Gorgon::Resource::Font
Font resource.
Definition: Font.h:16
Gorgon::Graphics::BitmapFont::SetKerning
void SetKerning(Glyph left, Glyph right, Geometry::Pointf kern)
Definition: BitmapFont.h:180
Gorgon::Filesystem::GetBasename
std::string GetBasename(std::string path)
Returns the filename from the given path, without extension.
Definition: Filesystem.h:197
Gorgon::Graphics::BitmapFont::linethickness
int linethickness
Definition: BitmapFont.h:427
BitmapFont.h
Gorgon::Graphics::BitmapFont::BitmapFont
BitmapFont(float baseline=0)
Definition: BitmapFont.h:132
Gorgon::Graphics::BitmapFont::ImportOptions::automatickerning
bool automatickerning
Whether to apply automatic kerning after import is completed.
Definition: BitmapFont.h:121
Gorgon::Graphics::BitmapFont::Alpha
@ Alpha
Characters are the filenames, not recommended as some symbols will not be accepted as filename.
Definition: BitmapFont.h:53
Gorgon::Graphics::BitmapFont::SetBaseline
void SetBaseline(float value)
Changes the baseline. Might cause problems if the font already has glyphs in it.
Definition: BitmapFont.h:260
Gorgon::Graphics::BitmapFont::underlinepos
int underlinepos
Definition: BitmapFont.h:429
Gorgon::Graphics::BitmapFont::ImportOptions::prepare
bool prepare
Prepares the loaded bitmaps. If pack option is set, this option is ignored.
Definition: BitmapFont.h:113
Gorgon::Graphics::BitmapFont::SetMaxWidth
void SetMaxWidth(int value)
Changes the maximum width for a character. Adding glyphs may override this value.
Definition: BitmapFont.h:240
Gorgon::Containers::Collection::FindLocation
long FindLocation(const T_ *item) const
Searches the position of a given item, if not found -1 is returned.
Definition: Collection.h:538
Gorgon::Graphics::BitmapFont::gtog::left
Glyph left
Definition: BitmapFont.h:407
Gorgon::YesNoAuto
YesNoAuto
This enumeration helps with systems that has boolen parameters that can be detected automatically,...
Definition: Types.h:55
Gorgon::Graphics::Bitmap::Clear
void Clear()
Cleans the contents of the buffer by setting every byte it contains to 0.
Definition: Bitmap.h:730
Gorgon::Graphics::BitmapFont::SetLineThickness
void SetLineThickness(int value)
Changes the line thickness to the specified value.
Definition: BitmapFont.h:254
Gorgon::Graphics::BitmapFont::GetBaseLine
virtual float GetBaseLine() const override
Baseline point of glyphs from the top.
Definition: BitmapFont.h:226
Gorgon::Graphics::BitmapFont::DeleteConstants
DeleteConstants
Definition: BitmapFont.h:60
Gorgon::Utils::NotImplemented
void NotImplemented(const std::string &what="This feature")
Definition: Assert.h:187
Gorgon::Graphics::BitmapFont::ImportOptions::estimatebaseline
bool estimatebaseline
If baseline is set to -1 (auto), setting this to true will use cheap baseline calculation instead of ...
Definition: BitmapFont.h:118
Gorgon::Graphics::BitmapFont::GlyphDescriptor::GlyphDescriptor
GlyphDescriptor(int index, Geometry::Pointf offset, float advance)
Definition: BitmapFont.h:35
Gorgon::Graphics::BitmapFont::begin
std::map< Glyph, GlyphDescriptor >::const_iterator begin() const
Definition: BitmapFont.h:393
Gorgon::Graphics::BasicFont::color
RGBAf color
Color of this renderer, can be overridden.
Definition: Font.h:423
Gorgon::Graphics::BitmapFont::Remove
void Remove(Glyph g)
Removes a glyph from the bitmap font.
Definition: BitmapFont.cpp:977
Gorgon::Graphics::BitmapFont::GetUnderlineOffset
virtual int GetUnderlineOffset() const override
The position of the underline, if it is to be drawn.
Definition: BitmapFont.h:234
Gorgon::Graphics::BitmapFont::glyphmap
std::map< Glyph, GlyphDescriptor > glyphmap
Definition: BitmapFont.h:403
Assert.h
Gorgon::Graphics::BitmapFont::GlyphDescriptor::index
int index
Definition: BitmapFont.h:40
Gorgon::Graphics::BitmapFont::GetHeight
virtual int GetHeight() const override
Height of glyphs, actual size could be smaller but all glyphs should have the same virtual height.
Definition: BitmapFont.h:224
Gorgon::Graphics::BitmapFont::ImportOptions::pack
bool pack
Packs the bitmap font.
Definition: BitmapFont.h:92