Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
freetypefontutils.h
Go to the documentation of this file.
1 
18 #ifndef ION_TEXT_FREETYPEFONTUTILS_H_
19 #define ION_TEXT_FREETYPEFONTUTILS_H_
20 
25 
26 #include <string>
27 #include <vector>
28 
29 #include "ion/math/vector.h"
30 #include "ion/text/layout.h"
31 
32 namespace ion {
33 namespace text {
34 
35 class Font;
36 class FreeTypeFont;
37 
39 struct TextSize {
43  math::Vector2f rect_size_in_pixels;
49  std::vector<float> line_widths_in_pixels;
50 };
51 
56  math::Vector2f scale;
58  std::vector<math::Vector2f> line_translations;
61 };
62 
64 typedef std::vector<std::string> Lines;
65 
71 const TextSize ComputeTextSize(const FreeTypeFont& font,
72  const LayoutOptions& options,
73  const Lines& lines);
74 
83  const Font& font, const LayoutOptions& options, const TextSize& text_size);
84 
86 const Layout LayOutText(const FreeTypeFont& font, bool use_icu,
87  const Lines& lines,
88  const FreeTypeFontTransformData& transform_data);
89 
90 } // namespace text
91 } // namespace ion
92 
93 #endif // ION_TEXT_FREETYPEFONTUTILS_H_
std::vector< std::string > Lines
Lines of text from a single string (usually split on ' ').
std::vector< float > line_widths_in_pixels
Width of each line of text in pixels.
const FreeTypeFontTransformData ComputeTransformData(const Font &font, const LayoutOptions &options, const TextSize &text_size)
Sets the scale and translation fields of the LayoutData instance with the scale and translation requi...
math::Vector2f rect_size_in_pixels
Size of the entire text rectangle in pixels.
This derived Font class represents a FreeType2 font.
Definition: freetypefont.h:35
const Layout LayOutText(const FreeTypeFont &font, bool use_icu, const Lines &lines, const FreeTypeFontTransformData &transform_data)
Returns a Layout populated by glyphs representing lines of text.
std::string text
std::vector< math::Vector2f > line_translations
Translation to apply to position glyphs for each line of text.
This struct defines parameters affecting layout of a single text string when passed to BuildLayout()...
Definition: layout.h:101
float text_height_in_pixels
Height of the text inside the rectangle in pixels.
float first_line_above_baseline
Max height above baseline of the first line of text (depends on contents!).
math::Vector2f scale
Scale to apply to resize glyphs.
float line_height_in_pixels
Height of a single line of text in pixels.
const TextSize ComputeTextSize(const FreeTypeFont &font, const LayoutOptions &options, const Lines &lines)
Computes the size of text and returns it as a TextSize instance.
A Layout instance specifies how glyphs are arranged to form text.
Definition: layout.h:127
float line_y_offset_in_pixels
How much to translate each successive line in y, in pixels.
TextSize contains information about the size of multi-line text.
This contains the values needed to transform glyph rectangles into the correct coordinates.
Font is a base class for implementation-specific representations of fonts.
Definition: font.h:43