+#ifdef HAVE_MBSTOWCS
+ size_t clen = strlen(text) + 1;
+ wchar_t *cstr = malloc(sizeof(wchar_t) * clen); /* yes we are allocating probably too much here, I know */
+ int text_count = mbstowcs(cstr, text, clen);
+ double w;
+ if (text_count == -1)
+ text_count = mbstowcs(cstr, "Enc-Err", 6);
+#ifdef __APPLE__
+ while (text_count > 0) {
+ text_count--;
+ cstr[text_count] = afm_fix_osx_charset(cstr[text_count]); /* unsafe macro */
+ }
+#endif
+ w = afm_get_text_width_wide(start, font, size, tabwidth, cstr);
+ free(cstr);
+ return w;
+#else
+ return afm_get_text_width_wide(start, font, size, tabwidth, text);
+#endif
+}
+
+double afm_get_text_width_wide( double UNUSED(start), const char* font, double size,
+ double UNUSED(tabwidth), const afm_char* text)
+{