[cairo] [question] small texts rendering problem

Ebrahim Jahandar shankimout at yahoo.com
Wed Feb 24 08:30:19 PST 2010


Hi , i am new to cairo . i wrote a code for displaying some numbers around a circle using cairo APIs and SDL Backend on Win32 but i have a problem which is some numbers does nt render properly .

look this picture : http://img198.imageshack.us/img198/8144/filen.png this a native png output from cairo . as you see some numbers doesnt render properly . for example look at first circle from left , the number 9 & 3 does not render properly as it should .

i used a simple sin & cos & cairo_arc for placing them around a circle and then i used cairo_show_text . 

this is the code :
int NumberedSteps = 0;
            
            for(int i=0;i<=(Range/DegreSteps);i++){
                
                NumberedSteps++;
                
                if(NumberedSteps == NumberingSteps){
                    
                    NumberedSteps = 0;
                    int Number = i*DegreSteps/DegreStepsNumbers;
                    double degre = angleFromZero(anglePerDegre * i * DegreSteps);
                    
                    cairo_arc(StaticCr, SPosCX-4, SPosCY+4, Radius+17,
                        rad(angleFromZero(anglePerDegre * RangeMin)),
                        rad(angleFromZero(anglePerDegre * i*DegreSteps)+1)
                    );
                    
                    char szStr[4];
                    sprintf(szStr, "%i", Number);
                    
                    cairo_text_extents_t extents;
                    cairo_text_extents (StaticCr, szStr, &extents);
                    
                    double tCX,tCY;
                    cairo_get_current_point(StaticCr, &tCX, &tCY);
                    
                    cairo_move_to(StaticCr, 
                        tCX - ((extents.width/2)*(sin(rad(angleFromZero(degre)))/2)),
                        tCY - ((extents.height/2)*(cos(rad(angleFromZero(degre)))/2))
                    ) ;
                    cairo_set_source_rgba(StaticCr, 1, 1, 1, 1);
                    cairo_show_text (StaticCr, szStr);
                }
                
                
            }

the problem does not relate to cairo_arc and extents , i writed another program with only sin & cos for moving the pointer but the problem has been exists .

this problem happens when i use small fonts sizes , in big sizes there is no problem like this. 

so what can i do to solve this ?!

Regards.


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100224/4f17aa0f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file.png
Type: application/octet-stream
Size: 7144 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100224/4f17aa0f/attachment.obj>


More information about the cairo mailing list