font_family.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib Team
4**
5** This software is provided 'as-is', without any express or implied
6** warranty. In no event will the authors be held liable for any damages
7** 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
11** freely, subject to the following restrictions:
12**
13** 1. The origin of this software must not be misrepresented; you must not
14** claim that you wrote the original software. If you use this software
15** in a product, an acknowledgment in the product documentation would be
16** appreciated but is not required.
17** 2. Altered source versions must be plainly marked as such, and must not be
18** misrepresented as being the original software.
19** 3. This notice may not be removed or altered from any source distribution.
20**
21** Note: Some of the libraries ClanLib may link to may have additional
22** requirements or restrictions.
23**
24** File Author(s):
25**
26** Magnus Norddahl
27** Mark Page
28*/
29
30#pragma once
31
32#include <memory>
33#include "../Render/graphic_context.h"
34#include "../Image/pixel_buffer.h"
35#include "../2D/sprite.h"
36#include "../2D/texture_group.h"
37#include "font_description.h"
38#include "glyph_metrics.h"
39
40namespace clan
41{
44
45 class FontProvider;
46 class Canvas;
47 class FontFamily_Impl;
48 class GlyphMetrics;
49
54 {
55 public:
58
60 FontFamily(const std::string &family_name, const TextureGroup &new_texture_group = TextureGroup(Size(256, 256)));
61
63 bool is_null() const { return !impl; }
64 explicit operator bool() const { return bool(impl); }
65
67 void throw_if_null() const;
68
70 const std::string &get_family_name() const;
71
73 void add(const std::string &typeface_name, float height);
74
75 // \brief Add standard font
76 void add(const std::string &typeface_name, const FontDescription &desc);
77
78 // \brief Add standard font
79 void add(const FontDescription &desc, const std::string &ttf_filename);
80
81 // \brief Add standard font
82 void add(const FontDescription &desc, const std::string &ttf_filename, FileSystem fs);
83
91 void add(Canvas &canvas, Sprite &sprite, const std::string &glyph_list, float spacelen, bool monospace, const FontMetrics &metrics);
92
93 private:
94 std::shared_ptr<FontFamily_Impl> impl;
95
96 friend class Font_Impl;
97 };
98
100}
2D Graphics Canvas
Definition canvas.h:72
Virtual File System (VFS).
Definition file_system.h:47
Font description class.
Definition font_description.h:66
FontFamily class.
Definition font_family.h:54
void add(const std::string &typeface_name, float height)
Add standard font.
void throw_if_null() const
Throw an exception if this object is invalid.
friend class Font_Impl
Definition font_family.h:96
const std::string & get_family_name() const
Font family name used for this font family.
void add(const std::string &typeface_name, const FontDescription &desc)
void add(const FontDescription &desc, const std::string &ttf_filename, FileSystem fs)
void add(const FontDescription &desc, const std::string &ttf_filename)
bool is_null() const
Returns true if this object is invalid.
Definition font_family.h:63
void add(Canvas &canvas, Sprite &sprite, const std::string &glyph_list, float spacelen, bool monospace, const FontMetrics &metrics)
Add a Font based on a sprite.
FontFamily()
Constructs a null font family.
FontFamily(const std::string &family_name, const TextureGroup &new_texture_group=TextureGroup(Size(256, 256)))
Constructs a font family with the given family name.
Font metrics class.
Definition font_metrics.h:46
2D (width,height) size structure - Integer
Definition size.h:171
Sprite class.
Definition sprite.h:55
Texture grouping class.
Definition texture_group.h:48
Definition clanapp.h:36