 |
Gorgon Game Engine
|
Go to the documentation of this file.
8 #include "../Geometry/Point.h"
9 #include "../Geometry/Size.h"
28 if(
Start == -1)
return 0;
50 Glyph decode(std::string::const_iterator &it, std::string::const_iterator
end);
57 inline int ceildiv(
int v,
float f) {
return (
int)std::ceil(v/f); }
58 inline int rounddiv(
int v,
float f) {
return (
int)std::round(v/f); }
143 virtual void Prepare(
const std::string &)
const { }
159 print(target, text, location);
163 print(target, text, location);
167 print(target, text, {x, y});
171 print(target, text, {location, w, 0}, align_override);
175 print(target, text, {location, w, 0});
179 print(target, text, {x, y, w, 0}, align_override);
183 print(target, text, {x, y, w, 0});
187 printnowrap(target, text, {location, w, 0}, align_override);
195 printnowrap(target, text, {x, y, w, 0}, align_override);
293 print(target, text, {location, w, 0}, align_override,
color);
301 print(target, text, {x, y, w, 0}, align_override,
color);
345 return renderer !=
nullptr;
466 renderer(&renderer), color(color), shadow(shadow) {
477 this->renderer = &renderer;
523 underlinecolor = color;
535 underlinecolor = value;
540 if(underlinecolor.
R == -1)
543 return underlinecolor;
548 underlinecolor = -1.f;
581 if(strikecolor.
R == -1)
601 if(strikepos == INT_MIN)
609 defaultalign = value;
668 vspace = (float)value / renderer->
GetHeight();
673 return (
int)std::round(vspace * renderer->
GetHeight());
729 return renderer !=
nullptr;
764 print(target, text, location, defaultalign);
791 bool underline =
false;
792 RGBAf underlinecolor = -1.f;
794 RGBAf strikecolor = -1.f;
795 int strikepos = INT_MIN;
797 bool justify =
false;
constexpr Type Font_Charmap_II
Definition: GID.h:205
basic_Point< T_ > TopLeft() const
Returns the top left coordinates of the rectangle.
Definition: Rectangle.h:198
virtual bool IsReady() const override
Whether the render can render text.
Definition: Font.h:728
virtual float GetBaseLine() const =0
Get the distance of baseline from the top of the text.
void PrintNoWrap(TextureTarget &target, const std::string &text, int x, int y, int w) const
Definition: Font.h:198
void Print(TextureTarget &target, const std::string &text, Geometry::Point location, int w, RGBAf color) const
Definition: Font.h:296
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
constexpr Type Font_BitmapProps
Definition: GID.h:206
constexpr Type Font_Charmap
Definition: GID.h:200
virtual bool IsFixedWidth() const =0
This function should return true if this font is fixed width.
void ResetUnderlineColor()
Sets underline color to match with text color.
Definition: Font.h:547
void simplelayout(const GlyphRenderer &renderer, std::string::const_iterator begin, std::string::const_iterator end, std::function< int(Glyph, Glyph)> spacing, std::function< int(Glyph)> advance, std::function< bool(Glyph, int, float)> process, std::function< void()> dotab, std::function< void(Glyph)> donewline)
helps with the simple layouts, decodes and executes unicode instructions.
Definition: Font.cpp:275
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
void SetDefaultAlign(TextAlignment value)
Sets the default alignment for the text.
Definition: Font.h:608
virtual void printnowrap(TextureTarget &target, const std::string &text, Geometry::Rectangle location) const =0
Should print the given text to the specified location and color.
virtual void print(TextureTarget &target, const std::string &text, Geometry::Point location) const override
Definition: Font.cpp:992
void save(Writer &writer) const override
Definition: Font.cpp:41
void SetColor(RGBAf value)
Changes the the color of the text. Color can only be overridden through BasicFont interface.
Definition: Font.h:335
virtual void printnowrap(TextureTarget &target, const std::string &text, Geometry::Rectangle location) const override
Should print the given text to the specified location and color.
Definition: Font.h:409
bool isspaced(Glyph g)
Definition: Font.cpp:75
void Print(TextureTarget &target, const std::string &text, int x, int y, int w, RGBAf color) const
Definition: Font.h:304
std::ostream & GetStream()
This should be last resort, use if the actual stream is needed.
Definition: Writer.h:96
virtual bool IsASCII() const =0
This function should return true if this font renderer supports only 7-bit ASCII.
int GetLetterSpacing() const
Returns the spacing between the letters in pixels.
Definition: Font.h:696
void SetLineSpacingPixels(int value)
Sets the line spacing in pixels, this spacing is the space between two lines, from the descender of t...
Definition: Font.h:667
virtual float GetBaseLine() const =0
Baseline point of glyphs from the top.
virtual float GetCursorAdvance(Glyph g) const =0
This function should return the number of pixels the cursor should advance after this glyph.
int GetParagraphSpacing() const
Get the space between paragraphs in pixels.
Definition: Font.h:724
virtual void Prepare(const std::string &) const
Notifies glyph renderer about a text to be rendered.
Definition: Font.h:143
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
virtual bool IsReady() const =0
Whether the render can render text.
void SetUnderline(bool value)
Sets underlining for the text.
Definition: Font.h:511
T_ X
X coordinate.
Definition: Point.h:368
virtual int GetCharacterIndex(const std::string &text, Geometry::Point location) const =0
Returns the character index of glyph immediately after the given location. This function is Unicode a...
StyledRenderer(GlyphRenderer &renderer, RGBAf color=1.f, TextShadow shadow={})
Renderer must be ready in order to calculate spacings correctly.
Definition: Font.h:465
void SetRenderer(Graphics::GlyphRenderer &renderer)
Changes the renderer to the given renderer.
Definition: Font.cpp:14
TextAlignment GetDefaultAlign() const
Returns the default alignment for the text.
Definition: Font.h:631
virtual int GetEMSize() const =0
Returns the size of the EM dash.
void Underline(RGBAf color)
Underlines the text with the given color.
Definition: Font.h:521
T_ X
X coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:354
void WriteChunkHeader(GID::Type type, unsigned long size)
Writes the header of a chunk.
Definition: Writer.h:364
static void SaveThis(Writer &writer, const Graphics::Bitmap &bmp, GID::Type type=GID::Image)
This function can be used to save a bitmap as image resource without modifying it.
Definition: Image.cpp:171
void WritePointf(Geometry::Pointf value)
Writes a point to the stream, point takes 2 x 4 bytes.
Definition: Writer.h:251
virtual Geometry::Size GetSize(const std::string &text, int width) const =0
Returns the size of the given text.
void Pack(bool tight=false, DeleteConstants del=Owned)
Converts individual glyphs to a single atlas.
Definition: BitmapFont.cpp:920
void SetTabWidthInLetters(float value)
Sets the tab width in digit widths.
Definition: Font.h:708
void dodefaulttab(T_ s, T_ &x, T_ w)
Definition: Font.cpp:196
TextShadow GetShadow() const
Returns text shadow.
Definition: Font.h:506
virtual int GetCharacterIndex(const std::string &text, Geometry::Point location) const override
Returns the character index of glyph immediately after the given location. This function is Unicode a...
Definition: Font.cpp:720
std::vector< T_ >::const_iterator begin(enum_type_id< T_ >)
Definition: Enum.h:283
void SetLineGap(float value)
Changes the distance between two lines. Non-integer values are not recommended.
Definition: BitmapFont.h:263
bool isbreaking(Glyph g)
Definition: Font.cpp:129
bool isnewline(Glyph g)
Definition: Font.cpp:79
virtual Geometry::Size GetSize(Glyph chr) const =0
This function should return the size of the requested glyph.
virtual void Prepare()
This function shall prepare this resource to be used after resource is loaded.
Definition: Base.cpp:16
std::vector< glyphmark >::iterator markvecit
Definition: Font.cpp:355
int rounddiv(int v, float f)
Definition: Font.h:58
long GetSize() const
Returns number of elements.
Definition: Collection.h:241
void SetParagraphSpacing(int value)
Changes the additional space between paragraphs.
Definition: Font.h:719
Glyph End
End point of the range. This value is included in the range.
Definition: Font.h:42
@ Left
Text is aligned to left.
void ReadArray(T_ *data, unsigned long size)
Reads an array from the file.
Definition: Reader.h:333
bool GetStrike() const
Returns whether the text would stroked.
Definition: Font.h:568
BasicFont(const GlyphRenderer &renderer, RGBAf color=1.f, TextAlignment defaultalign=TextAlignment::Left)
Definition: Font.h:273
virtual Geometry::Rectangle GetPosition(const std::string &text, int index) const override
Returns the position of the glyph at the character index.
Definition: Font.cpp:1130
virtual void printnowrap(TextureTarget &target, const std::string &text, Geometry::Rectangle location) const override
Should print the given text to the specified location and color.
Definition: Font.h:775
constexpr Type Font_FreeTypeProps
Definition: GID.h:208
virtual float GetLineGap() const =0
This is the default distance between two consecutive lines.
Should be implemented by the systems aimed to render fonts on the screen.
Definition: Font.h:67
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
void UseFlatShadow(RGBAf color, Geometry::Pointf offset={1.f, 1.f})
Uses flat shadow for text.
Definition: Font.h:501
constexpr Type Image
Image resource.
Definition: GID.h:149
Marker WriteObjectStart(const Base &base)
Writes the start of an object. Should have a matching WriteEnd with the returned marker.
Definition: File.cpp:211
void PrintNoWrap(TextureTarget &target, const std::string &text, int x, int y, int w, RGBAf color) const
Definition: Font.h:320
virtual void printnowrap(TextureTarget &target, const std::string &text, Geometry::Rectangle location, RGBAf color) const
Definition: Font.h:414
void SetShadow(TextShadow value)
Changes text shadow.
Definition: Font.h:491
T_ Width
Width of the rectangle.
Definition: Rectangle.h:360
Describes how a text shadow should be.
Definition: Font.h:432
int GetTabWidth() const
Returns tab width in pixels.
Definition: Font.h:713
void Print(TextureTarget &target, const std::string &text, RGBAf color) const
Definition: Font.h:280
virtual bool NeedsPrepare() const
Should return if the glyph renderer requires preparation regarding the text given.
Definition: Font.h:139
void boundedprint(const GlyphRenderer &renderer, std::string::const_iterator begin, std::string::const_iterator end, int width, std::function< void(Glyph, markvecit, markvecit, int)> doline, std::function< int(Glyph, Glyph)> spacing, std::function< int(Glyph)> advance, std::function< void(int &)> dotab)
Definition: Font.cpp:357
void DisableShadow()
Disables text shadow.
Definition: Font.h:496
float defaultspace(Glyph g, const GlyphRenderer &renderer)
Definition: Font.cpp:145
void WriteUInt32(unsigned long value)
Writes a 32-bit unsigned integer to the stream.
Definition: Writer.h:158
@ Right
Text is aligned to right.
Graphics::GlyphRenderer * data
Definition: Font.h:89
void PrintNoWrap(TextureTarget &target, const std::string &text, Geometry::Point location, int w, TextAlignment align_override, RGBAf color) const
Definition: Font.h:308
void ASSERT_FALSE(const std::string &message, int skip=1, int depth=4)
Definition: Assert.h:192
Glyph decode(std::string::const_iterator &it, std::string::const_iterator end)
Decodes a utf-8 character from the given iterator.
Definition: Font.cpp:9
void PrintNoWrap(TextureTarget &target, const std::string &text, Geometry::Point location, int w, RGBAf color) const
Definition: Font.h:312
virtual void print(TextureTarget &target, const std::string &text, Geometry::Point location) const =0
float ReadFloat()
Reads a 32 bit IEEE floating point number from the file.
Definition: Reader.h:271
void AlignRight()
Aligns the text to the right, removes justify.
Definition: Font.h:619
long ReadInt32()
Reads a 32-bit integer from the stream.
Definition: Reader.h:217
bool LoadGlyphs(GlyphRange range, bool prepare=true)
Loads the glyphs in the given range.
Definition: FreeType.cpp:1058
virtual int GetHeight() const override
Get the distance of baseline from the top of the text.
Definition: Font.h:740
virtual void Discard() override
This function shall discard any transitional data which is not vital after Prepare function is issued...
Definition: Font.cpp:252
virtual const GlyphRenderer & GetGlyphRenderer() const =0
Returns the glyphrenderer that is used by this text renderer.
virtual void Prepare() override
This function will only prepare images loaded from a resource, does not work for images loaded later.
Definition: Font.cpp:245
bool isspace(Glyph g)
Definition: Font.cpp:96
virtual int GetEMSize() const override
Returns the size of the EM dash.
Definition: Font.h:352
TextAlignment GetDefaultAlignment() const
Returns the current default alignment.
Definition: Font.h:330
int Count() const
Returns the number of the glyphs in the range.
Definition: Font.h:27
GlyphRenderer & GetGlyphRenderer()
Definition: Font.h:472
int GetStrikePosition() const
Returns current strike position.
Definition: Font.h:600
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Glyph Start
Start point of the range.
Definition: Font.h:39
This class represents a 2D geometric size.
Definition: Size.h:23
virtual void print(TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align_override) const =0
Should print the given text to the specified location and color.
void SetUnderlineOffset(int value)
Changes the underline position to the specified value.
Definition: BitmapFont.h:257
uint32_t Char
Definition: Types.h:46
constexpr Type Font_BitmapKerning
Definition: GID.h:207
void simpleprint(const GlyphRenderer &renderer, std::string::const_iterator begin, std::string::const_iterator end, std::function< int(Glyph, Glyph)> spacing, std::function< int(Glyph)> advance, std::function< void(Glyph, int, float)> render, std::function< void()> dotab, std::function< void(Glyph)> donewline)
helps with the simple layouts, decodes and executes unicode instructions.
Definition: Font.cpp:207
Marker WriteChunkStart(GID::Type type)
Writes the start of a chunk. Should have a matching WriteEnd.
Definition: Writer.h:351
virtual void print(TextureTarget &target, const std::string &text, Geometry::Rectangle location) const override
Definition: Font.h:399
float R
Red channel.
Definition: Color.h:588
void SetLetterSpacing(int value)
Spacing between letters of the text, in pixels.
Definition: Font.h:691
virtual void printnowrap(TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align, RGBAf color) const
Definition: Font.cpp:1600
bool HasData() const
Checks if this image resource has a data attached to it.
Definition: Bitmap.h:163
unsigned long ReadUInt32()
Reads a 32-bit unsigned integer from the stream.
Definition: Reader.h:226
virtual Geometry::Size GetTargetSize() const =0
Get size of the target.
void Print(TextureTarget &target, const std::string &text, int x, int y, int w, TextAlignment align_override, RGBAf color) const
Definition: Font.h:300
virtual void printnowrap(TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align) const override
Should print the given text to the specified location and color.
Definition: Font.cpp:1619
ShadowType type
Definition: Font.h:450
virtual int GetDigitWidth() const =0
Width of a digit, if digits do not have the same width, maximum should be returned.
void PrintNoWrap(TextureTarget &target, const std::string &text, int x, int y, int w, TextAlignment align_override) const
Definition: Font.h:194
void Print(TextureTarget &target, const std::string &text, Geometry::Point location, RGBAf color) const
Definition: Font.h:284
bool isowner
Definition: Font.h:93
int GetLineSpacingPixels() const
Returns the line spacing in pixels.
Definition: Font.h:672
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
unsigned long ReadChunkSize()
Reads chunk size from a stream.
Definition: Reader.h:381
void JustifyCenter()
Aligns the text to the center, sets justify.
Definition: Font.h:654
void Strike()
Strikes the text.
Definition: Font.h:557
Collection is a container for reference typed objects.
Definition: Collection.h:21
basic_Point< int > Point
Definition: Point.h:598
virtual int GetEMSize() const override
Returns the size of the EM dash.
Definition: Font.h:732
virtual float GetBaseLine() const override
Get the distance of baseline from the top of the text.
Definition: Font.h:356
@ Center
Text is aligned to center.
ShadowType
Definition: Font.h:435
TextAlignment
Defines how a text is aligned.
Definition: Graphics.h:67
Gorgon::Char Glyph
Glyph is a symbol for a character. In Gorgon, glyphs are UTF32 chars.
Definition: Font.h:15
virtual int GetUnderlineOffset() const =0
The position of the underline, if it is to be drawn.
This object contains an bitmap image.
Definition: Bitmap.h:25
void Normalize()
Definition: Font.h:33
virtual void print(TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align) const override
Should print the given text to the specified location and color.
Definition: Font.h:381
static Font * LoadResource(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size)
This function loads a bitmap font resource from the given file.
Definition: Font.cpp:116
virtual Geometry::Size GetSize(const std::string &text) const =0
Returns the size of the given text.
void SetHeight(int value)
Changes the line height of the font. Adding glyphs may override this value.
Definition: BitmapFont.h:237
RGBAf GetStrikeColor() const
Returns the current strike color.
Definition: Font.h:580
void SetGlyphSpacing(int value)
Changes the spacing between glyphs.
Definition: BitmapFont.h:248
void PrintNoWrap(TextureTarget &target, const std::string &text, Geometry::Point location, int w) const
Definition: Font.h:190
void AlignLeft()
Aligns the text to the left, removes justify.
Definition: Font.h:613
void SetUnderlineColor(RGBAf value)
Changes the underline color of the text.
Definition: Font.h:534
Mark Target(unsigned long delta)
Creates mark to the the target that is delta distance from current point in file.
Definition: Reader.h:193
void EatChunk(long size)
Removes a chunk of data with the given size from the stream.
Definition: Reader.h:389
void PrintNoWrap(TextureTarget &target, const std::string &text, Geometry::Point location, int w, TextAlignment align_override) const
Definition: Font.h:186
void PrintNoWrap(TextureTarget &target, const std::string &text, int x, int y, int w, TextAlignment align_override, RGBAf color) const
Definition: Font.h:316
This interface defines a class that can be used as a common target for texture based drawing.
Definition: TextureTargets.h:12
virtual int GetCharacterIndex(const std::string &text, int w, Geometry::Point location, bool wrap=true) const =0
Returns the character index of glyph immediately after the given location. This function is Unicode a...
@ Flat
Definition: Font.h:437
virtual bool Exists(Glyph g) const =0
Returns true if the glyph exists.
bool isadjustablespace(Glyph g)
Definition: Font.cpp:115
virtual const GlyphRenderer & GetGlyphRenderer() const override
Returns the glyphrenderer that is used by this text renderer.
Definition: Font.h:348
virtual bool IsReady() const override
Whether the render can render text.
Definition: Font.h:344
void SetTabWidth(int value)
Distance between tab stops.
Definition: Font.h:703
virtual int GetEMSize() const =0
Returns the size of the EM dash.
This class represents a 2D point.
Definition: Point.h:32
void SetGlyphRenderer(GlyphRenderer &renderer)
Definition: Font.h:476
This class allows resource objects to save their data to a stream.
Definition: Writer.h:59
virtual void Draw(const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f))=0
Draws a simple texture to the screen.
virtual int GetHeight() const =0
Get the distance of baseline from the top of the text.
GlyphRange(Glyph start, Glyph end)
Definition: Font.h:24
This class allows printing text on the screen.
Definition: Font.h:152
void Print(TextureTarget &target, const std::string &text, Geometry::Point location, int w, TextAlignment align_override, RGBAf color) const
Definition: Font.h:292
to be used internally.
Definition: BitmapFont.h:28
virtual void print(TextureTarget &target, const std::string &text, Geometry::Rectangle location) const =0
GID::Type ReadGID()
Reads a GID from the given stream.
Definition: Reader.h:341
virtual void Render(Glyph chr, TextureTarget &target, Geometry::Pointf location, RGBAf color) const =0
This function should render the given character to the target at the specified location and color.
virtual void printnowrap(TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align_override) const =0
Should print the given text to the specified location and color.
void SetLineSpacing(float value)
Sets the line spacing as percentage of line gap.
Definition: Font.h:680
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
@ None
Definition: Font.h:436
bool GetJustify() const
Returns whether the text would be justified.
Definition: Font.h:660
void WriteEnd(Marker &marker)
This function performs writes necessary to end a chunk that is represented by the marker.
Definition: Writer.h:373
This is the basic font, performing the minimal amount of operations necessary to render text on the s...
Definition: Font.h:271
T_ Y
Y coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:357
virtual float GetBaseLine() const override
Get the distance of baseline from the top of the text.
Definition: Font.h:736
@ Graphics
Definition: Template.h:164
bool LoadMetrics(int size)
Continues loading a file by setting font size and obtaining necessary information.
Definition: FreeType.cpp:314
T_ Height
Height of the rectangle.
Definition: Rectangle.h:363
float GetLineSpacing() const
Returns the line spacing as percentage of line gap.
Definition: Font.h:685
virtual Geometry::Size GetSize(const std::string &text) const override
Returns the size of the given text.
Definition: Font.cpp:678
virtual float GetLineGap() const override
This is the default distance between two consecutive lines.
Definition: BitmapFont.h:228
bool Assume(std::vector< Byte > &data)
Loads the given data.
Definition: FreeType.cpp:248
virtual ~TextRenderer()
Definition: Font.h:154
constexpr Type Font_Image
Definition: GID.h:203
Containers::Collection< Image > tobeprepared
Definition: Font.h:91
constexpr Type Font_FreeTypeData
Definition: GID.h:209
TextAlignment defaultalign
Default alignment if none is specified.
Definition: Font.h:420
T_ Y
Y coordinate.
Definition: Point.h:371
void WriteInt32(long value)
Writes a 32-bit integer to the stream.
Definition: Writer.h:149
Bitmap fonts provide an easy way to render text on the screen.
Definition: BitmapFont.h:24
void SetColor(RGBAf value)
Changes the color of the text.
Definition: Font.h:481
virtual const GlyphRenderer & GetGlyphRenderer() const override
Returns the glyphrenderer that is used by this text renderer.
Definition: Font.h:744
void AssumeGlyph(Glyph glyph, const RectangularDrawable &bitmap, int baseline=0)
Adds a new glyph bitmap to the list.
Definition: BitmapFont.h:164
This class represents a range of glyphs. Both start and end is included.
Definition: Font.h:18
void boundedlayout(const GlyphRenderer &renderer, std::string::const_iterator begin, std::string::const_iterator end, int width, std::function< bool(Glyph, markvecit, markvecit, int, int)> doline, std::function< int(Glyph, Glyph)> spacing, std::function< int(Glyph)> advance, std::function< void(int &)> dotab)
Definition: Font.cpp:503
virtual int GetMaxWidth() const =0
Returns the width of widest glyph.
std::vector< T_ >::const_iterator end(enum_type_id< T_ >)
Definition: Enum.h:288
virtual void print(TextureTarget &target, const std::string &text, Geometry::Rectangle location, RGBAf color) const
Definition: Font.h:404
void Print(TextureTarget &target, const std::string &text, int x, int y, RGBAf color) const
Definition: Font.h:288
TextShadow(ShadowType type)
Definition: Font.h:442
virtual Geometry::Size GetSize(const std::string &text) const override
Returns the size of the given text.
Definition: Font.cpp:1036
void ResetStrikeColor()
Sets strike color to match with text color.
Definition: Font.h:588
void JustifyLeft()
Aligns the text to the left, sets justify.
Definition: Font.h:642
virtual int GetHeight() const =0
Height of glyphs, actual size could be smaller but all glyphs should have the same virtual height.
void SetStrike(bool value)
Sets whether the text would be stroked.
Definition: Font.h:552
RGBAf GetColor() const
Returns the current text color.
Definition: Font.h:340
bool GetUnderline() const
Returns whether the text is underlined.
Definition: Font.h:527
Font resource.
Definition: Font.h:16
void SetKerning(Glyph left, Glyph right, Geometry::Pointf kern)
Definition: BitmapFont.h:180
Geometry::Point ReadPointf()
Reads a Pointf from the given stream.
Definition: Reader.h:365
virtual int GetCharacterIndex(const std::string &text, Geometry::Point location) const override
Returns the character index of glyph immediately after the given location. This function is Unicode a...
Definition: Font.cpp:1087
bool Push(T_ *Data)
Adds the given item to the end of the list if it is not already in the list.
Definition: Collection.h:266
void AlignCenter()
Aligns the text to the center, removes justify.
Definition: Font.h:625
constexpr Type Font_Props
Definition: GID.h:204
static Image * LoadResource(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size)
This function loads a image resource from the given file.
Definition: Image.cpp:9
virtual int GetHeight() const override
Get the distance of baseline from the top of the text.
Definition: Font.h:360
void Print(TextureTarget &target, const std::string &text, Geometry::Pointf location) const
Prints the given text to the target.
Definition: Font.h:158
TextShadow(RGBAf color, Geometry::Pointf offset={1.f, 1.f})
Definition: Font.h:447
This text renderer can style text according to the set parameters.
Definition: Font.h:461
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
virtual void print(TextureTarget &target, const std::string &text, Geometry::Point location) const override
Definition: Font.h:377
virtual void print(TextureTarget &target, const std::string &text, Geometry::Rectangle location) const override
Definition: Font.h:763
TextShadow(ShadowType type, RGBAf color, Geometry::Pointf offset)
Definition: Font.h:444
RGBAf GetUnderlineColor() const
Returns the current underline color.
Definition: Font.h:539
void SetBaseline(float value)
Changes the baseline. Might cause problems if the font already has glyphs in it.
Definition: BitmapFont.h:260
virtual Geometry::Pointf KerningDistance(Glyph left, Glyph right) const =0
This function should return the additional distance between given glyphs.
void SetMaxWidth(int value)
Changes the maximum width for a character. Adding glyphs may override this value.
Definition: BitmapFont.h:240
virtual ~GlyphRenderer()
Definition: Font.h:69
RGBAf GetColor() const
Returns color of the text.
Definition: Font.h:486
bool ReadCommonChunk(Base &self, GID::Type gid, unsigned long size)
Definition: File.cpp:41
long FindLocation(const T_ *item) const
Searches the position of a given item, if not found -1 is returned.
Definition: Collection.h:538
virtual Geometry::Rectangle GetPosition(const std::string &text, int index) const override
Returns the position of the glyph at the character index.
Definition: Font.cpp:827
virtual Geometry::Rectangle GetPosition(const std::string &text, int w, int index, bool wrap=true) const =0
Returns the position of the glyph at the character index.
void Underline()
Underlines the text.
Definition: Font.h:516
virtual Geometry::Rectangle GetPosition(const std::string &text, int index) const =0
Returns the position of the glyph at the character index.
Font()
Definition: Font.h:18
void SetLineThickness(int value)
Changes the line thickness to the specified value.
Definition: BitmapFont.h:254
This class allows using font files for text rendering.
Definition: FreeType.h:49
virtual float GetBaseLine() const override
Baseline point of glyphs from the top.
Definition: BitmapFont.h:226
RGBAf color
Definition: Font.h:451
void SetStrikePosition(int value)
Changes the strike position to the given value.
Definition: Font.h:595
int ceildiv(int v, float f)
Definition: Font.h:57
virtual void printnowrap(TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align) const override
Should print the given text to the specified location and color.
Definition: Font.h:394
void Strike(RGBAf color)
Strikes the text with the given color.
Definition: Font.h:562
RGBAf color
Color of this renderer, can be overridden.
Definition: Font.h:423
void JustifyRight()
Aligns the text to the right, sets justify.
Definition: Font.h:648
void WriteFloat(float value)
Writes a 32 bit IEEE floating point number to the file.
Definition: Writer.h:203
void SetJustify(bool value)
Sets whether the text would be justified.
Definition: Font.h:637
virtual float GetLineThickness() const =0
Should return the average thickness of a line.
void SetDefaultAlignment(TextAlignment value)
Changes the default alignment. It is possible to override default alignment through TextRenderer inte...
Definition: Font.h:325
virtual std::pair< int, int > GetLetterHeight(bool asciionly=false) const =0
Returns the offset (first) and maximum height (second) that is used by letters.
void SetStrikeColor(RGBAf value)
Changes the strike color of the text.
Definition: Font.h:575
GlyphRange(Glyph value=0xFFFF)
Creates a range that includes a single item.
Definition: Font.h:22
Geometry::Pointf offset
Definition: Font.h:452