SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

Revision: 3589
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3589&view=rev
Author: mdboom
Date: 2007年07月20日 07:15:29 -0700 (2007年7月20日)
Log Message:
-----------
Improve performance of inner loop and prevent segfaults with negative x or y in draw_bitmap.
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2007年07月20日 14:08:58 UTC (rev 3588)
+++ trunk/matplotlib/src/ft2font.cpp	2007年07月20日 14:15:29 UTC (rev 3589)
@@ -876,25 +876,28 @@
 return Py::Int(- bbox.yMin);;
 }
 
+#undef	CLAMP
+#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
+
 void
 FT2Font::draw_bitmap( FT_Bitmap* bitmap,
 		 FT_Int x,
 		 FT_Int y) {
 _VERBOSE("FT2Font::draw_bitmap");
 FT_Int i, j, p, q;
- FT_Int x_max = x + bitmap->width;
- FT_Int y_max = y + bitmap->rows;
-
 FT_Int width = (FT_Int)image.width;
 FT_Int height = (FT_Int)image.height;
- for ( i = x, p = 0; i < x_max; i++, p++ )
+
+ FT_Int x1 = CLAMP(x, 0, width);
+ FT_Int y1 = CLAMP(y, 0, height);
+ FT_Int x2 = CLAMP(x + bitmap->width, 0, width);
+ FT_Int y2 = CLAMP(y + bitmap->rows, 0, height);
+
+ for ( i = x1, p = 0; i < x2; ++i, ++p )
 {
- for ( j = y, q = 0; j < y_max; j++, q++ )
+ for ( j = y1, q = 0; j < y2; ++j, ++q )
 	{
-	 if ( i >= width || j >= height )
-	 continue;
-	 image.buffer[i + j*width] |= bitmap->buffer[p + q*bitmap->width];
-
+	 image.buffer[i + j*width] |= bitmap->buffer[p + q*bitmap->pitch];
 	}
 }
 }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月07日 17:40:06
Revision: 3681
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3681&view=rev
Author: mdboom
Date: 2007年08月07日 10:39:57 -0700 (2007年8月07日)
Log Message:
-----------
Fix bug with PDF non-math text
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2007年08月07日 15:29:25 UTC (rev 3680)
+++ trunk/matplotlib/src/ft2font.cpp	2007年08月07日 17:39:57 UTC (rev 3681)
@@ -56,7 +56,7 @@
 setattr("height", Py::Int( face->glyph->metrics.height) );
 setattr("horiBearingX", Py::Int( face->glyph->metrics.horiBearingX / HORIZ_HINTING) );
 setattr("horiBearingY", Py::Int( face->glyph->metrics.horiBearingY) );
- setattr("horiAdvance", Py::Int( face->glyph->metrics.horiAdvance / HORIZ_HINTING) );
+ setattr("horiAdvance", Py::Int( face->glyph->metrics.horiAdvance) );
 setattr("linearHoriAdvance", Py::Int( face->glyph->linearHoriAdvance / HORIZ_HINTING) );
 setattr("vertBearingX", Py::Int( face->glyph->metrics.vertBearingX) );
 
