Menu

[r3770]: / branches / mathtext_mgd / src / ft2font.h  Maximize  Restore  History

Download this file

155 lines (133 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* A python interface to freetype2 */
#ifndef _FT2FONT_H
#define _FT2FONT_H
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
extern "C" {
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_SFNT_NAMES_H
#include FT_TYPE1_TABLES_H
#include FT_TRUETYPE_TABLES_H
}
#include "CXX/Extensions.hxx"
#include "CXX/Objects.hxx"
// the freetype string rendered into a width, height buffer
class FT2Image {
public:
FT2Image();
~FT2Image();
bool bRotated;
unsigned char *buffer;
unsigned long width;
unsigned long height;
int offsetx, offsety;
};
class Glyph : public Py::PythonExtension<Glyph> {
public:
Glyph( const FT_Face&, const FT_Glyph&, size_t);
~Glyph();
int setattr( const char *_name, const Py::Object &value );
Py::Object getattr( const char *_name );
static void init_type(void);
size_t glyphInd;
Py::Object get_path( const FT_Face& face );
private:
Py::Dict __dict__;
static char get_path__doc__[];
};
class FT2Font : public Py::PythonExtension<FT2Font> {
public:
FT2Font(std::string);
~FT2Font();
static void init_type(void);
Py::Object set_bitmap_size(const Py::Tuple & args);
Py::Object clear(const Py::Tuple & args);
Py::Object set_size(const Py::Tuple & args);
Py::Object set_charmap(const Py::Tuple & args);
Py::Object set_text(const Py::Tuple & args);
Py::Object get_glyph(const Py::Tuple & args);
Py::Object get_kerning(const Py::Tuple & args);
Py::Object get_num_glyphs(const Py::Tuple & args);
Py::Object load_char(const Py::Tuple & args, const Py::Dict & kws);
Py::Object get_width_height(const Py::Tuple & args);
Py::Object get_descent(const Py::Tuple & args);
Py::Object write_bitmap(const Py::Tuple & args);
Py::Object draw_rect(const Py::Tuple & args);
Py::Object draw_rect_filled(const Py::Tuple & args);
Py::Object image_as_str(const Py::Tuple & args);
Py::Object get_xys(const Py::Tuple & args);
Py::Object draw_glyphs_to_bitmap(const Py::Tuple & args);
Py::Object draw_glyph_to_bitmap(const Py::Tuple & args);
Py::Object get_glyph_name(const Py::Tuple & args);
Py::Object get_charmap(const Py::Tuple & args);
Py::Object get_sfnt(const Py::Tuple & args);
Py::Object get_name_index(const Py::Tuple & args);
Py::Object get_ps_font_info(const Py::Tuple & args);
Py::Object get_sfnt_table(const Py::Tuple & args);
Py::Object horiz_image_to_vert_image(const Py::Tuple & args);
int setattr( const char *_name, const Py::Object &value );
Py::Object getattr( const char *_name );
FT2Image image;
private:
Py::Dict __dict__;
FT_Face face;
FT_Matrix matrix; /* transformation matrix */
FT_Vector pen; /* untransformed origin */
FT_Error error;
std::vector<FT_Glyph> glyphs;
std::vector<FT_Vector> pos;
std::vector<Glyph*> gms;
double angle;
FT_BBox compute_string_bbox();
void draw_bitmap( FT_Bitmap* bitmap, FT_Int x, FT_Int y);
void set_scalable_attributes();
static char set_bitmap_size__doc__ [];
static char clear__doc__ [];
static char set_size__doc__ [];
static char set_charmap__doc__ [];
static char set_text__doc__ [];
static char get_glyph__doc__ [];
static char get_num_glyphs__doc__ [];
static char load_char__doc__ [];
static char get_width_height__doc__ [];
static char get_descent__doc__ [];
static char get_kerning__doc__ [];
static char write_bitmap__doc__ [];
static char draw_rect__doc__ [];
static char draw_rect_filled__doc__ [];
static char image_as_str__doc__ [];
static char draw_glyphs_to_bitmap__doc__ [];
static char get_xys__doc__ [];
static char draw_glyph_to_bitmap__doc__ [];
static char get_glyph_name__doc__[];
static char get_charmap__doc__[];
static char get_sfnt__doc__ [];
static char get_name_index__doc__[];
static char get_ps_font_info__doc__[];
static char get_sfnt_table__doc__[];
static char horiz_image_to_vert_image__doc__[];
};
// the extension module
class ft2font_module : public Py::ExtensionModule<ft2font_module>
{
public:
ft2font_module()
: Py::ExtensionModule<ft2font_module>( "ft2font" )
{
Glyph::init_type();
FT2Font::init_type();
add_varargs_method("FT2Font", &ft2font_module::new_ft2font,
"FT2Font");
initialize( "The ft2font module" );
}
~ft2font_module();
//static FT_Library ft2Library;
private:
Py::Object new_ft2font (const Py::Tuple &args);
};
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.