From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / texfont.c
index b70a32d53358c9eaff2e13740ee35d30a22a7be6..7daa2d50d43746c62975001e3f4acbff086df094 100644 (file)
@@ -1,4 +1,4 @@
-/* texfonts, Copyright (c) 2005-2015 Jamie Zawinski <jwz@jwz.org>
+/* texfonts, Copyright (c) 2005-2016 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -193,7 +193,7 @@ bitmap_to_texture (Display *dpy, Pixmap p, Visual *visual, int depth,
 
 # ifdef DUMP_BITMAPS
       if (sx < ow && sy < oh)
-#  ifdef HAVE_COCOA
+#  ifdef HAVE_JWXYZ
         fprintf (stderr, "%c", 
                  r >= 0xFF000000 ? '#' : 
                  r >= 0x88000000 ? '%' : 
@@ -485,6 +485,7 @@ get_cache (texture_font_data *data, const char *string)
    */
   if (count > data->cache_size)
     {
+      if (!prev) abort();
       free (prev->string);
       prev->string     = 0;
       prev->tex_width  = 0;
@@ -655,6 +656,9 @@ print_texture_string (texture_font_data *data, const char *string)
     GLfloat qx0, qy0, qx1, qy1;
     GLfloat tx0, ty0, tx1, ty1;
 
+    /* If face culling is not enabled, draw front and back. */
+    Bool draw_back_face_p = !glIsEnabled (GL_CULL_FACE);
+
     /* Save the prevailing texture environment, and set up ours.
      */
     glGetIntegerv (GL_FRONT_FACE, &ofront);
@@ -690,6 +694,7 @@ print_texture_string (texture_font_data *data, const char *string)
     tx1 = (overall.rbearing - overall.lbearing) / (GLfloat) tex_width;
     ty0 = (overall.ascent + overall.descent)    / (GLfloat) tex_height;
 
+    glEnable (GL_CULL_FACE);
     glFrontFace (GL_CCW);
     glBegin (GL_QUADS);
     glTexCoord2f (tx0, ty0); glVertex3f (qx0, qy0, 0);
@@ -698,6 +703,18 @@ print_texture_string (texture_font_data *data, const char *string)
     glTexCoord2f (tx0, ty1); glVertex3f (qx0, qy1, 0);
     glEnd();
 
+    if (draw_back_face_p)
+      {
+        glFrontFace (GL_CW);
+        glBegin (GL_QUADS);
+        glTexCoord2f (tx0, ty0); glVertex3f (qx0, qy0, 0);
+        glTexCoord2f (tx1, ty0); glVertex3f (qx1, qy0, 0);
+        glTexCoord2f (tx1, ty1); glVertex3f (qx1, qy1, 0);
+        glTexCoord2f (tx0, ty1); glVertex3f (qx0, qy1, 0);
+        glEnd();
+        glDisable (GL_CULL_FACE);
+      }
+
     glPopMatrix();
 
     /* Reset to the caller's texture environment.
@@ -789,7 +806,8 @@ print_texture_label (Display *dpy,
       XCharStruct cs;
       int ascent, descent;
       int x, y, w, h, swap;
-      int rot = (int) current_device_rotation();
+      /* int rot = (int) current_device_rotation(); */
+      int rot = 0;  /* Since GL hacks rotate now */
 
       glLoadIdentity();
       glViewport (0, 0, window_width, window_height);
@@ -805,7 +823,9 @@ print_texture_label (Display *dpy,
 # ifdef USE_IPHONE
       {
         /* Size of the font is in points, so scale iOS pixels to points. */
-        GLfloat scale = window_width / 768.0;
+        GLfloat scale = ((window_width > window_height
+                          ? window_width : window_height)
+                         / 768.0);
         if (scale < 1) scale = 1;
 
         /* jwxyz-XLoadFont has already doubled the font size, to compensate
@@ -903,6 +923,17 @@ print_texture_label (Display *dpy,
 }
 
 
+#ifdef HAVE_JWXYZ
+char *
+texfont_unicode_character_name (texture_font_data *data, unsigned long uc)
+{
+  Font fid = data->xftfont->xfont->fid;
+  return jwxyz_unicode_character_name (fid, uc);
+}
+#endif /* HAVE_JWXYZ */
+
+
+
 /* Releases the font and texture.
  */
 void