cgv
Loading...
Searching...
No Matches
font.h
1#pragma once
2
3#include <cgv/base/base.h>
4#include <vector>
5#include <string>
6
7#include "lib_begin.h"
8
9#ifdef WIN32
10#pragma warning(disable:4275)
11#pragma warning(disable:4231)
12#endif
13
14namespace cgv {
15 namespace media {
17 namespace font {
18
21{
22 FFA_REGULAR = 0,
23 FFA_BOLD = 1,
24 FFA_ITALIC = 2,
25 FFA_BOLD_ITALIC = 3
26};
27
29class CGV_API font_face : public base::base
30{
31protected:
33 int ffa;
34public:
36 font_face(int _ffa);
38 std::string get_type_name() const;
40 virtual int get_attributes() const;
42 virtual void enumerate_sizes(std::vector<int>& supported_sizes) const = 0;
44 virtual float measure_text_width(const std::string& text, float font_size) const = 0;
46 virtual void enable(void* context_ptr, float _font_size) = 0;
48 virtual void draw_text(float& x, float& y, const std::string& text) const = 0;
49};
50
53
55class CGV_API font : public base::base
56{
57public:
59 std::string get_type_name() const;
61 virtual const char* get_name() const = 0;
67 virtual void enumerate_sizes(std::vector<int>& supported_sizes) const = 0;
68};
69
72
74extern CGV_API font_ptr find_font(const std::string& font_name);
75
77extern CGV_API font_ptr find_font_by_prefix(const std::string& font_name_prefix);
78
80extern CGV_API font_ptr find_font_or_default(const std::string& font_name, bool default_font_mono_space = false);
81
83extern CGV_API font_ptr default_font(bool mono_space = false);
84
85
87extern CGV_API void enumerate_font_names(std::vector<const char*>& font_names);
88
89#if _MSC_VER >= 1400
90CGV_TEMPLATE template class CGV_API data::ref_ptr<font>;
91CGV_TEMPLATE template class CGV_API data::ref_ptr<font_face>;
92#endif
93
94 }
95 }
96}
97
98#include <cgv/config/lib_end.h>
base class for all classes that can be registered with support for dynamic properties (see also secti...
Definition base.h:75
reference counted pointer, which can work together with types that are derived from ref_counted,...
Definition ref_ptr.h:160
interface class for different faces of a font, which can be constructed from a font
Definition font.h:30
virtual void enable(void *context_ptr, float _font_size)=0
enables font face of given size and should be called once before calling draw_text functions
virtual float measure_text_width(const std::string &text, float font_size) const =0
return the width of a text printed in the given size, which is measured in pixels
virtual void enumerate_sizes(std::vector< int > &supported_sizes) const =0
enumerate the supported sizes; if nothing is enumerated any size is supported
int ffa
store the actual attributes of the font face
Definition font.h:33
virtual void draw_text(float &x, float &y, const std::string &text) const =0
draw text at given location with font_face implementation dependent rendering api and advance locatio...
interface class for fonts. Construct font with the find_font function
Definition font.h:56
virtual const char * get_name() const =0
return the name of the font
virtual bool supports_font_face(cgv::media::font::FontFaceAttributes ffa) const =0
check whether the given font includes a face that include the possibly or-ed together selection of fo...
virtual void enumerate_sizes(std::vector< int > &supported_sizes) const =0
enumerate the supported font sizes
virtual font_face_ptr get_font_face(cgv::media::font::FontFaceAttributes ffa) const =0
return a pointer to a font face
font_ptr find_font(const std::string &font_name)
find an installed font by name
Definition font.cxx:32
font_ptr find_font_by_prefix(const std::string &font_name_prefix)
find an installed font by name prefix
Definition font.cxx:40
FontFaceAttributes
declaration of supported attributes of font faces
Definition font.h:21
font_ptr default_font(bool mono_space)
return platform dependend default font
Definition font.cxx:57
data::ref_ptr< font_face > font_face_ptr
always use this ref counted pointer to store font faces
Definition font.h:52
font_ptr find_font_or_default(const std::string &font_name, bool default_font_mono_space)
find an installed font by name
Definition font.cxx:48
data::ref_ptr< font > font_ptr
always use this ref counted pointer to store fonts
Definition font.h:71
void enumerate_font_names(std::vector< const char * > &font_names)
enumerate the names of all installed fonts
Definition font.cxx:65
the cgv namespace
Definition print.h:11