Squashed commit of the following: [standardize_font_handling]

closes #60, closes #5, closes #68

The major functionality added here was proper use of types in the module, by importing after finalization.

commit 5009fa0fb9
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sun Apr 7 22:44:15 2024 -0400

    PyFont - use the new standard method for instancing

commit a19781b56a
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sun Apr 7 15:21:17 2024 -0400

    Many hours of pain & research behind this small commit. Safe object building by not messing with types before interpreter is fully initialized

commit 159658521c
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sun Mar 31 21:41:45 2024 -0400

    Font mostly working, just a few weird bugs with the types of the default items added to the module
This commit is contained in:
John McCardle 2024-04-07 22:51:31 -04:00
commit 1a7186f745
8 changed files with 207 additions and 11 deletions

View file

@ -13,6 +13,7 @@
#include "PyColor.h"
//#include "PyLinkedColor.h"
#include "PyVector.h"
#include "PyFont.h"
enum PyObjectsEnum : int
{
@ -409,7 +410,7 @@ static int PyUIDrawable_set_click(PyUIGridObject* self, PyObject* value, void* c
* Begin PyFontType defs
*
*/
/*
typedef struct {
PyObject_HEAD
std::shared_ptr<sf::Font> data;
@ -444,6 +445,7 @@ static int PyUIDrawable_set_click(PyUIGridObject* self, PyObject* value, void* c
return (PyObject*)self;
}
};
*/
/*
*
@ -792,13 +794,14 @@ static int PyUIDrawable_set_click(PyUIGridObject* self, PyObject* value, void* c
//
// Set Font
//
std::cout << PyUnicode_AsUTF8(PyObject_Repr(font)) << std::endl;
if (font != NULL && !PyObject_IsInstance(font, (PyObject*)&PyFontType)){
PyErr_SetString(PyExc_TypeError, "font must be a mcrfpy.Font instance");
return -1;
} else if (font != NULL)
{
auto font_obj = (PyFontObject*)font;
self->data->text.setFont(*font_obj->data);
self->data->text.setFont(font_obj->data->font);
self->font = font;
Py_INCREF(font);
} else