5#ifndef INCLUDE_FIFECHAN_IMAGEFONT_HPP_
6#define INCLUDE_FIFECHAN_IMAGEFONT_HPP_
13#include "fifechan/platform.hpp"
16#include "fifechan/color.hpp"
17#include "fifechan/font.hpp"
18#include "fifechan/rectangle.hpp"
139 ImageFont(std::string
const & filename, std::string
const & glyphs);
188 std::string
const & filename,
unsigned char glyphsFrom = 32,
unsigned char glyphsTo = 126);
199 std::string
const & filename,
200 unsigned char glyphsFrom,
201 unsigned char glyphsTo,
266 virtual int getWidth(
unsigned char glyph)
const;
270 int getWidth(std::string
const & text)
const override;
Font(Font const &)=default
Copy constructor.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
virtual int getRowSpacing()
Gets the space between rows in pixels.
int mHeight
Holds the height of the image font.
virtual int drawGlyph(Graphics *graphics, unsigned char glyph, int x, int y)
Draws a glyph.
int getHeight() const override
Gets the height of the glyphs in the font.
int getStringIndexAt(std::string const &text, int x) const override
Gets a string index in a string providing an x coordinate.
Rectangle scanForGlyph(unsigned char glyph, int x, int y, Color const &separator)
Scans for a certain glyph.
Image * mImage
Holds the image with the font data.
std::array< Rectangle, 256 > mGlyph
Holds the glyphs areas in the image.
std::string mFilename
Holds the filename of the image with the font data.
virtual void setRowSpacing(int spacing)
Sets the space between rows in pixels.
ImageFont(std::string const &filename, std::string const &glyphs)
Constructor.
virtual int getWidth(unsigned char glyph) const
Gets a width of a glyph in pixels.
virtual int getGlyphSpacing()
Gets the spacing between letters in pixels.
virtual void setGlyphSpacing(int spacing)
Sets the spacing between glyphs in pixels.
int mGlyphSpacing
Holds the glyph spacing of the image font.
int mRowSpacing
Holds the row spacing of the image font.
void drawString(Graphics *graphics, std::string const &text, int x, int y) override
Draws a string.
Abstract holder for image data.
Represents a rectangular area (X, Y, Width, Height).
Used replacement tokens by configure_file():
SeparatorStrategy
Defines a font implementation using an image atlas containing glyph data.
Configuration struct for ImageFont constructors.
bool verbose
If true, enable verbose debug output while scanning fonts.
SeparatorStrategy strategy
Strategy used to detect separator color in the image.
int glyphPadding
Number of pixels to pad/ignore around detected glyphs.
Color explicitSeparator
Explicit separator color used when ExplicitColor strategy is selected.