Loading...
Searching...
No Matches
Font.h File Reference
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/FontInfo.h>
#include <SFML/Graphics/Glyph.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/InputStream.h>
#include <stddef.h>

Go to the source code of this file.

Functions

sfFontsfFont_createFromFile (const char *filename)
 Create a new font from a file.
 
sfFontsfFont_createFromMemory (const void *data, size_t sizeInBytes)
 Create a new image font a file in memory.
 
sfFontsfFont_createFromStream (sfInputStream *stream)
 Create a new image font a custom stream.
 
sfFontsfFont_copy (const sfFont *font)
 Copy an existing font.
 
void sfFont_destroy (sfFont *font)
 Destroy an existing font.
 
sfGlyph sfFont_getGlyph (const sfFont *font, sfUint32 codePoint, unsigned int characterSize, sfBool bold, float outlineThickness)
 Get a glyph in a font.
 
sfBool sfFont_hasGlyph (const sfFont *font, sfUint32 codePoint)
 Determine if this font has a glyph representing the requested code point.
 
float sfFont_getKerning (const sfFont *font, sfUint32 first, sfUint32 second, unsigned int characterSize)
 Get the kerning value corresponding to a given pair of characters in a font.
 
float sfFont_getBoldKerning (const sfFont *font, sfUint32 first, sfUint32 second, unsigned int characterSize)
 Get the bold kerning value corresponding to a given pair of characters in a font.
 
float sfFont_getLineSpacing (const sfFont *font, unsigned int characterSize)
 Get the line spacing value.
 
float sfFont_getUnderlinePosition (const sfFont *font, unsigned int characterSize)
 Get the position of the underline.
 
float sfFont_getUnderlineThickness (const sfFont *font, unsigned int characterSize)
 Get the thickness of the underline.
 
const sfTexturesfFont_getTexture (sfFont *font, unsigned int characterSize)
 Get the texture containing the glyphs of a given size in a font.
 
void sfFont_setSmooth (sfFont *font, sfBool smooth)
 Enable or disable the smooth filter.
 
sfBool sfFont_isSmooth (const sfFont *font)
 Tell whether the smooth filter is enabled or disabled.
 
sfFontInfo sfFont_getInfo (const sfFont *font)
 Get the font information.
 

Function Documentation

◆ sfFont_copy()

sfFont * sfFont_copy ( const sfFont font)

Copy an existing font.

Parameters
fontFont to copy
Returns
Copied object

◆ sfFont_createFromFile()

sfFont * sfFont_createFromFile ( const char *  filename)

Create a new font from a file.

Parameters
filenamePath of the font file to load
Returns
A new sfFont object, or NULL if it failed

◆ sfFont_createFromMemory()

sfFont * sfFont_createFromMemory ( const void *  data,
size_t  sizeInBytes 
)

Create a new image font a file in memory.

Parameters
dataPointer to the file data in memory
sizeInBytesSize of the data to load, in bytes
Returns
A new sfFont object, or NULL if it failed

◆ sfFont_createFromStream()

sfFont * sfFont_createFromStream ( sfInputStream stream)

Create a new image font a custom stream.

Parameters
streamSource stream to read from
Returns
A new sfFont object, or NULL if it failed

◆ sfFont_destroy()

void sfFont_destroy ( sfFont font)

Destroy an existing font.

Parameters
fontFont to delete

◆ sfFont_getBoldKerning()

float sfFont_getBoldKerning ( const sfFont font,
sfUint32  first,
sfUint32  second,
unsigned int  characterSize 
)

Get the bold kerning value corresponding to a given pair of characters in a font.

Parameters
fontSource font
firstUnicode code point of the first character
secondUnicode code point of the second character
characterSizeCharacter size, in pixels
Returns
Kerning offset, in pixels

◆ sfFont_getGlyph()

sfGlyph sfFont_getGlyph ( const sfFont font,
sfUint32  codePoint,
unsigned int  characterSize,
sfBool  bold,
float  outlineThickness 
)

Get a glyph in a font.

Parameters
fontSource font
codePointUnicode code point of the character to get
characterSizeCharacter size, in pixels
boldRetrieve the bold version or the regular one?
outlineThicknessThickness of outline (when != 0 the glyph will not be filled)
Returns
The corresponding glyph

◆ sfFont_getInfo()

sfFontInfo sfFont_getInfo ( const sfFont font)

Get the font information.

The returned structure will remain valid only if the font is still valid. If the font is invalid an invalid structure is returned.

Parameters
fontSource font
Returns
A structure that holds the font information

◆ sfFont_getKerning()

float sfFont_getKerning ( const sfFont font,
sfUint32  first,
sfUint32  second,
unsigned int  characterSize 
)

Get the kerning value corresponding to a given pair of characters in a font.

Parameters
fontSource font
firstUnicode code point of the first character
secondUnicode code point of the second character
characterSizeCharacter size, in pixels
Returns
Kerning offset, in pixels

◆ sfFont_getLineSpacing()

float sfFont_getLineSpacing ( const sfFont font,
unsigned int  characterSize 
)

Get the line spacing value.

Parameters
fontSource font
characterSizeCharacter size, in pixels
Returns
Line spacing, in pixels

◆ sfFont_getTexture()

const sfTexture * sfFont_getTexture ( sfFont font,
unsigned int  characterSize 
)

Get the texture containing the glyphs of a given size in a font.

Parameters
fontSource font
characterSizeCharacter size, in pixels
Returns
Read-only pointer to the texture

◆ sfFont_getUnderlinePosition()

float sfFont_getUnderlinePosition ( const sfFont font,
unsigned int  characterSize 
)

Get the position of the underline.

Underline position is the vertical offset to apply between the baseline and the underline.

Parameters
fontSource font
characterSizeReference character size
Returns
Underline position, in pixels

◆ sfFont_getUnderlineThickness()

float sfFont_getUnderlineThickness ( const sfFont font,
unsigned int  characterSize 
)

Get the thickness of the underline.

Underline thickness is the vertical size of the underline.

Parameters
fontSource font
characterSizeReference character size
Returns
Underline thickness, in pixels

◆ sfFont_hasGlyph()

sfBool sfFont_hasGlyph ( const sfFont font,
sfUint32  codePoint 
)

Determine if this font has a glyph representing the requested code point.

Most fonts only include a very limited selection of glyphs from specific Unicode subsets, like Latin, Cyrillic, or Asian characters.

While code points without representation will return a font specific default character, it might be useful to verify whether specific code points are included to determine whether a font is suited to display text in a specific language.

Parameters
fontSource font
codePointUnicode code point to check
Returns
sfTrue if the codepoint has a glyph representation, sfFalse otherwise

◆ sfFont_isSmooth()

sfBool sfFont_isSmooth ( const sfFont font)

Tell whether the smooth filter is enabled or disabled.

Parameters
fontSource font
Returns
sfTrue if smoothing is enabled, sfFalse if it is disabled
See also
setSmooth

◆ sfFont_setSmooth()

void sfFont_setSmooth ( sfFont font,
sfBool  smooth 
)

Enable or disable the smooth filter.

When the filter is activated, the font appears smoother so that pixels are less noticeable. However if you want the font to look exactly the same as its source file, you should disable it. The smooth filter is enabled by default.

Parameters
fontSource font
smoothsfTrue to enable smoothing, sfFalse to disable it
See also
isSmooth