void roadmap_canvas_get_text_extents(const char *text, int size, int *width, int *ascent, int *descent, int *can_tilt) { static NOPH_Font_t font; static int _ascent; static int _descent; static int _last_size; #ifdef RIMAPI if( (!font)|| (_last_size !=size)) { _last_size = size; font = roadmap_canvas_getFont(size); _ascent = NOPH_Font_getAscent(font); _descent = NOPH_Font_getDescent(font);// - _ascent; } #else if (!font) { font = NOPH_Font_getFont(NOPH_Font_FACE_SYSTEM, NOPH_Font_STYLE_BOLD, NOPH_Font_SIZE_MEDIUM); NOPH_Graphics_setFont(graphicsBuffer, font); printf( "!!!!!!!!!!!!!!!!!!!!!!!!!!! font metrics: height:%d, base:%d\n", NOPH_Font_getHeight(font), NOPH_Font_getBaselinePosition(font)); _ascent = NOPH_Font_getBaselinePosition(font) + 3; _descent = _ascent - NOPH_Font_getHeight(font) - 3; } #endif *ascent = _ascent; *descent = _descent; #ifdef RIMAPI if (can_tilt) *can_tilt = 1; *width = NOPH_Font_getAdvance(font, text) + 3; #else if (can_tilt) *can_tilt = 0; *width = NOPH_Font_stringWidth(font, text) + 10; #endif }
static void cibyl_timer(void) { static int64_t msec; static int cycle_time = 42; // 42 int64_t m, dt; int tx, ty, tw = 0; if (input_mode_show_counter > 0) { input_mode_show_counter--; tw = NOPH_Font_stringWidth(font, input_mode_names[input_mode]); tx = 160 + x_corr; ty = 160 + y_corr; NOPH_Graphics_setColor_int(graphics, 0xffffffff); NOPH_Graphics_fillRect(graphics, tx - 40, ty, 40, 20); NOPH_Graphics_setColor_int(graphics, 0xffdd2222); input_mode_show_counter--; if (input_mode_show_counter > 0) { NOPH_Graphics_drawString(graphics, input_mode_names[input_mode], tx - tw, ty, NOPH_Graphics_TOP | NOPH_Graphics_LEFT); } NOPH_GameCanvas_flushGraphics_rect(canvas, tx - 40, ty, 40, 20); } play_sound(); m = NOPH_System_currentTimeMillis(); dt = m - msec; while (dt < cycle_time) { NOPH_Thread_sleep(cycle_time - dt); m = NOPH_System_currentTimeMillis(); dt = m - msec; } msec = m; }