JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
OutlinedFont Class Reference

Same as jngl::Font but adds an outline. More...

#include <jngl/OutlinedFont.hpp>

Public Member Functions

 OutlinedFont (const std::string &filename, unsigned int size, float strokePercentage)
 Set strokePercentage to a positive value in %, e.g. 5 to add an outline of 5% to the font.
 
void print (const Mat3 &modelview, const std::string &text, jngl::Rgba innerColor, jngl::Rgba outerColor) const
 Print text using modelview in innerColor and an outline in outerColor.
 
void printCentered (Mat3 modelview, const std::string &text, jngl::Rgba innerColor, jngl::Rgba outerColor) const
 Print text using modelview in innerColor and an outline in outerColor.
 
double getTextWidth (std::string_view) const
 Calculates the width of text in scale-independent pixels if it would be drawn with this font.
 
std::shared_ptr< FontInterfacebake (jngl::Rgba innerColor, jngl::Rgba outerColor) const
 Creates a new FontInterface with pre-baked colors for the inner and outer (outline) text.
 

Detailed Description

Same as jngl::Font but adds an outline.

Definition at line 14 of file OutlinedFont.hpp.

Member Function Documentation

◆ bake()

std::shared_ptr< FontInterface > bake ( jngl::Rgba innerColor,
jngl::Rgba outerColor ) const

Creates a new FontInterface with pre-baked colors for the inner and outer (outline) text.

Parameters
innerColorThe color to use for the main text
outerColorThe color to use for the outline
Returns
A shared pointer to a FontInterface that can be used for rendering text with the specified colors
Note
The OutlinedFont can be safely destroyed while the returned FontInterface is still in use.

Example:

jngl::Text text("Outlined Text");
text.setFont(jngl::OutlinedFont("Arial.ttf", 20, 5.f)
.bake(jngl::Rgba(1, 1, 1, 1), jngl::Rgba(0, 0, 0, 1)));
Same as jngl::Font but adds an outline.
std::shared_ptr< FontInterface > bake(jngl::Rgba innerColor, jngl::Rgba outerColor) const
Creates a new FontInterface with pre-baked colors for the inner and outer (outline) text.
Object representing a RGBA color.
Definition Rgba.hpp:22
Rectangle shaped text block.
Definition text.hpp:39

The documentation for this class was generated from the following file: