41#include <unordered_map>
48#ifdef SFML_SYSTEM_ANDROID
103 explicit Font(
const std::filesystem::path& filename);
124 Font(
const void* data, std::size_t sizeInBytes);
168 [[nodiscard]]
bool openFromFile(
const std::filesystem::path& filename);
240 [[nodiscard]]
const Glyph&
getGlyph(
char32_t codePoint,
unsigned int characterSize,
bool bold,
float outlineThickness = 0)
const;
258 [[nodiscard]]
bool hasGlyph(
char32_t codePoint)
const;
277 [[nodiscard]]
float getKerning(std::uint32_t first, std::uint32_t second,
unsigned int characterSize,
bool bold =
false)
const;
368 Row(
unsigned int rowTop,
unsigned int rowHeight) : top(rowTop), height(rowHeight)
372 unsigned int width{};
380 using GlyphTable = std::unordered_map<std::uint64_t, Glyph>;
388 explicit Page(
bool smooth);
392 unsigned int nextRow{3};
393 std::vector<Row> rows;
410 Page& loadPage(
unsigned int characterSize)
const;
423 Glyph loadGlyph(
char32_t codePoint,
unsigned int characterSize,
bool bold,
float outlineThickness)
const;
434 IntRect findGlyphRect(Page& page, Vector2u size)
const;
444 [[nodiscard]]
bool setCurrentSize(
unsigned int characterSize)
const;
450 using PageTable = std::unordered_map<unsigned int, Page>;
455 std::shared_ptr<FontHandles> m_fontHandles;
456 bool m_isSmooth{
true};
458 mutable PageTable m_pages;
459 mutable std::vector<std::uint8_t> m_pixelBuffer;
460#ifdef SFML_SYSTEM_ANDROID
461 std::shared_ptr<priv::ResourceStream> m_stream;
#define SFML_GRAPHICS_API
bool openFromMemory(const void *data, std::size_t sizeInBytes)
Open the font from a file in memory.
float getLineSpacing(unsigned int characterSize) const
Get the line spacing.
const Texture & getTexture(unsigned int characterSize) const
Retrieve the texture containing the loaded glyphs of a certain size.
Font(InputStream &stream)
Construct the font from a custom stream.
float getUnderlinePosition(unsigned int characterSize) const
Get the position of the underline.
Font(const std::filesystem::path &filename)
Construct the font from a file.
void setSmooth(bool smooth)
Enable or disable the smooth filter.
Font(const void *data, std::size_t sizeInBytes)
Construct the font from a file in memory.
const Info & getInfo() const
Get the font information.
const Glyph & getGlyph(char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0) const
Retrieve a glyph of the font.
float getKerning(std::uint32_t first, std::uint32_t second, unsigned int characterSize, bool bold=false) const
Get the kerning offset of two glyphs.
bool openFromStream(InputStream &stream)
Open the font from a custom stream.
float getUnderlineThickness(unsigned int characterSize) const
Get the thickness of the underline.
bool isSmooth() const
Tell whether the smooth filter is enabled or not.
Font()=default
Default constructor.
bool openFromFile(const std::filesystem::path &filename)
Open the font from a file.
bool hasGlyph(char32_t codePoint) const
Determine if this font has a glyph representing the requested code point.
Image living on the graphics card that can be used for drawing.
Holds various information about a font.
std::string family
The font family.
Structure describing a glyph.