Author: manolo
Date: 2010-12-28 04:45:28 -0800 (Tue, 28 Dec 2010)
New Revision: 8127
Log:
Added right-to-left text drawing to PostScript graphics driver.

Modified:
   branches/branch-1.3/FL/Fl_PostScript.H
   branches/branch-1.3/src/Fl_PostScript.cxx

Modified: branches/branch-1.3/FL/Fl_PostScript.H
===================================================================
--- branches/branch-1.3/FL/Fl_PostScript.H      2010-12-28 12:02:23 UTC (rev 
8126)
+++ branches/branch-1.3/FL/Fl_PostScript.H      2010-12-28 12:45:28 UTC (rev 
8127)
@@ -119,6 +119,7 @@
    */
   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);

Modified: branches/branch-1.3/src/Fl_PostScript.cxx
===================================================================
--- branches/branch-1.3/src/Fl_PostScript.cxx   2010-12-28 12:02:23 UTC (rev 
8126)
+++ branches/branch-1.3/src/Fl_PostScript.cxx   2010-12-28 12:45:28 UTC (rev 
8127)
@@ -1094,6 +1094,25 @@
   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;
 

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to