Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f9f2f4

Browse files
committed
Added PyMac_getscript() which returns the pythonic name of the current script. Not ideal and not complete, but good enough for the time being. Idea and most of the code by Fredrik Lund.
1 parent 12d86c8 commit 1f9f2f4

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Mac/Python/macglue.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,40 @@ static PyObject *python_event_handler;
181181
*/
182182
int PyMac_AppearanceCompliant;
183183

184+
/*
185+
** Find out what the current script is.
186+
** Donated by Fredrik Lund.
187+
*/
188+
char *PyMac_getscript()
189+
{
190+
int font, script, lang;
191+
font = 0;
192+
font = GetSysFont();
193+
script = FontToScript(font);
194+
switch (script) {
195+
case smRoman:
196+
lang = GetScriptVariable(script, smScriptLang);
197+
if (lang == langIcelandic)
198+
return "mac-iceland";
199+
else if (lang == langTurkish)
200+
return "mac-turkish";
201+
else if (lang == langGreek)
202+
return "mac-greek";
203+
else
204+
return "mac-roman";
205+
break;
206+
case smJapanese:
207+
return "mac-japan";
208+
case smGreek:
209+
return "mac-greek";
210+
case smCyrillic:
211+
return "mac-cyrillic";
212+
default:
213+
return "mac-roman"; /* better than nothing */
214+
}
215+
}
216+
217+
184218
#ifdef USE_GUSI1
185219
/*
186220
** GUSI (1.6.0 and earlier, at the least) do not set the MacOS idea of

0 commit comments

Comments
 (0)