x = 500; y = 500; string_val = "string"; draw_text(x, y, string_val); width = string_width(string_val); height = string_height(string_val); draw_rectangle(x, y, x + width, y + height, 1); I am trying to implement a dialogue with form controls, text, etc. I have been having problems centering text. The ended up stripping everything down to basics which is the code you see above. I have printed some text and drawn a box around it to figure out the boundary lines. Horizontally it's pixel perfect. Vertically there are gaps between the top and bottom of where the text meets the border. The code above should work perfectly, but it doesn't.