XSetForeground(nedsim->dpy, nedsim->gc, temp.pixel);
}
-// TODO: Make this a lot faster.
-// Set font size to fill 'size' cells vertically, minus space for border and padding.
+// Set font size to fill 'size' cells vertically, minus space for border and
+// padding. There is probably a better way to do this. The current method is
+// horribly slow. Call this function as few times as possible.
static void
set_font_size(struct NEDsim * nedsim, int size)
{
const char * font_size_prefix = "-*-helvetica-*-r-*-*-";
const char * font_size_suffix = "-*-*-*-*-*-*-*";
- size_t buffer_size = strlen(font_size_prefix) + strlen(font_size_suffix) + 100; // '100' since nobody needs font with size in 'points' greater than 100 decimal digits long.
+ // In the buffer, we reserve 100 DIGITS for the font size integer.
+ size_t buffer_size = strlen(font_size_prefix) + strlen(font_size_suffix) + 100;
char * font_full_name = malloc(buffer_size);
- int font_size_in_points = 2; // Start with a 2 pt font and work our way up.
+ // Start with a 2pt font and work our way up.
+ int font_size_in_points = 2;
while (1) {
// Load the font.