You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
1
(10) |
2
(6) |
3
|
4
(10) |
5
(5) |
6
(5) |
7
(6) |
8
(2) |
9
(5) |
10
(7) |
11
(5) |
12
(8) |
13
(5) |
14
(7) |
15
(3) |
16
(1) |
17
(1) |
18
|
19
(1) |
20
(6) |
21
(6) |
22
(3) |
23
(3) |
24
(7) |
25
|
26
(5) |
27
(1) |
28
(3) |
29
(2) |
30
(3) |
|
|
|
Revision: 8438 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8438&view=rev Author: mdboom Date: 2010年06月15日 19:32:24 +0000 (2010年6月15日) Log Message: ----------- Fix out-of-buffer read errors. Modified Paths: -------------- trunk/matplotlib/ttconv/pprdrv_tt2.cpp Modified: trunk/matplotlib/ttconv/pprdrv_tt2.cpp =================================================================== --- trunk/matplotlib/ttconv/pprdrv_tt2.cpp 2010年06月15日 19:10:19 UTC (rev 8437) +++ trunk/matplotlib/ttconv/pprdrv_tt2.cpp 2010年06月15日 19:32:24 UTC (rev 8438) @@ -50,13 +50,13 @@ int advance_width; /* Variables to hold the character data. */ - int *epts_ctr; /* array of contour endpoints */ - int num_pts, num_ctr; /* number of points, number of coutours */ - FWord *xcoor, *ycoor; /* arrays of x and y coordinates */ - BYTE *tt_flags; /* array of TrueType flags */ + int *epts_ctr; /* array of contour endpoints */ + int num_pts, num_ctr; /* number of points, number of coutours */ + FWord *xcoor, *ycoor; /* arrays of x and y coordinates */ + BYTE *tt_flags; /* array of TrueType flags */ double *area_ctr; char *check_ctr; - int *ctrset; /* in contour index followed by out contour index */ + int *ctrset; /* in contour index followed by out contour index */ int stack_depth; /* A book-keeping variable for keeping track of the depth of the PS stack */ @@ -100,31 +100,31 @@ */ void GlyphToType3::stack(TTStreamWriter& stream, int new_elem) { - if( !pdf_mode && num_pts > 25 ) /* Only do something of we will */ - { /* have a log of points. */ - if(stack_depth == 0) - { - stream.put_char('{'); - stack_depth=1; - } + if( !pdf_mode && num_pts > 25 ) /* Only do something of we will */ + { /* have a log of points. */ + if(stack_depth == 0) + { + stream.put_char('{'); + stack_depth=1; + } - stack_depth += new_elem; /* Account for what we propose to add */ + stack_depth += new_elem; /* Account for what we propose to add */ - if(stack_depth > 100) - { - stream.puts("}_e{"); - stack_depth = 3 + new_elem; /* A rough estimate */ - } - } + if(stack_depth > 100) + { + stream.puts("}_e{"); + stack_depth = 3 + new_elem; /* A rough estimate */ + } + } } /* end of stack() */ -void GlyphToType3::stack_end(TTStreamWriter& stream) /* called at end */ +void GlyphToType3::stack_end(TTStreamWriter& stream) /* called at end */ { if( !pdf_mode && stack_depth ) - { - stream.puts("}_e"); - stack_depth=0; - } + { + stream.puts("}_e"); + stack_depth=0; + } } /* end of stack_end() */ /* @@ -163,79 +163,79 @@ area_ctr[0]=area(xcoor, ycoor, epts_ctr[0]+1); for (i=1; i<num_ctr; i++) - area_ctr[i]=area(xcoor+epts_ctr[i-1]+1, ycoor+epts_ctr[i-1]+1, epts_ctr[i]-epts_ctr[i-1]); + area_ctr[i]=area(xcoor+epts_ctr[i-1]+1, ycoor+epts_ctr[i-1]+1, epts_ctr[i]-epts_ctr[i-1]); for (i=0; i<num_ctr; i++) - { - if (area_ctr[i]>0) - { - ctrset[2*i]=i; ctrset[2*i+1]=nearout(i); - } - else - { - ctrset[2*i]=-1; ctrset[2*i+1]=-1; - } - } + { + if (area_ctr[i]>0) + { + ctrset[2*i]=i; ctrset[2*i+1]=nearout(i); + } + else + { + ctrset[2*i]=-1; ctrset[2*i+1]=-1; + } + } /* Step thru the coutours. */ /* I believe that a contour is a detatched */ /* set of curves and lines. */ i=j=k=0; while( i < num_ctr ) - { - fst = j = (k==0) ? 0 : (epts_ctr[k-1]+1); + { + fst = j = (k==0) ? 0 : (epts_ctr[k-1]+1); - /* Move to the first point on the contour. */ - stack(stream, 3); - PSMoveto(stream,xcoor[j],ycoor[j]); + /* Move to the first point on the contour. */ + stack(stream, 3); + PSMoveto(stream,xcoor[j],ycoor[j]); - start_offpt = 0; /* No off curve points yet. */ + start_offpt = 0; /* No off curve points yet. */ - /* Step thru the remaining points of this contour. */ - for(j++; j <= epts_ctr[k]; j++) - { - if (!(tt_flags[j]&1)) /* Off curve */ - { - if (!start_offpt) - { start_offpt = end_offpt = j; } - else - end_offpt++; - } - else - { /* On Curve */ - if (start_offpt) - { - stack(stream, 7); - PSCurveto(stream, xcoor[j],ycoor[j],start_offpt,end_offpt); - start_offpt = 0; - } - else - { + /* Step thru the remaining points of this contour. */ + for(j++; j <= epts_ctr[k]; j++) + { + if (!(tt_flags[j]&1)) /* Off curve */ + { + if (!start_offpt) + { start_offpt = end_offpt = j; } + else + end_offpt++; + } + else + { /* On Curve */ + if (start_offpt) + { + stack(stream, 7); + PSCurveto(stream, xcoor[j],ycoor[j],start_offpt,end_offpt); + start_offpt = 0; + } + else + { stack(stream, 3); - PSLineto(stream, xcoor[j], ycoor[j]); - } - } - } + PSLineto(stream, xcoor[j], ycoor[j]); + } + } + } - /* Do the final curve or line */ - /* of this coutour. */ - if (start_offpt) - { - stack(stream, 7); PSCurveto(stream, xcoor[fst],ycoor[fst],start_offpt,end_offpt); - } - else - { - stack(stream, 3); PSLineto(stream, xcoor[fst],ycoor[fst]); - } + /* Do the final curve or line */ + /* of this coutour. */ + if (start_offpt) + { + stack(stream, 7); PSCurveto(stream, xcoor[fst],ycoor[fst],start_offpt,end_offpt); + } + else + { + stack(stream, 3); PSLineto(stream, xcoor[fst],ycoor[fst]); + } - k=nextinctr(i,k); + k=nextinctr(i,k); - if (k==NOMOREINCTR) - i=k=nextoutctr(i); + if (k==NOMOREINCTR) + i=k=nextoutctr(i); - if (i==NOMOREOUTCTR) - break; - } + if (i==NOMOREOUTCTR) + break; + } /* Now, we can fill the whole thing. */ stack(stream, 1); @@ -251,98 +251,104 @@ } /* end of PSConvert() */ int GlyphToType3::nextoutctr(int co) - { - int j; + { + int j; - for(j=0; j<num_ctr; j++) - if (check_ctr[j]==0 && area_ctr[j] < 0) { - check_ctr[j]=1; - return j; - } + for(j=0; j<num_ctr; j++) + if (check_ctr[j]==0 && area_ctr[j] < 0) { + check_ctr[j]=1; + return j; + } - return NOMOREOUTCTR; - } /* end of nextoutctr() */ + return NOMOREOUTCTR; + } /* end of nextoutctr() */ int GlyphToType3::nextinctr(int co, int ci) - { - int j; + { + int j; - for(j=0; j<num_ctr; j++) + for(j=0; j<num_ctr; j++) if (ctrset[2*j+1]==co) if (check_ctr[ctrset[2*j]]==0) { - check_ctr[ctrset[2*j]]=1; - return ctrset[2*j]; - } + check_ctr[ctrset[2*j]]=1; + return ctrset[2*j]; + } - return NOMOREINCTR; - } + return NOMOREINCTR; + } /* ** find the nearest out contour to a specified in contour. */ int GlyphToType3::nearout(int ci) { - int k = 0; /* !!! is this right? */ + int k = 0; /* !!! is this right? */ int co; double a, a1=0; for (co=0; co < num_ctr; co++) - { - if(area_ctr[co] < 0) - { - a=intest(co,ci); - if (a<0 && a1==0) - { - k=co; - a1=a; - } - if(a<0 && a1!=0 && a>a1) - { - k=co; - a1=a; - } - } - } + { + if(area_ctr[co] < 0) + { + a=intest(co,ci); + if (a<0 && a1==0) + { + k=co; + a1=a; + } + if(a<0 && a1!=0 && a>a1) + { + k=co; + a1=a; + } + } + } return k; } /* end of nearout() */ double GlyphToType3::intest(int co, int ci) - { - int i, j, start, end; - double r1, r2, a; - FWord xi[3], yi[3]; + { + int i, j, start, end; + double r1, r2, a; + FWord xi[3], yi[3]; - j=start=(co==0)?0:(epts_ctr[co-1]+1); - end=epts_ctr[co]; - i=(ci==0)?0:(epts_ctr[ci-1]+1); - xi[0] = xcoor[i]; - yi[0] = ycoor[i]; - r1=sqr(xcoor[start] - xi[0]) + sqr(ycoor[start] - yi[0]); + j=start=(co==0)?0:(epts_ctr[co-1]+1); + end=epts_ctr[co]; + i=(ci==0)?0:(epts_ctr[ci-1]+1); + xi[0] = xcoor[i]; + yi[0] = ycoor[i]; + r1=sqr(xcoor[start] - xi[0]) + sqr(ycoor[start] - yi[0]); - for (i=start; i<=end; i++) { - r2 = sqr(xcoor[i] - xi[0])+sqr(ycoor[i] - yi[0]); - if (r2 < r1) { - r1=r2; j=i; - } - } - xi[1]=xcoor[j-1]; yi[1]=ycoor[j-1]; - xi[2]=xcoor[j+1]; yi[2]=ycoor[j+1]; - if (j==start) { xi[1]=xcoor[end]; yi[1]=ycoor[end]; } - if (j==end) { xi[2]=xcoor[start]; yi[2]=ycoor[start]; } - a=area(xi, yi, 3); + for (i=start; i<=end; i++) { + r2 = sqr(xcoor[i] - xi[0])+sqr(ycoor[i] - yi[0]); + if (r2 < r1) { + r1=r2; j=i; + } + } + if (j==start) { + xi[1]=xcoor[end]; yi[1]=ycoor[end]; + } else { + xi[1]=xcoor[j-1]; yi[1]=ycoor[j-1]; + } + if (j==end) { + xi[2]=xcoor[start]; yi[2]=ycoor[start]; + } else { + xi[2]=xcoor[j+1]; yi[2]=ycoor[j+1]; + } + a=area(xi, yi, 3); - return a; - } /* end of intest() */ + return a; + } /* end of intest() */ void GlyphToType3::PSMoveto(TTStreamWriter& stream, int x, int y) { stream.printf(pdf_mode ? "%d %d m\n" : "%d %d _m\n", - x, y); + x, y); } void GlyphToType3::PSLineto(TTStreamWriter& stream, int x, int y) { stream.printf(pdf_mode ? "%d %d l\n" : "%d %d _l\n", - x, y); + x, y); } /* @@ -355,26 +361,26 @@ N = t-s+2; for(i=0; i<N-1; i++) - { - sx[0] = i==0?xcoor[s-1]:(xcoor[i+s]+xcoor[i+s-1])/2; - sy[0] = i==0?ycoor[s-1]:(ycoor[i+s]+ycoor[i+s-1])/2; - sx[1] = xcoor[s+i]; - sy[1] = ycoor[s+i]; - sx[2] = i==N-2?x:(xcoor[s+i]+xcoor[s+i+1])/2; - sy[2] = i==N-2?y:(ycoor[s+i]+ycoor[s+i+1])/2; - cx[3] = sx[2]; - cy[3] = sy[2]; - cx[1] = (2*sx[1]+sx[0])/3; - cy[1] = (2*sy[1]+sy[0])/3; - cx[2] = (sx[2]+2*sx[1])/3; - cy[2] = (sy[2]+2*sy[1])/3; + { + sx[0] = i==0?xcoor[s-1]:(xcoor[i+s]+xcoor[i+s-1])/2; + sy[0] = i==0?ycoor[s-1]:(ycoor[i+s]+ycoor[i+s-1])/2; + sx[1] = xcoor[s+i]; + sy[1] = ycoor[s+i]; + sx[2] = i==N-2?x:(xcoor[s+i]+xcoor[s+i+1])/2; + sy[2] = i==N-2?y:(ycoor[s+i]+ycoor[s+i+1])/2; + cx[3] = sx[2]; + cy[3] = sy[2]; + cx[1] = (2*sx[1]+sx[0])/3; + cy[1] = (2*sy[1]+sy[0])/3; + cx[2] = (sx[2]+2*sx[1])/3; + cy[2] = (sy[2]+2*sy[1])/3; - stream.printf(pdf_mode ? - "%d %d %d %d %d %d c\n" : - "%d %d %d %d %d %d _c\n", - (int)cx[1], (int)cy[1], (int)cx[2], (int)cy[2], - (int)cx[3], (int)cy[3]); - } + stream.printf(pdf_mode ? + "%d %d %d %d %d %d c\n" : + "%d %d %d %d %d %d _c\n", + (int)cx[1], (int)cy[1], (int)cx[2], (int)cy[2], + (int)cx[3], (int)cy[3]); + } } /* end of PSCurveto() */ /* @@ -382,10 +388,10 @@ ** the data for the last simple glyph. */ GlyphToType3::~GlyphToType3() { - free(tt_flags); /* The flags array */ - free(xcoor); /* The X coordinates */ - free(ycoor); /* The Y coordinates */ - free(epts_ctr); /* The array of contour endpoints */ + free(tt_flags); /* The flags array */ + free(xcoor); /* The X coordinates */ + free(ycoor); /* The Y coordinates */ + free(epts_ctr); /* The array of contour endpoints */ // These last three should be NULL. Just // free'ing them for safety. free(area_ctr); @@ -406,10 +412,10 @@ /* Read the contour endpoints list. */ epts_ctr = (int *)calloc(num_ctr,sizeof(int)); for (x = 0; x < num_ctr; x++) - { - epts_ctr[x] = getUSHORT(glyph); - glyph += 2; - } + { + epts_ctr[x] = getUSHORT(glyph); + glyph += 2; + } /* From the endpoint of the last contour, we can */ /* determine the number of points. */ @@ -432,71 +438,71 @@ /* Read the flags array, uncompressing it as we go. */ /* There is danger of overflow here. */ for (x = 0; x < num_pts; ) - { - tt_flags[x++] = c = *(glyph++); + { + tt_flags[x++] = c = *(glyph++); - if (c&8) /* If next byte is repeat count, */ - { - ct = *(glyph++); + if (c&8) /* If next byte is repeat count, */ + { + ct = *(glyph++); - if( (x + ct) > num_pts ) - throw TTException("Error in TT flags"); + if( (x + ct) > num_pts ) + throw TTException("Error in TT flags"); - while (ct--) - tt_flags[x++] = c; - } - } + while (ct--) + tt_flags[x++] = c; + } + } /* Read the x coordinates */ for (x = 0; x < num_pts; x++) - { - if (tt_flags[x] & 2) /* one byte value with */ - { /* external sign */ - c = *(glyph++); - xcoor[x] = (tt_flags[x] & 0x10) ? c : (-1 * (int)c); - } - else if(tt_flags[x] & 0x10) /* repeat last */ - { - xcoor[x] = 0; - } - else /* two byte signed value */ - { - xcoor[x] = getFWord(glyph); - glyph+=2; - } - } + { + if (tt_flags[x] & 2) /* one byte value with */ + { /* external sign */ + c = *(glyph++); + xcoor[x] = (tt_flags[x] & 0x10) ? c : (-1 * (int)c); + } + else if(tt_flags[x] & 0x10) /* repeat last */ + { + xcoor[x] = 0; + } + else /* two byte signed value */ + { + xcoor[x] = getFWord(glyph); + glyph+=2; + } + } /* Read the y coordinates */ for(x = 0; x < num_pts; x++) - { - if (tt_flags[x] & 4) /* one byte value with */ - { /* external sign */ - c = *(glyph++); - ycoor[x] = (tt_flags[x] & 0x20) ? c : (-1 * (int)c); - } - else if (tt_flags[x] & 0x20) /* repeat last value */ - { - ycoor[x] = 0; - } - else /* two byte signed value */ - { - ycoor[x] = getUSHORT(glyph); - glyph+=2; - } - } + { + if (tt_flags[x] & 4) /* one byte value with */ + { /* external sign */ + c = *(glyph++); + ycoor[x] = (tt_flags[x] & 0x20) ? c : (-1 * (int)c); + } + else if (tt_flags[x] & 0x20) /* repeat last value */ + { + ycoor[x] = 0; + } + else /* two byte signed value */ + { + ycoor[x] = getUSHORT(glyph); + glyph+=2; + } + } /* Convert delta values to absolute values. */ for(x = 1; x < num_pts; x++) - { - xcoor[x] += xcoor[x-1]; - ycoor[x] += ycoor[x-1]; - } + { + xcoor[x] += xcoor[x-1]; + ycoor[x] += ycoor[x-1]; + } for(x=0; x < num_pts; x++) - { - xcoor[x] = topost(xcoor[x]); - ycoor[x] = topost(ycoor[x]); - } + { + xcoor[x] = topost(xcoor[x]); + ycoor[x] = topost(ycoor[x]); + } } /* end of load_char() */ @@ -515,101 +521,101 @@ USHORT scale10; /* Once around this loop for each component. */ - do { - flags = getUSHORT(glyph); /* read the flags word */ - glyph += 2; + do { + flags = getUSHORT(glyph); /* read the flags word */ + glyph += 2; - glyphIndex = getUSHORT(glyph); /* read the glyphindex word */ - glyph += 2; + glyphIndex = getUSHORT(glyph); /* read the glyphindex word */ + glyph += 2; - if(flags & ARG_1_AND_2_ARE_WORDS) - { /* The tt spec. seems to say these are signed. */ - arg1 = getSHORT(glyph); - glyph += 2; - arg2 = getSHORT(glyph); - glyph += 2; - } - else /* The tt spec. does not clearly indicate */ - { /* whether these values are signed or not. */ + if(flags & ARG_1_AND_2_ARE_WORDS) + { /* The tt spec. seems to say these are signed. */ + arg1 = getSHORT(glyph); + glyph += 2; + arg2 = getSHORT(glyph); + glyph += 2; + } + else /* The tt spec. does not clearly indicate */ + { /* whether these values are signed or not. */ arg1 = *(signed char *)(glyph++); arg2 = *(signed char *)(glyph++); - } + } - if(flags & WE_HAVE_A_SCALE) - { - xscale = yscale = getUSHORT(glyph); - glyph += 2; - scale01 = scale10 = 0; - } - else if(flags & WE_HAVE_AN_X_AND_Y_SCALE) - { - xscale = getUSHORT(glyph); - glyph += 2; - yscale = getUSHORT(glyph); - glyph += 2; - scale01 = scale10 = 0; - } - else if(flags & WE_HAVE_A_TWO_BY_TWO) - { - xscale = getUSHORT(glyph); - glyph += 2; - scale01 = getUSHORT(glyph); - glyph += 2; - scale10 = getUSHORT(glyph); - glyph += 2; - yscale = getUSHORT(glyph); - glyph += 2; - } - else - { - xscale = yscale = scale01 = scale10 = 0; - } + if(flags & WE_HAVE_A_SCALE) + { + xscale = yscale = getUSHORT(glyph); + glyph += 2; + scale01 = scale10 = 0; + } + else if(flags & WE_HAVE_AN_X_AND_Y_SCALE) + { + xscale = getUSHORT(glyph); + glyph += 2; + yscale = getUSHORT(glyph); + glyph += 2; + scale01 = scale10 = 0; + } + else if(flags & WE_HAVE_A_TWO_BY_TWO) + { + xscale = getUSHORT(glyph); + glyph += 2; + scale01 = getUSHORT(glyph); + glyph += 2; + scale10 = getUSHORT(glyph); + glyph += 2; + yscale = getUSHORT(glyph); + glyph += 2; + } + else + { + xscale = yscale = scale01 = scale10 = 0; + } - /* Debugging */ - #ifdef DEBUG_TRUETYPE - stream.printf("%% flags=%d, arg1=%d, arg2=%d, xscale=%d, yscale=%d, scale01=%d, scale10=%d\n", - (int)flags,arg1,arg2,(int)xscale,(int)yscale,(int)scale01,(int)scale10); - #endif + /* Debugging */ + #ifdef DEBUG_TRUETYPE + stream.printf("%% flags=%d, arg1=%d, arg2=%d, xscale=%d, yscale=%d, scale01=%d, scale10=%d\n", + (int)flags,arg1,arg2,(int)xscale,(int)yscale,(int)scale01,(int)scale10); + #endif - if (pdf_mode) { - if ( flags & ARGS_ARE_XY_VALUES ) { - /* We should have been able to use 'Do' to reference the - subglyph here. However, that doesn't seem to work with - xpdf or gs (only acrobat), so instead, this just includes - the subglyph here inline. */ - stream.printf("q 1 0 0 1 %d %d cm\n", topost(arg1), topost(arg2)); - } else { - stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2); - } - GlyphToType3(stream, font, glyphIndex, true); - if ( flags & ARGS_ARE_XY_VALUES ) { - stream.printf("\nQ\n"); - } - } else { - /* If we have an (X,Y) shif and it is non-zero, */ - /* translate the coordinate system. */ - if( flags & ARGS_ARE_XY_VALUES ) - { - if( arg1 != 0 || arg2 != 0 ) - stream.printf("gsave %d %d translate\n", topost(arg1), topost(arg2) ); - } - else - { - stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2); - } + if (pdf_mode) { + if ( flags & ARGS_ARE_XY_VALUES ) { + /* We should have been able to use 'Do' to reference the + subglyph here. However, that doesn't seem to work with + xpdf or gs (only acrobat), so instead, this just includes + the subglyph here inline. */ + stream.printf("q 1 0 0 1 %d %d cm\n", topost(arg1), topost(arg2)); + } else { + stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2); + } + GlyphToType3(stream, font, glyphIndex, true); + if ( flags & ARGS_ARE_XY_VALUES ) { + stream.printf("\nQ\n"); + } + } else { + /* If we have an (X,Y) shif and it is non-zero, */ + /* translate the coordinate system. */ + if( flags & ARGS_ARE_XY_VALUES ) + { + if( arg1 != 0 || arg2 != 0 ) + stream.printf("gsave %d %d translate\n", topost(arg1), topost(arg2) ); + } + else + { + stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2); + } - /* Invoke the CharStrings procedure to print the component. */ - stream.printf("false CharStrings /%s get exec\n", - ttfont_CharStrings_getname(font,glyphIndex)); + /* Invoke the CharStrings procedure to print the component. */ + stream.printf("false CharStrings /%s get exec\n", + ttfont_CharStrings_getname(font,glyphIndex)); - /* If we translated the coordinate system, */ - /* put it back the way it was. */ - if( flags & ARGS_ARE_XY_VALUES && (arg1 != 0 || arg2 != 0) ) { - stream.puts("grestore "); - } - } + /* If we translated the coordinate system, */ + /* put it back the way it was. */ + if( flags & ARGS_ARE_XY_VALUES && (arg1 != 0 || arg2 != 0) ) { + stream.puts("grestore "); + } + } - } while(flags & MORE_COMPONENTS); + } while(flags & MORE_COMPONENTS); } /* end of do_composite() */ @@ -623,24 +629,24 @@ /* Read the glyph offset from the index to location table. */ if(font->indexToLocFormat == 0) - { - off = getUSHORT( font->loca_table + (charindex * 2) ); - off *= 2; - length = getUSHORT( font->loca_table + ((charindex+1) * 2) ); - length *= 2; - length -= off; - } + { + off = getUSHORT( font->loca_table + (charindex * 2) ); + off *= 2; + length = getUSHORT( font->loca_table + ((charindex+1) * 2) ); + length *= 2; + length -= off; + } else - { - off = getULONG( font->loca_table + (charindex * 4) ); - length = getULONG( font->loca_table + ((charindex+1) * 4) ); - length -= off; - } + { + off = getULONG( font->loca_table + (charindex * 4) ); + length = getULONG( font->loca_table + ((charindex+1) * 4) ); + length -= off; + } if(length > 0) - return font->glyf_table + off; + return font->glyf_table + off; else - return (BYTE*)NULL; + return (BYTE*)NULL; } /* end of find_glyph_data() */ @@ -663,61 +669,61 @@ /* If the character is blank, it has no bounding box, */ /* otherwise read the bounding box. */ if( glyph == (BYTE*)NULL ) - { - llx=lly=urx=ury=0; /* A blank char has an all zero BoundingBox */ - num_ctr=0; /* Set this for later if()s */ - } + { + llx=lly=urx=ury=0; /* A blank char has an all zero BoundingBox */ + num_ctr=0; /* Set this for later if()s */ + } else - { - /* Read the number of contours. */ - num_ctr = getSHORT(glyph); + { + /* Read the number of contours. */ + num_ctr = getSHORT(glyph); - /* Read PostScript bounding box. */ - llx = getFWord(glyph + 2); - lly = getFWord(glyph + 4); - urx = getFWord(glyph + 6); - ury = getFWord(glyph + 8); + /* Read PostScript bounding box. */ + llx = getFWord(glyph + 2); + lly = getFWord(glyph + 4); + urx = getFWord(glyph + 6); + ury = getFWord(glyph + 8); - /* Advance the pointer. */ - glyph += 10; - } + /* Advance the pointer. */ + glyph += 10; + } /* If it is a simple character, load its data. */ if (num_ctr > 0) - load_char(font, glyph); + load_char(font, glyph); else num_pts=0; /* Consult the horizontal metrics table to determine */ /* the character width. */ if( charindex < font->numberOfHMetrics ) - advance_width = getuFWord( font->hmtx_table + (charindex * 4) ); + advance_width = getuFWord( font->hmtx_table + (charindex * 4) ); else - advance_width = getuFWord( font->hmtx_table + ((font->numberOfHMetrics-1) * 4) ); + advance_width = getuFWord( font->hmtx_table + ((font->numberOfHMetrics-1) * 4) ); /* Execute setcachedevice in order to inform the font machinery */ /* of the character bounding box and advance width. */ stack(stream, 7); if (pdf_mode) { - if (!embedded) - stream.printf("%d 0 %d %d %d %d d1\n", - topost(advance_width), - topost(llx), topost(lly), topost(urx), topost(ury) ); + if (!embedded) + stream.printf("%d 0 %d %d %d %d d1\n", + topost(advance_width), + topost(llx), topost(lly), topost(urx), topost(ury) ); } else - stream.printf("%d 0 %d %d %d %d _sc\n", - topost(advance_width), - topost(llx), topost(lly), topost(urx), topost(ury) ); + stream.printf("%d 0 %d %d %d %d _sc\n", + topost(advance_width), + topost(llx), topost(lly), topost(urx), topost(ury) ); /* If it is a simple glyph, convert it, */ /* otherwise, close the stack business. */ - if( num_ctr > 0 ) /* simple */ - { + if( num_ctr > 0 ) /* simple */ + { PSConvert(stream); - } - else if( num_ctr < 0 ) /* composite */ - { - do_composite(stream, font, glyph); - } + } + else if( num_ctr < 0 ) /* composite */ + { + do_composite(stream, font, glyph); + } stack_end(stream); } @@ -740,50 +746,50 @@ std::stack<int> glyph_stack; for (std::vector<int>::iterator i = glyph_ids.begin(); - i != glyph_ids.end(); ++i) { - glyph_stack.push(*i); + i != glyph_ids.end(); ++i) { + glyph_stack.push(*i); } while (glyph_stack.size()) { - int gind = glyph_stack.top(); - glyph_stack.pop(); + int gind = glyph_stack.top(); + glyph_stack.pop(); - BYTE* glyph = find_glyph_data( font, gind ); - if (glyph != (BYTE*)NULL) { + BYTE* glyph = find_glyph_data( font, gind ); + if (glyph != (BYTE*)NULL) { - int num_ctr = getSHORT(glyph); - if (num_ctr <= 0) { // This is a composite glyph + int num_ctr = getSHORT(glyph); + if (num_ctr <= 0) { // This is a composite glyph - glyph += 10; - USHORT flags = 0; + glyph += 10; + USHORT flags = 0; - do { - flags = getUSHORT(glyph); - glyph += 2; - gind = (int)getUSHORT(glyph); - glyph += 2; + do { + flags = getUSHORT(glyph); + glyph += 2; + gind = (int)getUSHORT(glyph); + glyph += 2; - std::vector<int>::iterator insertion = - std::lower_bound(glyph_ids.begin(), glyph_ids.end(), gind); - if (*insertion != gind) { - glyph_ids.insert(insertion, gind); - glyph_stack.push(gind); - } + std::vector<int>::iterator insertion = + std::lower_bound(glyph_ids.begin(), glyph_ids.end(), gind); + if (*insertion != gind) { + glyph_ids.insert(insertion, gind); + glyph_stack.push(gind); + } - if (flags & ARG_1_AND_2_ARE_WORDS) - glyph += 4; - else - glyph += 2; + if (flags & ARG_1_AND_2_ARE_WORDS) + glyph += 4; + else + glyph += 2; - if (flags & WE_HAVE_A_SCALE) - glyph += 2; - else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) - glyph += 4; - else if (flags & WE_HAVE_A_TWO_BY_TWO) - glyph += 8; - } while (flags & MORE_COMPONENTS); - } - } + if (flags & WE_HAVE_A_SCALE) + glyph += 2; + else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) + glyph += 4; + else if (flags & WE_HAVE_A_TWO_BY_TWO) + glyph += 8; + } while (flags & MORE_COMPONENTS); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8437 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8437&view=rev Author: mdboom Date: 2010年06月15日 19:10:19 +0000 (2010年6月15日) Log Message: ----------- Use the word "snapping" everywhere for consistency. This is the word used in the outward-facing interface all along. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/_backend_agg.h trunk/matplotlib/src/_macosx.m trunk/matplotlib/src/_path.cpp trunk/matplotlib/src/path_cleanup.cpp trunk/matplotlib/src/path_cleanup.h trunk/matplotlib/src/path_converters.h Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2010年06月15日 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/lib/matplotlib/path.py 2010年06月15日 19:10:19 UTC (rev 8437) @@ -188,7 +188,7 @@ return len(self.vertices) def iter_segments(self, transform=None, remove_nans=True, clip=None, - quantize=False, stroke_width=1.0, simplify=None, + snap=False, stroke_width=1.0, simplify=None, curves=True): """ Iterates over all of the curve segments in the path. Each @@ -208,11 +208,12 @@ *clip*: if not None, must be a four-tuple (x1, y1, x2, y2) defining a rectangle in which to clip the path. - *quantize*: if None, auto-quantize. If True, force quantize, - and if False, don't quantize. + *snap*: if None, auto-snap to pixels, to reduce + fuzziness of rectilinear lines. If True, force snapping, and + if False, don't snap. *stroke_width*: the width of the stroke being drawn. Needed - as a hint for the quantizer. + as a hint for the snapping algorithm. *simplify*: if True, perform simplification, to remove vertices that do not affect the appearance of the path. If @@ -236,7 +237,7 @@ STOP = self.STOP vertices, codes = cleanup_path(self, transform, remove_nans, clip, - quantize, stroke_width, simplify, curves) + snap, stroke_width, simplify, curves) len_vertices = len(vertices) i = 0 Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2010年06月15日 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/_backend_agg.cpp 2010年06月15日 19:10:19 UTC (rev 8437) @@ -270,11 +270,11 @@ Py::Callable method(method_obj); Py::Object py_snap = method.apply(Py::Tuple()); if (py_snap.isNone()) { - quantize_mode = QUANTIZE_AUTO; + snap_mode = SNAP_AUTO; } else if (py_snap.isTrue()) { - quantize_mode = QUANTIZE_TRUE; + snap_mode = SNAP_TRUE; } else { - quantize_mode = QUANTIZE_FALSE; + snap_mode = SNAP_FALSE; } } @@ -506,8 +506,8 @@ Py::Object RendererAgg::draw_markers(const Py::Tuple& args) { typedef agg::conv_transform<PathIterator> transformed_path_t; - typedef PathQuantizer<transformed_path_t> quantize_t; - typedef agg::conv_curve<quantize_t> curve_t; + typedef PathSnapper<transformed_path_t> snap_t; + typedef agg::conv_curve<snap_t> curve_t; typedef agg::conv_stroke<curve_t> stroke_t; typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; @@ -533,19 +533,19 @@ PathIterator marker_path(marker_path_obj); transformed_path_t marker_path_transformed(marker_path, marker_trans); - quantize_t marker_path_quantized(marker_path_transformed, - gc.quantize_mode, - marker_path.total_vertices(), - gc.linewidth); - curve_t marker_path_curve(marker_path_quantized); + snap_t marker_path_snapped(marker_path_transformed, + gc.snap_mode, + marker_path.total_vertices(), + gc.linewidth); + curve_t marker_path_curve(marker_path_snapped); PathIterator path(path_obj); transformed_path_t path_transformed(path, trans); - quantize_t path_quantized(path_transformed, - gc.quantize_mode, - path.total_vertices(), - 1.0); - curve_t path_curve(path_quantized); + snap_t path_snapped(path_transformed, + gc.snap_mode, + path.total_vertices(), + 1.0); + curve_t path_curve(path_snapped); path_curve.rewind(0); facepair_t face = _get_rgba_face(face_obj, gc.alpha); @@ -1079,8 +1079,8 @@ typedef agg::conv_transform<PathIterator> transformed_path_t; typedef PathNanRemover<transformed_path_t> nan_removed_t; typedef PathClipper<nan_removed_t> clipped_t; - typedef PathQuantizer<clipped_t> quantized_t; - typedef PathSimplifier<quantized_t> simplify_t; + typedef PathSnapper<clipped_t> snapped_t; + typedef PathSimplifier<snapped_t> simplify_t; typedef agg::conv_curve<simplify_t> curve_t; _VERBOSE("RendererAgg::draw_path"); @@ -1108,8 +1108,8 @@ transformed_path_t tpath(path, trans); nan_removed_t nan_removed(tpath, true, path.has_curves()); clipped_t clipped(nan_removed, clip, width, height); - quantized_t quantized(clipped, gc.quantize_mode, path.total_vertices(), gc.linewidth); - simplify_t simplified(quantized, simplify, path.simplify_threshold()); + snapped_t snapped(clipped, gc.snap_mode, path.total_vertices(), gc.linewidth); + simplify_t simplified(snapped, simplify, path.simplify_threshold()); curve_t curve(simplified); try { @@ -1141,8 +1141,8 @@ typedef agg::conv_transform<typename PathGenerator::path_iterator> transformed_path_t; typedef PathNanRemover<transformed_path_t> nan_removed_t; typedef PathClipper<nan_removed_t> clipped_t; - typedef PathQuantizer<clipped_t> quantized_t; - typedef agg::conv_curve<quantized_t> quantized_curve_t; + typedef PathSnapper<clipped_t> snapped_t; + typedef agg::conv_curve<snapped_t> snapped_curve_t; typedef agg::conv_curve<clipped_t> curve_t; PyArrayObject* offsets = NULL; @@ -1275,13 +1275,13 @@ transformed_path_t tpath(path, trans); nan_removed_t nan_removed(tpath, true, has_curves); clipped_t clipped(nan_removed, do_clip, width, height); - quantized_t quantized(clipped, gc.quantize_mode, - path.total_vertices(), gc.linewidth); + snapped_t snapped(clipped, gc.snap_mode, + path.total_vertices(), gc.linewidth); if (has_curves) { - quantized_curve_t curve(quantized); + snapped_curve_t curve(snapped); _draw_path(curve, has_clippath, face, gc); } else { - _draw_path(quantized, has_clippath, face, gc); + _draw_path(snapped, has_clippath, face, gc); } } else { gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); Modified: trunk/matplotlib/src/_backend_agg.h =================================================================== --- trunk/matplotlib/src/_backend_agg.h 2010年06月15日 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/_backend_agg.h 2010年06月15日 19:10:19 UTC (rev 8437) @@ -123,7 +123,7 @@ typedef std::vector<std::pair<double, double> > dash_t; double dashOffset; dash_t dashes; - e_quantize_mode quantize_mode; + e_snap_mode snap_mode; Py::Object hatchpath; Modified: trunk/matplotlib/src/_macosx.m =================================================================== --- trunk/matplotlib/src/_macosx.m 2010年06月15日 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/_macosx.m 2010年06月15日 19:10:19 UTC (rev 8437) @@ -288,7 +288,7 @@ 0, 0, rect, - QUANTIZE_FALSE, + SNAP_FALSE, 1.0, 0); Py_DECREF(transform); @@ -446,13 +446,13 @@ return p; } -static int _get_snap(GraphicsContext* self, enum e_quantize_mode* mode) +static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode) { PyObject* snap = PyObject_CallMethod((PyObject*)self, "get_snap", ""); if(!snap) return 0; - if(snap==Py_None) *mode = QUANTIZE_AUTO; - else if (PyBool_Check(snap)) *mode = QUANTIZE_TRUE; - else *mode = QUANTIZE_FALSE; + if(snap==Py_None) *mode = SNAP_AUTO; + else if (PyBool_Check(snap)) *mode = SNAP_TRUE; + else *mode = SNAP_FALSE; Py_DECREF(snap); return 1; } @@ -662,7 +662,7 @@ 0, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, 1.0, 0); Py_DECREF(transform); @@ -892,7 +892,7 @@ 1, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, linewidth, rgbFace == NULL); if (!iterator) @@ -970,7 +970,7 @@ 1, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, linewidth, 0); if (!iterator) @@ -1006,7 +1006,7 @@ CGMutablePathRef marker; void* iterator; double rect[4] = {0.0, 0.0, self->size.width, self->size.height}; - enum e_quantize_mode mode; + enum e_snap_mode mode; double xc, yc; unsigned code; @@ -1071,7 +1071,7 @@ 1, 1, rect, - QUANTIZE_TRUE, + SNAP_TRUE, 1.0, 0); if (!iterator) @@ -1225,7 +1225,7 @@ /* --------- Prepare some variables for the path iterator ------------- */ void* iterator; double rect[4] = {0.0, 0.0, self->size.width, self->size.height}; - enum e_quantize_mode mode; + enum e_snap_mode mode; ok = _get_snap(self, &mode); if (!ok) { @@ -1382,7 +1382,7 @@ 0, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, 1.0, 0); if (!iterator) @@ -1690,7 +1690,7 @@ 0, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, 1.0, 0); if (iterator) @@ -2676,7 +2676,7 @@ 0, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, 1.0, 0); if (iterator) Modified: trunk/matplotlib/src/_path.cpp =================================================================== --- trunk/matplotlib/src/_path.cpp 2010年06月15日 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/_path.cpp 2010年06月15日 19:10:19 UTC (rev 8437) @@ -55,7 +55,7 @@ add_varargs_method("convert_path_to_polygons", &_path_module::convert_path_to_polygons, "convert_path_to_polygons(path, trans, width, height)"); add_varargs_method("cleanup_path", &_path_module::cleanup_path, - "cleanup_path(path, trans, remove_nans, clip, quantize, simplify, curves)"); + "cleanup_path(path, trans, remove_nans, clip, snap, simplify, curves)"); initialize("Helper functions for paths"); } @@ -1228,22 +1228,22 @@ void _cleanup_path(PathIterator& path, const agg::trans_affine& trans, bool remove_nans, bool do_clip, const agg::rect_base<double>& rect, - e_quantize_mode quantize_mode, double stroke_width, + e_snap_mode snap_mode, double stroke_width, bool do_simplify, bool return_curves, std::vector<double>& vertices, std::vector<npy_uint8>& codes) { typedef agg::conv_transform<PathIterator> transformed_path_t; typedef PathNanRemover<transformed_path_t> nan_removal_t; typedef PathClipper<nan_removal_t> clipped_t; - typedef PathQuantizer<clipped_t> quantized_t; - typedef PathSimplifier<quantized_t> simplify_t; + typedef PathSnapper<clipped_t> snapped_t; + typedef PathSimplifier<snapped_t> simplify_t; typedef agg::conv_curve<simplify_t> curve_t; transformed_path_t tpath(path, trans); nan_removal_t nan_removed(tpath, remove_nans, path.has_curves()); clipped_t clipped(nan_removed, do_clip, rect); - quantized_t quantized(clipped, quantize_mode, path.total_vertices(), stroke_width); - simplify_t simplified(quantized, do_simplify, path.simplify_threshold()); + snapped_t snapped(clipped, snap_mode, path.total_vertices(), stroke_width); + simplify_t simplified(snapped, do_simplify, path.simplify_threshold()); vertices.reserve(path.total_vertices() * 2); codes.reserve(path.total_vertices()); @@ -1286,19 +1286,19 @@ do_clip = true; } - Py::Object quantize_obj = args[4]; - e_quantize_mode quantize_mode; - if (quantize_obj.isNone()) + Py::Object snap_obj = args[4]; + e_snap_mode snap_mode; + if (snap_obj.isNone()) { - quantize_mode = QUANTIZE_AUTO; + snap_mode = SNAP_AUTO; } - else if (quantize_obj.isTrue()) + else if (snap_obj.isTrue()) { - quantize_mode = QUANTIZE_TRUE; + snap_mode = SNAP_TRUE; } else { - quantize_mode = QUANTIZE_FALSE; + snap_mode = SNAP_FALSE; } double stroke_width = Py::Float(args[5]); @@ -1319,7 +1319,7 @@ std::vector<double> vertices; std::vector<npy_uint8> codes; - _cleanup_path(path, trans, remove_nans, do_clip, clip_rect, quantize_mode, + _cleanup_path(path, trans, remove_nans, do_clip, clip_rect, snap_mode, stroke_width, simplify, return_curves, vertices, codes); npy_intp length = codes.size(); Modified: trunk/matplotlib/src/path_cleanup.cpp =================================================================== --- trunk/matplotlib/src/path_cleanup.cpp 2010年06月15日 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/path_cleanup.cpp 2010年06月15日 19:10:19 UTC (rev 8437) @@ -12,8 +12,8 @@ typedef agg::conv_transform<PathIterator> transformed_path_t; typedef PathNanRemover<transformed_path_t> nan_removal_t; typedef PathClipper<nan_removal_t> clipped_t; - typedef PathQuantizer<clipped_t> quantized_t; - typedef PathSimplifier<quantized_t> simplify_t; + typedef PathSnapper<clipped_t> snapped_t; + typedef PathSimplifier<snapped_t> simplify_t; Py::Object m_path_obj; PathIterator m_path_iter; @@ -21,14 +21,14 @@ transformed_path_t m_transformed; nan_removal_t m_nan_removed; clipped_t m_clipped; - quantized_t m_quantized; + snapped_t m_snapped; simplify_t m_simplify; public: PathCleanupIterator(PyObject* path, agg::trans_affine trans, bool remove_nans, bool do_clip, const agg::rect_base<double>& rect, - e_quantize_mode quantize_mode, double stroke_width, + e_snap_mode snap_mode, double stroke_width, bool do_simplify) : m_path_obj(path, true), m_path_iter(m_path_obj), @@ -36,9 +36,9 @@ m_transformed(m_path_iter, m_transform), m_nan_removed(m_transformed, remove_nans, m_path_iter.has_curves()), m_clipped(m_nan_removed, do_clip, rect), - m_quantized(m_clipped, quantize_mode, m_path_iter.total_vertices(), - stroke_width), - m_simplify(m_quantized, do_simplify && m_path_iter.should_simplify(), + m_snapped(m_clipped, snap_mode, m_path_iter.total_vertices(), + stroke_width), + m_simplify(m_snapped, do_simplify && m_path_iter.should_simplify(), m_path_iter.simplify_threshold()) { Py_INCREF(path); @@ -55,7 +55,7 @@ void* get_path_iterator( PyObject* path, PyObject* trans, int remove_nans, int do_clip, - double rect[4], e_quantize_mode quantize_mode, double stroke_width, + double rect[4], e_snap_mode snap_mode, double stroke_width, int do_simplify) { agg::trans_affine agg_trans = py_to_agg_transformation_matrix(trans, false); @@ -63,7 +63,7 @@ PathCleanupIterator* pipeline = new PathCleanupIterator( path, agg_trans, remove_nans != 0, do_clip != 0, - clip_rect, quantize_mode, stroke_width, do_simplify != 0); + clip_rect, snap_mode, stroke_width, do_simplify != 0); return (void*)pipeline; } Modified: trunk/matplotlib/src/path_cleanup.h =================================================================== --- trunk/matplotlib/src/path_cleanup.h 2010年06月15日 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/path_cleanup.h 2010年06月15日 19:10:19 UTC (rev 8437) @@ -3,17 +3,17 @@ #include <Python.h> -enum e_quantize_mode +enum e_snap_mode { - QUANTIZE_AUTO, - QUANTIZE_FALSE, - QUANTIZE_TRUE + SNAP_AUTO, + SNAP_FALSE, + SNAP_TRUE }; void* get_path_iterator( PyObject* path, PyObject* trans, int remove_nans, int do_clip, - double rect[4], enum e_quantize_mode quantize_mode, double stroke_width, + double rect[4], enum e_snap_mode snap_mode, double stroke_width, int do_simplify); unsigned Modified: trunk/matplotlib/src/path_converters.h =================================================================== --- trunk/matplotlib/src/path_converters.h 2010年06月15日 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/path_converters.h 2010年06月15日 19:10:19 UTC (rev 8437) @@ -26,7 +26,7 @@ Agg where coordinates can not be larger than 24-bit signed integers. - 4. PathQuantizer: Rounds the path to the nearest center-pixels. + 4. PathSnapper: Rounds the path to the nearest center-pixels. This makes rectilinear curves look much better. 5. PathSimplifier: Removes line segments from highly dense paths @@ -361,36 +361,36 @@ }; /************************************************************ - PathQuantizer rounds vertices to their nearest center-pixels. This + PathSnapper rounds vertices to their nearest center-pixels. This makes rectilinear paths (rectangles, horizontal and vertical lines etc.) look much cleaner. */ -enum e_quantize_mode +enum e_snap_mode { - QUANTIZE_AUTO, - QUANTIZE_FALSE, - QUANTIZE_TRUE + SNAP_AUTO, + SNAP_FALSE, + SNAP_TRUE }; template<class VertexSource> -class PathQuantizer +class PathSnapper { private: VertexSource* m_source; - bool m_quantize; - double m_quantize_value; + bool m_snap; + double m_snap_value; - static bool should_quantize(VertexSource& path, - e_quantize_mode quantize_mode, - unsigned total_vertices) { + static bool should_snap(VertexSource& path, + e_snap_mode snap_mode, + unsigned total_vertices) { // If this contains only straight horizontal or vertical lines, it should be - // quantized to the nearest pixels + // snapped to the nearest pixels double x0, y0, x1, y1; unsigned code; - switch (quantize_mode) + switch (snap_mode) { - case QUANTIZE_AUTO: + case SNAP_AUTO: if (total_vertices > 1024) { return false; @@ -420,9 +420,9 @@ } return true; - case QUANTIZE_FALSE: + case SNAP_FALSE: return false; - case QUANTIZE_TRUE: + case SNAP_TRUE: return true; } @@ -431,21 +431,21 @@ public: /* - quantize_mode should be one of: - - QUANTIZE_AUTO: Examine the path to determine if it should be quantized - - QUANTIZE_TRUE: Force quantization - - QUANTIZE_FALSE: No quantization + snap_mode should be one of: + - SNAP_AUTO: Examine the path to determine if it should be snapped + - SNAP_TRUE: Force snapping + - SNAP_FALSE: No snapping */ - PathQuantizer(VertexSource& source, e_quantize_mode quantize_mode, + PathSnapper(VertexSource& source, e_snap_mode snap_mode, unsigned total_vertices=15, double stroke_width=0.0) : m_source(&source) { - m_quantize = should_quantize(source, quantize_mode, total_vertices); + m_snap = should_snap(source, snap_mode, total_vertices); - if (m_quantize) + if (m_snap) { - int odd_even = (int)mpl_round(stroke_width) % 2; - m_quantize_value = (odd_even) ? 0.5 : 0.0; + int is_odd = (int)mpl_round(stroke_width) % 2; + m_snap_value = (is_odd) ? 0.5 : 0.0; } source.rewind(0); @@ -460,17 +460,17 @@ { unsigned code; code = m_source->vertex(x, y); - if (m_quantize && agg::is_vertex(code)) - { - *x = mpl_round(*x) + m_quantize_value; - *y = mpl_round(*y) + m_quantize_value; + if (m_snap && agg::is_vertex(code)) + { + *x = mpl_round(*x) + m_snap_value; + *y = mpl_round(*y) + m_snap_value; } return code; } - inline bool is_quantizing() + inline bool is_snapping() { - return m_quantize; + return m_snap; } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8436 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8436&view=rev Author: mdboom Date: 2010年06月15日 13:01:22 +0000 (2010年6月15日) Log Message: ----------- Support the "Enter" key event in the Qt4 backend. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010年06月14日 05:51:06 UTC (rev 8435) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010年06月15日 13:01:22 UTC (rev 8436) @@ -129,6 +129,7 @@ keyvald = { QtCore.Qt.Key_Control : 'control', QtCore.Qt.Key_Shift : 'shift', QtCore.Qt.Key_Alt : 'alt', + QtCore.Qt.Key_Return : 'enter' } # left 1, middle 2, right 3 buttond = {1:1, 2:3, 4:2} @@ -314,16 +315,19 @@ self.window._destroying = False self.toolbar = self._get_toolbar(self.canvas, self.window) - self.window.addToolBar(self.toolbar) - QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"), - self.window.statusBar().showMessage) + if self.toolbar is not None: + self.window.addToolBar(self.toolbar) + QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"), + self.window.statusBar().showMessage) + tbs_height = self.toolbar.sizeHint().height() + else: + tbs_height = 0 # resize the main window so it will display the canvas with the # requested size: cs = canvas.sizeHint() - tbs = self.toolbar.sizeHint() sbs = self.window.statusBar().sizeHint() - self.window.resize(cs.width(), cs.height()+tbs.height()+sbs.height()) + self.window.resize(cs.width(), cs.height()+tbs_height+sbs.height()) self.window.setCentralWidget(self.canvas) @@ -335,7 +339,8 @@ def notify_axes_change( fig ): # This will be called whenever the current axes is changed - if self.toolbar != None: self.toolbar.update() + if self.toolbar is not None: + self.toolbar.update() self.canvas.figure.add_axobserver( notify_axes_change ) def _widgetclosed( self ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.