2 /* =========================== Module Fm ============================ */
9 #include "pymactoolbox.h"
14 ** Parse/generate ComponentDescriptor records
21 return Py_BuildValue("O&O&O&O&O&",
22 PyMac_BuildFixed
, itself
->ascent
,
23 PyMac_BuildFixed
, itself
->descent
,
24 PyMac_BuildFixed
, itself
->leading
,
25 PyMac_BuildFixed
, itself
->widMax
,
26 ResObj_New
, itself
->wTabHandle
);
32 FMRec_Convert(v
, p_itself
)
36 return PyArg_ParseTuple(v
, "O&O&O&O&O&",
37 PyMac_GetFixed
, &itself
->ascent
,
38 PyMac_GetFixed
, &itself
->descent
,
39 PyMac_GetFixed
, &itself
->leading
,
40 PyMac_GetFixed
, &itself
->widMax
,
41 ResObj_Convert
, &itself
->wTabHandle
);
46 static PyObject
*Fm_Error
;
48 #if !TARGET_API_MAC_CARBON
50 static PyObject
*Fm_InitFonts(_self
, _args
)
54 PyObject
*_res
= NULL
;
55 if (!PyArg_ParseTuple(_args
, ""))
64 static PyObject
*Fm_GetFontName(_self
, _args
)
68 PyObject
*_res
= NULL
;
71 if (!PyArg_ParseTuple(_args
, "h",
76 _res
= Py_BuildValue("O&",
77 PyMac_BuildStr255
, name
);
81 static PyObject
*Fm_GetFNum(_self
, _args
)
85 PyObject
*_res
= NULL
;
88 if (!PyArg_ParseTuple(_args
, "O&",
89 PyMac_GetStr255
, name
))
93 _res
= Py_BuildValue("h",
98 static PyObject
*Fm_RealFont(_self
, _args
)
102 PyObject
*_res
= NULL
;
106 if (!PyArg_ParseTuple(_args
, "hh",
110 _rv
= RealFont(fontNum
,
112 _res
= Py_BuildValue("b",
117 #if !TARGET_API_MAC_CARBON
119 static PyObject
*Fm_SetFontLock(_self
, _args
)
123 PyObject
*_res
= NULL
;
125 if (!PyArg_ParseTuple(_args
, "b",
128 SetFontLock(lockFlag
);
135 static PyObject
*Fm_SetFScaleDisable(_self
, _args
)
139 PyObject
*_res
= NULL
;
140 Boolean fscaleDisable
;
141 if (!PyArg_ParseTuple(_args
, "b",
144 SetFScaleDisable(fscaleDisable
);
150 static PyObject
*Fm_FontMetrics(_self
, _args
)
154 PyObject
*_res
= NULL
;
155 FMetricRec theMetrics
;
156 if (!PyArg_ParseTuple(_args
, ""))
158 FontMetrics(&theMetrics
);
159 _res
= Py_BuildValue("O&",
160 FMRec_New
, &theMetrics
);
164 static PyObject
*Fm_SetFractEnable(_self
, _args
)
168 PyObject
*_res
= NULL
;
170 if (!PyArg_ParseTuple(_args
, "b",
173 SetFractEnable(fractEnable
);
179 static PyObject
*Fm_GetDefFontSize(_self
, _args
)
183 PyObject
*_res
= NULL
;
185 if (!PyArg_ParseTuple(_args
, ""))
187 _rv
= GetDefFontSize();
188 _res
= Py_BuildValue("h",
193 static PyObject
*Fm_IsOutline(_self
, _args
)
197 PyObject
*_res
= NULL
;
201 if (!PyArg_ParseTuple(_args
, "O&O&",
202 PyMac_GetPoint
, &numer
,
203 PyMac_GetPoint
, &denom
))
205 _rv
= IsOutline(numer
,
207 _res
= Py_BuildValue("b",
212 static PyObject
*Fm_SetOutlinePreferred(_self
, _args
)
216 PyObject
*_res
= NULL
;
217 Boolean outlinePreferred
;
218 if (!PyArg_ParseTuple(_args
, "b",
221 SetOutlinePreferred(outlinePreferred
);
227 static PyObject
*Fm_GetOutlinePreferred(_self
, _args
)
231 PyObject
*_res
= NULL
;
233 if (!PyArg_ParseTuple(_args
, ""))
235 _rv
= GetOutlinePreferred();
236 _res
= Py_BuildValue("b",
241 static PyObject
*Fm_SetPreserveGlyph(_self
, _args
)
245 PyObject
*_res
= NULL
;
246 Boolean preserveGlyph
;
247 if (!PyArg_ParseTuple(_args
, "b",
250 SetPreserveGlyph(preserveGlyph
);
256 static PyObject
*Fm_GetPreserveGlyph(_self
, _args
)
260 PyObject
*_res
= NULL
;
262 if (!PyArg_ParseTuple(_args
, ""))
264 _rv
= GetPreserveGlyph();
265 _res
= Py_BuildValue("b",
270 #if !TARGET_API_MAC_CARBON
272 static PyObject
*Fm_FlushFonts(_self
, _args
)
276 PyObject
*_res
= NULL
;
278 if (!PyArg_ParseTuple(_args
, ""))
281 if (_err
!= noErr
) return PyMac_Error(_err
);
288 static PyObject
*Fm_GetSysFont(_self
, _args
)
292 PyObject
*_res
= NULL
;
294 if (!PyArg_ParseTuple(_args
, ""))
297 _res
= Py_BuildValue("h",
302 static PyObject
*Fm_GetAppFont(_self
, _args
)
306 PyObject
*_res
= NULL
;
308 if (!PyArg_ParseTuple(_args
, ""))
311 _res
= Py_BuildValue("h",
316 static PyObject
*Fm_SetAntiAliasedTextEnabled(_self
, _args
)
320 PyObject
*_res
= NULL
;
323 SInt16 inMinFontSize
;
324 if (!PyArg_ParseTuple(_args
, "bh",
328 _err
= SetAntiAliasedTextEnabled(inEnable
,
330 if (_err
!= noErr
) return PyMac_Error(_err
);
336 static PyObject
*Fm_IsAntiAliasedTextEnabled(_self
, _args
)
340 PyObject
*_res
= NULL
;
342 SInt16 outMinFontSize
;
343 if (!PyArg_ParseTuple(_args
, ""))
345 _rv
= IsAntiAliasedTextEnabled(&outMinFontSize
);
346 _res
= Py_BuildValue("bh",
352 static PyMethodDef Fm_methods
[] = {
354 #if !TARGET_API_MAC_CARBON
355 {"InitFonts", (PyCFunction
)Fm_InitFonts
, 1,
358 {"GetFontName", (PyCFunction
)Fm_GetFontName
, 1,
359 "(short familyID) -> (Str255 name)"},
360 {"GetFNum", (PyCFunction
)Fm_GetFNum
, 1,
361 "(Str255 name) -> (short familyID)"},
362 {"RealFont", (PyCFunction
)Fm_RealFont
, 1,
363 "(short fontNum, short size) -> (Boolean _rv)"},
365 #if !TARGET_API_MAC_CARBON
366 {"SetFontLock", (PyCFunction
)Fm_SetFontLock
, 1,
367 "(Boolean lockFlag) -> None"},
369 {"SetFScaleDisable", (PyCFunction
)Fm_SetFScaleDisable
, 1,
370 "(Boolean fscaleDisable) -> None"},
371 {"FontMetrics", (PyCFunction
)Fm_FontMetrics
, 1,
372 "() -> (FMetricRec theMetrics)"},
373 {"SetFractEnable", (PyCFunction
)Fm_SetFractEnable
, 1,
374 "(Boolean fractEnable) -> None"},
375 {"GetDefFontSize", (PyCFunction
)Fm_GetDefFontSize
, 1,
376 "() -> (short _rv)"},
377 {"IsOutline", (PyCFunction
)Fm_IsOutline
, 1,
378 "(Point numer, Point denom) -> (Boolean _rv)"},
379 {"SetOutlinePreferred", (PyCFunction
)Fm_SetOutlinePreferred
, 1,
380 "(Boolean outlinePreferred) -> None"},
381 {"GetOutlinePreferred", (PyCFunction
)Fm_GetOutlinePreferred
, 1,
382 "() -> (Boolean _rv)"},
383 {"SetPreserveGlyph", (PyCFunction
)Fm_SetPreserveGlyph
, 1,
384 "(Boolean preserveGlyph) -> None"},
385 {"GetPreserveGlyph", (PyCFunction
)Fm_GetPreserveGlyph
, 1,
386 "() -> (Boolean _rv)"},
388 #if !TARGET_API_MAC_CARBON
389 {"FlushFonts", (PyCFunction
)Fm_FlushFonts
, 1,
392 {"GetSysFont", (PyCFunction
)Fm_GetSysFont
, 1,
393 "() -> (short _rv)"},
394 {"GetAppFont", (PyCFunction
)Fm_GetAppFont
, 1,
395 "() -> (short _rv)"},
396 {"SetAntiAliasedTextEnabled", (PyCFunction
)Fm_SetAntiAliasedTextEnabled
, 1,
397 "(Boolean inEnable, SInt16 inMinFontSize) -> None"},
398 {"IsAntiAliasedTextEnabled", (PyCFunction
)Fm_IsAntiAliasedTextEnabled
, 1,
399 "() -> (Boolean _rv, SInt16 outMinFontSize)"},
414 m
= Py_InitModule("Fm", Fm_methods
);
415 d
= PyModule_GetDict(m
);
416 Fm_Error
= PyMac_GetOSErrException();
417 if (Fm_Error
== NULL
||
418 PyDict_SetItemString(d
, "Error", Fm_Error
) != 0)
419 Py_FatalError("can't initialize Fm.Error");
422 /* ========================= End module Fm ========================== */