Custom Font. Keeping the font width same.

Posted by user338322 on Stack Overflow See other posts from Stack Overflow or by user338322
Published on 2010-05-13T08:32:16Z Indexed on 2010/05/13 8:34 UTC
Read the original article Hit count: 158

Filed under:
|

I am trying to draw a string using quartz 2d.

What i am doing is, i am drawing each letter of the string individually, because each letter has special attributes associated with it, by taking each letter into a new string.

The string gets printed, but the space between the letters is not uniform. It looks very ugly to read . I read someting about using custom fonts. But i have no Idea, if I can do it!! my code is here.

  • (void) drawRect : (CGRect)rect{ NSString *string=@"My Name Is Adam"; float j=0; const char *charStr=[string cStringUsingEncoding: NSASCIIStringEncoding];

    for(int i=0;i

    { NSString *str=[NSString stringWithFormat:@"%c",charStr[i]]; const char *s=[str cStringUsingEncoding:NSASCIIStringEncoding]; NSLog(@"%s",s);

      CGContextRef context=[self getMeContextRef];
      CGContextSetTextMatrix (context,CGAffineTransformMakeScale(1.0, -1.0)) ;
      CGContextSelectFont(context, "Arial", 24, kCGEncodingMacRoman);
     //CGContextSetCharacterSpacing (context, 10);
    
    
       CGContextSetRGBFillColor (context, 0,0,200, 1); 
       CGContextSetTextDrawingMode(context,kCGTextFill);
       CGContextShowTextAtPoint(context, 80+j,80,s,1);
       j=j+15;
    

    }

    } In the output 'My Name is Adam' gets printed but the space between the letters is not uniform.!! is there any way to make the space uniform!!!

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about iphone