diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c old mode 100644 new mode 100755 index ff95f6b..ffc487c --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -67,10 +67,12 @@ bool list_display_title(struct gui_synclist *list, enum screen_type screen); static bool draw_title(struct screen *display, struct gui_synclist *list) { const int screen = display->screen_type; + int oy; if (!list_display_title(list, screen)) return false; title_text[screen] = *(list->parent[screen]); - title_text[screen].height = font_get(title_text[screen].font)->height; + font_getstringsize(list->title, NULL, NULL, &oy, title_text[screen].font); + title_text[screen].height = font_get_linespace(font_get(title_text[screen].font), -1) + oy; if (list->title_icon != Icon_NOICON && global_settings.show_icons) { @@ -83,7 +85,7 @@ static bool draw_title(struct screen *display, struct gui_synclist *list) title_text[screen].x += title_icon.width; display->set_viewport(&title_icon); - screen_put_icon(display, 0, 0, list->title_icon); + screen_put_icon_with_offset(display, 0, 0, 0, oy, list->title_icon); } title_text[screen].drawmode = STYLE_DEFAULT; #ifdef HAVE_LCD_COLOR @@ -113,7 +115,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) #endif int item_offset; bool show_title; - line_height = font_get(parent->font)->height; + line_height = font_get_linespace(font_get(parent->font), -1); display->set_viewport(parent); display->clear_viewport(); display->stop_scroll(); @@ -181,8 +183,8 @@ void list_draw(struct screen *display, struct gui_synclist *list) display->set_viewport(&list_text[screen]); list_text[screen].drawmode = STYLE_DEFAULT; /* position the string at the correct offset place */ - int item_width,h; - display->getstringsize(entry_name, &item_width, &h); + int item_width,h,oy; + display->getstringsize(entry_name, &item_width, &h, &oy); item_offset = gui_list_get_item_offset(list, item_width, text_pos, display, &list_text[screen]); @@ -262,19 +264,22 @@ void list_draw(struct screen *display, struct gui_synclist *list) { display->set_viewport(&list_icons); screen_put_icon_with_offset(display, show_cursor?1:0, - (i-start),show_cursor?ICON_PADDING:0,0, + (i-start),show_cursor?ICON_PADDING:0, + oy + (h - line_height)/2, list->callback_get_item_icon(i, list->data)); if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { - screen_put_icon(display, 0, i-start, Icon_Cursor); + screen_put_icon_with_offset(display, 0, i-start, 0, + oy + (h - line_height)/2, Icon_Cursor); } } else if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { display->set_viewport(&list_icons); - screen_put_icon(display, 0, (i-start), Icon_Cursor); + screen_put_icon_with_offset(display, 0, (i-start), 0, + oy + (h - line_height)/2, Icon_Cursor); } } display->set_viewport(parent); @@ -317,7 +322,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) if (nb_lines < gui_list->nb_items) { int scrollbar_size = nb_lines* - font_get(gui_list->parent[screen]->font)->height; + font_get_linespace(font_get(gui_list->parent[screen]->font), -1); int actual_y = y - list_text[screen].y; int new_selection = (actual_y * gui_list->nb_items) @@ -355,7 +360,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) int line_height, actual_y; actual_y = y - list_text[screen].y; - line_height = font_get(gui_list->parent[screen]->font)->height; + line_height = font_get_linespace(font_get(gui_list->parent[screen]->font), -1); line = actual_y / line_height; /* Pressed below the list*/ diff --git a/apps/gui/buttonbar.c b/apps/gui/buttonbar.c index abf1800..6bf7f4a 100644 --- a/apps/gui/buttonbar.c +++ b/apps/gui/buttonbar.c @@ -72,7 +72,7 @@ static void gui_buttonbar_draw_button(struct gui_buttonbar * buttonbar, int num) display->fillrect(0, 0, button_width - 1, vp.height); if(buttonbar->caption[num][0] != 0) { - display->getstringsize(buttonbar->caption[num], &fw, &fh); + display->getstringsize(buttonbar->caption[num], &fw, &fh, NULL); display->putsxy((button_width - fw)/2, (vp.height-fh)/2, buttonbar->caption[num]); } diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c index 026ae82..b059355 100644 --- a/apps/gui/color_picker.c +++ b/apps/gui/color_picker.c @@ -176,14 +176,14 @@ static void draw_screen(struct screen *display, char *title, { buf[0] = str(LANG_COLOR_RGB_LABELS)[i]; buf[1] = '\0'; - x = display->getstringsize(buf, NULL, NULL); + x = display->getstringsize(buf, NULL, NULL, NULL); if (x > max_label_width) max_label_width = x; } /* Draw title string */ set_drawinfo(display, DRMODE_SOLID, text_color, background_color); - display->getstringsize(title, &x, &y); + display->getstringsize(title, &x, &y, NULL); display->putsxy((vp.width - x) / 2, MARGIN_TOP, title); /* Get slider positions and top starting position */ @@ -297,7 +297,7 @@ static void draw_screen(struct screen *display, char *title, /* Draw RGB: #rrggbb in middle of swatch */ display->set_drawmode(DRMODE_FG); - display->getstringsize(buf, &x, &y); + display->getstringsize(buf, &x, &y, NULL); display->set_foreground(get_black_or_white(rgb)); x = left + (width - x) / 2; @@ -314,7 +314,7 @@ static void draw_screen(struct screen *display, char *title, else { /* Display RGB value only centered on remaining display if room */ - display->getstringsize(buf, &x, &y); + display->getstringsize(buf, &x, &y, NULL); i = text_top + SWATCH_TOP_MARGIN; if (i + y <= display->getheight() - MARGIN_BOTTOM) @@ -356,7 +356,7 @@ static int touchscreen_slider(struct rgb_pick *rgb, int *selected_slider) { buf[0] = str(LANG_COLOR_RGB_LABELS)[i]; buf[1] = '\0'; - x1 = display->getstringsize(buf, NULL, NULL); + x1 = display->getstringsize(buf, NULL, NULL, NULL); if (x1 > max_label_width) max_label_width = x1; } diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index b43c357..1d2afa4 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -482,7 +482,7 @@ static void draw_progressbar(struct gui_wps *gwps, if (y < 0) { - int line_height = font_get(wps_vp->vp.font)->height; + int line_height = font_get_linespace(font_get(wps_vp->vp.font), -1); /* center the pb in the line, but only if the line is higher than the pb */ int center = (line_height-pb->height)/2; /* if Y was not set calculate by font height,Y is -line_number-1 */ @@ -1796,20 +1796,20 @@ static void write_line(struct screen *display, int scroll_width; /* calculate different string sizes and positions */ - display->getstringsize((unsigned char *)" ", &space_width, &string_height); + display->getstringsize((unsigned char *)" ", &space_width, &string_height, NULL); if (format_align->left != 0) { display->getstringsize((unsigned char *)format_align->left, - &left_width, &string_height); + &left_width, &string_height, NULL); } if (format_align->right != 0) { display->getstringsize((unsigned char *)format_align->right, - &right_width, &string_height); + &right_width, &string_height, NULL); } if (format_align->center != 0) { display->getstringsize((unsigned char *)format_align->center, - ¢er_width, &string_height); + ¢er_width, &string_height, NULL); } left_xpos = 0; @@ -2075,7 +2075,7 @@ bool gui_wps_refresh(struct gui_wps *gwps, /* the peakmeter should be alone on its line */ update_line = false; - int h = font_get(wps_vp->vp.font)->height; + int h = font_get_linespace(font_get(wps_vp->vp.font), -1); int peak_meter_y = (line - wps_vp->first_line)* h; /* The user might decide to have the peak meter in the last diff --git a/apps/gui/icon.c b/apps/gui/icon.c old mode 100644 new mode 100755 index 3e1e793..b5a3d66 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c @@ -101,14 +101,12 @@ void screen_put_icon_with_offset(struct screen * display, enum themable_icons icon) { int xpos, ypos; - int width, height; + int ls = display->get_linespace(-1); int screen = display->screen_type; - display->getstringsize((unsigned char *)"M", &width, &height); xpos = x*ICON_WIDTH(screen) + off_x; - ypos = y*height + off_y; - - if ( height > ICON_HEIGHT(screen) )/* center the cursor */ - ypos += (height - ICON_HEIGHT(screen)) / 2; + ypos = y*ls + off_y; + if ( ls > ICON_HEIGHT(screen) )/* center the cursor */ + ypos += (ls - ICON_HEIGHT(screen)) / 2; screen_put_iconxy(display, xpos, ypos, icon); } diff --git a/apps/gui/list.c b/apps/gui/list.c index 8df0a29..e21be79 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -250,7 +250,7 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list, struct viewport vp = *gui_list->parent[screen]; #ifdef HAVE_LCD_BITMAP if (list_display_title(gui_list, screen)) - vp.height -= font_get(gui_list->parent[screen]->font)->height; + vp.height -= font_get_linespace(font_get(gui_list->parent[screen]->font), -1); #endif nb_lines = viewport_get_nb_lines(&vp); @@ -351,7 +351,7 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list, struct viewport vp = *gui_list->parent[i]; #ifdef HAVE_LCD_BITMAP if (list_display_title(gui_list, i)) - vp.height -= font_get(gui_list->parent[i]->font)->height; + vp.height -= font_get_linespace(font_get(gui_list->parent[i]->font), -1); #endif nb_lines = viewport_get_nb_lines(&vp); if (offset > 0) @@ -431,7 +431,7 @@ void gui_synclist_set_title(struct gui_synclist * gui_list, #ifdef HAVE_LCD_BITMAP int i; FOR_NB_SCREENS(i) - screens[i].getstringsize(title, &gui_list->title_width, NULL); + screens[i].getstringsize(title, &gui_list->title_width, NULL, NULL); #else gui_list->title_width = strlen(title); #endif @@ -791,7 +791,7 @@ bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, struct viewport vp = *lists->parent[screen]; #ifdef HAVE_LCD_BITMAP if (list_display_title(lists, screen)) - vp.height -= font_get(lists->parent[screen]->font)->height; + vp.height -= font_get_linespace(font_get(lists->parent[screen]->font), -1); #endif return item <= (lists->start_item[screen] + viewport_get_nb_lines(&vp)); } diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c old mode 100644 new mode 100755 index db50a5d..afb0e2f --- a/apps/gui/pitchscreen.c +++ b/apps/gui/pitchscreen.c @@ -62,7 +62,7 @@ static void pitchscreen_fix_viewports(struct viewport *parent, struct viewport pitch_viewports[PITCH_ITEM_COUNT]) { int i, height; - height = font_get(parent->font)->height; + height = font_get_linespace(font_get(parent->font), -1); for (i = 0; i < PITCH_ITEM_COUNT; i++) { pitch_viewports[i] = *parent; @@ -118,7 +118,7 @@ static void pitchscreen_draw (struct screen *display, int max_lines, } else { ptr = str(LANG_PITCH_UP_SEMITONE); } - display->getstringsize(ptr,&w,&h); + display->getstringsize(ptr,&w, NULL, NULL); display->clear_viewport(); /* draw text */ display->putsxy((pitch_viewports[PITCH_TOP].width / 2) - @@ -132,7 +132,7 @@ static void pitchscreen_draw (struct screen *display, int max_lines, } else { ptr = str(LANG_PITCH_DOWN_SEMITONE); } - display->getstringsize(ptr,&w,&h); + display->getstringsize(ptr,&w, NULL, NULL); display->clear_viewport(); /* draw text */ display->putsxy((pitch_viewports[PITCH_BOTTOM].width / 2) - @@ -142,7 +142,7 @@ static void pitchscreen_draw (struct screen *display, int max_lines, display->set_viewport(&pitch_viewports[PITCH_MID]); snprintf((char *)buf, sizeof(buf), "%s", str(LANG_PITCH)); - display->getstringsize(buf,&w,&h); + display->getstringsize(buf,&w, NULL, NULL); /* lets hide LANG_PITCH for smaller screens */ display->clear_viewport(); if ((show_lang_pitch = (max_lines >= 3))) @@ -152,7 +152,7 @@ static void pitchscreen_draw (struct screen *display, int max_lines, /* "XXX.X%" */ snprintf((char *)buf, sizeof(buf), "%d.%d%%", pitch / 10, pitch % 10 ); - display->getstringsize(buf,&width_val,&h); + display->getstringsize(buf,&width_val,&h, NULL); display->putsxy((pitch_viewports[PITCH_MID].width / 2) - (width_val / 2), (show_lang_pitch? h : h/2), buf); @@ -164,7 +164,7 @@ static void pitchscreen_draw (struct screen *display, int max_lines, /* Let's treat '+' and '-' as equally wide * This saves a getstringsize call * Also, it wouldn't look nice if -2% shows up, but +2% not */ - display->getstringsize("+2%",&width_val,&h); + display->getstringsize("+2%",&width_val,&h, NULL); w += width_val*2; /* hide +2%/-2% for a narrow screens */ if (w <= pitch_viewports[PITCH_MID].width) diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index b39105d..b1d582f 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -87,9 +87,9 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, /* adjust the left/right items widths to fit the screen nicely */ s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id)); - left_width = display->getstringsize(s, NULL, NULL); + left_width = display->getstringsize(s, NULL, NULL, NULL); s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id)); - right_width = display->getstringsize(s, NULL, NULL); + right_width = display->getstringsize(s, NULL, NULL, NULL); nb_lines -= bottom_lines; width = MAX(left_width, right_width); @@ -145,8 +145,8 @@ static void quickscreen_draw_text(char *s, int item, bool title, struct screen *display, struct viewport *vp) { int nb_lines = viewport_get_nb_lines(vp); - int w, h, line = 0, x = 0; - display->getstringsize(s, &w, &h); + int w, line = 0, x = 0; + display->getstringsize(s, &w, NULL, NULL); if (nb_lines > 1 && !title) line = 1; @@ -165,7 +165,7 @@ static void quickscreen_draw_text(char *s, int item, bool title, if (w>vp->width) display->puts_scroll(0, line, s); else - display->putsxy(x, line*h, s); + display->putsxy(x, line*(display->get_linespace(-1)), s); } static void gui_quickscreen_draw(struct gui_quickscreen *qs, diff --git a/apps/gui/splash.c b/apps/gui/splash.c old mode 100644 new mode 100755 index 034e4a5..9aac4a6 --- a/apps/gui/splash.c +++ b/apps/gui/splash.c @@ -57,20 +57,21 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap) int line = 0; int x = 0; int y, i; - int space_w, w, h; + int space_w, w, ls, oy; #ifdef HAVE_LCD_BITMAP int maxw = 0; #if LCD_DEPTH > 1 unsigned prevfg = 0; #endif - screen->getstringsize(" ", &space_w, &h); + screen->getstringsize(" ", &space_w, NULL, NULL); + ls = screen->get_linespace(-1); #else /* HAVE_LCD_CHARCELLS */ - space_w = h = 1; + space_w = ls = 1; screen->double_height (false); #endif - y = h; + y = ls; vsnprintf(splash_buf, sizeof(splash_buf), fmt, ap); va_end(ap); @@ -85,7 +86,8 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap) while (true) { #ifdef HAVE_LCD_BITMAP - screen->getstringsize(next, &w, NULL); + screen->getstringsize(next, &w, NULL, &oy); + y += oy; #else w = utf8length(next); #endif @@ -98,10 +100,10 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap) if (x > maxw) maxw = x; #endif - if ((y + h > screen->lcdheight) || (line >= (MAXLINES-1))) + if ((y + ls > screen->lcdheight) || (line >= (MAXLINES-1))) break; /* screen full or out of lines */ x = 0; - y += h; + y += ls; lines[++line] = next; } else @@ -174,7 +176,7 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap) #else screen->puts(x, y, lines[i]); #endif - y += h; + y += ls; } #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH > 1) diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index d420b96..e22cd25 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -422,7 +422,7 @@ static void gui_statusbar_icon_battery(struct screen * display, int percent, /* Numeric display */ display->setfont(FONT_SYSFIXED); snprintf(buffer, sizeof(buffer), "%3d", percent); - display->getstringsize(buffer, &width, &height); + display->getstringsize(buffer, &width, &height, NULL); if (height <= STATUSBAR_HEIGHT) display->putsxy(STATUSBAR_BATTERY_X_POS + STATUSBAR_BATTERY_WIDTH / 2 @@ -504,7 +504,7 @@ static bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume) { display->setfont(FONT_SYSFIXED); snprintf(buffer, sizeof(buffer), "%2d", volume); - display->getstringsize(buffer, &width, &height); + display->getstringsize(buffer, &width, &height, NULL); if (height <= STATUSBAR_HEIGHT) { display->putsxy(STATUSBAR_VOLUME_X_POS @@ -616,7 +616,7 @@ static void gui_statusbar_time(struct screen * display, struct tm *time) strncpy(buffer, "--:--", sizeof buffer); } display->setfont(FONT_SYSFIXED); - display->getstringsize(buffer, &width, &height); + display->getstringsize(buffer, &width, &height, NULL); if (height <= STATUSBAR_HEIGHT) { display->putsxy(STATUSBAR_TIME_X_END(display->getwidth()) - width, STATUSBAR_Y_POS, buffer); @@ -739,7 +739,7 @@ static void gui_statusbar_icon_recording_info(struct screen * display) 5, STATUSBAR_HEIGHT); snprintf(buffer, sizeof(buffer), "%d", global_settings.rec_quality); - display->getstringsize(buffer, &width, &height); + display->getstringsize(buffer, &width, &height, NULL); if (height <= STATUSBAR_HEIGHT) display->putsxy(STATUSBAR_ENCODER_X_POS + 13, STATUSBAR_Y_POS, buffer); #endif /* CONFIG_CODEC == SWCODEC */ @@ -765,7 +765,7 @@ static void gui_statusbar_icon_recording_info(struct screen * display) sizeof(buffer)); } - display->getstringsize(buffer, &width, &height); + display->getstringsize(buffer, &width, &height, NULL); if (height <= STATUSBAR_HEIGHT) display->putsxy(STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS, buffer); diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index 480c37a..3f3a782 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -40,7 +40,7 @@ static int statusbar_enabled = 0; int viewport_get_nb_lines(struct viewport *vp) { #ifdef HAVE_LCD_BITMAP - return vp->height/font_get(vp->font)->height; + return vp->height/font_get_linespace(font_get(vp->font), -1); #else (void)vp; return 2; diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index ba2e217..028d98f 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -871,7 +871,7 @@ static int parse_progressbar(const char *wps_bufptr, struct progressbar *pb; struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp; #ifndef __PCTOOL__ - int font_height = font_get(vp->font)->height; + int font_height = font_get_linespace(font_get(vp->font), -1); #else int font_height = 8; #endif diff --git a/apps/lang/english.lang b/apps/lang/english.lang old mode 100644 new mode 100755 index 6827257..b84a798 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -12418,3 +12418,59 @@ speaker: "Enable Speaker" + + id: LANG_LINE_SPACE_MENU + desc: line space menu + user: core + + *: "Line Space" + + + *: "Line Space" + + + *: "line space" + + + + id: LANG_LINE_SPACE_WIDE + desc: line space: wide mode + user: core + + *: "Wide" + + + *: "Wide" + + + *: "wide" + + + + id: LANG_LINE_SPACE_MIDDLE + desc: line space: middle mode + user: core + + *: "Middle" + + + *: "Middle" + + + *: "middle" + + + + id: LANG_LINE_SPACE_NARROW + desc: line space: narrow mode + user: core + + *: "Narrow" + + + *: "Narrow" + + + *: "narrow" + + diff --git a/apps/logfdisp.c b/apps/logfdisp.c index d55b3ba..1eb641d 100644 --- a/apps/logfdisp.c +++ b/apps/logfdisp.c @@ -38,7 +38,7 @@ bool logfdisplay(void) { - int w, h; + int w; int lines; int columns; int i; @@ -46,14 +46,14 @@ bool logfdisplay(void) bool lcd = false; /* fixed atm */ int index; - lcd_getstringsize("A", &w, &h); + lcd_getstringsize("A", &w, NULL, NULL); lines = (lcd? #ifdef HAVE_REMOTE_LCD LCD_REMOTE_HEIGHT #else 0 #endif - :LCD_HEIGHT)/h; + :LCD_HEIGHT)/lcd_get_linespace(-1); columns = (lcd? #ifdef HAVE_REMOTE_LCD LCD_REMOTE_WIDTH diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c index d70cf37..23b663b 100644 --- a/apps/menus/display_menu.c +++ b/apps/menus/display_menu.c @@ -496,6 +496,9 @@ MAKE_MENU(peak_meter_menu, ID2P(LANG_PM_MENU), NULL, Icon_NOICON, MENUITEM_SETTING(codepage_setting, &global_settings.default_codepage, NULL); +#ifdef HAVE_LCD_BITMAP +MENUITEM_SETTING(linespace_setting, &global_settings.linespace, NULL); +#endif MAKE_MENU(display_menu, ID2P(LANG_DISPLAY), NULL, Icon_Display_menu, @@ -508,4 +511,7 @@ MAKE_MENU(display_menu, ID2P(LANG_DISPLAY), &bars_menu, &peak_meter_menu, #endif &codepage_setting, +#ifdef HAVE_LCD_BITMAP + &linespace_setting, +#endif ); diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c index 1b38681..4d46b06 100644 --- a/apps/menus/eq_menu.c +++ b/apps/menus/eq_menu.c @@ -281,17 +281,17 @@ static int draw_eq_slider(struct screen * screen, int x, int y, /* Print out the band label */ if (band == 0) { screen->putsxy(x1, y1, "LS: "); - screen->getstringsize("LS:", &w, &h); + screen->getstringsize("LS:", &w, &h, NULL); } else if (band == 4) { screen->putsxy(x1, y1, "HS: "); - screen->getstringsize("HS:", &w, &h); + screen->getstringsize("HS:", &w, &h, NULL); } else { snprintf(buf, sizeof(buf), "PK%d:", band); screen->putsxy(x1, y1, buf); - screen->getstringsize(buf, &w, &h); + screen->getstringsize(buf, &w, &h, NULL); } - screen->getstringsize("A", &w, &h); + screen->getstringsize("A", &w, &h, NULL); x1 += 5*w; /* 4 chars for label + 1 space = 5 */ /* Print out gain part of status line (left justify after label) */ @@ -304,7 +304,7 @@ static int draw_eq_slider(struct screen * screen, int x, int y, abs_gain / EQ_USER_DIVISOR, abs_gain % EQ_USER_DIVISOR, screen->lcdwidth >= 160 ? "dB" : ""); screen->putsxy(x1, y1, buf); - screen->getstringsize(buf, &w, &h); + screen->getstringsize(buf, &w, &h, NULL); x1 += w; /* Print out Q part of status line (right justify) */ @@ -315,7 +315,7 @@ static int draw_eq_slider(struct screen * screen, int x, int y, snprintf(buf, sizeof(buf), "%d.%d%s", q / EQ_USER_DIVISOR, q % EQ_USER_DIVISOR, screen->lcdwidth >= 160 ? " Q" : ""); - screen->getstringsize(buf, &w, &h); + screen->getstringsize(buf, &w, &h, NULL); x2 = x + width - w - 2; screen->putsxy(x2, y1, buf); @@ -327,7 +327,7 @@ static int draw_eq_slider(struct screen * screen, int x, int y, snprintf(buf, sizeof(buf), "%5d%s", cutoff, screen->lcdwidth >= 160 ? "Hz" : ""); - screen->getstringsize(buf, &w, &h); + screen->getstringsize(buf, &w, &h, NULL); x1 = x1 + (x2 - x1 - w)/2; screen->putsxy(x1, y1, buf); @@ -401,7 +401,7 @@ bool eq_menu_graphical(void) screens[i].clear_display(); /* Figure out how many sliders can be drawn on the screen */ - screens[i].getstringsize("A", &w, &h); + screens[i].getstringsize("A", &w, &h, NULL); /* Total height includes margins (1), text, slider, and line selector (1) */ height = 3 + h + 1 + SCROLLBAR_SIZE + 3; diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c index 6d5abed..abda88b 100644 --- a/apps/menus/time_menu.c +++ b/apps/menus/time_menu.c @@ -163,7 +163,7 @@ static void talk_timedate(void) static void draw_timedate(struct viewport *vp, struct screen *display) { struct tm *tm = get_time(); - int w, line; + int w, oy, ls, line; char time[16], date[16]; if (vp->height == 0) return; @@ -193,18 +193,19 @@ static void draw_timedate(struct viewport *vp, struct screen *display) snprintf(time, 16, "%s", "--:--:--"); snprintf(date, 16, "%s", str(LANG_UNKNOWN)); } - display->getstringsize(time, &w, NULL); + display->getstringsize(time, &w, NULL, &oy); + ls = display->get_linespace(-1); if (w > vp->width) display->puts_scroll(0, line, time); else - display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, time); + display->putsxy((vp->width - w)/2, line * ls + oy, time); line++; - display->getstringsize(date, &w, NULL); + display->getstringsize(date, &w, NULL, &oy); if (w > vp->width) display->puts_scroll(0, line, date); else - display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, date); + display->putsxy((vp->width - w)/2, line * ls + oy, date); display->update_viewport(); } @@ -273,7 +274,7 @@ int time_screen(void* ignored) #endif nb_lines = viewport_get_nb_lines(&clock[i]); menu[i] = clock[i]; - font_h = font_get(clock[i].font)->height; + font_h = font_get_linespace(font_get(clock[i].font), -1); if (nb_lines > 3) { if (nb_lines >= 5) diff --git a/apps/misc.c b/apps/misc.c index d7a64b3..0d4e264 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -635,14 +635,14 @@ int show_logo( void ) lcd_clear_display(); #ifdef SANSA_CLIP /* display the logo in the blue area of the screen */ lcd_setfont(FONT_SYSFIXED); - lcd_getstringsize((unsigned char *)"A", &font_w, &font_h); + lcd_getstringsize((unsigned char *)"A", &font_w, NULL, NULL); lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2), 0, (unsigned char *)version); lcd_bitmap(rockboxlogo, 0, 16, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo); #else lcd_bitmap(rockboxlogo, 0, 10, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo); lcd_setfont(FONT_SYSFIXED); - lcd_getstringsize((unsigned char *)"A", &font_w, &font_h); + lcd_getstringsize((unsigned char *)"A", &font_w, &font_h, NULL); lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2), LCD_HEIGHT-font_h, (unsigned char *)version); #endif @@ -663,7 +663,7 @@ int show_logo( void ) lcd_remote_bitmap(remote_rockboxlogo, 0, 10, BMPWIDTH_remote_rockboxlogo, BMPHEIGHT_remote_rockboxlogo); lcd_remote_setfont(FONT_SYSFIXED); - lcd_remote_getstringsize((unsigned char *)"A", &font_w, &font_h); + lcd_remote_getstringsize((unsigned char *)"A", &font_w, &font_h, NULL); lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - ((strlen(version)*font_w)/2), LCD_REMOTE_HEIGHT-font_h, (unsigned char *)version); lcd_remote_setfont(FONT_UI); diff --git a/apps/mpeg.c b/apps/mpeg.c index dcccb98..51fddbb 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c @@ -872,11 +872,11 @@ static struct trackdata *add_track_to_tag_list(const char *filename) track->id3.elapsed = 0; #ifdef HAVE_LCD_BITMAP if (track->id3.title) - lcd_getstringsize(track->id3.title, NULL, NULL); + lcd_getstringsize(track->id3.title, NULL, NULL, NULL); if (track->id3.artist) - lcd_getstringsize(track->id3.artist, NULL, NULL); + lcd_getstringsize(track->id3.artist, NULL, NULL, NULL); if (track->id3.album) - lcd_getstringsize(track->id3.album, NULL, NULL); + lcd_getstringsize(track->id3.album, NULL, NULL, NULL); #endif if (cuesheet_callback) if (cuesheet_callback(filename)) diff --git a/apps/plugin.c b/apps/plugin.c old mode 100644 new mode 100755 index 115db06..90eb705 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -88,6 +88,7 @@ static const struct plugin_api rockbox_api = { lcd_puts, lcd_puts_scroll, lcd_stop_scroll, + lcd_get_linespace, #ifdef HAVE_LCD_CHARCELLS lcd_define_pattern, lcd_get_locked_pattern, @@ -148,6 +149,8 @@ static const struct plugin_api rockbox_api = { font_get, font_getstringsize, font_get_width, + font_getboundingboxsize, + font_get_linespace, screen_clear_area, gui_scrollbar_draw, #endif /* HAVE_LCD_BITMAP */ @@ -192,6 +195,7 @@ static const struct plugin_api rockbox_api = { &lcd_remote_framebuffer[0][0], lcd_remote_update, lcd_remote_update_rect, + lcd_remote_get_linespace, remote_backlight_on, remote_backlight_off, diff --git a/apps/plugin.h b/apps/plugin.h old mode 100644 new mode 100755 index 1c8682f..354bfb7 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -127,12 +127,12 @@ void* plugin_get_buffer(size_t *buffer_size); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 143 +#define PLUGIN_API_VERSION 144 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 143 +#define PLUGIN_MIN_API_VERSION 144 /* plugin return codes */ enum plugin_status { @@ -153,11 +153,12 @@ struct plugin_api { void (*lcd_set_contrast)(int x); void (*lcd_update)(void); void (*lcd_clear_display)(void); - int (*lcd_getstringsize)(const unsigned char *str, int *w, int *h); + int (*lcd_getstringsize)(const unsigned char *str, int *w, int *h, int *y); void (*lcd_putsxy)(int x, int y, const unsigned char *string); void (*lcd_puts)(int x, int y, const unsigned char *string); void (*lcd_puts_scroll)(int x, int y, const unsigned char* string); void (*lcd_stop_scroll)(void); + int (*lcd_get_linespace)(int mode); #ifdef HAVE_LCD_CHARCELLS void (*lcd_define_pattern)(unsigned long ucs, const char *pattern); unsigned long (*lcd_get_locked_pattern)(void); @@ -230,9 +231,11 @@ struct plugin_api { const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code ); struct font* (*font_load)(const char *path); struct font* (*font_get)(int font); - int (*font_getstringsize)(const unsigned char *str, int *w, int *h, + int (*font_getstringsize)(const unsigned char *str, int *w, int *h, int *y, int fontnumber); int (*font_get_width)(struct font* pf, unsigned short char_code); + void (*font_getboundingboxsize)(struct font *pf, unsigned short ch, int *bw, int *ba, int *bd); + int (*font_get_linespace)(const struct font* pf, int mode); void (*screen_clear_area)(struct screen * display, int xstart, int ystart, int width, int height); void (*gui_scrollbar_draw)(struct screen * screen, int x, int y, @@ -274,7 +277,7 @@ struct plugin_api { void (*lcd_remote_set_drawmode)(int mode); int (*lcd_remote_get_drawmode)(void); void (*lcd_remote_setfont)(int font); - int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h); + int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h, int *y); void (*lcd_remote_drawpixel)(int x, int y); void (*lcd_remote_drawline)(int x1, int y1, int x2, int y2); void (*lcd_remote_hline)(int x1, int x2, int y); @@ -293,6 +296,7 @@ struct plugin_api { fb_remote_data* lcd_remote_framebuffer; void (*lcd_remote_update)(void); void (*lcd_remote_update_rect)(int x, int y, int width, int height); + int (*lcd_remote_get_linespace)(int mode); void (*remote_backlight_on)(void); void (*remote_backlight_off)(void); diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 40b9998..f476550 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -423,9 +423,9 @@ typedef void (*plcdfunc)(int x, int y, const unsigned char *str); static void put_centered_str(const char* str, plcdfunc putsxy, int lcd_width, int line) { - int strwdt, strhgt; - rb->lcd_getstringsize(str, &strwdt, &strhgt); - putsxy((lcd_width - strwdt)/2, line*(strhgt), str); + int strwdt; + rb->lcd_getstringsize(str, &strwdt, NULL, NULL); + putsxy((lcd_width - strwdt)/2, line*(rb->lcd_get_linespace(-1)), str); } #endif diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c index cb0a653..f5c9de6 100644 --- a/apps/plugins/blackjack.c +++ b/apps/plugins/blackjack.c @@ -453,39 +453,40 @@ static void blackjack_init(struct game_context* bj) { * blackjack_drawtable() draws the table and some text. ******************************************************************************/ static void blackjack_drawtable(struct game_context* bj) { - unsigned int w, h, y_loc; + unsigned int w, ls, y_loc; char str[10]; - + + ls = rb->lcd_get_linespace(-1); #if LCD_HEIGHT <= 64 - rb->lcd_getstringsize("Bet", &w, &h); - rb->lcd_putsxy(LCD_WIDTH - w, 2*h + 1, "Bet"); + rb->lcd_getstringsize("Bet", &w, NULL, NULL); + rb->lcd_putsxy(LCD_WIDTH - w, 2*ls + 1, "Bet"); rb->snprintf(str, 9, "$%d", bj->current_bet); - rb->lcd_getstringsize(str, &w, &h); - rb->lcd_putsxy(LCD_WIDTH - w, 3*h + 1, str); + rb->lcd_getstringsize(str, &w, NULL, NULL); + rb->lcd_putsxy(LCD_WIDTH - w, 3*ls + 1, str); y_loc = LCD_HEIGHT/2; #else - rb->lcd_getstringsize("Bet", &w, &h); - rb->lcd_putsxy(LCD_WIDTH - w, 5*h / 2, "Bet"); + rb->lcd_getstringsize("Bet", &w, NULL, NULL); + rb->lcd_putsxy(LCD_WIDTH - w, 5*ls / 2, "Bet"); rb->snprintf(str, 9, "$%d", bj->current_bet); - rb->lcd_getstringsize(str, &w, &h); - rb->lcd_putsxy(LCD_WIDTH - w, 7*h / 2, str); + rb->lcd_getstringsize(str, &w, NULL, NULL); + rb->lcd_putsxy(LCD_WIDTH - w, 7*ls / 2, str); rb->lcd_hline(0, LCD_WIDTH, LCD_HEIGHT/2); - y_loc = LCD_HEIGHT/2 + h; + y_loc = LCD_HEIGHT/2 + ls; #endif rb->lcd_putsxy(0,0, "Dealer"); - rb->lcd_getstringsize("Player", &w, &h); + rb->lcd_getstringsize("Player", &w, NULL, NULL); rb->lcd_putsxy(0, y_loc, "Player"); - rb->lcd_getstringsize("Total", &w, &h); + rb->lcd_getstringsize("Total", &w, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH - w, y_loc, "Total"); - rb->lcd_getstringsize("Money", &w, &h); + rb->lcd_getstringsize("Money", &w, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH - w, 0, "Money"); rb->snprintf(str, 9, "$%d", bj->player_money - bj->current_bet); - rb->lcd_getstringsize(str, &w, &h); - rb->lcd_putsxy(LCD_WIDTH - w, h + 1, str); + rb->lcd_getstringsize(str, &w, NULL, NULL); + rb->lcd_putsxy(LCD_WIDTH - w, ls + 1, str); rb->snprintf(str, 3, "%d", bj->player_total); - rb->lcd_getstringsize(str, &w, &h); - rb->lcd_putsxy(LCD_WIDTH - w, y_loc + h, str); + rb->lcd_getstringsize(str, &w, NULL, NULL); + rb->lcd_putsxy(LCD_WIDTH - w, y_loc + ls, str); } /***************************************************************************** @@ -623,14 +624,15 @@ static void redraw_board(struct game_context* bj) { ******************************************************************************/ static void update_total(struct game_context* bj) { char total[3]; - unsigned int w, h; + unsigned int w, ls; rb->snprintf(total, 3, "%d", bj->player_total); - rb->lcd_getstringsize(total, &w, &h); + rb->lcd_getstringsize(total, &w, NULL, NULL); + ls = rb->lcd_get_linespace(-1); #if LCD_HEIGHT > 64 - h *= 2; + ls *= 2; #endif - rb->lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 + h, total); - rb->lcd_update_rect(LCD_WIDTH - w, LCD_HEIGHT/2 + h, w, h); + rb->lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 + ls, total); + rb->lcd_update_rect(LCD_WIDTH - w, LCD_HEIGHT/2 + ls, w, ls); } @@ -706,7 +708,7 @@ static void finish_dealer(struct game_context* bj) { * finish_game() completes the game once player's turn is over. ******************************************************************************/ static void finish_game(struct game_context* bj) { - unsigned int rValue, w, h; + unsigned int rValue, w, ls; char str[19]; do { @@ -735,18 +737,18 @@ static void finish_game(struct game_context* bj) { rb->snprintf(str, sizeof(str), " Blackjack! "); bj->player_money += bj->current_bet * 3 / 2; } - rb->lcd_getstringsize(str, &w, &h); - + rb->lcd_getstringsize(str, &w, NULL, NULL); + ls = rb->lcd_get_linespace(-1); #if LCD_HEIGHT <= 64 rb->lcd_set_drawmode(DRMODE_BG+DRMODE_INVERSEVID); rb->lcd_fillrect(0, LCD_HEIGHT/2, LCD_WIDTH, LCD_HEIGHT/2); rb->lcd_set_drawmode(DRMODE_SOLID); - rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 + h, str); + rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 + ls, str); rb->snprintf(str, 12, "You have %d", bj->player_total); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2, str); #else - rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 - h/2, str); + rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 - ls/2, str); #endif rb->lcd_update(); } @@ -899,7 +901,7 @@ static void blackjack_callback(void* param) { ******************************************************************************/ static unsigned int blackjack_get_yes_no(char message[20]) { int button; - unsigned int w, h, b, choice = 0; + unsigned int w, ls, b, choice = 0; bool breakout = false; char message_yes[24], message_no[24]; @@ -907,30 +909,31 @@ static unsigned int blackjack_get_yes_no(char message[20]) { rb->strcpy(message_no, message); rb->strcat(message_yes, " Yes"); rb->strcat(message_no, " No"); - rb->lcd_getstringsize(message_yes, &w, &h); + rb->lcd_getstringsize(message_yes, &w, NULL, NULL); + ls = rb->lcd_get_linespace(-1); const char *stg[] = {message_yes, message_no}; #if LCD_HEIGHT <= 64 - b = 2*h+1; + b = 2*ls+1; #else - b = h-1; + b = ls-1; #endif #ifdef HAVE_LCD_COLOR - rb->lcd_fillrect(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 + b, w+1, h+3); + rb->lcd_fillrect(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 + b, w+1, ls+3); rb->lcd_set_foreground(LCD_BLACK); rb->lcd_set_background(LCD_WHITE); #else rb->lcd_set_drawmode(DRMODE_BG+DRMODE_INVERSEVID); - rb->lcd_fillrect(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 + b, w+1, h+3); + rb->lcd_fillrect(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 + b, w+1, ls+3); rb->lcd_set_drawmode(DRMODE_SOLID); #endif - rb->lcd_drawrect(LCD_WIDTH/2 - w/2 - 1, LCD_HEIGHT/2 + b - 1, w+3, h+4); + rb->lcd_drawrect(LCD_WIDTH/2 - w/2 - 1, LCD_HEIGHT/2 + b - 1, w+3, ls+4); while(!breakout) { rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 + b +1, stg[choice]); rb->lcd_update_rect(LCD_WIDTH/2 - w/2 - 1, LCD_HEIGHT/2 + b -1, - w+3, h+4); + w+3, ls+4); button = rb->button_get(true); switch(button) { @@ -964,10 +967,11 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit, int button; char str[6]; bool changed = false; - unsigned int w, h; + unsigned int w, h, ls; signed int amount; - rb->lcd_getstringsize("A", &w, &h); /* find the size of one character */ + rb->lcd_getstringsize("A", &w, &h, NULL); /* find the size of one character */ + ls = rb->lcd_get_linespace(-1); if (start > upper_limit) amount = upper_limit; @@ -993,34 +997,34 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit, rb->lcd_update(); #else rb->lcd_set_drawmode(DRMODE_BG+DRMODE_INVERSEVID); - rb->lcd_fillrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3, 37*w / 2, - 8*h -3); + rb->lcd_fillrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*ls - 3, 37*w / 2, + 8*ls -3); rb->lcd_set_drawmode(DRMODE_SOLID); - rb->lcd_drawrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3, 37*w / 2, - 8*h -3); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 4*h - 1, message); + rb->lcd_drawrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*ls - 3, 37*w / 2, + 8*ls -3); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 4*ls - 1, message); rb->snprintf(str, 9, "$%d", amount); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, str); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*ls, str); #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ (CONFIG_KEYPAD == IPOD_3G_PAD) || \ (CONFIG_KEYPAD == IPOD_1G2G_PAD) - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - h-2, " >>|: +1"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - ls - 2, " >>|: +1"); rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 1, " |<<: -1"); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + h, "SCROLL+: +10"); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + 2*h + 1, "SCROLL-: -10"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + ls, "SCROLL+: +10"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + 2*ls + 1, "SCROLL-: -10"); #elif CONFIG_KEYPAD == IRIVER_H10_PAD - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - h-2, "RIGHT: +1"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - ls - 2, "RIGHT: +1"); rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 1, "LEFT: -1"); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + h, "SCROLL+: +10"); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + 2*h + 1, "SCROLL-: -10"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + ls, "SCROLL+: +10"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + 2*ls + 1, "SCROLL-: -10"); #else - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - h-2, "RIGHT: +1"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - ls - 2, "RIGHT: +1"); rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 1, "LEFT: -1"); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + h, "UP: +10"); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + 2*h + 1, "DOWN: -10"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + ls, "UP: +10"); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + 2*ls + 1, "DOWN: -10"); #endif - rb->lcd_update_rect(LCD_WIDTH/2 - 9*w - 2, LCD_HEIGHT/2 - 9*h/2, 37*w/2 + 1, - 8*h-2); + rb->lcd_update_rect(LCD_WIDTH/2 - 9*w - 2, LCD_HEIGHT/2 - 9*ls/2, 37*w/2 + 1, + 8*ls-2); #endif while(true) { @@ -1081,10 +1085,10 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit, rb->lcd_update(); #else rb->lcd_set_drawmode(DRMODE_BG+DRMODE_INVERSEVID); - rb->lcd_fillrect(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, 5*w, h); + rb->lcd_fillrect(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*ls, 5*w, h); rb->lcd_set_drawmode(DRMODE_SOLID); - rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, str); - rb->lcd_update_rect(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, 5*w, h); + rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*ls, str); + rb->lcd_update_rect(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*ls, 5*w, h); #endif changed = false; } @@ -1158,7 +1162,7 @@ static unsigned int blackjack_menu(struct game_context* bj) { int button; char *title = "Blackjack"; char str[18]; - unsigned int i, w, h; + unsigned int i, w; bool breakout = false; bool showscores = false; @@ -1171,7 +1175,7 @@ static unsigned int blackjack_menu(struct game_context* bj) { if(!showscores) { /* welcome screen to display key bindings */ - rb->lcd_getstringsize(title, &w, &h); + rb->lcd_getstringsize(title, &w, NULL, NULL); rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, title); #if CONFIG_KEYPAD == RECORDER_PAD @@ -1316,7 +1320,7 @@ static unsigned int blackjack_menu(struct game_context* bj) { #endif } else { rb->snprintf(str, 12, "%s", "High Scores"); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, NULL, NULL); rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, str); /* print high scores */ @@ -1374,7 +1378,7 @@ static unsigned int blackjack_menu(struct game_context* bj) { ******************************************************************************/ static int blackjack(struct game_context* bj) { int button; - unsigned int w, h, temp_var, done = 0, todo = 1; + unsigned int w, h, oy, ls, temp_var, done = 0, todo = 1; signed int temp; bool breakout = false; bool dbl_down = false; @@ -1544,21 +1548,22 @@ static int blackjack(struct game_context* bj) { bj->player_total = temp_var; temp_var = temp; finish_game(bj); - rb->lcd_getstringsize(" Split 1 ", &w, &h); - rb->lcd_putsxy(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, + rb->lcd_getstringsize(" Split 1 ", &w, &h, &oy); + ls = rb->lcd_get_linespace(-1); + rb->lcd_putsxy(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*ls/2, " Split 1 "); - rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, + rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*ls/2+oy, w,h); bj->current_bet /= 2; - rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, + rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*ls/2+oy, w,h); rb->sleep(HZ*2); bj->player_total = temp_var; finish_game(bj); - rb->lcd_getstringsize(" Split 2 ", &w, &h); - rb->lcd_putsxy(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, + rb->lcd_getstringsize(" Split 2 ", &w, &h, &oy); + rb->lcd_putsxy(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*ls/2, " Split 2 "); - rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*h/2, + rb->lcd_update_rect(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-3*ls/2+oy, w,h); rb->sleep(HZ*2); } diff --git a/apps/plugins/bounce.c b/apps/plugins/bounce.c index e7e88cc..0b5068b 100644 --- a/apps/plugins/bounce.c +++ b/apps/plugins/bounce.c @@ -610,12 +610,12 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_clear_display(); /* Get horizontel centering for text */ - rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h); + rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h, NULL); rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2, (unsigned char *)SS_TITLE); /* Get horizontel centering for text */ - rb->lcd_getstringsize((unsigned char *)off, &w, &h); + rb->lcd_getstringsize((unsigned char *)off, &w, &h, NULL); rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h, (unsigned char *)off); diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 15c1641..e41d412 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c @@ -889,7 +889,7 @@ void sleep (int secs) if (vscoresnprintf(s, sizeof(s), "%d", vscore); - rb->lcd_getstringsize(s, &sw, &w); + rb->lcd_getstringsize(s, &sw, &w, NULL); #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s); #else @@ -1035,8 +1035,8 @@ int game_menu(int when) #endif rb->lcd_putsxy(HIGHSCORE_XPOS, HIGHSCORE_YPOS, "High Score"); rb->snprintf(str, sizeof(str), "%d", highscore); - rb->lcd_getstringsize("High Score", &sw, NULL); - rb->lcd_getstringsize(str, &w, NULL); + rb->lcd_getstringsize("High Score", &sw, NULL, NULL); + rb->lcd_getstringsize(str, &w, NULL, NULL); rb->lcd_putsxy(HIGHSCORE_XPOS+sw/2-w/2, HIGHSCORE_YPOS+9, str); rb->lcd_set_drawmode(DRMODE_SOLID); @@ -1130,7 +1130,7 @@ int help(int when) rb->lcd_clear_display(); #endif - rb->lcd_getstringsize("BrickMania", &w, &h); + rb->lcd_getstringsize("BrickMania", &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH/2-w/2+xoffset, 1+yoffset, "BrickMania"); #ifdef HAVE_LCD_COLOR @@ -1344,7 +1344,7 @@ int game_loop(void) flip_sides=false; } rb->snprintf(s, sizeof(s), "%d", num_count); - rb->lcd_getstringsize(s, &sw, NULL); + rb->lcd_getstringsize(s, &sw, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH/2-2, STRINGPOS_FLIP, s); } @@ -1359,17 +1359,17 @@ int game_loop(void) #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) rb->snprintf(s, sizeof(s), "L%d", cur_level+1); - rb->lcd_getstringsize(s, &sw, NULL); + rb->lcd_getstringsize(s, &sw, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH-sw, 0, s); #else rb->snprintf(s, sizeof(s), "Level %d", cur_level+1); - rb->lcd_getstringsize(s, &sw, NULL); + rb->lcd_getstringsize(s, &sw, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH-sw-2, 2, s); #endif if (vscoresnprintf(s, sizeof(s), "%d", vscore); - rb->lcd_getstringsize(s, &sw, NULL); + rb->lcd_getstringsize(s, &sw, NULL, NULL); #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s); #else @@ -1387,7 +1387,7 @@ int game_loop(void) #else rb->snprintf(s, sizeof(s), "Press SELECT To Continue"); #endif - rb->lcd_getstringsize(s, &sw, NULL); + rb->lcd_getstringsize(s, &sw, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_NAVI, s); sec_count=*rb->current_tick+HZ; @@ -1840,16 +1840,16 @@ int game_loop(void) sleep(2); } else { - rb->lcd_getstringsize("Congratulations!", &sw, NULL); + rb->lcd_getstringsize("Congratulations!", &sw, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_CONGRATS, "Congratulations!"); #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) - rb->lcd_getstringsize("No more levels", &sw, NULL); + rb->lcd_getstringsize("No more levels", &sw, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_FINISH, "No more levels"); #else rb->lcd_getstringsize("You have finished the game!", - &sw, NULL); + &sw, NULL, NULL); rb->lcd_putsxy(LCD_WIDTH/2-sw/2, STRINGPOS_FINISH, "You have finished the game!"); #endif diff --git a/apps/plugins/bubbles.c b/apps/plugins/bubbles.c index 1d199e8..19f96d3 100644 --- a/apps/plugins/bubbles.c +++ b/apps/plugins/bubbles.c @@ -1489,25 +1489,25 @@ static void bubbles_drawboard(struct game_context* bb) { tipy-(((cos_int(bb->angle+135)>>4)*BUBBLE_HEIGHT/3)>>10)); /* draw text */ - rb->lcd_getstringsize(level, &w, &h); + rb->lcd_getstringsize(level, &w, NULL, NULL); rb->lcd_putsxy(XOFS/2-w/2, 2, level); rb->snprintf(str, 4, "%d", bb->level); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, NULL, NULL); rb->lcd_putsxy(XOFS/2-w/2, 11, str); - rb->lcd_getstringsize(score, &w, &h); + rb->lcd_getstringsize(score, &w, NULL, NULL); rb->lcd_putsxy(XOFS/2-w/2, 29, score); rb->snprintf(str, 10, "%d", bb->score); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, NULL, NULL); rb->lcd_putsxy(XOFS/2-w/2, 38, str); - rb->lcd_getstringsize(next, &w, &h); + rb->lcd_getstringsize(next, &w, NULL, NULL); rb->lcd_putsxy(XOFS/2-w/2, SHOTY-9, next); if(bb->elapsedshot >= (MAX_SHOTTIME*7)/10) { - rb->lcd_getstringsize(hurry, &w, &h); + rb->lcd_getstringsize(hurry, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH/2-w/2, LCD_HEIGHT/2-h/2, hurry); } } diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c index 1795bca..09bc806 100644 --- a/apps/plugins/calculator.c +++ b/apps/plugins/calculator.c @@ -604,7 +604,7 @@ void drawButtons(int group) int i, j, w, h; for (i = 0; i <= 4; i++){ for (j = 0; j <= 4; j++){ - rb->lcd_getstringsize( buttonChar[group][i][j],&w,&h); + rb->lcd_getstringsize( buttonChar[group][i][j],&w,&h, NULL); if (i == btn_row && j == btn_col) /* selected item */ rb->lcd_set_drawmode(DRMODE_SOLID); else @@ -631,7 +631,7 @@ void cal_initial (void) { int w,h; - rb->lcd_getstringsize("A",&w,&h); + rb->lcd_getstringsize("A",&w,&h, NULL); if (h >= REC_HEIGHT) rb->lcd_setfont(FONT_SYSFIXED); @@ -967,7 +967,7 @@ void flashButton(void) int k, w, h; for (k=2;k>0;k--) { - rb->lcd_getstringsize( buttonChar[buttonGroup][btn_row][btn_col],&w,&h); + rb->lcd_getstringsize( buttonChar[buttonGroup][btn_row][btn_col],&w,&h, NULL); rb->lcd_set_drawmode(DRMODE_SOLID|(k==1) ? 0 : DRMODE_INVERSEVID); rb->lcd_fillrect( X_0_POS + btn_col*REC_WIDTH + 1, Y_1_POS + btn_row*REC_HEIGHT + 1, @@ -1216,7 +1216,7 @@ void printResult(void) } - rb->lcd_getstringsize(buf, &w, &h); + rb->lcd_getstringsize(buf, &w, &h, NULL); rb->screen_clear_area(rb->screens[0], 0, 0, LCD_WIDTH, REC_HEIGHT-1); rb->lcd_putsxy(4, Y_1_POS - h -1, operbuf); rb->lcd_putsxy(LCD_WIDTH - w - 4, Y_1_POS - h -1, buf); diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c index a570f37..fe7fed3 100644 --- a/apps/plugins/calendar.c +++ b/apps/plugins/calendar.c @@ -239,7 +239,7 @@ static void calendar_init(struct today *today, struct shown *shown) #else (void)today; #endif - rb->lcd_getstringsize("A",&w,&h); + rb->lcd_getstringsize("A",&w,&h, NULL); if ( ((w * 14) > LCD_WIDTH) || ((h * 7) > LCD_HEIGHT) ) { rb->lcd_setfont(FONT_SYSFIXED); @@ -269,7 +269,7 @@ static void draw_headers(void) for (i = 0; i < 7; i++) { - rb->lcd_getstringsize(dayname[i],&w,&h); + rb->lcd_getstringsize(dayname[i],&w,&h, NULL); if (w > CELL_WIDTH) { dayname = (const char**)&dayname_short; @@ -277,7 +277,7 @@ static void draw_headers(void) } } - rb->lcd_getstringsize("A",&w,&h); + rb->lcd_getstringsize("A",&w,&h, NULL); for (i = 0; i < 7; i++) { rb->lcd_putsxy(x, 0 , dayname[i]); @@ -309,7 +309,7 @@ static void draw_calendar(struct shown *shown) }; if(use_system_font) rb->lcd_setfont(FONT_SYSFIXED); - rb->lcd_getstringsize("A",&w,&h); + rb->lcd_getstringsize("A",&w,&h, NULL); rb->lcd_clear_display(); draw_headers(); if (shown->firstday > 6) diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c index 15333c4..7214590 100644 --- a/apps/plugins/chopper.c +++ b/apps/plugins/chopper.c @@ -674,7 +674,7 @@ static void chopDrawScene(void) #else rb->snprintf(s, sizeof(s), "Distance: %d", score); #endif - rb->lcd_getstringsize(s, &w, NULL); + rb->lcd_getstringsize(s, &w, NULL, NULL); rb->lcd_putsxy(2, 2, s); if (score < highscore) { @@ -684,7 +684,7 @@ static void chopDrawScene(void) #else rb->snprintf(s, sizeof(s), "Best: %d", highscore); #endif - rb->lcd_getstringsize(s, &w2, NULL); + rb->lcd_getstringsize(s, &w2, NULL, NULL); if (LCD_WIDTH - 2 - w2 > w + 2) rb->lcd_putsxy(LCD_WIDTH - 2 - w2, 2, s); } diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c index 0251849..50b6231 100644 --- a/apps/plugins/credits.c +++ b/apps/plugins/credits.c @@ -167,12 +167,12 @@ static void roll_credits(void) rb->lcd_clear_display(); rb->lcd_update(); - rb->lcd_getstringsize("A", NULL, &font_h); + font_h = rb->lcd_get_linespace(-1); /* snprintf "credits" text, and save the width and height */ rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d", j+1, numnames); - rb->lcd_getstringsize(elapsednames, &credits_w, NULL); + rb->lcd_getstringsize(elapsednames, &credits_w, NULL, NULL); /* fly in "credits" text from the left */ for(credits_pos = 0 - credits_w; credits_pos <= CREDITS_TARGETPOS; @@ -190,11 +190,11 @@ static void roll_credits(void) for(i=0; isnprintf(name, sizeof(name), "%s", credits[i]); - rb->lcd_getstringsize(name, &name_w, &name_h); + rb->lcd_getstringsize(name, &name_w, &name_h, NULL); rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d", i+1, numnames); - rb->lcd_getstringsize(elapsednames, &credits_w, NULL); + rb->lcd_getstringsize(elapsednames, &credits_w, NULL, NULL); rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames); rb->lcd_update_rect(CREDITS_TARGETPOS, 0, credits_w, font_h); @@ -248,7 +248,7 @@ static void roll_credits(void) rb->snprintf(name, sizeof(name), "%s", credits[j+i-NUM_VISIBLE_LINES]); - rb->lcd_getstringsize(name, &name_w, &name_h); + rb->lcd_getstringsize(name, &name_w, &name_h, NULL); /* fly out an existing line.. */ while(namepossnprintf(name, sizeof(name), "%s", credits[j+i]); - rb->lcd_getstringsize(name, &name_w, &name_h); + rb->lcd_getstringsize(name, &name_w, &name_h, NULL); rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d/%d", j+i+1, numnames); - rb->lcd_getstringsize(elapsednames, &credits_w, NULL); + rb->lcd_getstringsize(elapsednames, &credits_w, NULL, NULL); rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames); if (j+i < NUM_VISIBLE_LINES) /* takes care of trail on loop */ rb->lcd_update_rect(0, 0, LCD_WIDTH, font_h); @@ -327,7 +327,7 @@ static void roll_credits(void) rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %d-%d/%d", j+1, j+NUM_VISIBLE_LINES, numnames); - rb->lcd_getstringsize(elapsednames, &credits_w, NULL); + rb->lcd_getstringsize(elapsednames, &credits_w, NULL, NULL); rb->lcd_putsxy(CREDITS_TARGETPOS, 0, elapsednames); for(i=0; igetstringsize("M", &char_width, &char_height); + display->getstringsize("M", &char_width, &char_height, NULL); int display_nb_row=display->getheight()/char_height; int display_nb_col=display->getwidth()/char_width; diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c index 2018d8c..84adbad 100644 --- a/apps/plugins/dict.c +++ b/apps/plugins/dict.c @@ -50,7 +50,7 @@ void init_screen(void) #ifdef HAVE_LCD_BITMAP int w,h; - rb->lcd_getstringsize("o", &w, &h); + rb->lcd_getstringsize("o", &w, &h, NULL); display_lines = LCD_HEIGHT / h; display_columns = LCD_WIDTH / w; #else diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c index ae0b1db..7b029ce 100644 --- a/apps/plugins/flipit.c +++ b/apps/plugins/flipit.c @@ -369,7 +369,7 @@ static void draw_info_panel(void) GRID_WIDTH, PANEL_HEIGHT ); rb->snprintf( s, sizeof(s), "Flips: %d", moves ); - rb->lcd_putsxy( (LCD_WIDTH - rb->lcd_getstringsize(s, NULL, NULL)) / 2, + rb->lcd_putsxy( (LCD_WIDTH - rb->lcd_getstringsize(s, NULL, NULL, NULL)) / 2, GRID_TOP + 4*(TK_HEIGHT+TK_SPACE) + 2, s ); } diff --git a/apps/plugins/goban/display.c b/apps/plugins/goban/display.c index 55ea0d6..3d4e536 100644 --- a/apps/plugins/goban/display.c +++ b/apps/plugins/goban/display.c @@ -150,7 +150,7 @@ draw_all_marks (void) display_marks[x + y * board_width] & (~(1 << 7)); to_display[1] = '\0'; - rb->lcd_getstringsize (to_display, &width, &height); + rb->lcd_getstringsize (to_display, &width, &height, NULL); int display_x = pixel_x (POS (x, y)) + LINE_OFFSET - (width / 2); @@ -460,7 +460,7 @@ vert_string_size (char *string, int *width, int *height) while (*string) { temp_buffer[0] = *string; - rb->lcd_getstringsize (temp_buffer, &temp_width, &temp_height); + rb->lcd_getstringsize (temp_buffer, &temp_width, &temp_height, NULL); ret_height += temp_height; @@ -500,7 +500,7 @@ putsxy_vertical (int x, int y, int width, char *str) while (*str) { temp_buffer[0] = *str; - rb->lcd_getstringsize (temp_buffer, &temp_width, &temp_height); + rb->lcd_getstringsize (temp_buffer, &temp_width, &temp_height, NULL); DEBUGF ("putting %s at %d %d\n", temp_buffer, x + (width - temp_width) / 2, y); rb->lcd_putsxy (x + (width - temp_width) / 2, y, temp_buffer); @@ -534,7 +534,7 @@ draw_footer (void) "%d", white_captures); - rb->lcd_getstringsize (captures_buffer, &size_x, &size_y); + rb->lcd_getstringsize (captures_buffer, &size_x, &size_y, NULL); #if defined(GBN_TALL_SCREEN) rb->lcd_putsxy (size_y + 2, LCD_HEIGHT - size_y, captures_buffer); #else @@ -583,7 +583,7 @@ draw_footer (void) rb->snprintf (captures_buffer, sizeof (captures_buffer), "%d", black_captures); - rb->lcd_getstringsize (captures_buffer, &size_x, &size_y); + rb->lcd_getstringsize (captures_buffer, &size_x, &size_y, NULL); #if defined(GBN_TALL_SCREEN) rb->lcd_putsxy (LCD_WIDTH - (size_y + 1) - size_x, LCD_HEIGHT - size_y, captures_buffer); @@ -633,7 +633,7 @@ draw_footer (void) rb->snprintf (captures_buffer, sizeof (captures_buffer), "%d%s", move_num, display_flags); - rb->lcd_getstringsize (captures_buffer, &size_x, &size_y); + rb->lcd_getstringsize (captures_buffer, &size_x, &size_y, NULL); #if defined(GBN_TALL_SCREEN) rb->lcd_putsxy ((LCD_WIDTH - size_x) / 2, LCD_HEIGHT - size_y, captures_buffer); diff --git a/apps/plugins/jackpot.c b/apps/plugins/jackpot.c index e13dcf8..eedca00 100644 --- a/apps/plugins/jackpot.c +++ b/apps/plugins/jackpot.c @@ -220,7 +220,7 @@ void jackpot_info_message(struct screen* display, char* message) #else int xpos, ypos; int message_height, message_width; - display->getstringsize(message, &message_width, &message_height); + display->getstringsize(message, &message_width, &message_height, NULL); xpos=(display->getwidth()-message_width)/2; ypos=display->getheight()-message_height; rb->screen_clear_area(display, 0, ypos, display->getwidth(), diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c index 00839af..1eef64c 100644 --- a/apps/plugins/jewels.c +++ b/apps/plugins/jewels.c @@ -565,15 +565,15 @@ static void jewels_drawboard(struct game_context* bj) { #endif /* print text */ - rb->lcd_getstringsize(title, &w, &h); + rb->lcd_getstringsize(title, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, 1, title); rb->snprintf(str, 4, "%d", bj->level); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, 10, str); rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, LCD_HEIGHT-8, str); @@ -611,7 +611,7 @@ static void jewels_drawboard(struct game_context* bj) { rb->lcd_putsxy(1, LCD_HEIGHT-10, str); rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, &h, NULL); rb->lcd_putsxy((LCD_WIDTH-2)-w, LCD_HEIGHT-10, str); #else /* square layout */ @@ -651,7 +651,7 @@ static void jewels_drawboard(struct game_context* bj) { rb->lcd_putsxy(1, LCD_HEIGHT-(LCD_HEIGHT-(8*TILE_HEIGHT+YOFS))/2-3, str); rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, &h, NULL); rb->lcd_putsxy((LCD_WIDTH-2)-w, LCD_HEIGHT-(LCD_HEIGHT-(8*TILE_HEIGHT+YOFS))/2-3, str); @@ -706,7 +706,7 @@ static enum menu_result jewels_showmenu(struct jewels_menu* menu, } /* draw menu items */ - rb->lcd_getstringsize(menu->title, &w, &h); + rb->lcd_getstringsize(menu->title, &w, &h, NULL); rb->lcd_putsxy((LCD_WIDTH-w)/2, firstline*FONT_HEIGHT, menu->title); for(i=0; iitemcnt; i++) { @@ -1470,7 +1470,7 @@ static int jewels_main(struct game_context* bj) { cmd = MCMD_NONE; rb->snprintf(str, 18, "High Score: %d", bj->highscores[0]); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, &h, NULL); rb->lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT-8, str); rb->lcd_update(); @@ -1503,7 +1503,7 @@ static int jewels_main(struct game_context* bj) { j = 0; if(LCD_HEIGHT-NUM_SCORES*8 >= 8) { rb->snprintf(str, 12, "%s", "High Scores"); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, &h, NULL); rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, str); j = 2; } @@ -1527,7 +1527,7 @@ static int jewels_main(struct game_context* bj) { /* welcome screen to display key bindings */ rb->lcd_clear_display(); rb->snprintf(str, 5, "%s", "Help"); - rb->lcd_getstringsize(str, &w, &h); + rb->lcd_getstringsize(str, &w, &h, NULL); rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, str); #if CONFIG_KEYPAD == RECORDER_PAD rb->lcd_puts(0, 2, "Controls:"); diff --git a/apps/plugins/jpeg/jpeg.c b/apps/plugins/jpeg/jpeg.c index 5f9999a..74c8271 100644 --- a/apps/plugins/jpeg/jpeg.c +++ b/apps/plugins/jpeg/jpeg.c @@ -886,7 +886,7 @@ struct t_disp* get_image(struct jpeg* p_jpg, int ds) if(!running_slideshow) { rb->snprintf(print, sizeof(print), " %ld.%02ld sec ", time/HZ, time%HZ); - rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */ + rb->lcd_getstringsize(print, &w, &h, NULL); /* centered in progress bar */ rb->lcd_putsxy((LCD_WIDTH - w)/2, LCD_HEIGHT - h, print); rb->lcd_update(); } diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h index 7c990ad..7d89a56 100644 --- a/apps/plugins/lib/grey.h +++ b/apps/plugins/lib/grey.h @@ -74,7 +74,8 @@ void grey_set_background(unsigned brightness); unsigned grey_get_background(void); void grey_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness); void grey_setfont(int newfont); -int grey_getstringsize(const unsigned char *str, int *w, int *h); +int grey_getstringsize(const unsigned char *str, int *w, int *h, int *y); +int gray_get_linespace(int mode); /* Whole display */ void grey_clear_display(void); diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c old mode 100644 new mode 100755 index 286cae0..ba8ef78 --- a/apps/plugins/lib/grey_draw.c +++ b/apps/plugins/lib/grey_draw.c @@ -541,11 +541,12 @@ void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str) while ((ch = *ucs++) != 0 && x < _grey_info.width) { - int width; + int width, a, d, oy; const unsigned char *bits; /* get proportional width and glyph bits */ - width = rb->font_get_width(pf, ch); + rb->font_getboundingboxsize(pf, ch, &width, &a, &d); + oy = pf->maxascent - a; if (ofs > width) { @@ -555,7 +556,7 @@ void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str) bits = rb->font_get_bits(pf, ch); - grey_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height); + grey_mono_bitmap_part(bits, ofs, oy, width, x, y + oy, width - ofs, a + d); x += width - ofs; ofs = 0; diff --git a/apps/plugins/lib/grey_parm.c b/apps/plugins/lib/grey_parm.c old mode 100644 new mode 100755 index 00193e1..9703c2d --- a/apps/plugins/lib/grey_parm.c +++ b/apps/plugins/lib/grey_parm.c @@ -112,7 +112,7 @@ void grey_setfont(int newfont) } /* Get width and height of a text when printed with the current font */ -int grey_getstringsize(const unsigned char *str, int *w, int *h) +int grey_getstringsize(const unsigned char *str, int *w, int *h, int *y) { - return rb->font_getstringsize(str, w, h, _grey_info.curfont); + return rb->font_getstringsize(str, w, h, y, _grey_info.curfont); } diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index de667ec..fc9ee56 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c @@ -432,7 +432,7 @@ static void grey_splash(int ticks, const unsigned char *fmt, ...) va_end(ap); - grey_getstringsize(buffer, &w, &h); + grey_getstringsize(buffer, &w, &h, NULL); oldfg = grey_get_foreground(); oldmode = grey_get_drawmode(); @@ -489,7 +489,7 @@ static void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc) /* Put positition on left */ ts_to_hms(pos, &hms); hms_format(str, sizeof(str), &hms); - lcd_(getstringsize)(str, NULL, &text_h); + lcd_(getstringsize)(str, NULL, &text_h, NULL); text_y = SLIDER_Y - SLIDER_TEXTMARGIN - text_h; if (rc == NULL) @@ -506,7 +506,7 @@ static void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc) /* Put duration on right */ ts_to_hms(range, &hms); hms_format(str, sizeof(str), &hms); - lcd_(getstringsize)(str, &text_w, NULL); + lcd_(getstringsize)(str, &text_w, NULL, NULL); lcd_(putsxy)(SLIDER_X + SLIDER_WIDTH - text_w, text_y, str); diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index eaf8f24..a97f033 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -679,7 +679,7 @@ static void wvs_text_init(void) ts_to_hms(stream_get_duration(), &hms); hms_format(buf, sizeof (buf), &hms); - lcd_(getstringsize)(buf, &wvs.time_rect.r, &wvs.time_rect.b); + lcd_(getstringsize)(buf, &wvs.time_rect.r, &wvs.time_rect.b, NULL); /* Choose well-sized bitmap images relative to font height */ if (wvs.time_rect.b < 12) { @@ -709,8 +709,8 @@ static void wvs_text_init(void) rb->snprintf(buf, sizeof(buf), "%d%s", phys, rb->sound_unit(SOUND_VOLUME)); - lcd_(getstringsize)(" ", &spc_width, NULL); - lcd_(getstringsize)(buf, &wvs.vol_rect.r, &wvs.vol_rect.b); + lcd_(getstringsize)(" ", &spc_width, NULL, NULL); + lcd_(getstringsize)(buf, &wvs.vol_rect.r, &wvs.vol_rect.b, NULL); wvs.prog_rect.r = SCREEN_WIDTH - WVS_BDR_L - spc_width - wvs.vol_rect.r - WVS_BDR_R; @@ -861,7 +861,7 @@ static void wvs_refresh_volume(void) rb->snprintf(buf, sizeof (buf), "%d%s", rb->sound_val2phys(SOUND_VOLUME, volume), rb->sound_unit(SOUND_VOLUME)); - lcd_(getstringsize)(buf, &width, NULL); + lcd_(getstringsize)(buf, &width, NULL, NULL); /* Right-justified */ draw_clear_area_rect(&wvs.vol_rect); diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c index 5d55bb4..6256768 100644 --- a/apps/plugins/oscilloscope.c +++ b/apps/plugins/oscilloscope.c @@ -483,7 +483,7 @@ void anim_horizontal(int cur_left, int cur_right) { int width; - rb->lcd_getstringsize(message, &width, NULL); + rb->lcd_getstringsize(message, &width, NULL, NULL); last_pos -= width - 1; rb->lcd_putsxy(last_pos, 0, message); displaymsg = false; @@ -733,7 +733,7 @@ enum plugin_status plugin_start(const void* parameter) /* Turn off backlight timeout */ backlight_force_on(); /* backlight control in lib/helper.c */ - rb->lcd_getstringsize("A", NULL, &font_height); + font_height = rb->lcd_get_linespace(-1); while (!exit) { diff --git a/apps/plugins/pegbox.c b/apps/plugins/pegbox.c index 514b92e..8346dad 100644 --- a/apps/plugins/pegbox.c +++ b/apps/plugins/pegbox.c @@ -736,7 +736,8 @@ static void display_text(char *str, bool waitkey) rb->lcd_clear_display(); - rb->lcd_getstringsize("a", &char_width, &char_height); + rb->lcd_getstringsize("a", &char_width, NULL, NULL); + char_height = rb->lcd_get_linespace(-1); chars_by_line = LCD_WIDTH / char_width; lines_by_screen = LCD_HEIGHT / char_height; @@ -1183,9 +1184,9 @@ static unsigned int pegbox_menu(struct game_context* pb) { MENU_X, MENU_Y+ITEM_HEIGHT*3, ITEM_WIDTH, ITEM_HEIGHT); } #else - unsigned int w,h; + unsigned int w; rb->lcd_clear_display(); - rb->lcd_getstringsize("PegBox", &w, &h); + rb->lcd_getstringsize("PegBox", &w, NULL, NULL); rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, "PegBox"); rb->lcd_putsxy((LCD_WIDTH)/4, 16, "New Game"); rb->lcd_putsxy((LCD_WIDTH)/4, 24, "Resume"); diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index 5613ce8..a514166 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c @@ -749,7 +749,7 @@ void draw_progressbar(int step) const int w = LCD_WIDTH - 20; const int x = 10; - rb->lcd_getstringsize("Preparing album artwork", &txt_w, &txt_h); + rb->lcd_getstringsize("Preparing album artwork", &txt_w, &txt_h, NULL); int y = (LCD_HEIGHT - txt_h)/2; @@ -1942,7 +1942,7 @@ void show_track_list(void) for (;track_i < track_list_visible_entries+start_index_track_list; track_i++) { - MYLCD(getstringsize)(get_track_name(track_i), &titletxt_w, NULL); + MYLCD(getstringsize)(get_track_name(track_i), &titletxt_w, NULL, NULL); titletxt_x = (LCD_WIDTH-titletxt_w)/2; if ( track_i == selected_track ) { draw_gradient(titletxt_y, titletxt_h); @@ -2018,7 +2018,7 @@ void draw_album_text(void) } MYLCD(set_foreground)(G_BRIGHT(c)); - MYLCD(getstringsize)(albumtxt, &albumtxt_w, &albumtxt_h); + MYLCD(getstringsize)(albumtxt, &albumtxt_w, &albumtxt_h, NULL); if (center_index != prev_center_index) { albumtxt_x = 0; albumtxt_dir = -1; diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c index 148f1a1..5146748 100644 --- a/apps/plugins/pong.c +++ b/apps/plugins/pong.c @@ -492,7 +492,7 @@ void showscore(struct pong *p) int w; rb->snprintf(buffer, sizeof(buffer), "%d - %d", p->score[0], p->score[1]); - w = rb->lcd_getstringsize((unsigned char *)buffer, NULL, NULL); + w = rb->lcd_getstringsize((unsigned char *)buffer, NULL, NULL, NULL); rb->lcd_putsxy( (LCD_WIDTH / 2) - (w / 2), 0, (unsigned char *)buffer); } diff --git a/apps/plugins/reversi/reversi-gui.c b/apps/plugins/reversi/reversi-gui.c index b6bbd5f..7ba34a7 100644 --- a/apps/plugins/reversi/reversi-gui.c +++ b/apps/plugins/reversi/reversi-gui.c @@ -293,7 +293,7 @@ static void reversi_gui_display_board(void) { /* Draw the current score */ reversi_count_occupied_cells(&game, &r, &c); - rb->lcd_getstringsize("x", &x_width, &x_height); + rb->lcd_getstringsize("x", &x_width, &x_height, NULL); x = LEGEND_X(0); y = LEGEND_Y(0); diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c index 7ae5721..89e3fbc 100644 --- a/apps/plugins/robotfindskitten.c +++ b/apps/plugins/robotfindskitten.c @@ -866,9 +866,9 @@ static void instructions() "Press", "any", "key", "to", "start", }; rb->lcd_clear_display(); - rb->lcd_getstringsize(" ", &space_w, &height); + rb->lcd_getstringsize(" ", &space_w, &height, NULL); for (i = 0; i < WORDS; i++) { - rb->lcd_getstringsize(instructions[i], &width, NULL); + rb->lcd_getstringsize(instructions[i], &width, NULL, NULL); /* Skip to next line if the current one can't fit the word */ if (x + width > LCD_WIDTH - MARGIN) { x = MARGIN; diff --git a/apps/plugins/rockblox1d.c b/apps/plugins/rockblox1d.c index d7779fa..b722e7a 100644 --- a/apps/plugins/rockblox1d.c +++ b/apps/plugins/rockblox1d.c @@ -195,7 +195,7 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_setfont(FONT_SYSFIXED); - rb->lcd_getstringsize("100000000", &f_width, &f_height); + rb->lcd_getstringsize("100000000", &f_width, &f_height, NULL); rb->lcd_clear_display(); @@ -221,7 +221,7 @@ enum plugin_status plugin_start(const void* parameter) score_x = SCORE_X; /* Next box */ - rb->lcd_getstringsize("next", &f_width, NULL); + rb->lcd_getstringsize("next", &f_width, NULL, NULL); #if (LCD_WIDTH > LCD_HEIGHT) && !(LCD_WIDTH > 132) rb->lcd_drawrect(NEXT_X-5, NEXT_Y-5, WIDTH+10, NEXT_H+10); rb->lcd_putsxy(score_x-4, NEXT_Y-5, "next"); diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index d10e2b6..075e4b8 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c @@ -43,7 +43,7 @@ static int getbutton(char *text) { int fw, fh; rb->lcd_clear_display(); - rb->font_getstringsize(text, &fw, &fh,0); + rb->font_getstringsize(text, &fw, &fh, 0, 0); rb->lcd_putsxy(LCD_WIDTH/2-fw/2, LCD_HEIGHT/2-fh/2, text); rb->lcd_update(); rb->sleep(30); diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c old mode 100644 new mode 100755 index 19d0860..5a9118b --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c @@ -480,19 +480,27 @@ static void buffer_putsxyofs( fb_data *buf, int buf_width, int buf_height, { unsigned short ch; unsigned short *ucs; + int font = FONT_UI; + struct font *pf; - struct font *pf = rb->font_get( FONT_UI ); - if( !pf ) pf = rb->font_get( FONT_SYSFIXED ); + + pf = rb->font_get( font ); + if ( !pf ) + { + font = FONT_SYSFIXED; + pf = rb->font_get( font ); + } ucs = rb->bidi_l2v( str, 1 ); while( (ch = *ucs++) != 0 && x < buf_width ) { - int width; + int width, a, d, oy; const unsigned char *bits; /* get proportional width and glyph bits */ - width = rb->font_get_width( pf, ch ); + rb->font_getboundingboxsize(pf, ch, &width, &a, &d); + oy = pf->maxascent - a; if( ofs > width ) { @@ -502,7 +510,8 @@ static void buffer_putsxyofs( fb_data *buf, int buf_width, int buf_height, bits = rb->font_get_bits( pf, ch ); - buffer_mono_bitmap_part( buf, buf_width, buf_height, bits, ofs, 0, width, x, y, width - ofs, pf->height); + buffer_mono_bitmap_part( buf, buf_width, buf_height, bits, ofs, oy, width, + x, y + oy, width - ofs, a + d); x += width - ofs; ofs = 0; @@ -601,7 +610,7 @@ static int draw_window( int height, int width, const char *title ) { int fh; - rb->lcd_getstringsize( title, NULL, &fh ); + rb->lcd_getstringsize( title, NULL, &fh, NULL ); fh++; const int _top = ( LCD_HEIGHT - height ) / 2; @@ -631,14 +640,14 @@ static int menu_display( struct menu_items menu[], int prev_value ) top, left; int scroll = 0, onscreen = 0; - rb->lcd_getstringsize( menu[0].label, &width, &fh ); + rb->lcd_getstringsize( menu[0].label, &width, &fh, NULL ); for( i=1; menu[i].value != MENU_END; i++ ) { if( prev_value == menu[i].value ) { selection = i; } - rb->lcd_getstringsize( menu[i].label, &a, &b ); + rb->lcd_getstringsize( menu[i].label, &a, &b, NULL ); if( a > width ) width = a; if( b > fh ) fh = b; } @@ -756,7 +765,7 @@ static bool browse( char *dst, int dst_size, const char *start ) int fh; char *a; - rb->lcd_getstringsize( "Ap", NULL, &fh ); + rb->lcd_getstringsize( "Ap", NULL, &fh, NULL ); rb->strcpy( bbuf, start ); a = bbuf+rb->strlen(bbuf)-1; @@ -976,7 +985,7 @@ static bool browse_fonts( char *dst, int dst_size ) rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s", de->d_name ); rb->font_load( bbuf ); - rb->font_getstringsize( de->d_name, &fw, &fh, FONT_UI ); + rb->font_getstringsize( de->d_name, &fw, &fh, NULL, FONT_UI ); if( nvih > 0 ) { nvih -= fh; @@ -1011,7 +1020,7 @@ static bool browse_fonts( char *dst, int dst_size ) rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s", de->d_name ); rb->font_load( bbuf ); - rb->font_getstringsize( de->d_name, NULL, &fh, FONT_UI ); + rb->font_getstringsize( de->d_name, NULL, &fh, NULL, FONT_UI ); nvih = fh; } } diff --git a/apps/plugins/searchengine/searchengine.h b/apps/plugins/searchengine/searchengine.h index 090adb7..52022ae 100644 --- a/apps/plugins/searchengine/searchengine.h +++ b/apps/plugins/searchengine/searchengine.h @@ -28,7 +28,7 @@ extern int w, h, y; #ifdef HAVE_LCD_BITMAP #define PUTS(str) do { \ rb->lcd_putsxy(1, y, str); \ - rb->lcd_getstringsize(str, &w, &h); \ + rb->lcd_getstringsize(str, &w, &h, NULL); \ y += h + 1; \ } while (0); \ rb->lcd_update() diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c index c5c8c67..e9e88f8 100644 --- a/apps/plugins/sliding_puzzle.c +++ b/apps/plugins/sliding_puzzle.c @@ -409,7 +409,7 @@ static void draw_spot(int p, int x, int y) rb->lcd_set_drawmode(DRMODE_SOLID); rb->snprintf(s, sizeof(s), "%d", p); rb->lcd_setfont(num_font); - rb->lcd_getstringsize(s, &w, &h); + rb->lcd_getstringsize(s, &w, &h, NULL); rb->lcd_putsxy(x + (SPOTS_WIDTH/2) - w / 2, y + (SPOTS_HEIGHT/2) - h / 2, s); } @@ -435,7 +435,7 @@ static void move_spot(int x, int y) rb->lcd_setfont(moves_font); #if LCD_WIDTH > LCD_HEIGHT rb->snprintf(s, sizeof(s), "%d", moves); - w = rb->lcd_getstringsize(s, NULL, NULL); + w = rb->lcd_getstringsize(s, NULL, NULL, NULL); rb->lcd_putsxy((IMAGE_WIDTH+1+(LCD_WIDTH-IMAGE_WIDTH-1)/2) - w / 2, moves_y, s); #else @@ -473,11 +473,11 @@ static void draw_playfield(void) rb->lcd_setfont(moves_font); #if LCD_WIDTH > LCD_HEIGHT rb->lcd_vline(IMAGE_WIDTH, 0, LCD_HEIGHT-1); - w = rb->lcd_getstringsize("Moves", NULL, NULL); + w = rb->lcd_getstringsize("Moves", NULL, NULL, NULL); rb->lcd_putsxy((IMAGE_WIDTH+1+(LCD_WIDTH-IMAGE_WIDTH-1)/2) - w / 2, 10, "Moves"); rb->snprintf(s, sizeof(s), "%d", moves); - w = rb->lcd_getstringsize(s, NULL, NULL); + w = rb->lcd_getstringsize(s, NULL, NULL, NULL); rb->lcd_putsxy((IMAGE_WIDTH+1+(LCD_WIDTH-IMAGE_WIDTH-1)/2) - w / 2, moves_y, s); #else @@ -646,7 +646,7 @@ enum plugin_status plugin_start( picmode = PICMODE_DEFAULT_PICTURE; /* print title */ - rb->lcd_getstringsize((unsigned char *)"Sliding Puzzle", &w, &h); + rb->lcd_getstringsize((unsigned char *)"Sliding Puzzle", &w, &h, NULL); w = (w+1)/2; h = (h+1)/2; rb->lcd_clear_display(); @@ -724,23 +724,23 @@ enum plugin_status plugin_start( /* Calculate possible font sizes and text positions */ rb->lcd_setfont(FONT_UI); - rb->lcd_getstringsize("15", &w, &h); + rb->lcd_getstringsize("15", &w, &h, NULL); if ((w > (SPOTS_WIDTH-2)) || (h > (SPOTS_HEIGHT-2))) num_font = FONT_SYSFIXED; #if LCD_WIDTH > LCD_HEIGHT - rb->lcd_getstringsize("Moves", &w, &h); + rb->lcd_getstringsize("Moves", &w, &h, NULL); if (w > (LCD_WIDTH-IMAGE_WIDTH-1)) moves_font = FONT_SYSFIXED; rb->lcd_setfont(moves_font); - rb->lcd_getstringsize("Moves", &w, &h); + rb->lcd_getstringsize("Moves", &w, &h, NULL); moves_y = 10 + h; #else - rb->lcd_getstringsize("Moves: 999", &w, &h); + rb->lcd_getstringsize("Moves: 999", &w, &h, NULL); if ((w > LCD_WIDTH) || (h > (LCD_HEIGHT-IMAGE_HEIGHT-1))) moves_font = FONT_SYSFIXED; rb->lcd_setfont(moves_font); - rb->lcd_getstringsize("Moves: 999", &w, &h); + rb->lcd_getstringsize("Moves: 999", &w, &h, NULL); moves_y = (IMAGE_HEIGHT+1+(LCD_HEIGHT-IMAGE_HEIGHT-1)/2) - h / 2; #endif for (i=0; ilcd_bitmap(snake2_bottom,0,BMPHEIGHT_snake2_header+BMPHEIGHT_snake2_left,BMPWIDTH_snake2_bottom, BMPHEIGHT_snake2_bottom); rb->snprintf(counter,sizeof(counter),"%d",applecount); - rb->lcd_getstringsize(counter,&strwdt,&strhgt); + rb->lcd_getstringsize(counter,&strwdt,&strhgt, NULL); rb->lcd_putsxy(TOP_X3-strwdt/2,TOP_Y2,counter); rb->snprintf(pscore,sizeof(pscore),"%d",score); - rb->lcd_getstringsize(pscore,&strwdt,&strhgt); + rb->lcd_getstringsize(pscore,&strwdt,&strhgt, NULL); rb->lcd_putsxy(TOP_X4-strwdt/2,TOP_Y2,pscore); #endif @@ -957,28 +957,28 @@ void die (void) applecount=0; - rb->lcd_getstringsize("You died!",&strwdt,&strhgt); + rb->lcd_getstringsize("You died!",&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt,"You died!"); rb->snprintf(pscore,sizeof(pscore),"Your score: %d",score); - rb->lcd_getstringsize(pscore,&strwdt,&strhgt); + rb->lcd_getstringsize(pscore,&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt * 2 + 2,pscore); if (score>hiscore) { hiscore=score; - rb->lcd_getstringsize("New high score!",&strwdt,&strhgt); + rb->lcd_getstringsize("New high score!",&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt * 4 + 2,"New high score!"); } else { rb->snprintf(phscore,sizeof(phscore),"High score: %d",hiscore); - rb->lcd_getstringsize(phscore,&strwdt,&strhgt); + rb->lcd_getstringsize(phscore,&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt * 5,phscore); } rb->snprintf(phscore,sizeof(phscore),"Press %s...",SNAKE2_PLAYPAUSE_TEXT); - rb->lcd_getstringsize(phscore,&strwdt,&strhgt); + rb->lcd_getstringsize(phscore,&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt * 7,phscore); rb->lcd_update(); @@ -1199,7 +1199,7 @@ void game_pause (void) int button; rb->lcd_clear_display(); - rb->lcd_getstringsize("Paused",&strwdt,&strhgt); + rb->lcd_getstringsize("Paused",&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,LCD_HEIGHT/2,"Paused"); rb->lcd_update(); @@ -1350,46 +1350,46 @@ void game_init(void) rb->lcd_bitmap(snake2_bottom,0,BMPHEIGHT_snake2_header+BMPHEIGHT_snake2_left,BMPWIDTH_snake2_bottom, BMPHEIGHT_snake2_bottom); rb->snprintf(plevel,sizeof(plevel),"%d",level); - rb->lcd_getstringsize(plevel,&strwdt,&strhgt); + rb->lcd_getstringsize(plevel,&strwdt,&strhgt, NULL); rb->lcd_putsxy(TOP_X3-strwdt/2,TOP_Y2, plevel); rb->snprintf(plevel,sizeof(plevel),"%d",level_from_file); - rb->lcd_getstringsize(plevel,&strwdt,&strhgt); + rb->lcd_getstringsize(plevel,&strwdt,&strhgt, NULL); rb->lcd_putsxy(TOP_X2-strwdt/2,TOP_Y1, plevel); if(game_type==0){ - rb->lcd_getstringsize("A",&strwdt,&strhgt); + rb->lcd_getstringsize("A",&strwdt,&strhgt, NULL); rb->lcd_putsxy(TOP_X1,TOP_Y1,"A"); } else{ - rb->lcd_getstringsize("B",&strwdt,&strhgt); + rb->lcd_getstringsize("B",&strwdt,&strhgt, NULL); rb->lcd_putsxy(TOP_X1,TOP_Y1,"B"); } rb->snprintf(phscore,sizeof(phscore),"%d",hiscore); - rb->lcd_getstringsize(phscore,&strwdt,&strhgt); + rb->lcd_getstringsize(phscore,&strwdt,&strhgt, NULL); rb->lcd_putsxy(TOP_X4-strwdt/2,TOP_Y2, phscore); #else rb->snprintf(plevel,sizeof(plevel),"Speed: %02d",level); - rb->lcd_getstringsize("Speed: 00",&strwdt,&strhgt); + rb->lcd_getstringsize("Speed: 00",&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt+4, plevel); rb->snprintf(plevel,sizeof(plevel),"Maze: %d",level_from_file); - rb->lcd_getstringsize(plevel,&strwdt,&strhgt); + rb->lcd_getstringsize(plevel,&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt*2+4, plevel); if(game_type==0){ - rb->lcd_getstringsize("Game Type: A ",&strwdt,&strhgt); + rb->lcd_getstringsize("Game Type: A ",&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt*3+4,"Game Type: A"); } else{ - rb->lcd_getstringsize("Game Type: B ",&strwdt,&strhgt); + rb->lcd_getstringsize("Game Type: B ",&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt*3+4,"Game Type: B"); } rb->snprintf(phscore,sizeof(phscore),"Hi Score: %d",hiscore); - rb->lcd_getstringsize(phscore,&strwdt,&strhgt); + rb->lcd_getstringsize(phscore,&strwdt,&strhgt, NULL); rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt*4+4, phscore); #endif diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c index e8ccdac..efb75d7 100644 --- a/apps/plugins/sokoban.c +++ b/apps/plugins/sokoban.c @@ -1512,23 +1512,23 @@ static bool sokoban_loop(void) /* Show level complete message & stats */ rb->snprintf(buf, sizeof(buf), "Level %d Complete!", current_info.level.index + 1); - rb->lcd_getstringsize(buf, &w, &h); + rb->lcd_getstringsize(buf, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 - h*3, buf); rb->snprintf(buf, sizeof(buf), "%4d Moves ", current_info.level.moves); - rb->lcd_getstringsize(buf, &w, &h); + rb->lcd_getstringsize(buf, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 - h, buf); rb->snprintf(buf, sizeof(buf), "%4d Pushes", current_info.level.pushes); - rb->lcd_getstringsize(buf, &w, &h); + rb->lcd_getstringsize(buf, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2, buf); if (undo_info.count < MAX_UNDOS) { rb->snprintf(buf, sizeof(buf), "%s: Save solution", BUTTON_SAVE_NAME); - rb->lcd_getstringsize(buf, &w, &h); + rb->lcd_getstringsize(buf, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 + h*2, buf); } @@ -1589,7 +1589,7 @@ static bool sokoban_loop(void) if (current_info.level.index >= current_info.max_level) { /* Show levelset complete message */ rb->snprintf(buf, sizeof(buf), "You WIN!!"); - rb->lcd_getstringsize(buf, &w, &h); + rb->lcd_getstringsize(buf, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 - h/2, buf); rb->lcd_set_drawmode(DRMODE_COMPLEMENT); @@ -1634,7 +1634,7 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_setfont(SOKOBAN_FONT); rb->lcd_clear_display(); - rb->lcd_getstringsize(SOKOBAN_TITLE, &w, &h); + rb->lcd_getstringsize(SOKOBAN_TITLE, &w, &h, NULL); rb->lcd_putsxy(LCD_WIDTH/2 - w/2, LCD_HEIGHT/2 - h/2, SOKOBAN_TITLE); rb->lcd_update(); rb->sleep(HZ); /* Show title for 1 second */ diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c index c6cf6f0..daf11e2 100644 --- a/apps/plugins/solitaire.c +++ b/apps/plugins/solitaire.c @@ -646,7 +646,7 @@ static void init_help(void) int para_len; char *para = helptext; - rb->lcd_getstringsize(" ", &w_space, &h); + rb->lcd_getstringsize(" ", &w_space, &h, NULL); displaylines = LCD_HEIGHT / h; para_len = rb->strlen(para); @@ -659,7 +659,7 @@ static void init_help(void) next = rb->strtok_r(para, " ", &store); while (next) { - rb->lcd_getstringsize(next, &w, NULL); + rb->lcd_getstringsize(next, &w, NULL, NULL); if (!first) { if (x + w > LCD_WIDTH) diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c index 81a8b24..0526a33 100644 --- a/apps/plugins/splitedit.c +++ b/apps/plugins/splitedit.c @@ -206,7 +206,7 @@ static void update_data(void) format_time_ms(timebuf, sizeof buf, xpos_to_time(split_x)); rb->snprintf(buf, sizeof buf, "Split at: %s", timebuf); - rb->lcd_getstringsize(buf, &w, &h); + rb->lcd_getstringsize(buf, &w, &h, NULL); rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); rb->lcd_fillrect(0, 0, LCD_WIDTH, h); @@ -665,7 +665,7 @@ static int save( long offset; unsigned long last_header = rb->mpeg_get_last_header(); - rb->lcd_getstringsize("M", &x, &y); + rb->lcd_getstringsize("M", &x, &y, NULL); /* Find the next frame boundary */ rb->lseek(src_file, end, SEEK_SET); diff --git a/apps/plugins/star.c b/apps/plugins/star.c index c4251cd..bd6998b 100644 --- a/apps/plugins/star.c +++ b/apps/plugins/star.c @@ -1013,7 +1013,7 @@ static int star_menu(void) bool menu_quit = false; struct viewport vp[NB_SCREENS]; /* get the size of char */ - rb->lcd_getstringsize("a", &char_width, &char_height); + rb->lcd_getstringsize("a", &char_width, &char_height, NULL); MENUITEM_STRINGLIST(menu,"Star Menu",NULL,"Play","Choose Level", "Information","Keys","Quit"); @@ -1117,7 +1117,7 @@ static int star_menu(void) if (selection == MENU_START) { rb->lcd_setfont(FONT_SYSFIXED); - rb->lcd_getstringsize("a", &char_width, &char_height); + rb->lcd_getstringsize("a", &char_width, &char_height, NULL); level--; star_run_game(level); } diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c index 8b5c64d..e93a195 100644 --- a/apps/plugins/starfield.c +++ b/apps/plugins/starfield.c @@ -341,7 +341,7 @@ int plugin_main(void) int button, avg_peak, t_disp=0; int font_h, font_w; bool pulse=true; - rb->lcd_getstringsize("A", &font_w, &font_h); + rb->lcd_getstringsize("A", &font_w, &font_h, NULL); starfield_init(&starfield); starfield_add_stars(&starfield, INIT_STARS); diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c index 4cba167..04833ed 100644 --- a/apps/plugins/stopwatch.c +++ b/apps/plugins/stopwatch.c @@ -362,7 +362,7 @@ enum plugin_status plugin_start(const void* parameter) #ifdef HAVE_LCD_BITMAP int h; rb->lcd_setfont(FONT_UI); - rb->lcd_getstringsize("M", NULL, &h); + rb->lcd_getstringsize("M", NULL, &h, NULL); lines = (LCD_HEIGHT / h) - (LAP_Y); #else lines = 1; diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index 31f04b3..23c3597 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c @@ -588,9 +588,9 @@ static int do_help(void) { "and", "number", "of", "troops", "on", "them.", }; rb->lcd_clear_display(); - rb->lcd_getstringsize(" ", &space_w, &height); + rb->lcd_getstringsize(" ", &space_w, &height, NULL); for (i = 0; i < WORDS; i++) { - rb->lcd_getstringsize(instructions[i], &width, NULL); + rb->lcd_getstringsize(instructions[i], &width, NULL, NULL); /* Skip to next line if the current one can't fit the word */ if (x + width > LCD_WIDTH - MARGIN) { x = MARGIN; @@ -781,7 +781,7 @@ int get_number(char* param, int* value) { rb->snprintf(buf,sizeof(buf), "%d", *value); rb->lcd_putsxy(NUM_MARGIN_X+10, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, buf); int height, width; - rb->lcd_getstringsize(param, &width, &height); + rb->lcd_getstringsize(param, &width, &height, NULL); rb->lcd_putsxy((LCD_WIDTH-width)/2, (NUM_MARGIN_Y-height)/2, param); rb->lcd_set_drawmode(DRMODE_COMPLEMENT); rb->lcd_fillrect(NUM_MARGIN_X+(NUM_BOX_WIDTH*x), diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index b99e57b..f69c236 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -44,7 +44,7 @@ static bool log_init(bool use_logfile) { int h; - rb->lcd_getstringsize("A", NULL, &h); + rb->lcd_getstringsize("A", NULL, &h, NULL); max_line = LCD_HEIGHT / h; line = 0; rb->lcd_clear_display(); diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index 2fa841b..641f5cb 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c @@ -78,7 +78,7 @@ static bool log_init(void) { int h; - rb->lcd_getstringsize("A", NULL, &h); + rb->lcd_getstringsize("A", NULL, &h, NULL); max_line = LCD_HEIGHT / h; line = 0; rb->lcd_clear_display(); diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c index c688a54..4382ee6 100644 --- a/apps/plugins/test_fps.c +++ b/apps/plugins/test_fps.c @@ -57,13 +57,13 @@ static void log_init(void) { int h; - rb->lcd_getstringsize("A", NULL, &h); + rb->lcd_getstringsize("A", NULL, &h, NULL); max_line = LCD_HEIGHT / h; line = 0; rb->lcd_clear_display(); rb->lcd_update(); #ifdef HAVE_REMOTE_LCD - rb->lcd_remote_getstringsize("A", NULL, &h); + rb->lcd_remote_getstringsize("A", NULL, &h, NULL); remote_max_line = LCD_REMOTE_HEIGHT / h; remote_line = 0; rb->lcd_remote_clear_display(); diff --git a/apps/plugins/video.c b/apps/plugins/video.c index bcbbb99..ad678a2 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c @@ -264,7 +264,7 @@ void DrawPosition(int pos, int total) else /* a very long clip, hh:mm format */ rb->snprintf(gPrint, sizeof(gPrint), "%02d:%02dh", sec/3600, (sec/60)%60); - rb->lcd_getstringsize(gPrint, &w, &h); + rb->lcd_getstringsize(gPrint, &w, &h, NULL); w++; ypos = gBuf.osd_ypos + (gBuf.osd_height - h) / 2; rb->lcd_putsxy(0, ypos, gPrint); @@ -291,7 +291,7 @@ void osd_show_text(void) rb->lcd_fillrect(0, gBuf.osd_ypos, LCD_WIDTH, gBuf.osd_height); rb->lcd_set_drawmode(DRMODE_SOLID); - rb->lcd_getstringsize(gPrint, NULL, &h); + rb->lcd_getstringsize(gPrint, NULL, &h, NULL); ypos = gBuf.osd_ypos + (gBuf.osd_height - h) / 2; rb->lcd_putsxy(0, ypos, gPrint); @@ -899,7 +899,7 @@ int main(char* filename) gBuf.pBufFill = gBuf.pBufStart; /* all empty */ /* init OSD */ - rb->lcd_getstringsize("X", NULL, &retval); + rb->lcd_getstringsize("X", NULL, &retval, NULL); gBuf.osd_height = (retval + 7) & ~7; gBuf.osd_ypos = LCD_HEIGHT - gBuf.osd_height; diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c old mode 100644 new mode 100755 index f01afbb..645b5c9 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c @@ -431,7 +431,7 @@ static unsigned char *next_line_ptr; #ifdef HAVE_LCD_BITMAP static struct font *pf; #endif - +static int ls; int glyph_width(int ch) { @@ -1067,7 +1067,7 @@ static void viewer_draw(int col) } if (col != -1 && line_width > col) #ifdef HAVE_LCD_BITMAP - rb->lcd_putsxy(left_col, i*pf->height, utf8_buffer); + rb->lcd_putsxy(left_col, i*ls, utf8_buffer); #else rb->lcd_puts(left_col, i, utf8_buffer); #endif @@ -1152,14 +1152,15 @@ static bool viewer_init(void) #ifdef HAVE_LCD_BITMAP pf = rb->font_get(FONT_UI); - - display_lines = LCD_HEIGHT / pf->height; + ls = rb->font_get_linespace(pf, -1); + display_lines = LCD_HEIGHT / ls; draw_columns = display_columns = LCD_WIDTH; #else /* REAL fixed pitch :) all chars use up 1 cell */ display_lines = 2; draw_columns = display_columns = 11; par_indent_spaces = 2; + ls = 1; #endif fd = rb->open(file_name, O_RDONLY); diff --git a/apps/plugins/zxbox/zxbox_keyb.c b/apps/plugins/zxbox/zxbox_keyb.c index 7464f2e..b059b48 100644 --- a/apps/plugins/zxbox/zxbox_keyb.c +++ b/apps/plugins/zxbox/zxbox_keyb.c @@ -259,13 +259,13 @@ int zx_kbd_input(char* text/*, int buflen*/) FOR_NB_SCREENS(l) { param[l].font = rb->font_get(param[l].curfont); - param[l].font_h = param[l].font->height; + param[l].font_h = rb->font_get_linespace(param[l].font, -1); /* check if FONT_UI fits the screen */ if (2*param[l].font_h+3 + BUTTONBAR_HEIGHT > rb->screens[l]->getheight()) { param[l].font = rb->font_get(FONT_SYSFIXED); - param[l].font_h = param[l].font->height; + param[l].font_h = rb->font_get_linespace(param[l].font, -1); param[l].curfont = FONT_SYSFIXED; } @@ -384,7 +384,7 @@ int zx_kbd_input(char* text/*, int buflen*/) for (i=j=0; j < param[l].lines && k < param[l].nchars; k++) { utf8 = rb->utf8encode(param[l].kbd_buf[k], outline); *utf8 = 0; - rb->screens[l]->getstringsize(outline, &w, NULL); + rb->screens[l]->getstringsize(outline, &w, NULL, NULL); rb->screens[l]->putsxy(i*param[l].font_w + (param[l].font_w-w)/2, j*param[l].font_h + statusbar_size, outline); if (++i == param[l].max_chars) { @@ -418,13 +418,13 @@ int zx_kbd_input(char* text/*, int buflen*/) outline[j] = 0; j=0; i++; - rb->screens[l]->getstringsize(outline, &w, NULL); + rb->screens[l]->getstringsize(outline, &w, NULL, NULL); rb->screens[l]->putsxy(i*text_w + (text_w-w)/2, param[l].main_y, outline); } } if (param[l].leftpos) { - rb->screens[l]->getstringsize("<", &w, NULL); + rb->screens[l]->getstringsize("<", &w, NULL, NULL); rb->screens[l]->putsxy(text_w - w, param[l].main_y, "<"); } if (len_utf8 - param[l].leftpos > param[l].max_chars_text) diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index a308710..ea0471d 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c @@ -384,14 +384,14 @@ int kbd_input(char* text, int buflen) int i, w; pm->font = font_get(pm->curfont); - pm->font_h = pm->font->height; + pm->font_h = font_get_linespace(pm->font, -1); /* check if FONT_UI fits the screen */ if (2*pm->font_h + 3 + statusbar_size + BUTTONBAR_HEIGHT > sc->getheight()) { pm->font = font_get(FONT_SYSFIXED); - pm->font_h = pm->font->height; + pm->font_h = font_get_linespace(pm->font, -1); pm->curfont = FONT_SYSFIXED; } @@ -619,7 +619,7 @@ int kbd_input(char* text, int buflen) utf8 = utf8encode(pm->kbd_buf[k], outline); *utf8 = 0; - sc->getstringsize(outline, &w, NULL); + sc->getstringsize(outline, &w, NULL, NULL); sc->putsxy(i*pm->font_w + (pm->font_w-w) / 2, j*pm->font_h + statusbar_size, outline); @@ -668,7 +668,7 @@ int kbd_input(char* text, int buflen) outline[j] = 0; j=0; i++; - sc->getstringsize(outline, &w, NULL); + sc->getstringsize(outline, &w, NULL, NULL); sc->putsxy(i*text_w + (text_w-w)/2, pm->main_y, outline); } } @@ -685,7 +685,7 @@ int kbd_input(char* text, int buflen) else { int w; - sc->getstringsize("<", &w, NULL); + sc->getstringsize("<", &w, NULL, NULL); sc->putsxy(text_w - w, pm->main_y, "<"); } } diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c old mode 100644 new mode 100755 index f3270d1..77a47bf --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -504,7 +504,7 @@ int radio_screen(void) screens[i].update_viewport(); } - fh = font_get(FONT_UI)->height; + fh = font_get_linespace(font_get(FONT_UI), -1); /* Adjust for font size, trying to center the information vertically */ if(fh < 10) diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index de979dd..4d1df47 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -1097,6 +1097,7 @@ bool recording_screen(bool no_source) FOR_NB_SCREENS(i) { struct viewport *v; + int ls; /* top vp, 4 lines, force sys font if total screen < 6 lines NOTE: one could limit the list to 1 line and get away with 5 lines */ v = &vp_top[i]; @@ -1114,7 +1115,7 @@ bool recording_screen(bool no_source) else compact_view[i] = false; } - v->height = (font_get(v->font)->height)*(compact_view[i] ? 3 : 4); + v->height = font_get_linespace(font_get(v->font), -1) * (compact_view[i] ? 3 : 4); /* list section, rest of the screen */ v = &vp_list[i]; @@ -1124,11 +1125,12 @@ bool recording_screen(bool no_source) v->height = screens[i].lcdheight - v->y; /* the rest */ screens[i].set_viewport(&vp_top[i]); /* req for next calls */ - screens[i].getstringsize("W", &w, &h); - pm_y[i] = font_get(vp_top[i].font)->height * 2; - trig_ypos[i] = font_get(vp_top[i].font)->height * 3; + screens[i].getstringsize("W", &w, &h, NULL); + ls = font_get_linespace(font_get(vp_top[i].font), -1); + pm_y[i] = ls * 2; + trig_ypos[i] = ls * 3; if(compact_view[i]) - trig_ypos[i] -= (font_get(vp_top[i].font)->height)/2; + trig_ypos[i] -= ls/2; } /* init the bottom list */ @@ -1158,13 +1160,13 @@ bool recording_screen(bool no_source) { int clipwidth = 0; screens[i].getstringsize(str(LANG_PM_CLIPCOUNT), - &clipwidth, &h); /* h is same */ + &clipwidth, &h, NULL); /* h is same */ pm_x[i] = clipwidth+1; } if(global_settings.rec_trigger_mode == TRIG_MODE_OFF) - pm_h[i] = font_get(vp_top[i].font)->height * 2; + pm_h[i] = font_get_linespace(font_get(vp_top[i].font), -1) * 2; else - pm_h[i] = font_get(vp_top[i].font)->height; + pm_h[i] = font_get_linespace(font_get(vp_top[i].font), -1); if(compact_view[i]) pm_h[i] /= 2; trig_width[i] = vp_top[i].width - pm_x[i]; @@ -1968,7 +1970,7 @@ static bool f2_rec_screen(void) FOR_NB_SCREENS(i) { screens[i].setfont(FONT_SYSFIXED); - screens[i].getstringsize("A",&w,&h); + screens[i].getstringsize("A",&w,&h, NULL); } while (!exit) { @@ -1996,12 +1998,13 @@ static bool f2_rec_screen(void) ptr = freq_str[global_settings.rec_frequency]; FOR_NB_SCREENS(i) { - screens[i].getstringsize(buf,&w,&h); - screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf); - screens[i].getstringsize(ptr, &w, &h); - screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); + int ls = screens[i].get_linespace(-1); + screens[i].getstringsize(buf,&w, NULL, NULL); + screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - ls*2, buf); + screens[i].getstringsize(ptr, &w, NULL, NULL); + screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - ls, ptr); screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], - LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8); + LCD_WIDTH/2 - 3, LCD_HEIGHT - ls*3, 7, 8); } /* Channel mode */ @@ -2017,13 +2020,14 @@ static bool f2_rec_screen(void) FOR_NB_SCREENS(i) { - screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h); - screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, + int ls = screens[i].get_linespace(-1); + screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, NULL, NULL); + screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - ls*2, str(LANG_SYSFONT_CHANNELS)); - screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h); - screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, + screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, NULL, NULL); + screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - ls, str(LANG_SYSFONT_MODE)); - screens[i].getstringsize(ptr, &w, &h); + screens[i].getstringsize(ptr, &w, NULL, NULL); screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr); screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward], LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8); @@ -2103,7 +2107,7 @@ static bool f3_rec_screen(void) FOR_NB_SCREENS(i) { screens[i].setfont(FONT_SYSFIXED); - screens[i].getstringsize("A",&w,&h); + screens[i].getstringsize("A",&w,&h, NULL); } while (!exit) { @@ -2111,14 +2115,15 @@ static bool f3_rec_screen(void) ptr = src_str[global_settings.rec_source]; FOR_NB_SCREENS(i) { + int ls = screens[i].get_linespace(-1); screens[i].clear_display(); /* Recording source */ - screens[i].putsxy(0, LCD_HEIGHT/2 - h*2, + screens[i].putsxy(0, LCD_HEIGHT/2 - ls*2, str(LANG_SYSFONT_RECORDING_SOURCE)); - screens[i].getstringsize(ptr, &w, &h); - screens[i].putsxy(0, LCD_HEIGHT/2-h, ptr); + screens[i].getstringsize(ptr, &w, NULL, NULL); + screens[i].putsxy(0, LCD_HEIGHT/2-ls, ptr); screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8); } @@ -2127,10 +2132,11 @@ static bool f3_rec_screen(void) ptr = str(LANG_SYSFONT_RECORD_TRIGGER); FOR_NB_SCREENS(i) { - screens[i].getstringsize(ptr,&w,&h); - screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr); + int ls = screens[i].get_linespace(-1); + screens[i].getstringsize(ptr,&w, NULL, NULL); + screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - ls*2, ptr); screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], - LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8); + LCD_WIDTH/2 - 3, LCD_HEIGHT - ls*3, 7, 8); screens[i].update(); } diff --git a/apps/screen_access.c b/apps/screen_access.c index 2f928b7..21f95a7 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c @@ -45,7 +45,7 @@ static int screen_helper_getcharwidth(void) static int screen_helper_getcharheight(void) { #ifdef HAVE_LCD_BITMAP - return font_get(lcd_getfont())->height; + return font_get(lcd_getfont())->maxheight; #else return 1; #endif @@ -126,6 +126,7 @@ struct screen screens[NB_SCREENS] = .getwidth=&lcd_getwidth, .getheight=&lcd_getheight, .getstringsize=&lcd_getstringsize, + .get_linespace=&lcd_get_linespace, #ifdef HAVE_LCD_BITMAP .setfont=&lcd_setfont, .getfont=&lcd_getfont, @@ -217,6 +218,7 @@ struct screen screens[NB_SCREENS] = .getwidth=&lcd_remote_getwidth, .getheight=&lcd_remote_getheight, .getstringsize=&lcd_remote_getstringsize, + .get_linespace=&lcd_remote_get_linespace, #if 1 /* all remote LCDs are bitmapped so far */ .setfont=&lcd_remote_setfont, .getfont=&lcd_remote_getfont, diff --git a/apps/screen_access.h b/apps/screen_access.h index c76d2b1..e06a173 100644 --- a/apps/screen_access.h +++ b/apps/screen_access.h @@ -76,7 +76,8 @@ struct screen void (*set_viewport)(struct viewport* vp); int (*getwidth)(void); int (*getheight)(void); - int (*getstringsize)(const unsigned char *str, int *w, int *h); + int (*getstringsize)(const unsigned char *str, int *w, int *h, int *y); + int (*get_linespace)(int mode); #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) /* always bitmap */ void (*setfont)(int newfont); int (*getfont)(void); diff --git a/apps/screens.c b/apps/screens.c index 8a787a5..91a7a96 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -522,16 +522,16 @@ bool set_time_screen(const char* title, struct tm *tm) /* recalculate the positions and offsets */ if (nb_lines >= 3) - screens[s].getstringsize(title, NULL, &prev_line_height); + screens[s].getstringsize(title, NULL, &prev_line_height, NULL); else prev_line_height = 0; - screens[s].getstringsize(SEPARATOR, &separator_width, NULL); + screens[s].getstringsize(SEPARATOR, &separator_width, NULL, NULL); /* weekday */ screens[s].getstringsize(str(LANG_WEEKDAY_SUNDAY + tm->tm_wday), - &weekday_width, NULL); - screens[s].getstringsize(" ", &separator_width, NULL); + &weekday_width, NULL, NULL); + screens[s].getstringsize(" ", &separator_width, NULL, NULL); for(i=0, j=0; i < 6; i++) { @@ -540,7 +540,7 @@ bool set_time_screen(const char* title, struct tm *tm) j = weekday_width + separator_width;; prev_line_height *= 2; } - screens[s].getstringsize(ptr[i], &width, NULL); + screens[s].getstringsize(ptr[i], &width, NULL, NULL); cursor[i][INDEX_Y] = prev_line_height + statusbar_height; cursor[i][INDEX_X] = j; j += width + separator_width; diff --git a/apps/settings.c b/apps/settings.c index 71c29f6..d3e8edc 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -965,6 +965,9 @@ void settings_apply(bool read_disk) enc_global_settings_apply(); #endif list_init_viewports(NULL); +#ifdef HAVE_LCD_BITMAP + set_linespace_mode(global_settings.linespace); +#endif } diff --git a/apps/settings.h b/apps/settings.h index 3ea9ee9..1ecbe26 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -729,6 +729,7 @@ struct user_settings #ifdef HAVE_ACCESSORY_SUPPLY bool accessory_supply; /* 0=off 1=on, accessory power supply for iPod */ #endif + int linespace; /* 0=wide 1=middle 2=narrow */ #ifdef HAVE_SPEAKER bool speaker_enabled; diff --git a/apps/settings_list.c b/apps/settings_list.c index 2d9be08..a41d4f4 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -53,6 +53,7 @@ #include "iap.h" #endif #include "statusbar.h" +#include "font.h" #define NVRAM(bytes) (bytes<font; } -int lcd_getstringsize(const unsigned char *str, int *w, int *h) +int lcd_getstringsize(const unsigned char *str, int *w, int *h, int *y) { - return font_getstringsize(str, w, h, current_vp->font); + return font_getstringsize(str, w, h, y, current_vp->font); } +int lcd_get_linespace(int mode) +{ + return font_get_linespace(font_get(current_vp->font), mode); +} /*** low-level drawing functions ***/ #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) @@ -903,12 +907,12 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) while ((ch = *ucs++) != 0 && x < current_vp->width) { - int width; + int width, oy, a, d; const unsigned char *bits; /* get proportional width and glyph bits */ - width = font_get_width(pf,ch); - + font_getboundingboxsize(pf, ch, &width, &a, &d); + oy = pf->maxascent - a; if (ofs > width) { ofs -= width; @@ -917,7 +921,7 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) bits = font_get_bits(pf, ch); - lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height); + lcd_mono_bitmap_part(bits, ofs, oy, width, x, y + oy, width - ofs, a + d); x += width - ofs; ofs = 0; @@ -953,7 +957,7 @@ void lcd_puts_offset(int x, int y, const unsigned char *str, int offset) void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style, int offset) { - int xpos,ypos,w,h,xrect; + int xpos,ypos,w,h,oy,xrect; int lastmode = current_vp->drawmode; int oldfgcolor = current_vp->fg_pattern; int oldbgcolor = current_vp->bg_pattern; @@ -964,9 +968,9 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style, if(!str || !str[0]) return; - lcd_getstringsize(str, &w, &h); + lcd_getstringsize(str, &w, &h, &oy); xpos = x*w / utf8length(str); - ypos = y*h; + ypos = y*lcd_get_linespace(-1); current_vp->drawmode = (style & STYLE_INVERT) ? (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; if (style & STYLE_COLORED) { @@ -981,17 +985,20 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style, if (style & STYLE_GRADIENT) { current_vp->drawmode = DRMODE_FG; if (CURLN_UNPACK(style) == 0) - lcd_gradient_rect(xpos, current_vp->width, ypos, h*NUMLN_UNPACK(style)); + lcd_gradient_rect(xpos, current_vp->width, ypos + oy, h*NUMLN_UNPACK(style)); current_vp->fg_pattern = current_vp->lst_pattern; } else if (style & STYLE_COLORBAR) { current_vp->drawmode = DRMODE_FG; current_vp->fg_pattern = current_vp->lss_pattern; - lcd_fillrect(xpos, ypos, current_vp->width - xpos, h); + lcd_fillrect(xpos, ypos + oy, current_vp->width - xpos, h); current_vp->fg_pattern = current_vp->lst_pattern; } + else if (style == 0) { + current_vp->drawmode = DRMODE_SOLID; + } else { - lcd_fillrect(xrect, ypos, current_vp->width - xrect, h); + lcd_fillrect(xpos, ypos + oy, current_vp->width, h); current_vp->drawmode = (style & STYLE_INVERT) ? (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; } @@ -1023,7 +1030,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, int style, int offset) { struct scrollinfo* s; - int w, h; + int w; if ((unsigned)y >= (unsigned)current_vp->height) return; @@ -1039,7 +1046,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, s->style = style; lcd_puts_style_offset(x,y,string,style,offset); - lcd_getstringsize(string, &w, &h); + lcd_getstringsize(string, &w, NULL, NULL); if (current_vp->width - x * 8 < w) { /* prepare scroll line */ @@ -1049,7 +1056,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, strcpy(s->line, string); /* get width */ - s->width = lcd_getstringsize(s->line, &w, &h); + s->width = lcd_getstringsize(s->line, NULL, NULL, NULL); /* scroll bidirectional or forward only depending on the string width */ @@ -1063,7 +1070,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, if (!s->bidir) { /* add spaces if scrolling in the round */ strcat(s->line, " "); /* get new width incl. spaces */ - s->width = lcd_getstringsize(s->line, &w, &h); + s->width = lcd_getstringsize(s->line, NULL, NULL, NULL); } end = strchr(s->line, '\0'); @@ -1089,6 +1096,7 @@ void lcd_scroll_fn(void) unsigned old_fgcolor; unsigned old_bgcolor; struct viewport* old_vp = current_vp; + int h, oy; for ( index = 0; index < lcd_scroll_info.lines; index++ ) { s = &lcd_scroll_info.scroll[index]; @@ -1118,8 +1126,9 @@ void lcd_scroll_fn(void) s->offset += lcd_scroll_info.step; pf = font_get(current_vp->font); + lcd_getstringsize(s->line, NULL, &h, &oy); xpos = s->startx; - ypos = s->y * pf->height; + ypos = s->y * lcd_get_linespace(-1); if (s->bidir) { /* scroll bidirectional */ if (s->offset <= 0) { @@ -1150,13 +1159,13 @@ void lcd_scroll_fn(void) /* Solid colour line selector */ current_vp->drawmode = DRMODE_FG; current_vp->fg_pattern = current_vp->lss_pattern; - lcd_fillrect(xpos, ypos, current_vp->width - xpos, pf->height); + lcd_fillrect(xpos, ypos + oy, current_vp->width - xpos, h); current_vp->fg_pattern = current_vp->lst_pattern; break; case STYLE_GRADIENT: /* Gradient line selector */ current_vp->drawmode = DRMODE_FG; - lcd_gradient_rect_scroll(xpos, current_vp->width, ypos, (signed)pf->height, + lcd_gradient_rect_scroll(xpos, current_vp->width, ypos + oy, (signed)h, NUMLN_UNPACK(s->style), CURLN_UNPACK(s->style)); current_vp->fg_pattern = current_vp->lst_pattern; @@ -1169,7 +1178,7 @@ void lcd_scroll_fn(void) current_vp->drawmode = lastmode; current_vp->fg_pattern = old_fgcolor; current_vp->bg_pattern = old_bgcolor; - lcd_update_viewport_rect(xpos, ypos, current_vp->width - xpos, pf->height); + lcd_update_viewport_rect(xpos, ypos + oy, current_vp->width - xpos, h); } lcd_set_viewport(old_vp); diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c old mode 100644 new mode 100755 index 75d1e66..4fac220 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c @@ -127,11 +127,15 @@ int LCDFN(getfont)(void) return current_vp->font; } -int LCDFN(getstringsize)(const unsigned char *str, int *w, int *h) +int LCDFN(getstringsize)(const unsigned char *str, int *w, int *h, int *y) { - return font_getstringsize(str, w, h, current_vp->font); + return font_getstringsize(str, w, h, y, current_vp->font); } +int LCDFN(get_linespace)(int mode) +{ + return font_get_linespace(font_get(current_vp->font), mode); +} /*** low-level drawing functions ***/ static void setpixel(int x, int y) @@ -684,11 +688,12 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) while ((ch = *ucs++) != 0 && x < current_vp->width) { - int width; + int width, oy, a, d; const unsigned char *bits; /* get proportional width and glyph bits */ - width = font_get_width(pf, ch); + font_getboundingboxsize(pf, ch, &width, &a, &d); + oy = pf->maxascent - a; if (ofs > width) { @@ -698,8 +703,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) bits = font_get_bits(pf, ch); - LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x, y, width - ofs, - pf->height); + LCDFN(mono_bitmap_part)(bits, ofs, oy, width, x, y + oy, width - ofs, a + d); x += width - ofs; ofs = 0; @@ -734,7 +738,7 @@ void LCDFN(puts_offset)(int x, int y, const unsigned char *str, int offset) void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, int style, int offset) { - int xpos,ypos,w,h,xrect; + int xpos,ypos,w,h,oy; int lastmode = current_vp->drawmode; /* make sure scrolling is turned off on the line we are updating */ @@ -743,15 +747,17 @@ void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, if(!str || !str[0]) return; - LCDFN(getstringsize)(str, &w, &h); + LCDFN(getstringsize)(str, &w, &h, &oy); xpos = x*w / utf8length(str); - ypos = y*h; + ypos = y*LCDFN(get_linespace)(-1); + if (style & STYLE_INVERT) + { + current_vp->drawmode = DRMODE_SOLID; + LCDFN(fillrect)(xpos, ypos + oy, current_vp->width, h); + } current_vp->drawmode = (style & STYLE_INVERT) ? (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; LCDFN(putsxyofs)(xpos, ypos, offset, str); - current_vp->drawmode ^= DRMODE_INVERSEVID; - xrect = xpos + MAX(w - offset, 0); - LCDFN(fillrect)(xrect, ypos, current_vp->width - xrect, h); current_vp->drawmode = lastmode; } @@ -778,7 +784,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, int style, int offset) { struct scrollinfo* s; - int w, h; + int w; if ((unsigned)y >= (unsigned)current_vp->height) return; @@ -798,7 +804,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, else LCDFN(puts_offset)(x,y,string,offset); - LCDFN(getstringsize)(string, &w, &h); + LCDFN(getstringsize)(string, &w, NULL, NULL); if (current_vp->width - x * 8 < w) { /* prepare scroll line */ @@ -808,7 +814,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, strcpy(s->line, string); /* get width */ - s->width = LCDFN(getstringsize)(s->line, &w, &h); + s->width = LCDFN(getstringsize)(s->line, NULL, NULL, NULL); /* scroll bidirectional or forward only depending on the string width */ @@ -822,7 +828,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, if (!s->bidir) { /* add spaces if scrolling in the round */ strcat(s->line, " "); /* get new width incl. spaces */ - s->width = LCDFN(getstringsize)(s->line, &w, &h); + s->width = LCDFN(getstringsize)(s->line, NULL, NULL, NULL); } end = strchr(s->line, '\0'); @@ -847,6 +853,7 @@ void LCDFN(scroll_fn)(void) int xpos, ypos; int lastmode; struct viewport* old_vp = current_vp; + int h, oy; for ( index = 0; index < LCDFN(scroll_info).lines; index++ ) { s = &LCDFN(scroll_info).scroll[index]; @@ -863,8 +870,10 @@ void LCDFN(scroll_fn)(void) s->offset += LCDFN(scroll_info).step; pf = font_get(current_vp->font); + LCDFN(getstringsize)(s->line, NULL, &h, &oy); + xpos = s->startx; - ypos = s->y * pf->height; + ypos = s->y * LCDFN(get_linespace)(-1); if (s->bidir) { /* scroll bidirectional */ if (s->offset <= 0) { @@ -891,7 +900,7 @@ void LCDFN(scroll_fn)(void) (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; LCDFN(putsxyofs)(xpos, ypos, s->offset, s->line); current_vp->drawmode = lastmode; - LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos, pf->height); + LCDFN(update_viewport_rect)(xpos, ypos + oy, current_vp->width - xpos, h); } LCDFN(set_viewport)(old_vp); diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c old mode 100644 new mode 100755 index 0328f9c..c988320 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c @@ -161,11 +161,15 @@ int lcd_getfont(void) return current_vp->font; } -int lcd_getstringsize(const unsigned char *str, int *w, int *h) +int lcd_getstringsize(const unsigned char *str, int *w, int *h, int *y) { - return font_getstringsize(str, w, h, current_vp->font); + return font_getstringsize(str, w, h, y, current_vp->font); } +int lcd_get_linespace(int mode) +{ + return font_get_linespace(font_get(current_vp->font), mode); +} /*** low-level drawing functions ***/ static void setpixel(int x, int y) @@ -873,11 +877,12 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) while ((ch = *ucs++) != 0 && x < current_vp->width) { - int width; + int width, oy, a, d; const unsigned char *bits; /* get proportional width and glyph bits */ - width = font_get_width(pf,ch); + font_getboundingboxsize(pf, ch, &width, &a, &d); + oy = pf->maxascent - a; if (ofs > width) { @@ -887,8 +892,7 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) bits = font_get_bits(pf, ch); - lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, - pf->height); + lcd_mono_bitmap_part(bits, ofs, oy, width, x, y + oy, width - ofs, a + d); x += width - ofs; ofs = 0; @@ -924,7 +928,7 @@ void lcd_puts_offset(int x, int y, const unsigned char *str, int offset) void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style, int offset) { - int xpos,ypos,w,h,xrect; + int xpos,ypos,w,h,oy; int lastmode = current_vp->drawmode; /* make sure scrolling is turned off on the line we are updating */ @@ -933,15 +937,17 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, if(!str || !str[0]) return; - lcd_getstringsize(str, &w, &h); + lcd_getstringsize(str, &w, &h, &oy); xpos = x*w / utf8length((char *)str); - ypos = y*h; + ypos = y*lcd_get_linespace(-1); + if (style & STYLE_INVERT) + { + current_vp->drawmode = DRMODE_SOLID; + lcd_fillrect(xpos, ypos + oy, current_vp->width, h); + } current_vp->drawmode = (style & STYLE_INVERT) ? (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; lcd_putsxyofs(xpos, ypos, offset, str); - current_vp->drawmode ^= DRMODE_INVERSEVID; - xrect = xpos + MAX(w - offset, 0); - lcd_fillrect(xrect, ypos, current_vp->width - xrect, h); current_vp->drawmode = lastmode; } @@ -965,7 +971,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, int style, int offset) { struct scrollinfo* s; - int w, h; + int w; if ((unsigned)y >= (unsigned)current_vp->height) return; @@ -985,7 +991,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, else lcd_puts_offset(x,y,string,offset); - lcd_getstringsize(string, &w, &h); + lcd_getstringsize(string, &w, NULL, NULL); if (current_vp->width - x * 8 < w) { /* prepare scroll line */ @@ -995,7 +1001,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, strcpy(s->line, (char *)string); /* get width */ - s->width = lcd_getstringsize((unsigned char *)s->line, &w, &h); + s->width = lcd_getstringsize((unsigned char *)s->line, NULL, NULL, NULL); /* scroll bidirectional or forward only depending on the string width */ @@ -1009,7 +1015,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, if (!s->bidir) { /* add spaces if scrolling in the round */ strcat(s->line, " "); /* get new width incl. spaces */ - s->width = lcd_getstringsize((unsigned char *)s->line, &w, &h); + s->width = lcd_getstringsize((unsigned char *)s->line, NULL, NULL, NULL); } end = strchr(s->line, '\0'); @@ -1033,6 +1039,7 @@ void lcd_scroll_fn(void) int xpos, ypos; int lastmode; struct viewport* old_vp = current_vp; + int h, oy; for ( index = 0; index < lcd_scroll_info.lines; index++ ) { s = &lcd_scroll_info.scroll[index]; @@ -1049,8 +1056,9 @@ void lcd_scroll_fn(void) s->offset += lcd_scroll_info.step; pf = font_get(current_vp->font); + lcd_getstringsize(s->line, NULL, &h, &oy); xpos = s->startx; - ypos = s->y * pf->height; + ypos = s->y * lcd_get_linespace(-1); if (s->bidir) { /* scroll bidirectional */ if (s->offset <= 0) { @@ -1077,7 +1085,7 @@ void lcd_scroll_fn(void) (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; lcd_putsxyofs(xpos, ypos, s->offset, s->line); current_vp->drawmode = lastmode; - lcd_update_viewport_rect(xpos, ypos, current_vp->width - xpos, pf->height); + lcd_update_viewport_rect(xpos, ypos + oy, current_vp->width - xpos, h); } lcd_set_viewport(old_vp); diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c old mode 100644 new mode 100755 index d12ebbc..a806893 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c @@ -164,11 +164,15 @@ int lcd_getfont(void) return current_vp->font; } -int lcd_getstringsize(const unsigned char *str, int *w, int *h) +int lcd_getstringsize(const unsigned char *str, int *w, int *h, int *y) { - return font_getstringsize(str, w, h, current_vp->font); + return font_getstringsize(str, w, h, y, current_vp->font); } +int lcd_get_linespace(int mode) +{ + return font_get_linespace(font_get(current_vp->font), mode); +} /*** low-level drawing functions ***/ static void setpixel(int x, int y) @@ -1011,11 +1015,12 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) while ((ch = *ucs++) != 0 && x < current_vp->width) { - int width; + int width, oy, a, d; const unsigned char *bits; /* get proportional width and glyph bits */ - width = font_get_width(pf,ch); + font_getboundingboxsize(pf, ch, &width, &a, &d); + oy = pf->maxascent - a; if (ofs > width) { @@ -1025,8 +1030,7 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) bits = font_get_bits(pf, ch); - lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, - pf->height); + lcd_mono_bitmap_part(bits, ofs, oy, width, x, y + oy, width - ofs, a + d); x += width - ofs; ofs = 0; @@ -1062,7 +1066,7 @@ void lcd_puts_offset(int x, int y, const unsigned char *str, int offset) void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style, int offset) { - int xpos,ypos,w,h,xrect; + int xpos,ypos,w,h,oy; int lastmode = current_vp->drawmode; /* make sure scrolling is turned off on the line we are updating */ @@ -1071,15 +1075,17 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, if(!str || !str[0]) return; - lcd_getstringsize(str, &w, &h); + lcd_getstringsize(str, &w, &h, &oy); xpos = x*w / utf8length((char *)str); - ypos = y*h; + ypos = y*lcd_get_linespace(-1); + if (style & STYLE_INVERT) + { + current_vp->drawmode = DRMODE_SOLID; + lcd_fillrect(xpos, ypos + oy, current_vp->width, h); + } current_vp->drawmode = (style & STYLE_INVERT) ? (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; lcd_putsxyofs(xpos, ypos, offset, str); - current_vp->drawmode ^= DRMODE_INVERSEVID; - xrect = xpos + MAX(w - offset, 0); - lcd_fillrect(xrect, ypos, current_vp->width - xrect, h); current_vp->drawmode = lastmode; } @@ -1104,7 +1110,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, int style, int offset) { struct scrollinfo* s; - int w, h; + int w; if ((unsigned)y >= (unsigned)current_vp->height) return; @@ -1124,7 +1130,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, else lcd_puts_offset(x,y,string,offset); - lcd_getstringsize(string, &w, &h); + lcd_getstringsize(string, &w, NULL, NULL); if (current_vp->width - x * 8< w) { /* prepare scroll line */ @@ -1134,7 +1140,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, strcpy(s->line, (char *)string); /* get width */ - s->width = lcd_getstringsize((unsigned char *)s->line, &w, &h); + s->width = lcd_getstringsize((unsigned char *)s->line, NULL, NULL, NULL); /* scroll bidirectional or forward only depending on the string width */ @@ -1148,7 +1154,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, if (!s->bidir) { /* add spaces if scrolling in the round */ strcat(s->line, " "); /* get new width incl. spaces */ - s->width = lcd_getstringsize((unsigned char *)s->line, &w, &h); + s->width = lcd_getstringsize((unsigned char *)s->line, NULL, NULL, NULL); } end = strchr(s->line, '\0'); @@ -1173,6 +1179,7 @@ void lcd_scroll_fn(void) int xpos, ypos; int lastmode; struct viewport* old_vp = current_vp; + int h, oy; for ( index = 0; index < lcd_scroll_info.lines; index++ ) { s = &lcd_scroll_info.scroll[index]; @@ -1189,8 +1196,9 @@ void lcd_scroll_fn(void) s->offset += lcd_scroll_info.step; pf = font_get(current_vp->font); + lcd_getstringsize(s->line, NULL, &h, &oy); xpos = s->startx; - ypos = s->y * pf->height; + ypos = s->y * lcd_get_linespace(-1); if (s->bidir) { /* scroll bidirectional */ if (s->offset <= 0) { @@ -1217,8 +1225,7 @@ void lcd_scroll_fn(void) (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; lcd_putsxyofs(xpos, ypos, s->offset, s->line); current_vp->drawmode = lastmode; - lcd_update_viewport_rect(xpos, ypos, - current_vp->width - xpos, pf->height); + lcd_update_viewport_rect(xpos, ypos + oy, current_vp->width - xpos, h); } lcd_set_viewport(old_vp); diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c old mode 100644 new mode 100755 index 1c0a717..2261ca6 --- a/firmware/drivers/lcd-2bit-vi.c +++ b/firmware/drivers/lcd-2bit-vi.c @@ -185,11 +185,15 @@ int LCDFN(getfont)(void) return current_vp->font; } -int LCDFN(getstringsize)(const unsigned char *str, int *w, int *h) +int LCDFN(getstringsize)(const unsigned char *str, int *w, int *h, int *y) { - return font_getstringsize(str, w, h, current_vp->font); + return font_getstringsize(str, w, h, y, current_vp->font); } +int LCDFN(get_linespace)(int mode) +{ + return font_get_linespace(font_get(current_vp->font), mode); +} /*** low-level drawing functions ***/ static void setpixel(int x, int y) @@ -1027,11 +1031,12 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) while ((ch = *ucs++) != 0 && x < current_vp->width) { - int width; + int width, oy, a, d; const unsigned char *bits; /* get proportional width and glyph bits */ - width = font_get_width(pf, ch); + font_getboundingboxsize(pf, ch, &width, &a, &d); + oy = pf->maxascent - a; if (ofs > width) { @@ -1041,8 +1046,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) bits = font_get_bits(pf, ch); - LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x, y, width - ofs, - pf->height); + LCDFN(mono_bitmap_part)(bits, ofs, oy, width, x, y + oy, width - ofs, a + d); x += width - ofs; ofs = 0; @@ -1078,7 +1082,7 @@ void LCDFN(puts_offset)(int x, int y, const unsigned char *str, int offset) void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, int style, int offset) { - int xpos,ypos,w,h,xrect; + int xpos,ypos,w,h,oy; int lastmode = current_vp->drawmode; /* make sure scrolling is turned off on the line we are updating */ @@ -1087,15 +1091,17 @@ void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, if(!str || !str[0]) return; - LCDFN(getstringsize)(str, &w, &h); + LCDFN(getstringsize)(str, &w, &h, &oy); xpos = x*w / utf8length((char *)str); - ypos = y*h; + ypos = y*LCDFN(get_linespace)(-1); + if (style & STYLE_INVERT) + { + current_vp->drawmode = DRMODE_SOLID; + LCDFN(fillrect)(xpos, ypos + oy, current_vp->width, h); + } current_vp->drawmode = (style & STYLE_INVERT) ? (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; LCDFN(putsxyofs)(xpos, ypos, offset, str); - current_vp->drawmode ^= DRMODE_INVERSEVID; - xrect = xpos + MAX(w - offset, 0); - LCDFN(fillrect)(xrect, ypos, current_vp->width - xrect, h); current_vp->drawmode = lastmode; } @@ -1119,7 +1125,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, int style, int offset) { struct scrollinfo* s; - int w, h; + int w; if ((unsigned)y >= (unsigned)current_vp->height) return; @@ -1139,7 +1145,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, else LCDFN(puts_offset)(x,y,string,offset); - LCDFN(getstringsize)(string, &w, &h); + LCDFN(getstringsize)(string, &w, NULL, NULL); if (current_vp->width - x * 8 < w) { /* prepare scroll line */ @@ -1149,7 +1155,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, strcpy(s->line, string); /* get width */ - s->width = LCDFN(getstringsize)(s->line, &w, &h); + s->width = LCDFN(getstringsize)(s->line, NULL, NULL, NULL); /* scroll bidirectional or forward only depending on the string width */ @@ -1163,7 +1169,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, if (!s->bidir) { /* add spaces if scrolling in the round */ strcat(s->line, " "); /* get new width incl. spaces */ - s->width = LCDFN(getstringsize)(s->line, &w, &h); + s->width = LCDFN(getstringsize)(s->line, NULL, NULL, NULL); } end = strchr(s->line, '\0'); @@ -1188,6 +1194,7 @@ void LCDFN(scroll_fn)(void) int xpos, ypos; int lastmode; struct viewport* old_vp = current_vp; + int h, oy; for ( index = 0; index < LCDFN(scroll_info).lines; index++ ) { s = &LCDFN(scroll_info).scroll[index]; @@ -1204,8 +1211,9 @@ void LCDFN(scroll_fn)(void) s->offset += LCDFN(scroll_info).step; pf = font_get(current_vp->font); + LCDFN(getstringsize)(s->line, NULL, &h, &oy); xpos = s->startx; - ypos = s->y * pf->height; + ypos = s->y * LCDFN(get_linespace)(-1); if (s->bidir) { /* scroll bidirectional */ if (s->offset <= 0) { @@ -1228,12 +1236,14 @@ void LCDFN(scroll_fn)(void) } lastmode = current_vp->drawmode; + current_vp->drawmode = DRMODE_SOLID; + LCDFN(fillrect)(xpos, ypos + oy, current_vp->width - xpos, h); current_vp->drawmode = (s->style&STYLE_INVERT) ? (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; LCDFN(putsxyofs)(xpos, ypos, s->offset, s->line); current_vp->drawmode = lastmode; - LCDFN(update_viewport_rect)(xpos, ypos, - current_vp->width - xpos, pf->height); + LCDFN(update_viewport_rect)(xpos, ypos + oy, + current_vp->width - xpos, h); } LCDFN(set_viewport)(old_vp); diff --git a/firmware/drivers/lcd-charcell.c b/firmware/drivers/lcd-charcell.c index ca58098..3f4d109 100644 --- a/firmware/drivers/lcd-charcell.c +++ b/firmware/drivers/lcd-charcell.c @@ -102,7 +102,7 @@ int lcd_getheight(void) return current_vp->height; } -int lcd_getstringsize(const unsigned char *str, int *w, int *h) +int lcd_getstringsize(const unsigned char *str, int *w, int *h, int *y) { int width = utf8length(str); @@ -110,10 +110,17 @@ int lcd_getstringsize(const unsigned char *str, int *w, int *h) *w = width; if (h) *h = 1; + if (y) + *y = 0; return width; } +int lcd_get_linespace(int mode) +{ + (void)mode; + return 1; +} /** low-level functions **/ static int find_xchar(unsigned long ucs) diff --git a/firmware/export/font.h b/firmware/export/font.h old mode 100644 new mode 100755 index 5f1fa9e..2ad9d75 --- a/firmware/export/font.h +++ b/firmware/export/font.h @@ -52,6 +52,10 @@ #define GLYPH_CACHE_FILE ROCKBOX_DIR"/.glyphcache" +#define FONT_LINE_SPACE_WIDE 0 +#define FONT_LINE_SPACE_MIDDLE 1 +#define FONT_LINE_SPACE_NARROW 2 + /* * Fonts are specified by number, and used for display * of menu information as well as mp3 filename data. @@ -77,7 +81,7 @@ enum { * ------------------------- ---- ------------------------------ * UCHAR version[4] 4 magic number and version bytes * USHORT maxwidth 2 font max width in pixels - * USHORT height 2 font height in pixels + * USHORT maxheight 2 font max height in pixels * USHORT ascent 2 font ascent (baseline) in pixels * UCHAR ascent delta 1 max font ascent in pixels - ascent * UCHAR descent delta 1 max font descent in pixels - descent @@ -100,7 +104,7 @@ enum { /* based on The Microwindows Project http://microwindows.org */ struct font { int maxwidth; /* max width in pixels*/ - unsigned int height; /* height in pixels (= maxascent + maxdescent)*/ + unsigned int maxheight; /* max height in pixels (= maxascent + maxdescent)*/ int ascent; /* ascent (baseline) height*/ int descent; /* descent height*/ int maxascent; /* max ascent height*/ @@ -119,10 +123,13 @@ void font_init(void); struct font* font_load(const char *path); struct font* font_get(int font); void font_reset(void); -int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber); +void font_getboundingboxsize(struct font* ft, unsigned short ch, int *bw, int *ba, int *bd); +int font_getstringsize(const unsigned char *str, int *w, int *h, int *y, int fontnumber); int font_get_width(struct font* ft, unsigned short ch); const unsigned char * font_get_bits(struct font* ft, unsigned short ch); void glyph_cache_save(void); +void set_linespace_mode(int mode); +int font_get_linespace(const struct font* ft, int mode); #else /* HAVE_LCD_BITMAP */ diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h old mode 100644 new mode 100755 index 01df5a7..5ea28bb --- a/firmware/export/lcd-remote.h +++ b/firmware/export/lcd-remote.h @@ -154,7 +154,8 @@ extern int lcd_remote_getwidth(void); extern int lcd_remote_getheight(void); extern void lcd_remote_setfont(int font); extern int lcd_remote_getfont(void); -extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h); +extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h, int *y); +extern int lcd_remote_get_linespace(int mode); /* low level drawing function pointer arrays */ #if LCD_REMOTE_DEPTH > 1 diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index e435d17..df8f52f 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -111,7 +111,7 @@ extern int lcd_default_contrast(void); extern void lcd_set_contrast(int val); extern int lcd_getwidth(void); extern int lcd_getheight(void); -extern int lcd_getstringsize(const unsigned char *str, int *w, int *h); +extern int lcd_getstringsize(const unsigned char *str, int *w, int *h, int *y); extern void lcd_set_viewport(struct viewport* vp); extern void lcd_update(void); @@ -132,7 +132,7 @@ extern void lcd_scroll_delay(int ms); extern void lcd_puts_scroll(int x, int y, const unsigned char* string); extern void lcd_puts_scroll_style(int x, int y, const unsigned char* string, int style); - +extern int lcd_get_linespace(int mode); #ifdef HAVE_LCD_BITMAP /* performance function */ diff --git a/firmware/font.c b/firmware/font.c old mode 100644 new mode 100755 index a07bca5..465a3e1 --- a/firmware/font.c +++ b/firmware/font.c @@ -73,6 +73,9 @@ static int long_offset = 0; static int glyph_file; /* End Font cache structures */ +/* line space mode */ +static int linespace_mode = FONT_LINE_SPACE_WIDE; + static void glyph_cache_load(void); void font_init(void) @@ -138,11 +141,11 @@ static struct font* font_load_header(struct font *pf) /* font info*/ pf->maxwidth = readshort(); - pf->height = readshort(); + pf->maxheight = readshort(); pf->ascent = readshort(); delta = readshort(); pf->maxascent = pf->ascent + (delta & 0xff); - pf->maxdescent = pf->height - pf->maxascent; + pf->maxdescent = pf->maxheight - pf->maxascent; pf->descent = pf->maxdescent - (delta >> 8); pf->firstchar = readlong(); pf->defaultchar = readlong(); @@ -283,7 +286,7 @@ static struct font* font_load_cached(struct font* pf) fileptr = oldfileptr; /* Create the cache */ - cache_create(pf->maxwidth, pf->height); + cache_create(pf->maxwidth, pf->maxheight); return pf; } @@ -379,7 +382,7 @@ struct font* font_get(int font) while (1) { pf = sysfonts[font]; - if (pf && pf->height) + if (pf && pf->maxheight) return pf; if (--font < 0) panicf("No font!"); @@ -422,13 +425,13 @@ load_cache_entry(struct font_cache_entry* p, void* callback_data) } else { - bitmap_offset = ((pf->height + 7) / 8) * p->width * char_code; + bitmap_offset = ((pf->maxheight + 7) / 8) * p->width * char_code; } int32_t file_offset = FONT_HEADER_SIZE + bitmap_offset; lseek(fnt_file, file_offset, SEEK_SET); - int src_bytes = p->width * ((pf->height + 7) / 8); + int src_bytes = p->width * ((pf->maxheight + 7) / 8); read(fnt_file, p->bitmap, src_bytes); } @@ -477,7 +480,7 @@ const unsigned char* font_get_bits(struct font* pf, unsigned short char_code) { bits = pf->bits + (pf->offset? pf->offset[char_code]: - (((pf->height + 7) / 8) * pf->maxwidth * char_code)); + (((pf->maxheight + 7) / 8) * pf->maxwidth * char_code)); } return bits; @@ -590,7 +593,7 @@ const unsigned char* font_get_bits(struct font* pf, unsigned short char_code) bits = pf->bits + (pf->offset? pf->offset[char_code]: - (((pf->height + 7) / 8) * pf->maxwidth * char_code)); + (((pf->maxheight + 7) / 8) * pf->maxwidth * char_code)); return bits; } @@ -598,25 +601,166 @@ const unsigned char* font_get_bits(struct font* pf, unsigned short char_code) #endif /* BOOTLOADER */ /* + * get width, ascent, descent of the bounding box including a given character. + */ +void font_getboundingboxsize(struct font* pf, unsigned short char_code, + int *bw, int *ba, int *bd) +{ + int c; + int i; + int j; + const unsigned char *p1 = NULL; + const unsigned char *p2 = NULL; + const unsigned char *sp = NULL; + int r; + + /* get width */ + *bw = font_get_width(pf, char_code); + + *ba = 0; + *bd = 0; + if (pf->maxascent == pf->ascent) + *ba = pf->maxascent; + + if (pf->maxdescent == pf->descent) + *bd = pf->maxdescent; + + if (*ba == 0 || *bd == 0) + { + p1 = font_get_bits(pf, char_code); + sp = p1; + } + + /* get ascent */ + if (*ba == 0) + { + r = 8 - ((pf->maxascent - pf->ascent) & 0x07); + c = (pf->maxascent - pf->ascent) >> 3; + p2 = p1; + for (i = *bw; i > 0; i--) + { + for (j = c; j > 0; j--) + { + if (*p1) + { + *ba = pf->maxascent; + break; + } + p1 += *bw; + } + + if (*ba == 0 && ((*p1 << r) & 0xff)) + *ba = pf->maxascent; + + if (*ba > 0) + break; + + p1 = ++p2; + } + } + + if (*ba == 0) + *ba = pf->ascent; + + /* get descent */ + if (*bd == 0) + { + r = 8 - ((pf->maxascent + pf->descent) & 0x07); + c = (pf->maxdescent - pf->descent - r + 7) >> 3; + p1 = sp + (*bw) * ((pf->maxascent + pf->descent) >> 3); + p2 = p1; + for (i = *bw; i > 0; i--) + { + if (*p1 >> r) + { + *bd = pf->maxdescent; + break; + } + + for (j = c; j > 0; j--) + { + p1 += *bw; + if (*p1) + { + *bd = pf->maxdescent; + break; + } + } + if (*bd) + break; + + p1 = ++p2; + } + } + + if (*bd == 0) + *bd = pf->descent; +} + +/* * Returns the stringsize of a given string. */ -int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber) +int font_getstringsize(const unsigned char *str, int *w, int *h, int *y, int fontnumber) { struct font* pf = font_get(fontnumber); unsigned short ch; int width = 0; + int bw, ba, bd; + int ma = 0; + int md = 0; for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) { + font_getboundingboxsize(pf, ch, &bw, &ba, &bd); + width += bw; - /* get proportional width and glyph bits*/ - width += font_get_width(pf,ch); + if (ba > ma) + ma = ba; + + if (bd > md) + md = bd; } if ( w ) *w = width; if ( h ) - *h = pf->height; - return width; + *h = ma + md; + if ( y ) + *y = pf->maxascent - ma; + + return width; + } + +void set_linespace_mode(int mode) +{ + linespace_mode = mode; +} + +/* + * Returns line space a given font and mode. + * If mode is invalid (e.g. -1), mode is treated as global_settings.linespace_mode. + */ +int font_get_linespace(const struct font* pf, int mode) +{ + int ls = 0; + + if (mode < 0 || mode > FONT_LINE_SPACE_NARROW) + mode = linespace_mode; + switch (mode) + { + case FONT_LINE_SPACE_WIDE: + ls = pf->maxascent + pf->maxdescent; + break; + case FONT_LINE_SPACE_MIDDLE: + if (pf->maxascent + pf->descent > pf->ascent + pf->maxdescent) + ls = pf->maxascent + pf->descent; + else + ls = pf->ascent + pf->maxdescent; + break; + case FONT_LINE_SPACE_NARROW: + ls = pf->ascent + pf->descent; + break; + } + return ls; } /* ----------------------------------------------------------------- diff --git a/firmware/logf.c b/firmware/logf.c index 8821f4a..0da419a 100644 --- a/firmware/logf.c +++ b/firmware/logf.c @@ -65,14 +65,14 @@ bool logfwrap; static void displayremote(void) { /* TODO: we should have a debug option that enables/disables this! */ - int w, h; + int w; int lines; int columns; int i; int index; - lcd_remote_getstringsize("A", &w, &h); - lines = LCD_REMOTE_HEIGHT/h; + lcd_remote_getstringsize("A", &w, NULL, NULL); + lines = LCD_REMOTE_HEIGHT/lcd_get_linespace(-1); columns = LCD_REMOTE_WIDTH/w; lcd_remote_clear_display(); diff --git a/tools/convbdf.c b/tools/convbdf.c index 86f308e..bcd8f15 100644 --- a/tools/convbdf.c +++ b/tools/convbdf.c @@ -37,7 +37,7 @@ typedef unsigned short bitmap_t; /* bitmap image unit size*/ /* based on The Microwindows Project http://microwindows.org */ struct font { int maxwidth; /* max width in pixels*/ - int height; /* height in pixels*/ + int maxheight; /* max height in pixels*/ int ascent; /* ascent (baseline) height*/ int descent; /* descent height*/ int maxascent; /* max ascent (baseline) height*/ @@ -490,7 +490,7 @@ int bdf_read_header(FILE *fp, struct font* pf) pf->name, pf->maxdescent + pf->fbby); } - pf->height = pf->maxascent + pf->maxdescent; + pf->maxheight = pf->maxascent + pf->maxdescent; /* calc default char*/ if (pf->defaultchar < 0 || @@ -507,8 +507,8 @@ int bdf_read_header(FILE *fp, struct font* pf) /*maxwidth = pf->fbbw - pf->fbbx;*/ maxwidth = pf->fbbw; - /* initially use font maxwidth * height for bits allocation*/ - pf->bits_size = nchars * BITMAP_WORDS(maxwidth) * pf->height; + /* initially use font maxwidth * maxheight for bits allocation*/ + pf->bits_size = nchars * BITMAP_WORDS(maxwidth) * pf->maxheight; /* allocate bits, offset, and width arrays*/ pf->bits = (bitmap_t *)malloc(pf->bits_size * sizeof(bitmap_t) + EXTRA); @@ -608,7 +608,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) pf->width[encoding-pf->firstchar] = width; /* clear bitmap*/ - memset(ch_bitmap, 0, BITMAP_BYTES(width) * pf->height); + memset(ch_bitmap, 0, BITMAP_BYTES(width) * pf->maxheight); ch_words = BITMAP_WORDS(width); #define BM(row,col) (*(ch_bitmap + ((row)*ch_words) + (col))) @@ -626,7 +626,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) break; r = pf->maxascent - bby - bbh + i; - if (r < 0 || r >= pf->height) + if (r < 0 || r >= pf->maxheight) continue; hexnibbles = strlen(buf); @@ -652,8 +652,8 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) } } - ofs += BITMAP_WORDS(width) * pf->height; - ofr += pf->width[encoding-pf->firstchar] * ((pf->height+7)/8); + ofs += BITMAP_WORDS(width) * pf->maxheight; + ofr += pf->width[encoding-pf->firstchar] * ((pf->maxheight+7)/8); continue; } @@ -680,7 +680,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) encodetable = 1; break; } - l += pf->maxwidth * ((pf->height + 7) / 8); + l += pf->maxwidth * ((pf->maxheight + 7) / 8); } #else l = 0; @@ -689,7 +689,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) encodetable = 1; break; } - l += BITMAP_WORDS(pf->width[i]) * pf->height; + l += BITMAP_WORDS(pf->width[i]) * pf->maxheight; } #endif if (!encodetable) { @@ -895,7 +895,7 @@ int gen_c_source(struct font* pf, char *path) fprintf(ofp, hdr1, buf, pf->name, pf->facename? pf->facename: "", - pf->maxwidth, pf->height, + pf->maxwidth, pf->maxheight, pf->size, pf->ascent, pf->descent, pf->maxascent, pf->maxdescent, @@ -910,7 +910,7 @@ int gen_c_source(struct font* pf, char *path) int x; int bitcount = 0; int width = pf->width ? pf->width[i] : pf->maxwidth; - int height = pf->height; + int height = pf->maxheight; bitmap_t *bits; bitmap_t bitvalue=0; @@ -918,7 +918,7 @@ int gen_c_source(struct font* pf, char *path) if (pf->offset && (pf->offset[i] == (unsigned int)-1)) continue; - bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->height * i)); + bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->maxheight * i)); fprintf(ofp, "\n/* Character %d (0x%02x):\n width %d", i+pf->firstchar, i+pf->firstchar, width); @@ -956,15 +956,15 @@ int gen_c_source(struct font* pf, char *path) else fprintf(ofp, " */\n"); - bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->height * i)); + bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->maxheight * i)); #ifdef ROTATE /* pre-rotated into Rockbox bitmap format */ { unsigned char bytemap[512]; int y8, ix=0; int size = rotleft(bytemap, sizeof(bytemap), bits, width, - pf->height); - for (y8=0; y8height; y8+=8) /* column rows */ + pf->maxheight); + for (y8=0; y8maxheight; y8+=8) /* column rows */ { for (x=0; xheight; x>0; --x) { + for (x=BITMAP_WORDS(width)*pf->maxheight; x>0; --x) { fprintf(ofp, "0x%04x,\n", *bits); if (!did_syncmsg && *bits++ != *ofs++) { fprintf(stderr, "Warning: found encoding values in non-sorted order (not an error).\n"); @@ -1035,7 +1035,7 @@ int gen_c_source(struct font* pf, char *path) fprintf(ofp, "/* Exported structure definition. */\n" "const struct font sysfont = {\n" " %d, /* maxwidth */\n" - " %d, /* height */\n" + " %d, /* maxheight */\n" " %d, /* ascent */\n" " %d, /* descent */\n" " %d, /* maxascent */\n" @@ -1049,7 +1049,7 @@ int gen_c_source(struct font* pf, char *path) " %d /* bits_size */\n" "};\n" "#endif /* HAVE_LCD_BITMAP */\n", - pf->maxwidth, pf->height, + pf->maxwidth, pf->maxheight, pf->ascent, pf->descent, pf->maxascent, @@ -1105,7 +1105,7 @@ int gen_h_header(struct font* pf, char *path) pf->name, pf->facename? pf->facename: "", pf->maxwidth, - pf->height, + pf->maxheight, pf->size, pf->ascent); @@ -1188,7 +1188,7 @@ int gen_fnt_file(struct font* pf, char *path) #endif /* font info*/ writeshort(ofp, pf->maxwidth); - writeshort(ofp, pf->height); + writeshort(ofp, pf->maxheight); writeshort(ofp, pf->ascent); writebyte(ofp, pf->maxascent - pf->ascent); writebyte(ofp, pf->maxdescent - pf->descent); @@ -1213,9 +1213,9 @@ int gen_fnt_file(struct font* pf, char *path) if (pf->offset && (pf->offset[i] == (unsigned int)-1)) continue; - bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->height * i)); + bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->maxheight * i)); - size = rotleft(bytemap, sizeof(bytemap), bits, width, pf->height); + size = rotleft(bytemap, sizeof(bytemap), bits, width, pf->maxheight); writestr(ofp, (char *)bytemap, size); /* update offrot since bits are now in sorted order */