@@ -697,7 +697,7 @@
 FT_Vector delta;
 
 if (!FT_Get_Kerning( face, left, right, mode, &delta )) {
- return Py::Int(delta.x / HORIZ_HINTING);
+ return Py::Int(delta.x);
 }
 else {
 return Py::Int(0);
@@ -775,7 +775,7 @@
 FT_Vector delta;
 FT_Get_Kerning( face, previous, glyph_index,
 		 FT_KERNING_DEFAULT, &delta );
- pen.x += delta.x / HORIZ_HINTING;
+ pen.x += delta.x;
 }
 error = FT_Load_Glyph( face, glyph_index, flags );
 if ( error ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年08月07日 17:47:31
Revision: 3682
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3682&view=rev
Author: mdboom
Date: 2007年08月07日 10:47:30 -0700 (2007年8月07日)
Log Message:
-----------
Fix bug with SVG non-math text
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2007年08月07日 17:39:57 UTC (rev 3681)
+++ trunk/matplotlib/src/ft2font.cpp	2007年08月07日 17:47:30 UTC (rev 3682)
@@ -697,7 +697,7 @@
 FT_Vector delta;
 
 if (!FT_Get_Kerning( face, left, right, mode, &delta )) {
- return Py::Int(delta.x);
+ return Py::Int(delta.x / HORIZ_HINTING);
 }
 else {
 return Py::Int(0);
@@ -775,7 +775,7 @@
 FT_Vector delta;
 FT_Get_Kerning( face, previous, glyph_index,
 		 FT_KERNING_DEFAULT, &delta );
- pen.x += delta.x;
+ pen.x += delta.x / HORIZ_HINTING;
 }
 error = FT_Load_Glyph( face, glyph_index, flags );
 if ( error ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年09月05日 14:02:28
Revision: 3783
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3783&view=rev
Author: mdboom
Date: 2007年09月05日 07:02:22 -0700 (2007年9月05日)
Log Message:
-----------
Add a helpful comment.
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2007年09月05日 13:28:37 UTC (rev 3782)
+++ trunk/matplotlib/src/ft2font.cpp	2007年09月05日 14:02:22 UTC (rev 3783)
@@ -243,7 +243,10 @@
 _VERBOSE("FT2Image::as_str");
 args.verify_length(0);
 
- return Py::asObject(PyString_FromStringAndSize((const char *)_buffer, _width*_height));
+ return Py::asObject
+ (PyString_FromStringAndSize((const char *)_buffer, 
+				_width*_height)
+ );
 }
 
 void FT2Image::makeRgbCopy() {
@@ -298,6 +301,8 @@
 unsigned char *dst		= _rgbaCopy->_buffer;
 
 while (src != src_end) {
+ // We know the array has already been zero'ed out in
+ // the resize method, so we just skip over the r, g and b.
 dst += 3;
 *dst++ = *src++;
 }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年09月05日 14:46:19
Revision: 3785
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3785&view=rev
Author: mdboom
Date: 2007年09月05日 07:46:14 -0700 (2007年9月05日)
Log Message:
-----------
Fix segfault in FT2Font::clear()
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2007年09月05日 14:03:09 UTC (rev 3784)
+++ trunk/matplotlib/src/ft2font.cpp	2007年09月05日 14:46:14 UTC (rev 3785)
@@ -75,6 +75,7 @@
 if (width != _width || height != _height) {
 if (numBytes > _width*_height) {
 delete [] _buffer;
+ _buffer = NULL;
 _buffer = new unsigned char [numBytes];
 }
 
@@ -781,6 +782,7 @@
 args.verify_length(0);
 
 delete image;
+ image = NULL;
 
 angle = 0.0;
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年09月05日 15:47:40
Revision: 3790
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3790&view=rev
Author: mdboom
Date: 2007年09月05日 08:47:35 -0700 (2007年9月05日)
Log Message:
-----------
Fix some recent reference counting bugs in ft2font.cpp (Thanks to Paul Kienzle).
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2007年09月05日 15:28:21 UTC (rev 3789)
+++ trunk/matplotlib/src/ft2font.cpp	2007年09月05日 15:47:35 UTC (rev 3790)
@@ -743,8 +743,7 @@
 {
 _VERBOSE("FT2Font::~FT2Font");
 
- if(image)
- Py::_XDECREF(image);
+ Py_XDECREF(image);
 FT_Done_Face ( face );
 
 for (size_t i=0; i<glyphs.size(); i++) {
@@ -781,7 +780,7 @@
 _VERBOSE("FT2Font::clear");
 args.verify_length(0);
 
- delete image;
+ Py_XDECREF(image);
 image = NULL;
 
 angle = 0.0;
@@ -1037,7 +1036,7 @@
 if ( (size_t)num >= gms.size())
 throw Py::ValueError("Glyph index out of range");
 
- //todo: refcount?
+ Py_INCREF(gms[num]);
 return Py::asObject(gms[num]);
 }
 
@@ -1667,8 +1666,11 @@
 Py::Object
 FT2Font::get_image (const Py::Tuple &args) {
 args.verify_length(0);
- Py_INCREF(image);
- return Py::asObject(image);
+ if (image) {
+ Py_XINCREF(image);
+ return Py::asObject(image);
+ } 
+ throw Py::RuntimeError("You must call .set_text() before .get_image()");
 }
 
 char FT2Font::attach_file__doc__ [] =
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月29日 14:44:27
Revision: 4047
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4047&view=rev
Author: mdboom
Date: 2007年10月29日 07:44:18 -0700 (2007年10月29日)
Log Message:
-----------
Fixing bug in font rendering -- the patented freetype hinter appears
to be unable to deal with the non-square hinting grid hack. [Forgot
this file].
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2007年10月29日 14:30:51 UTC (rev 4046)
+++ trunk/matplotlib/src/ft2font.cpp	2007年10月29日 14:44:18 UTC (rev 4047)
@@ -943,7 +943,7 @@
 
 angle = angle/360.0*2*3.14159;
 
- long flags = FT_LOAD_DEFAULT;
+ long flags = FT_LOAD_FORCE_AUTOHINT;
 if (kwargs.hasKey("flags"))
 flags = Py::Long(kwargs["flags"]);
 
@@ -1054,7 +1054,7 @@
 }
 
 char FT2Font::load_char__doc__[] =
-"load_char(charcode, flags=LOAD_LOAD_DEFAULT)\n"
+"load_char(charcode, flags=LOAD_FORCE_AUTOHINT)\n"
 "\n"
 "Load character with charcode in current fontfile and set glyph.\n"
 "The flags argument can be a bitwise-or of the LOAD_XXX constants.\n"
@@ -1075,7 +1075,7 @@
 //load a char using the unsigned long charcode
 
 args.verify_length(1);
- long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_DEFAULT);
+ long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_FORCE_AUTOHINT);
 if (kwargs.hasKey("flags"))
 flags = Py::Long(kwargs["flags"]);
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年02月01日 18:03:12
Revision: 4923
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4923&view=rev
Author: mdboom
Date: 2008年02月01日 10:03:04 -0800 (2008年2月01日)
Log Message:
-----------
Backing out Glyph object leak fix, since it causes segfaults with PDF
backend. Will look into it further.
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2008年02月01日 18:02:14 UTC (rev 4922)
+++ trunk/matplotlib/src/ft2font.cpp	2008年02月01日 18:03:04 UTC (rev 4923)
@@ -1036,6 +1036,7 @@
 if ( (size_t)num >= gms.size())
 throw Py::ValueError("Glyph index out of range");
 
+ Py_INCREF(gms[num]);
 return Py::asObject(gms[num]);
 }
 
@@ -1093,6 +1094,7 @@
 glyphs.push_back(thisGlyph);
 Glyph* gm = new Glyph(face, thisGlyph, num);
 gms.push_back(gm);
+ Py_INCREF(gm);
 return Py::asObject( gm);
 }
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年06月12日 12:17:12
Revision: 5478
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5478&view=rev
Author: mdboom
Date: 2008年06月12日 05:17:07 -0700 (2008年6月12日)
Log Message:
-----------
Fix compiler warnings.
Modified Paths:
--------------
 trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2008年06月11日 18:35:01 UTC (rev 5477)
+++ trunk/matplotlib/src/ft2font.cpp	2008年06月12日 12:17:07 UTC (rev 5478)
@@ -74,15 +74,15 @@
 if (height < 0) height = 1;
 size_t numBytes = width*height;
 
- if (width != _width || height != _height) {
+ if ((unsigned long)width != _width || (unsigned long)height != _height) {
 if (numBytes > _width*_height) {
 delete [] _buffer;
 _buffer = NULL;
 _buffer = new unsigned char [numBytes];
 }
 
- _width = width;
- _height = height;
+ _width = (unsigned long)width;
+ _height = (unsigned long)height;
 }
 
 memset(_buffer, 0, numBytes);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
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.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /