88/* *
99 To improve the hinting of the fonts, this code uses a hack
1010 presented here:
11-
11+
1212 http://antigrain.com/research/font_rasterization/index.html
13-
13+
1414 The idea is to limit the effect of hinting in the x-direction, while
1515 preserving hinting in the y-direction. Since freetype does not
1616 support this directly, the dpi in the x-direction is set higher than
2020 hinting, whereas the global transform does not, this is documented
2121 behavior of freetype, and therefore hopefully unlikely to change.
2222 The freetype 2 tutorial says:
23-
23+
2424 NOTE: The transformation is applied to every glyph that is
2525 loaded through FT_Load_Glyph and is completely independent of
2626 any hinting process. This means that you won't get the same
4242
4343FT_Library _ft2Library;
4444
45- // FT2Image::FT2Image() :
45+ // FT2Image::FT2Image() :
4646// _isDirty(true),
4747// _buffer(NULL),
4848// _width(0), _height(0),
@@ -53,18 +53,18 @@ FT_Library _ft2Library;
5353
5454FT2Image::FT2Image (unsigned long width, unsigned long height) :
5555 _isDirty(true ),
56- _buffer(NULL ),
56+ _buffer(NULL ),
5757 _width(0 ), _height(0 ),
5858 _rgbCopy(NULL ),
5959 _rgbaCopy(NULL ) {
6060 _VERBOSE (" FT2Image::FT2Image" );
6161 resize (width, height);
6262}
6363
64- FT2Image::~FT2Image () {
64+ FT2Image::~FT2Image () {
6565 _VERBOSE (" FT2Image::~FT2Image" );
66- delete [] _buffer;
67- _buffer=NULL ;
66+ delete [] _buffer;
67+ _buffer=NULL ;
6868 delete _rgbCopy;
6969 delete _rgbaCopy;
7070}
@@ -151,7 +151,7 @@ FT2Image::py_write_bitmap(const Py::Tuple & args) {
151151}
152152
153153void
154- FT2Image::draw_rect (unsigned long x0, unsigned long y0,
154+ FT2Image::draw_rect (unsigned long x0, unsigned long y0,
155155 unsigned long x1, unsigned long y1) {
156156 if ( x0<0 || y0<0 || x1<0 || y1<0 ||
157157 x0>_width || x1>_width ||
@@ -195,7 +195,7 @@ FT2Image::py_draw_rect(const Py::Tuple & args) {
195195 return Py::Object ();
196196}
197197
198- void FT2Image::draw_rect_filled (unsigned long x0, unsigned long y0,
198+ void FT2Image::draw_rect_filled (unsigned long x0, unsigned long y0,
199199 unsigned long x1, unsigned long y1) {
200200 x0 = CLAMP (x0, 0 , _width);
201201 y0 = CLAMP (y0, 0 , _height);
@@ -209,7 +209,7 @@ void FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0,
209209 }
210210
211211 _isDirty = true ;
212- }
212+ }
213213
214214char FT2Image::draw_rect_filled__doc__[] =
215215" draw_rect_filled(x0, y0, x1, y1)\n "
@@ -245,7 +245,7 @@ FT2Image::py_as_str(const Py::Tuple & args) {
245245 args.verify_length (0 );
246246
247247 return Py::asObject
248- (PyString_FromStringAndSize ((const char *)_buffer,
248+ (PyString_FromStringAndSize ((const char *)_buffer,
249249 _width*_height)
250250 );
251251}
@@ -284,7 +284,7 @@ FT2Image::py_as_rgb_str(const Py::Tuple & args) {
284284 args.verify_length (0 );
285285
286286 makeRgbCopy ();
287-
287+
288288 return _rgbCopy->py_as_str (args);
289289}
290290
@@ -321,7 +321,7 @@ FT2Image::py_as_rgba_str(const Py::Tuple & args) {
321321 args.verify_length (0 );
322322
323323 makeRgbaCopy ();
324-
324+
325325 return _rgbaCopy->py_as_str (args);
326326}
327327
@@ -671,7 +671,7 @@ FT2Font::FT2Font(std::string facefile) :
671671 }
672672
673673 // set a default fontsize 12 pt at 72dpi
674- #ifdef VERTICAL_HINTING
674+ #ifdef VERTICAL_HINTING
675675 error = FT_Set_Char_Size ( face, 12 * 64 , 0 , 72 * HORIZ_HINTING, 72 );
676676 static FT_Matrix transform = { 65536 / HORIZ_HINTING, 0 , 0 , 65536 };
677677 FT_Set_Transform ( face, &transform, 0 );
@@ -829,7 +829,7 @@ FT2Font::set_size(const Py::Tuple & args) {
829829 int error = FT_Set_Char_Size ( face, (long )(ptsize * 64 ), 0 ,
830830 (unsigned int )dpi,
831831 (unsigned int )dpi );
832- #endif
832+ #endif
833833 if (error)
834834 throw Py::RuntimeError (" Could not set the fontsize" );
835835 return Py::Object ();
@@ -1036,7 +1036,6 @@ FT2Font::get_glyph(const Py::Tuple & args){
10361036 if ( (size_t )num >= gms.size ())
10371037 throw Py::ValueError (" Glyph index out of range" );
10381038
1039- Py_INCREF (gms[num]);
10401039 return Py::asObject (gms[num]);
10411040}
10421041
@@ -1078,7 +1077,7 @@ FT2Font::load_char(const Py::Tuple & args, const Py::Dict & kwargs) {
10781077 long charcode = Py::Long (args[0 ]), flags = Py::Long (FT_LOAD_FORCE_AUTOHINT);
10791078 if (kwargs.hasKey (" flags" ))
10801079 flags = Py::Long (kwargs[" flags" ]);
1081-
1080+
10821081 int error = FT_Load_Char ( face, (unsigned long )charcode, flags);
10831082
10841083 if (error)
@@ -1094,7 +1093,6 @@ FT2Font::load_char(const Py::Tuple & args, const Py::Dict & kwargs) {
10941093 glyphs.push_back (thisGlyph);
10951094 Glyph* gm = new Glyph (face, thisGlyph, num);
10961095 gms.push_back (gm);
1097- Py_INCREF (gm); // todo: refcount correct?
10981096 return Py::asObject ( gm);
10991097}
11001098
@@ -1659,7 +1657,7 @@ FT2Font::get_sfnt_table(const Py::Tuple & args) {
16591657 }
16601658}
16611659
1662- char FT2Font::get_image__doc__ [] =
1660+ char FT2Font::get_image__doc__ [] =
16631661 " get_image()\n "
16641662 " \n "
16651663 " Returns the underlying image buffer for this font object.\n " ;
@@ -1669,7 +1667,7 @@ FT2Font::get_image (const Py::Tuple &args) {
16691667 if (image) {
16701668 Py_XINCREF (image);
16711669 return Py::asObject (image);
1672- }
1670+ }
16731671 throw Py::RuntimeError (" You must call .set_text() before .get_image()" );
16741672}
16751673
@@ -1684,7 +1682,7 @@ FT2Font::attach_file (const Py::Tuple &args) {
16841682 args.verify_length (1 );
16851683
16861684 std::string filename = Py::String (args[0 ]);
1687- FT_Error error =
1685+ FT_Error error =
16881686 FT_Attach_File (face, filename.c_str ());
16891687
16901688 if (error) {
@@ -1884,7 +1882,7 @@ initft2font(void)
18841882 d[" KERNING_DEFAULT" ] = Py::Int (FT_KERNING_DEFAULT);
18851883 d[" KERNING_UNFITTED" ] = Py::Int (FT_KERNING_UNFITTED);
18861884 d[" KERNING_UNSCALED" ] = Py::Int (FT_KERNING_UNSCALED);
1887-
1885+
18881886 d[" LOAD_DEFAULT" ] = Py::Long (FT_LOAD_DEFAULT);
18891887 d[" LOAD_NO_SCALE" ] = Py::Long (FT_LOAD_NO_SCALE);
18901888 d[" LOAD_NO_HINTING" ] = Py::Long (FT_LOAD_NO_HINTING);
@@ -1894,7 +1892,7 @@ initft2font(void)
18941892 d[" LOAD_FORCE_AUTOHINT" ] = Py::Long (FT_LOAD_FORCE_AUTOHINT);
18951893 d[" LOAD_CROP_BITMAP" ] = Py::Long (FT_LOAD_CROP_BITMAP);
18961894 d[" LOAD_PEDANTIC" ] = Py::Long (FT_LOAD_PEDANTIC);
1897- d[" LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH" ] =
1895+ d[" LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH" ] =
18981896 Py::Long (FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);
18991897 d[" LOAD_NO_RECURSE" ] = Py::Long (FT_LOAD_NO_RECURSE);
19001898 d[" LOAD_IGNORE_TRANSFORM" ] = Py::Long (FT_LOAD_IGNORE_TRANSFORM);
0 commit comments