vector_font.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 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 ** Harry Storbacka
28 */
29 
30 
31 #pragma once
32 
33 #include "../api_display.h"
34 #include "font.h"
35 
36 namespace clan
37 {
40 
41 class VectorFont_Impl;
42 class FontMetrics;
43 class FileSystem;
44 class VectorFont_Impl;
45 
47 class CL_API_DISPLAY VectorFont
48 {
51 
52 public:
54  VectorFont();
55 
61  VectorFont( Canvas &canvas, const std::string &typeface_name, int height, const std::string &filename);
62 
67  VectorFont( Canvas &canvas, const FontDescription &desc, const std::string &filename);
68 
70  explicit VectorFont( const Font &font);
71 
72  ~VectorFont();
73 
77 
78 public:
79 
83  bool is_null() const;
84 
86  Rectf get_bounding_box(const std::string &reference_string) const;
87 
88  const std::vector<Vec2f> &get_glyph_filled(unsigned int glyph);
89  const std::vector< std::vector<Vec2f> > &get_glyph_outline(unsigned int glyph);
90 
99  Size get_text_size(Canvas &canvas, const std::string &text);
100 
107  Size get_glyph_size(Canvas &canvas, unsigned int glyph);
108 
110  FontMetrics get_font_metrics();
111 
115 
116 public:
126  void draw_text(Canvas &canvas, int x, int y, const std::string &text, const Colorf &color = Colorf::white);
127 
137  void draw_text(Canvas &canvas, float x, float y, const std::string &text, const Colorf &color = Colorf::white);
138 
147  void draw_text(Canvas &canvas, const Pointf &position, const std::string &text, const Colorf &color = Colorf::white);
148 
159  void draw_text_ellipsis(Canvas &canvas, int x, int y, Rect content_box, const std::string &text, const Colorf &color = Colorf::white);
160 
171  void draw_text_ellipsis(Canvas &canvas, float x, float y, Rectf content_box, const std::string &text, const Colorf &color = Colorf::white);
172 
182  void draw_text_ellipsis(Canvas &canvas, const Pointf &position, Rectf content_box, const std::string &text, const Colorf &color = Colorf::white);
183 
185  void set_filled(bool enable = true);
186 
192  void set_texture(const Texture2D &src_texture, const Rectf &bounding_rect, const Rectf &texture_rect = Rectf(0.0f, 0.0f, 1.0f, 1.0f) );
193  void set_texture(const Texture2D &src_texture, const Rectf &bounding_rect, const Rect &texture_rect );
194 
196  void reset_texture();
197 
201  std::shared_ptr<VectorFont_Impl> impl;
202 
204 };
205 
206 }
207 
Floating point color description class (for float).
Definition: color.h:661
Font description class.
Definition: font_description.h:47
static Colorf white
Definition: color.h:1245
2D Graphics Canvas
Definition: canvas.h:70
Vector font drawing class.
Definition: vector_font.h:47
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:453
2D texture object class.
Definition: texture_2d.h:42
2D (left,top,right,bottom) rectangle structure - Float
Definition: rect.h:467
std::shared_ptr< VectorFont_Impl > impl
Definition: vector_font.h:201
Font class.
Definition: font.h:52
2D (width,height) size structure - Integer
Definition: size.h:157
2D (x,y) point structure - Float
Definition: point.h:73
Font metrics class.
Definition: font_metrics.h:47