+/*
+ * Try to work out a horizontal scaling factor for the current font
+ * that will give a chracter width of wantwidth. Return it in numer
+ * and denom (suitable for passing to StdText()).
+ */
+static void mac_workoutfontscale(Session *s, int wantwidth,
+ Point *numerp, Point *denomp)
+{
+ Point numer, denom, tmpnumer, tmpdenom;
+ int gotwidth, i;
+ const char text = 'W';
+ FontInfo fi;
+
+ numer.v = denom.v = 1; /* always */
+ numer.h = denom.h = 1;
+ for (i = 0; i < 3; i++) {
+ tmpnumer = numer;
+ tmpdenom = denom;
+ if (s->window->grafProcs != NULL)
+ gotwidth = InvokeQDTxMeasUPP(1, &text, &tmpnumer, &tmpdenom, &fi,
+ s->window->grafProcs->txMeasProc);
+ else
+ gotwidth = StdTxMeas(1, &text, &tmpnumer, &tmpdenom, &fi);
+ /* The result of StdTxMeas must be scaled by the factors it returns. */
+ gotwidth = FixRound(FixMul(gotwidth << 16,
+ FixRatio(tmpnumer.h, tmpdenom.h)));
+ if (gotwidth == wantwidth)
+ break;
+ numer.h *= wantwidth;
+ denom.h *= gotwidth;
+ }
+ *numerp = numer;
+ *denomp = denom;
+}
+
+static UnicodeToTextFallbackUPP uni_to_font_fallback_upp;
+