CSFML 3.0.0
Loading...
Searching...
No Matches
Text.h
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
30#include <CSFML/Graphics/Export.h>
31
32#include <CSFML/Graphics/Color.h>
33#include <CSFML/Graphics/Rect.h>
34#include <CSFML/Graphics/Transform.h>
35#include <CSFML/Graphics/Types.h>
36#include <CSFML/System/Vector2.h>
37
38#include <stddef.h>
39
40
44 typedef enum
45{
46 sfTextRegular = 0,
47 sfTextBold = 1 << 0,
48 sfTextItalic = 1 << 1,
49 sfTextUnderlined = 1 << 2,
50 sfTextStrikeThrough = 1 << 3
51} sfTextStyle;
52
53
62 CSFML_GRAPHICS_API sfText* sfText_create(const sfFont* font);
63
72 CSFML_GRAPHICS_API sfText* sfText_copy(const sfText* text);
73
80 CSFML_GRAPHICS_API void sfText_destroy(const sfText* text);
81
93 CSFML_GRAPHICS_API void sfText_setPosition(sfText* text, sfVector2f position);
94
106 CSFML_GRAPHICS_API void sfText_setRotation(sfText* text, float angle);
107
119 CSFML_GRAPHICS_API void sfText_setScale(sfText* text, sfVector2f scale);
120
135 CSFML_GRAPHICS_API void sfText_setOrigin(sfText* text, sfVector2f origin);
136
145 CSFML_GRAPHICS_API sfVector2f sfText_getPosition(const sfText* text);
146
157 CSFML_GRAPHICS_API float sfText_getRotation(const sfText* text);
158
167 CSFML_GRAPHICS_API sfVector2f sfText_getScale(const sfText* text);
168
177 CSFML_GRAPHICS_API sfVector2f sfText_getOrigin(const sfText* text);
178
189 CSFML_GRAPHICS_API void sfText_move(sfText* text, sfVector2f offset);
190
201 CSFML_GRAPHICS_API void sfText_rotate(sfText* text, float angle);
202
213 CSFML_GRAPHICS_API void sfText_scale(sfText* text, sfVector2f factors);
214
223 CSFML_GRAPHICS_API sfTransform sfText_getTransform(const sfText* text);
224
233 CSFML_GRAPHICS_API sfTransform sfText_getInverseTransform(const sfText* text);
234
244 CSFML_GRAPHICS_API void sfText_setString(sfText* text, const char* string);
245
253 CSFML_GRAPHICS_API void sfText_setUnicodeString(sfText* text, const sfChar32* string);
254
269 CSFML_GRAPHICS_API void sfText_setFont(sfText* text, const sfFont* font);
270
280 CSFML_GRAPHICS_API void sfText_setCharacterSize(sfText* text, unsigned int size);
281
295 CSFML_GRAPHICS_API void sfText_setLineSpacing(sfText* text, float spacingFactor);
296
315 CSFML_GRAPHICS_API void sfText_setLetterSpacing(sfText* text, float spacingFactor);
316
328 CSFML_GRAPHICS_API void sfText_setStyle(sfText* text, uint32_t style);
329
341 CSFML_GRAPHICS_API void sfText_setFillColor(sfText* text, sfColor color);
342
352 CSFML_GRAPHICS_API void sfText_setOutlineColor(sfText* text, sfColor color);
353
368 CSFML_GRAPHICS_API void sfText_setOutlineThickness(sfText* text, float thickness);
369
378 CSFML_GRAPHICS_API const char* sfText_getString(const sfText* text);
379
388 CSFML_GRAPHICS_API const sfChar32* sfText_getUnicodeString(const sfText* text);
389
402 CSFML_GRAPHICS_API const sfFont* sfText_getFont(const sfText* text);
403
412 CSFML_GRAPHICS_API unsigned int sfText_getCharacterSize(const sfText* text);
413
424 CSFML_GRAPHICS_API float sfText_getLetterSpacing(const sfText* text);
425
436 CSFML_GRAPHICS_API float sfText_getLineSpacing(const sfText* text);
437
446 CSFML_GRAPHICS_API uint32_t sfText_getStyle(const sfText* text);
447
456 CSFML_GRAPHICS_API sfColor sfText_getFillColor(const sfText* text);
457
466 CSFML_GRAPHICS_API sfColor sfText_getOutlineColor(const sfText* text);
467
476 CSFML_GRAPHICS_API float sfText_getOutlineThickness(const sfText* text);
477
494 CSFML_GRAPHICS_API sfVector2f sfText_findCharacterPos(const sfText* text, size_t index);
495
510 CSFML_GRAPHICS_API sfFloatRect sfText_getLocalBounds(const sfText* text);
511
526 CSFML_GRAPHICS_API sfFloatRect sfText_getGlobalBounds(const sfText* text);
Color.h
sfChar32
uint32_t sfChar32
Define sfChar32.
Definition Config.h:161
Export.h
CSFML_GRAPHICS_API
#define CSFML_GRAPHICS_API
Definition Graphics/Export.h:42
Types.h
sfText
struct sfText sfText
Definition Graphics/Types.h:38
sfFont
struct sfFont sfFont
Definition Graphics/Types.h:30
Rect.h
sfText_getFont
const sfFont * sfText_getFont(const sfText *text)
Get the font used by a text.
sfText_getLetterSpacing
float sfText_getLetterSpacing(const sfText *text)
Get the size of the letter spacing factor.
sfText_getInverseTransform
sfTransform sfText_getInverseTransform(const sfText *text)
Get the inverse of the combined transform of a text.
sfText_getString
const char * sfText_getString(const sfText *text)
Get the string of a text (returns an ANSI string).
sfText_setOutlineColor
void sfText_setOutlineColor(sfText *text, sfColor color)
Set the outline color of the text.
sfText_setUnicodeString
void sfText_setUnicodeString(sfText *text, const sfChar32 *string)
Set the string of a text (from a unicode string).
sfText_scale
void sfText_scale(sfText *text, sfVector2f factors)
Scale a text.
sfText_setCharacterSize
void sfText_setCharacterSize(sfText *text, unsigned int size)
Set the character size of a text.
sfText_getPosition
sfVector2f sfText_getPosition(const sfText *text)
Get the position of a text.
sfText_setPosition
void sfText_setPosition(sfText *text, sfVector2f position)
Set the position of a text.
sfText_setFont
void sfText_setFont(sfText *text, const sfFont *font)
Set the font of a text.
sfText_getLocalBounds
sfFloatRect sfText_getLocalBounds(const sfText *text)
Get the local bounding rectangle of a text.
sfTextStyle
sfTextStyle
sfText styles
Definition Text.h:45
sfTextRegular
@ sfTextRegular
Regular characters, no style.
Definition Text.h:46
sfTextBold
@ sfTextBold
Bold characters.
Definition Text.h:47
sfTextStrikeThrough
@ sfTextStrikeThrough
Strike through characters.
Definition Text.h:50
sfTextUnderlined
@ sfTextUnderlined
Underlined characters.
Definition Text.h:49
sfTextItalic
@ sfTextItalic
Italic characters.
Definition Text.h:48
sfText_getRotation
float sfText_getRotation(const sfText *text)
Get the orientation of a text.
sfText_getOutlineThickness
float sfText_getOutlineThickness(const sfText *text)
Get the outline thickness of a text.
sfText_move
void sfText_move(sfText *text, sfVector2f offset)
Move a text by a given offset.
sfText_getScale
sfVector2f sfText_getScale(const sfText *text)
Get the current scale of a text.
sfText_create
sfText * sfText_create(const sfFont *font)
Create a new text.
sfText_setLineSpacing
void sfText_setLineSpacing(sfText *text, float spacingFactor)
Set the line spacing factor.
sfText_getCharacterSize
unsigned int sfText_getCharacterSize(const sfText *text)
Get the size of the characters of a text.
sfText_setString
void sfText_setString(sfText *text, const char *string)
Set the string of a text (from an ANSI string).
sfText_getOutlineColor
sfColor sfText_getOutlineColor(const sfText *text)
Get the outline color of a text.
sfText_getFillColor
sfColor sfText_getFillColor(const sfText *text)
Get the fill color of a text.
sfText_setScale
void sfText_setScale(sfText *text, sfVector2f scale)
Set the scale factors of a text.
sfText_setStyle
void sfText_setStyle(sfText *text, uint32_t style)
Set the style of a text.
sfText_setRotation
void sfText_setRotation(sfText *text, float angle)
Set the orientation of a text.
sfText_getLineSpacing
float sfText_getLineSpacing(const sfText *text)
Get the size of the line spacing factor.
sfText_findCharacterPos
sfVector2f sfText_findCharacterPos(const sfText *text, size_t index)
Return the position of the index-th character in a text.
sfText_getUnicodeString
const sfChar32 * sfText_getUnicodeString(const sfText *text)
Get the string of a text (returns a unicode string).
sfText_setOrigin
void sfText_setOrigin(sfText *text, sfVector2f origin)
Set the local origin of a text.
sfText_rotate
void sfText_rotate(sfText *text, float angle)
Rotate a text.
sfText_getOrigin
sfVector2f sfText_getOrigin(const sfText *text)
Get the local origin of a text.
sfText_setLetterSpacing
void sfText_setLetterSpacing(sfText *text, float spacingFactor)
Set the letter spacing factor.
sfText_getStyle
uint32_t sfText_getStyle(const sfText *text)
Get the style of a text.
sfText_setFillColor
void sfText_setFillColor(sfText *text, sfColor color)
Set the fill color of a text.
sfText_getGlobalBounds
sfFloatRect sfText_getGlobalBounds(const sfText *text)
Get the global bounding rectangle of a text.
sfText_setOutlineThickness
void sfText_setOutlineThickness(sfText *text, float thickness)
Set the thickness of the text's outline.
sfText_destroy
void sfText_destroy(const sfText *text)
Destroy an existing text.
sfText_copy
sfText * sfText_copy(const sfText *text)
Copy an existing text.
sfText_getTransform
sfTransform sfText_getTransform(const sfText *text)
Get the combined transform of a text.
Transform.h
Vector2.h
sfColor
Utility class for manpulating RGBA colors.
Definition Color.h:38
sfFloatRect
sfFloatRect and sfIntRect are utility classes for manipulating rectangles.
Definition Rect.h:40
sfTransform
Encapsulate a 3x3 transform matrix.
Definition Transform.h:42
sfVector2f
2-component vector of floats
Definition Vector2.h:60