btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / libs / agg / agg_gsv_text.h
blob269c8a499b2ea571cad680301740c3f80545e16c
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 // Class gsv_text
18 //----------------------------------------------------------------------------
20 #ifndef AGG_GSV_TEXT_INCLUDED
21 #define AGG_GSV_TEXT_INCLUDED
23 #include "agg_array.h"
24 #include "agg_conv_stroke.h"
25 #include "agg_conv_transform.h"
27 namespace agg
31 //---------------------------------------------------------------gsv_text
33 // See Implementation agg_gsv_text.cpp
35 class gsv_text
37 enum status
39 initial,
40 next_char,
41 start_glyph,
42 glyph
45 public:
46 gsv_text();
48 void font(const void* font);
49 void flip(bool flip_y) { m_flip = flip_y; }
50 void load_font(const char* file);
51 void size(double height, double width=0.0);
52 void space(double space);
53 void line_space(double line_space);
54 void start_point(double x, double y);
55 void text(const char* text);
57 void rewind(unsigned path_id);
58 unsigned vertex(double* x, double* y);
60 private:
61 // not supposed to be copied
62 gsv_text(const gsv_text&);
63 const gsv_text& operator = (const gsv_text&);
65 int16u value(const int8u* p) const
67 int16u v;
68 if(m_big_endian)
70 *(int8u*)&v = p[1];
71 *((int8u*)&v + 1) = p[0];
73 else
75 *(int8u*)&v = p[0];
76 *((int8u*)&v + 1) = p[1];
78 return v;
81 private:
82 double m_x;
83 double m_y;
84 double m_start_x;
85 double m_width;
86 double m_height;
87 double m_space;
88 double m_line_space;
89 char m_chr[2];
90 char* m_text;
91 pod_array<char> m_text_buf;
92 char* m_cur_chr;
93 const void* m_font;
94 pod_array<char> m_loaded_font;
95 status m_status;
96 bool m_big_endian;
97 bool m_flip;
98 int8u* m_indices;
99 int8* m_glyphs;
100 int8* m_bglyph;
101 int8* m_eglyph;
102 double m_w;
103 double m_h;
109 //--------------------------------------------------------gsv_text_outline
110 template<class Transformer = trans_affine> class gsv_text_outline
112 public:
113 gsv_text_outline(gsv_text& text, const Transformer& trans) :
114 m_polyline(text),
115 m_trans(m_polyline, trans)
119 void width(double w)
121 m_polyline.width(w);
124 void transformer(const Transformer* trans)
126 m_trans->transformer(trans);
129 void rewind(unsigned path_id)
131 m_trans.rewind(path_id);
132 m_polyline.line_join(round_join);
133 m_polyline.line_cap(round_cap);
136 unsigned vertex(double* x, double* y)
138 return m_trans.vertex(x, y);
141 private:
142 conv_stroke<gsv_text> m_polyline;
143 conv_transform<conv_stroke<gsv_text>, Transformer> m_trans;
151 #endif