Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ed648a25
Kaydet (Commit)
ed648a25
authored
Ock 17, 1997
tarafından
Roger E. Masse
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Renamed, but not tested. Guido will you try your test script on this?
üst
e474fb36
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
95 deletions
+94
-95
fmmodule.c
Modules/fmmodule.c
+94
-95
No files found.
Modules/fmmodule.c
Dosyayı görüntüle @
ed648a25
...
...
@@ -31,9 +31,7 @@ PERFORMANCE OF THIS SOFTWARE.
/* Font Manager module */
#include "allobjects.h"
#include "modsupport.h"
#include "Python.h"
#include <gl.h>
#include <device.h>
...
...
@@ -43,153 +41,154 @@ PERFORMANCE OF THIS SOFTWARE.
/* Font Handle object implementation */
typedef
struct
{
OB
_HEAD
PyObject
_HEAD
fmfonthandle
fh_fh
;
}
fhobject
;
staticforward
typeo
bject
Fhtype
;
staticforward
PyTypeO
bject
Fhtype
;
#define is_fhobject(v) ((v)->ob_type == &Fhtype)
static
o
bject
*
static
PyO
bject
*
newfhobject
(
fh
)
fmfonthandle
fh
;
{
fhobject
*
fhp
;
if
(
fh
==
NULL
)
{
err_setstr
(
RuntimeError
,
"error creating new font handle"
);
PyErr_SetString
(
PyExc_RuntimeError
,
"error creating new font handle"
);
return
NULL
;
}
fhp
=
NEWOBJ
(
fhobject
,
&
Fhtype
);
fhp
=
PyObject_NEW
(
fhobject
,
&
Fhtype
);
if
(
fhp
==
NULL
)
return
NULL
;
fhp
->
fh_fh
=
fh
;
return
(
o
bject
*
)
fhp
;
return
(
PyO
bject
*
)
fhp
;
}
/* Font Handle methods */
static
o
bject
*
static
PyO
bject
*
fh_scalefont
(
self
,
args
)
fhobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
double
size
;
if
(
!
getargs
(
args
,
"d"
,
&
size
))
if
(
!
PyArg_Parse
(
args
,
"d"
,
&
size
))
return
NULL
;
return
newfhobject
(
fmscalefont
(
self
->
fh_fh
,
size
));
}
/* XXX fmmakefont */
static
o
bject
*
static
PyO
bject
*
fh_setfont
(
self
,
args
)
fhobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
fmsetfont
(
self
->
fh_fh
);
INCREF
(
None
);
return
None
;
Py_INCREF
(
Py_
None
);
return
Py_
None
;
}
static
o
bject
*
static
PyO
bject
*
fh_getfontname
(
self
,
args
)
fhobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
char
fontname
[
256
];
int
len
;
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
len
=
fmgetfontname
(
self
->
fh_fh
,
sizeof
fontname
,
fontname
);
if
(
len
<
0
)
{
err_setstr
(
RuntimeError
,
"error in fmgetfontname"
);
PyErr_SetString
(
PyExc_
RuntimeError
,
"error in fmgetfontname"
);
return
NULL
;
}
return
newsizedstringobject
(
fontname
,
len
);
return
PyString_FromStringAndSize
(
fontname
,
len
);
}
static
o
bject
*
static
PyO
bject
*
fh_getcomment
(
self
,
args
)
fhobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
char
comment
[
256
];
int
len
;
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
len
=
fmgetcomment
(
self
->
fh_fh
,
sizeof
comment
,
comment
);
if
(
len
<
0
)
{
err_setstr
(
RuntimeError
,
"error in fmgetcomment"
);
PyErr_SetString
(
PyExc_
RuntimeError
,
"error in fmgetcomment"
);
return
NULL
;
}
return
newsizedstringobject
(
comment
,
len
);
return
PyString_FromStringAndSize
(
comment
,
len
);
}
static
o
bject
*
static
PyO
bject
*
fh_getfontinfo
(
self
,
args
)
fhobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
fmfontinfo
info
;
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
if
(
fmgetfontinfo
(
self
->
fh_fh
,
&
info
)
<
0
)
{
err_setstr
(
RuntimeError
,
"error in fmgetfontinfo"
);
PyErr_SetString
(
PyExc_
RuntimeError
,
"error in fmgetfontinfo"
);
return
NULL
;
}
return
mkv
alue
(
"(llllllll)"
,
info
.
printermatched
,
info
.
fixed_width
,
info
.
xorig
,
info
.
yorig
,
info
.
xsize
,
info
.
ysize
,
info
.
height
,
info
.
nglyphs
);
return
Py_BuildV
alue
(
"(llllllll)"
,
info
.
printermatched
,
info
.
fixed_width
,
info
.
xorig
,
info
.
yorig
,
info
.
xsize
,
info
.
ysize
,
info
.
height
,
info
.
nglyphs
);
}
#if 0
static
o
bject *
static
PyO
bject *
fh_getwholemetrics(self, args)
fhobject *self;
o
bject *args;
PyO
bject *args;
{
}
#endif
static
o
bject
*
static
PyO
bject
*
fh_getstrwidth
(
self
,
args
)
fhobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
char
*
str
;
if
(
!
getstrarg
(
args
,
&
str
))
if
(
!
PyArg_Parse
(
args
,
"s"
,
&
str
))
return
NULL
;
return
newintobject
(
fmgetstrwidth
(
self
->
fh_fh
,
str
));
return
PyInt_FromLong
(
fmgetstrwidth
(
self
->
fh_fh
,
str
));
}
static
struct
methodlist
fh_methods
[]
=
{
{
"scalefont"
,
(
method
)
fh_scalefont
},
{
"setfont"
,
(
method
)
fh_setfont
},
{
"getfontname"
,
(
method
)
fh_getfontname
},
{
"getcomment"
,
(
method
)
fh_getcomment
},
{
"getfontinfo"
,
(
method
)
fh_getfontinfo
},
static
PyMethodDef
fh_methods
[]
=
{
{
"scalefont"
,
(
PyCFunction
)
fh_scalefont
},
{
"setfont"
,
(
PyCFunction
)
fh_setfont
},
{
"getfontname"
,
(
PyCFunction
)
fh_getfontname
},
{
"getcomment"
,
(
PyCFunction
)
fh_getcomment
},
{
"getfontinfo"
,
(
PyCFunction
)
fh_getfontinfo
},
#if 0
{"getwholemetrics", (
method
)fh_getwholemetrics},
{"getwholemetrics", (
PyCFunction
)fh_getwholemetrics},
#endif
{
"getstrwidth"
,
(
method
)
fh_getstrwidth
},
{
"getstrwidth"
,
(
PyCFunction
)
fh_getstrwidth
},
{
NULL
,
NULL
}
/* sentinel */
};
static
o
bject
*
static
PyO
bject
*
fh_getattr
(
fhp
,
name
)
fhobject
*
fhp
;
char
*
name
;
char
*
name
;
{
return
findmethod
(
fh_methods
,
(
o
bject
*
)
fhp
,
name
);
return
Py_FindMethod
(
fh_methods
,
(
PyO
bject
*
)
fhp
,
name
);
}
static
void
...
...
@@ -197,11 +196,11 @@ fh_dealloc(fhp)
fhobject
*
fhp
;
{
fmfreefont
(
fhp
->
fh_fh
);
DEL
(
fhp
);
PyMem_
DEL
(
fhp
);
}
static
typeo
bject
Fhtype
=
{
OB_HEAD_INIT
(
&
Typet
ype
)
static
PyTypeO
bject
Fhtype
=
{
PyObject_HEAD_INIT
(
&
PyType_T
ype
)
0
,
/*ob_size*/
"font handle"
,
/*tp_name*/
sizeof
(
fhobject
),
/*tp_size*/
...
...
@@ -218,72 +217,72 @@ static typeobject Fhtype = {
/* Font Manager functions */
static
o
bject
*
static
PyO
bject
*
fm_init
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
fminit
();
INCREF
(
None
);
return
None
;
Py_INCREF
(
Py_
None
);
return
Py_
None
;
}
static
o
bject
*
static
PyO
bject
*
fm_findfont
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
char
*
str
;
if
(
!
getstrarg
(
args
,
&
str
))
if
(
!
PyArg_Parse
(
args
,
"s"
,
&
str
))
return
NULL
;
return
newfhobject
(
fmfindfont
(
str
));
}
static
o
bject
*
static
PyO
bject
*
fm_prstr
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
char
*
str
;
if
(
!
getstrarg
(
args
,
&
str
))
if
(
!
PyArg_Parse
(
args
,
"s"
,
&
str
))
return
NULL
;
fmprstr
(
str
);
INCREF
(
None
);
return
None
;
Py_INCREF
(
Py_
None
);
return
Py_
None
;
}
/* XXX This uses a global variable as temporary! Not re-entrant! */
static
o
bject
*
fontlist
;
static
PyO
bject
*
fontlist
;
static
void
clientproc
(
fontname
)
char
*
fontname
;
{
int
err
;
o
bject
*
v
;
PyO
bject
*
v
;
if
(
fontlist
==
NULL
)
return
;
v
=
newstringobject
(
fontname
);
v
=
PyString_FromString
(
fontname
);
if
(
v
==
NULL
)
err
=
-
1
;
else
{
err
=
addlistitem
(
fontlist
,
v
);
DECREF
(
v
);
err
=
PyList_Append
(
fontlist
,
v
);
Py_
DECREF
(
v
);
}
if
(
err
!=
0
)
{
DECREF
(
fontlist
);
Py_
DECREF
(
fontlist
);
fontlist
=
NULL
;
}
}
static
o
bject
*
static
PyO
bject
*
fm_enumerate
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
o
bject
*
res
;
if
(
!
getnoarg
(
args
))
PyO
bject
*
res
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
fontlist
=
newlistobject
(
0
);
fontlist
=
PyList_New
(
0
);
if
(
fontlist
==
NULL
)
return
NULL
;
fmenumerate
(
clientproc
);
...
...
@@ -292,28 +291,28 @@ fm_enumerate(self, args)
return
res
;
}
static
o
bject
*
static
PyO
bject
*
fm_setpath
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
char
*
str
;
if
(
!
getstrarg
(
args
,
&
str
))
if
(
!
PyArg_Parse
(
args
,
"s"
,
&
str
))
return
NULL
;
fmsetpath
(
str
);
INCREF
(
None
);
return
None
;
Py_INCREF
(
Py_
None
);
return
Py_
None
;
}
static
o
bject
*
static
PyO
bject
*
fm_fontpath
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
return
newstringobject
(
fmfontpath
());
return
PyString_FromString
(
fmfontpath
());
}
static
struct
methodlist
fm_methods
[]
=
{
static
PyMethodDef
fm_methods
[]
=
{
{
"init"
,
fm_init
},
{
"findfont"
,
fm_findfont
},
{
"enumerate"
,
fm_enumerate
},
...
...
@@ -327,6 +326,6 @@ static struct methodlist fm_methods[] = {
void
initfm
()
{
initm
odule
(
"fm"
,
fm_methods
);
Py_InitM
odule
(
"fm"
,
fm_methods
);
fminit
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment