font_family.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2016 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 
52  class FontFamily
53  {
54  public:
56  FontFamily();
57 
59  FontFamily(const std::string &family_name);
60 
62  bool is_null() const { return !impl; }
63  explicit operator bool() const { return bool(impl); }
64 
66  void throw_if_null() const;
67 
69  const std::string &get_family_name() const;
70 
72  void add(const std::string &typeface_name, float height);
73 
74  // \brief Add standard font
75  void add(const std::string &typeface_name, const FontDescription &desc);
76 
77  // \brief Add standard font
78  void add(const FontDescription &desc, const std::string &ttf_filename);
79 
80  // \brief Add standard font
81  void add(const FontDescription &desc, const std::string &ttf_filename, FileSystem fs);
82 
90  void add(Canvas &canvas, Sprite &sprite, const std::string &glyph_list, float spacelen, bool monospace, const FontMetrics &metrics);
91 
92  private:
93  std::shared_ptr<FontFamily_Impl> impl;
94 
95  friend class Font_Impl;
96  };
97 
99 }
Definition: clanapp.h:35
Font description class.
Definition: font_description.h:65
2D Graphics Canvas
Definition: canvas.h:71
void add(const std::string &typeface_name, float height)
Add standard font.
Sprite class.
Definition: sprite.h:54
Virtual File System (VFS).
Definition: file_system.h:46
bool is_null() const
Returns true if this object is invalid.
Definition: font_family.h:62
const std::string & get_family_name() const
Font family name used for this font family.
void throw_if_null() const
Throw an exception if this object is invalid.
FontFamily class.
Definition: font_family.h:52
FontFamily()
Constructs a null font family.
friend class Font_Impl
Definition: font_family.h:95
Font metrics class.
Definition: font_metrics.h:45