Any Way to Adjust Kerning When Drawing a Font?

Is there a way to draw a text font with kerning (the horizontal space between each letter) adjusted? I want to draw an outline around the font, but then the letters run into each other without being able to adjust kerning.
 
I don't see any easy way, and only ugly ones:
  • draw 5 lines of text: 4 lines in the outline color with an offset, left, right, top, down, then your text in the middle in regular color. Outline can overlap, but I don't imagine your main text would
  • draw each letter individually with a custom script to fetch the pixel to leave before next letter (yeah I know)
I hope some gamemaker heavyweight can help you out :)
 

RangerX

Member
Draw_text_ext() function lets you set the space between characters.

EDIT: hmm sorry, its the space between horizontal lines....
 

TheouAegis

Member
you can use a fixed width setup or you could try setting the width of the space character 32 - but i don't think that will work for kerning, and requires a sprite font anyway.
 

Tsa05

Member
Not home to test at the moment but I imagine this ought to do it...
Code:
// draw_text_kern(x,y,text,kern)
var tx, ty, txt, kern, ch,tox;
tx = argument[0];
ty = argument[1];
txt = argument[2];
kern = argument[3];
tox = tx;

for(var i=1;i<=string_length(text);i+=1){
     ch = string_char_at(txt,z);
     if(ch=="\n"){
          // Change \n to # if using older GM
          ty+=string_height("|");
          tx = tox;
     }else{
          draw_text(tx,ty,ch);
          tx+=string_width(ch);
          tx+=kern;
     }
}
 
Top