FifeGUI 0.2.0
A C++ GUI library designed for games.
font.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_FONT_HPP_
6#define INCLUDE_FIFECHAN_FONT_HPP_
7
8#include <string>
9
10#include "fifechan/platform.hpp"
11
12namespace fcn
13{
14 class Graphics;
15
23 class FIFEGUI_API Font
24 {
25 public:
26 virtual ~Font() = default;
27
28 Font(Font const &) = default;
29 Font& operator=(Font const &) = default;
30 Font(Font&&) = default;
31 Font& operator=(Font&&) = default;
32
40 virtual int getWidth(std::string const & text) const = 0;
41
47 virtual int getHeight() const = 0;
48
58 virtual int getStringIndexAt(std::string const & text, int x) const;
59
71 virtual void drawString(Graphics* graphics, std::string const & text, int x, int y) = 0;
72
73 protected:
74 Font() = default;
75 };
76} // namespace fcn
77
78#endif // INCLUDE_FIFECHAN_FONT_HPP_
virtual int getWidth(std::string const &text) const =0
Gets the width of a string.
virtual int getHeight() const =0
Gets the height of the glyphs in the font.
virtual void drawString(Graphics *graphics, std::string const &text, int x, int y)=0
Draws a string.
virtual int getStringIndexAt(std::string const &text, int x) const
Gets a string index in a string providing an x coordinate.
Definition font.cpp:11
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:57