Skip to content

Commit 2ab665d

Browse files
committed
Use os.fspath instead of str
1 parent 4dee30d commit 2ab665d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

manimpango/register_font.pyx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pathlib import Path
22
from pango cimport *
33
import copy
4+
import os
45

56
cpdef bint fc_register_font(str font_path):
67
"""This function registers the font file using ``fontconfig`` so that
@@ -27,9 +28,9 @@ cpdef bint fc_register_font(str font_path):
2728
AssertionError
2829
Font is missing.
2930
"""
30-
a=Path(font_path)
31+
a = Path(font_path)
3132
assert a.exists(), f"font doesn't exist at {a.absolute()}"
32-
font_path = str(a.absolute())
33+
font_path = os.fspath(a.absolute())
3334
font_path_bytes=font_path.encode('utf-8')
3435
cdef const unsigned char* fontPath = font_path_bytes
3536
fontAddStatus = FcConfigAppFontAddFile(FcConfigGetCurrent(), fontPath)
@@ -93,7 +94,7 @@ ELIF UNAME_SYSNAME == "Windows":
9394
"""
9495
a=Path(font_path)
9596
assert a.exists(), f"font doesn't exist at {a.absolute()}"
96-
font_path = str(a.absolute())
97+
font_path = os.fspath(a.absolute())
9798
fontAddStatus = AddFontResourceExW(
9899
<bytes>font_path,
99100
FR_PRIVATE,
@@ -125,7 +126,7 @@ ELIF UNAME_SYSNAME == "Windows":
125126
"""
126127
a=Path(font_path)
127128
assert a.exists(), f"font doesn't exist at {a.absolute()}"
128-
font_path = str(a.absolute())
129+
font_path = os.fspath(a.absolute())
129130
return RemoveFontResourceExW(
130131
<bytes>font_path,
131132
FR_PRIVATE,

0 commit comments

Comments
 (0)