font_family.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 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 "font_description.h"
37 #include "glyph_metrics.h"
38 
39 namespace clan
40 {
43 
44 class FontProvider;
45 class Canvas;
46 class FontFamily_Impl;
47 class GlyphMetrics;
48 
53 {
56 
57 public:
60 
62  FontFamily(const std::string &family_name);
63 
65 
68 public:
70  bool is_null() const { return !impl; }
71 
73  void throw_if_null() const;
74 
76  const std::string &get_family_name() const;
77 
81 
82 public:
84  void add(const std::string &typeface_name, float height);
85 
86  // \brief Add standard font
87  void add(const std::string &typeface_name, const FontDescription &desc);
88 
89  // \brief Add standard font
90  void add(const FontDescription &desc, const std::string &ttf_filename);
91 
92  // \brief Add standard font
93  void add(const FontDescription &desc, const std::string &ttf_filename, FileSystem fs);
94 
102  void add(Canvas &canvas, Sprite &sprite, const std::string &glyph_list, float spacelen, bool monospace, const FontMetrics &metrics);
103 
107 
108 private:
109  std::shared_ptr<FontFamily_Impl> impl;
110 
111  friend class Font_Impl;
112 
114 };
115 
116 }
117 
119 
FontFamily(const std::string &family_name)
Constructs a font family with the given family name.
Font description class.
Definition: font_description.h:67
void throw_if_null() const
Throw an exception if this object is invalid.
void add(const FontDescription &desc, const std::string &ttf_filename, FileSystem fs)
void add(const FontDescription &desc, const std::string &ttf_filename)
void add(const std::string &typeface_name, const FontDescription &desc)
FontFamily()
Constructs a null font family.
bool is_null() const
Returns true if this object is invalid.
Definition: font_family.h:70
2D Graphics Canvas
Definition: canvas.h:73
friend class Font_Impl
Definition: font_family.h:111
const std::string & get_family_name() const
Font family name used for this font family.
Sprite class.
Definition: sprite.h:56
Definition: clanapp.h:36
Virtual File System (VFS).
Definition: file_system.h:48
FontFamily class.
Definition: font_family.h:53
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.
void add(const std::string &typeface_name, float height)
Add standard font.
Font metrics class.
Definition: font_metrics.h:47