Line data Source code
1 : // Copyright (c) 2021 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // https://snapwebsites.org/project/ftmesh
4 : // contact@m2osw.com
5 : //
6 : // This program is free software; you can redistribute it and/or modify
7 : // it under the terms of the GNU General Public License as published by
8 : // the Free Software Foundation; either version 2 of the License, or
9 : // (at your option) any later version.
10 : //
11 : // This program is distributed in the hope that it will be useful,
12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : // GNU General Public License for more details.
15 : //
16 : // You should have received a copy of the GNU General Public License along
17 : // with this program; if not, write to the Free Software Foundation, Inc.,
18 : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 : #pragma once
20 :
21 : /** \file
22 : * \brief Definitions of the ftpolygon class.
23 : *
24 : * A glyph is defined as a set of \em contours which are actually forming
25 : * polygons. Here we transform the FreeType vectors and tags in a list of
26 : * points with a direction.
27 : *
28 : * \private
29 : */
30 :
31 :
32 : // self
33 : //
34 : #include <ftmesh/point.h>
35 :
36 :
37 : // FreeType lib
38 : //
39 : // ft2build.h must come first
40 : #include <ft2build.h>
41 :
42 : #include FT_FREETYPE_H
43 : //#include FT_GLYPH_H
44 : //#include FT_OUTLINE_H
45 :
46 :
47 : namespace ftmesh
48 : {
49 :
50 :
51 :
52 :
53 11 : class polygon
54 : {
55 : public:
56 : typedef std::shared_ptr<polygon> pointer_t;
57 : typedef std::vector<pointer_t> vector_t;
58 :
59 : polygon(
60 : FT_Vector * contour
61 : , char * tags
62 : , unsigned int n);
63 :
64 : std::size_t size() const;
65 : point const & at(int idx) const;
66 : point const & leftmost() const;
67 : void apply_parity(int parity);
68 :
69 : private:
70 : void add_point(point const & p);
71 : void evaluate_quadratic_curve(
72 : point const & a
73 : , point const & b
74 : , point const & c);
75 : void evaluate_cubic_curve(
76 : point const & a
77 : , point const & b
78 : , point const & c
79 : , point const & d);
80 :
81 : point::vector_t f_points = point::vector_t();
82 : bool f_clockwise = false;
83 : point f_leftmost = point(65536.0, 0.0);
84 : };
85 :
86 :
87 : } // namespace ftmesh
88 : // vim: ts=4 sw=4 et
89 :
|