Font::Font(const String& filename, const String& order, uint32 x, uint32 y) { this->x = x; this->y = y; this->order = order; texture = new Texture(filename); float xStep = 1.0f / (float)x; float yStep = 1.0f / (float)y; for (uint32 yp = 0; yp < y; yp++) { for (uint32 xp = 0; xp < x; xp++) { float x0 = (float)xp * xStep; float x1 = x0 + xStep; float y0 = (float)yp * yStep; float y1 = y0 + yStep; charMap.addObject(CHAR_INFO(order[xp + yp * x], vec2(x0, y0), vec2(x1, y0), vec2(x1, y1), vec2(x0, y1))); // printf("%c", order[xp + yp * x]); } } }
boolean get_char_info (charcode_type code, char_type *c) { char_info_type *char_info = get_char (font_name, code); if (char_info == NULL) return false; CHAR_INFO (*c) = *char_info; return true; }
/* Calculate the sidebearings of C using the left sidebearing percentage and the character's displacement. */ void do_displacement (char_type *c) { int sidebearings_amount = sym_string_to_value (CHAR_DISPLACEMENT (*c)) - CHAR_BITMAP_WIDTH (CHAR_INFO (*c)); if (sidebearings_amount < 0) { WARNING1 ("Character %c displacement too small; \ setting sidebearings to 0", CHAR_CHARCODE (*c)); CHAR_LSB (*c) = 0; CHAR_RSB (*c) = 0; }