Added right-to-left text drawing to PostScript graphics driver.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8127 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2010-12-28 12:45:28 +00:00
parent b431c1e0e7
commit 64dd2cfa68
2 changed files with 20 additions and 0 deletions

View File

@ -119,6 +119,7 @@ class Clip {
*/
void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };
void draw(int angle, const char *str, int n, int x, int y);
void rtl_draw(const char* s, int n, int x, int y);
void transformed_draw(const char* s, int n, double x, double y); //precise text placing
void transformed_draw(const char* s, double x, double y);
int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);

View File

@ -1094,6 +1094,25 @@ void Fl_PostScript_Graphics_Driver::transformed_draw(const char* str, int n, dou
fprintf(output, "> %g %g show_pos_width\n", x, y);
}
void Fl_PostScript_Graphics_Driver::rtl_draw(const char* str, int n, int x, int y) {
const char *last = str + n;
const char *str2 = str;
unsigned unis[n + 1];
char out[n + 1];
int u = 0, len;
char *p = out;
double w = fl_width(str, n);
while (str2 < last) {
unis[u++] = fl_utf8decode(str2, last, &len);
str2 += len;
}
while (u > 0) {
len = fl_utf8encode(unis[--u], p);
p += len;
}
transformed_draw(out, p - out, x - w, y);
}
struct matrix {double a, b, c, d, x, y;};
extern matrix * fl_matrix;