cpython/Mac/Modules/fm/Fmmodule.c

424 lines
9.1 KiB
C
Raw Normal View History

1996-01-09 17:15:16 +00:00
/* =========================== Module Fm ============================ */
#include "Python.h"
#include "macglue.h"
#include "pymactoolbox.h"
1996-01-09 17:15:16 +00:00
#include <Fonts.h>
/*
** Parse/generate ComponentDescriptor records
*/
static PyObject *
FMRec_New(itself)
1996-01-09 17:15:16 +00:00
FMetricRec *itself;
{
return Py_BuildValue("O&O&O&O&O&",
PyMac_BuildFixed, itself->ascent,
PyMac_BuildFixed, itself->descent,
PyMac_BuildFixed, itself->leading,
PyMac_BuildFixed, itself->widMax,
ResObj_New, itself->wTabHandle);
}
#if 0
/* Not needed... */
static int
1996-01-09 17:15:16 +00:00
FMRec_Convert(v, p_itself)
PyObject *v;
FMetricRec *p_itself;
{
return PyArg_ParseTuple(v, "O&O&O&O&O&",
PyMac_GetFixed, &itself->ascent,
PyMac_GetFixed, &itself->descent,
PyMac_GetFixed, &itself->leading,
PyMac_GetFixed, &itself->widMax,
ResObj_Convert, &itself->wTabHandle);
}
#endif
static PyObject *Fm_Error;
#ifndef TARGET_API_MAC_CARBON
1996-01-09 17:15:16 +00:00
static PyObject *Fm_InitFonts(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
InitFonts();
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
1996-01-09 17:15:16 +00:00
static PyObject *Fm_GetFontName(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
short familyID;
Str255 name;
if (!PyArg_ParseTuple(_args, "h",
&familyID))
return NULL;
GetFontName(familyID,
name);
_res = Py_BuildValue("O&",
PyMac_BuildStr255, name);
return _res;
}
static PyObject *Fm_GetFNum(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Str255 name;
short familyID;
if (!PyArg_ParseTuple(_args, "O&",
PyMac_GetStr255, name))
return NULL;
GetFNum(name,
&familyID);
_res = Py_BuildValue("h",
familyID);
return _res;
}
static PyObject *Fm_RealFont(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean _rv;
short fontNum;
short size;
if (!PyArg_ParseTuple(_args, "hh",
&fontNum,
&size))
return NULL;
_rv = RealFont(fontNum,
size);
_res = Py_BuildValue("b",
_rv);
return _res;
}
#ifndef TARGET_API_MAC_CARBON
1996-01-09 17:15:16 +00:00
static PyObject *Fm_SetFontLock(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean lockFlag;
if (!PyArg_ParseTuple(_args, "b",
&lockFlag))
return NULL;
SetFontLock(lockFlag);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
1996-01-09 17:15:16 +00:00
static PyObject *Fm_SetFScaleDisable(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean fscaleDisable;
if (!PyArg_ParseTuple(_args, "b",
&fscaleDisable))
return NULL;
SetFScaleDisable(fscaleDisable);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Fm_FontMetrics(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
FMetricRec theMetrics;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
FontMetrics(&theMetrics);
_res = Py_BuildValue("O&",
FMRec_New, &theMetrics);
return _res;
}
static PyObject *Fm_SetFractEnable(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean fractEnable;
if (!PyArg_ParseTuple(_args, "b",
&fractEnable))
return NULL;
SetFractEnable(fractEnable);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Fm_GetDefFontSize(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
short _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetDefFontSize();
_res = Py_BuildValue("h",
_rv);
return _res;
}
static PyObject *Fm_IsOutline(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean _rv;
Point numer;
Point denom;
if (!PyArg_ParseTuple(_args, "O&O&",
PyMac_GetPoint, &numer,
PyMac_GetPoint, &denom))
return NULL;
_rv = IsOutline(numer,
denom);
_res = Py_BuildValue("b",
_rv);
return _res;
}
static PyObject *Fm_SetOutlinePreferred(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean outlinePreferred;
if (!PyArg_ParseTuple(_args, "b",
&outlinePreferred))
return NULL;
SetOutlinePreferred(outlinePreferred);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Fm_GetOutlinePreferred(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetOutlinePreferred();
_res = Py_BuildValue("b",
_rv);
return _res;
}
static PyObject *Fm_SetPreserveGlyph(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean preserveGlyph;
if (!PyArg_ParseTuple(_args, "b",
&preserveGlyph))
return NULL;
SetPreserveGlyph(preserveGlyph);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Fm_GetPreserveGlyph(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetPreserveGlyph();
_res = Py_BuildValue("b",
_rv);
return _res;
}
#ifndef TARGET_API_MAC_CARBON
1996-01-09 17:15:16 +00:00
static PyObject *Fm_FlushFonts(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_err = FlushFonts();
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
1996-01-09 17:15:16 +00:00
static PyObject *Fm_GetSysFont(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
short _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetSysFont();
_res = Py_BuildValue("h",
_rv);
return _res;
}
static PyObject *Fm_GetAppFont(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
short _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetAppFont();
_res = Py_BuildValue("h",
_rv);
return _res;
}
static PyObject *Fm_SetAntiAliasedTextEnabled(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
Boolean inEnable;
SInt16 inMinFontSize;
if (!PyArg_ParseTuple(_args, "bh",
&inEnable,
&inMinFontSize))
return NULL;
_err = SetAntiAliasedTextEnabled(inEnable,
inMinFontSize);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Fm_IsAntiAliasedTextEnabled(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean _rv;
SInt16 outMinFontSize;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = IsAntiAliasedTextEnabled(&outMinFontSize);
_res = Py_BuildValue("bh",
_rv,
outMinFontSize);
return _res;
}
1996-01-09 17:15:16 +00:00
static PyMethodDef Fm_methods[] = {
#ifndef TARGET_API_MAC_CARBON
1996-01-09 17:15:16 +00:00
{"InitFonts", (PyCFunction)Fm_InitFonts, 1,
"() -> None"},
#endif
1996-01-09 17:15:16 +00:00
{"GetFontName", (PyCFunction)Fm_GetFontName, 1,
"(short familyID) -> (Str255 name)"},
{"GetFNum", (PyCFunction)Fm_GetFNum, 1,
"(Str255 name) -> (short familyID)"},
{"RealFont", (PyCFunction)Fm_RealFont, 1,
"(short fontNum, short size) -> (Boolean _rv)"},
#ifndef TARGET_API_MAC_CARBON
1996-01-09 17:15:16 +00:00
{"SetFontLock", (PyCFunction)Fm_SetFontLock, 1,
"(Boolean lockFlag) -> None"},
#endif
1996-01-09 17:15:16 +00:00
{"SetFScaleDisable", (PyCFunction)Fm_SetFScaleDisable, 1,
"(Boolean fscaleDisable) -> None"},
{"FontMetrics", (PyCFunction)Fm_FontMetrics, 1,
"() -> (FMetricRec theMetrics)"},
{"SetFractEnable", (PyCFunction)Fm_SetFractEnable, 1,
"(Boolean fractEnable) -> None"},
{"GetDefFontSize", (PyCFunction)Fm_GetDefFontSize, 1,
"() -> (short _rv)"},
{"IsOutline", (PyCFunction)Fm_IsOutline, 1,
"(Point numer, Point denom) -> (Boolean _rv)"},
{"SetOutlinePreferred", (PyCFunction)Fm_SetOutlinePreferred, 1,
"(Boolean outlinePreferred) -> None"},
{"GetOutlinePreferred", (PyCFunction)Fm_GetOutlinePreferred, 1,
"() -> (Boolean _rv)"},
{"SetPreserveGlyph", (PyCFunction)Fm_SetPreserveGlyph, 1,
"(Boolean preserveGlyph) -> None"},
{"GetPreserveGlyph", (PyCFunction)Fm_GetPreserveGlyph, 1,
"() -> (Boolean _rv)"},
#ifndef TARGET_API_MAC_CARBON
1996-01-09 17:15:16 +00:00
{"FlushFonts", (PyCFunction)Fm_FlushFonts, 1,
"() -> None"},
#endif
1996-01-09 17:15:16 +00:00
{"GetSysFont", (PyCFunction)Fm_GetSysFont, 1,
"() -> (short _rv)"},
{"GetAppFont", (PyCFunction)Fm_GetAppFont, 1,
"() -> (short _rv)"},
{"SetAntiAliasedTextEnabled", (PyCFunction)Fm_SetAntiAliasedTextEnabled, 1,
"(Boolean inEnable, SInt16 inMinFontSize) -> None"},
{"IsAntiAliasedTextEnabled", (PyCFunction)Fm_IsAntiAliasedTextEnabled, 1,
"() -> (Boolean _rv, SInt16 outMinFontSize)"},
1996-01-09 17:15:16 +00:00
{NULL, NULL, 0}
};
void initFm()
{
PyObject *m;
PyObject *d;
m = Py_InitModule("Fm", Fm_methods);
d = PyModule_GetDict(m);
Fm_Error = PyMac_GetOSErrException();
if (Fm_Error == NULL ||
PyDict_SetItemString(d, "Error", Fm_Error) != 0)
Py_FatalError("can't initialize Fm.Error");
}
/* ========================= End module Fm ========================== */