Index: apps/gui/skin_engine/skin_parser.c =================================================================== --- apps/gui/skin_engine/skin_parser.c (revision 24175) +++ apps/gui/skin_engine/skin_parser.c (working copy) @@ -89,6 +89,8 @@ /* the current line, linked to the above viewport */ static struct skin_line *curr_line; +static int follow_lang_direction = 0; + #ifdef HAVE_LCD_BITMAP #if LCD_DEPTH > 1 @@ -140,6 +142,17 @@ struct wps_token *token, struct wps_data *wps_data); static int parse_setting_and_lang(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); + + +int parse_languagealign(const char *wps_bufptr, + struct wps_token *token, struct wps_data *wps_data) +{ + (void)wps_bufptr; + (void)token; + (void)wps_data; + follow_lang_direction = 2; + return 0; +} #ifdef HAVE_LCD_BITMAP static int parse_viewport_display(const char *wps_bufptr, @@ -190,6 +203,7 @@ { WPS_TOKEN_ALIGN_CENTER, "ac", 0, NULL }, { WPS_TOKEN_ALIGN_LEFT, "al", 0, NULL }, { WPS_TOKEN_ALIGN_RIGHT, "ar", 0, NULL }, + { WPS_NO_TOKEN, "aa", 0, parse_languagealign }, { WPS_TOKEN_BATTERY_PERCENT, "bl", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_BATTERY_VOLTS, "bv", WPS_REFRESH_DYNAMIC, NULL }, @@ -749,10 +763,14 @@ struct viewport *vp = &skin_vp->vp; /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ + if (follow_lang_direction && lang_is_rtl()) + vp->flags |= VP_FLAG_ALIGN_RIGHT; + else + vp->flags &= ~VP_FLAG_ALIGN_RIGHT; /* ignore right-to-left languages */ + if (!(ptr = viewport_parse_viewport(vp, curr_screen, ptr, '|'))) return WPS_ERROR_INVALID_PARAM; - - vp->flags &= ~VP_FLAG_ALIGN_RIGHT; /* ignore right-to-left languages */ + /* Check for trailing | */ if (*ptr != '|') return WPS_ERROR_INVALID_PARAM; @@ -1500,6 +1518,8 @@ while (*wps_bufptr && !fail) { + if (follow_lang_direction) + follow_lang_direction--; /* first make sure there is enough room for tokens */ if (max_tokens <= data->num_tokens + 5) { Index: apps/gui/viewport.c =================================================================== --- apps/gui/viewport.c (revision 24175) +++ apps/gui/viewport.c (working copy) @@ -473,6 +473,10 @@ vp->x += screens[screen].lcdwidth; if (vp->y < 0) vp->y += screens[screen].lcdheight; + + /* fix for RTL if set */ + if (VP_IS_RTL(vp)) + vp->x = screens[screen].lcdwidth - vp->width - vp->x; /* fix defaults, * and negative width/height which means "extend to edge minus value */