OpenCores
URL https://opencores.org/ocsvn/orsoc_graphics_accelerator/orsoc_graphics_accelerator/trunk

Subversion Repositories orsoc_graphics_accelerator

[/] [orsoc_graphics_accelerator/] [trunk/] [sw/] [utils/] [fonter/] [ttfpoint.h] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 maiden
#ifndef TTFPOINT_H
2
#define TTFPOINT_H
3
 
4
#include <iostream>
5
#include <fstream>
6
#include <deque>
7
 
8
#include <ft2build.h>
9
#include <freetype2/freetype/ftglyph.h>
10
#include FT_FREETYPE_H
11
using namespace std;
12
 
13
#include "poly2tri/poly2tri.h"
14
using namespace p2t;
15
 
16
class BPoint
17
{
18
public:
19
    BPoint(int X = 0, int Y = 0, int OnLine = 0, int EndOfContour = 0, int InternalControlPoint = 0)
20
        : x(X), y(Y), onLine(OnLine), endOfContour(EndOfContour), internalControlPoint(InternalControlPoint)
21
    {}
22
 
23
    // x and y coordinates of a point
24
    int x, y, onLine,endOfContour, internalControlPoint;
25
};
26
 
27
class TriangleWrite
28
{
29
public:
30
    TriangleWrite(BPoint A = BPoint(), BPoint B = BPoint(), BPoint C = BPoint())
31
        : a(A), b(B), c(C)
32
    {}
33
 
34
    BPoint a;
35
    BPoint b;
36
    BPoint c;
37
};
38
 
39
class BezierWrite
40
{
41
public:
42
    BezierWrite(BPoint Start = BPoint(), BPoint Control = BPoint(), BPoint End = BPoint(), int FillInside = 0)
43
        : start(Start), control(Control), end(End), fillInside(FillInside)
44
    {}
45
 
46
    // Do an area calculation (the same that will be performed when calculating culling in the graphics card)
47
    // If needed, swaps the points so that the shape will not be culled.
48
    // Sets inside/outside fill
49
    // Returns if the control point is an "inside" control point or not (used in triangulation)
50
    int FixArea();
51
 
52
    // start point of bezier curve
53
    BPoint start;
54
    // control point of bezier curve
55
    BPoint control;
56
    // end point of bezier curve
57
    BPoint end;
58
    // check if inside or outside is filled
59
    int fillInside;
60
};
61
 
62
class Glyph
63
{
64
public:
65
    // the 'letter' or 'glyph' ex. A, B, C, # % q i
66
    int index;
67
    int advance_x;
68
    // all bezier draws to form the glyph
69
    deque<BezierWrite> writes;
70
    deque<TriangleWrite> triangles;
71
};
72
 
73
 
74
class TTFPoint
75
{
76
public:
77
    TTFPoint();
78
 
79
    static void     InitFreeType(); // must run first.
80
 
81
    void            LoadFont(string filename); // must run second.
82
    void            GenerateWrites(bool all, wstring charmap); // must run third
83
    void            WriteFontFile(string fontname); // must run last
84
private:
85
    FT_Outline      LoadGlyphOutline(int character, FT_Matrix &matrix, FT_Vector &pen);
86
 
87
    deque<BPoint>   UntangleGlyphPoints(FT_Outline outline);
88
 
89
    Glyph           BuildGlyph(deque<BPoint> &untangledPointList, int character);
90
 
91
    vector<Point*>       GetShapePoints(int i, vector< vector<BPoint> > &shapes);
92
    deque<TriangleWrite> Triangulate(deque<BPoint> &untangledPointList);
93
 
94
    // List that holds all glyphs
95
    deque<Glyph>        mGlyphs;
96
 
97
    //freetype veriables
98
    FT_Face             mFace;
99
    static FT_Library   mLibrary;
100
    static FT_Error     mError;
101
};
102
 
103
#endif // TTFPOINT_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.