- int sw, sh;
- GLfloat scale = 0.6;
- char *title = frame->title ? frame->title : "(untitled)";
- sw = texture_string_width (ss->texfont, title, &sh);
+ int sw = 0, sh = 0;
+ int ascent, descent;
+ GLfloat tw = w * 2;
+ GLfloat th = h1 - h;
+ GLfloat scale = 1;
+ const char *title = frame->title ? frame->title : "(untitled)";
+ XCharStruct e;
+
+ texture_string_metrics (ss->texfont, title, &e, &ascent, &descent);
+ sw = e.width;
+ sh = ascent; /* + descent; */
+
+ /* Scale the text to match the pixel size of the photo */
+ scale *= w / 150.0;
+
+# if defined(HAVE_COCOA)
+ scale /= 2;
+# endif
+
+# if defined(HAVE_MOBILE)
+ scale /= 2;
+# endif
+
+ /* Clip characters off the left end of the string until it fits. */
+ if (clip_p || polaroid_p)
+ while (sw * scale > tw && strlen (title) > 10)
+ {
+ title++;
+ texture_string_metrics (ss->texfont, title, &e, &ascent, &descent);
+ sw = e.width;
+ }
+
+ if (th <= 0) /* Non-polaroid */
+ th = -sh * 1.2;
+
+ glTranslatef (-w, -h1, 0);
+ glTranslatef ((tw - sw*scale) / 2, (th - sh*scale) / 2, 0);