Skip to content

Commit

Permalink
Intialise glib using g_set_prgname
Browse files Browse the repository at this point in the history
  • Loading branch information
naveen521kk committed Apr 16, 2021
1 parent 9c77649 commit 3b86250
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
10 changes: 5 additions & 5 deletions manimpango/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
from ._version import __version__ # noqa: F403,F401

try:
from ._deprecated import * # noqa: F403,F401
from .utils import * # noqa: F403,F401
initialize_glib()

from .font_description import * # noqa: F403,F401
from .layout import * # noqa: F403,F401
from .register_font import * # noqa: F403,F401
from .renderer import * # noqa: F403,F401
from .utils import * # noqa: F403,F401

# from ._cutils import * # noqa: F403,F401
from ._deprecated import * # noqa: F403,F401
except ImportError as ie: # pragma: no cover
py_ver = ".".join(map(str, sys.version_info[:3]))
msg = f"""
ManimPango could not import and load the necessary shared libraries.
ManimPango could not import and initialize itself.
This error may occur when ManimPango and its dependencies are improperly set up.
Please make sure the following versions are what you expect:
Expand Down
4 changes: 3 additions & 1 deletion manimpango/font_description/font_description.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ cdef class FontDescription:
# self.font_description,
# family.encode('utf-8'),
# )


# TODO: implement other properties

def __eq__(self, other: FontDescription) -> bool:
if isinstance(other, FontDescription):
return bool(pango_font_description_equal(self.font_description, other.font_description))
Expand Down
1 change: 1 addition & 0 deletions manimpango/includes/glib.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ cdef extern from "glib.h":
ctypedef char gchar
void g_object_unref(gpointer object)
void g_free(gpointer mem)
void g_set_prgname(const gchar *prgname)
4 changes: 4 additions & 0 deletions manimpango/utils/_cutils.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from pango cimport *
from cairo cimport *

cpdef int initialize_glib():
g_set_prgname('ManimPango')
return 1

cpdef str pango_version():
return pango_version_string().decode('utf-8')

Expand Down

0 comments on commit 3b86250

Please sign in to comment.