Skip to content

Commit c6620f9

Browse files
authored
Merge pull request #2 from moi15moi/Correct-macOS-system-version-check-and-some-doc
Correct mac os system version check and some doc
2 parents aee712b + ce59872 commit c6620f9

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .fonts_filename import get_system_fonts_filename
22
from .exceptions import FontConfigNotFound, OSNotSupported
33

4-
__version__ = "0.0.3"
4+
__version__ = "0.0.4"

find_system_fonts_filename/linux_fonts.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def get_system_fonts_filename() -> Set[str]:
8282

8383
return fonts_filename
8484

85-
8685
@staticmethod
8786
def _load_font_config_library():
8887
font_config_library_name = util.find_library("fontconfig")
@@ -92,17 +91,22 @@ def _load_font_config_library():
9291

9392
LinuxFonts._font_config = cdll.LoadLibrary(font_config_library_name)
9493

94+
# https://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcinitloadconfigandfonts.html
9595
LinuxFonts._font_config.FcInitLoadConfigAndFonts.restype = c_void_p
9696
LinuxFonts._font_config.FcInitLoadConfigAndFonts.argtypes = []
9797

98+
# https://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcpatterncreate.html
9899
LinuxFonts._font_config.FcPatternCreate.restype = c_void_p
99100
LinuxFonts._font_config.FcPatternCreate.argtypes = []
100101

102+
# https://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcobjectsetbuild.html
101103
LinuxFonts._font_config.FcObjectSetBuild.restype = c_void_p
102104
LinuxFonts._font_config.FcObjectSetBuild.argtypes = [c_char_p, c_void_p]
103105

106+
# https://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcfontlist.html
104107
LinuxFonts._font_config.FcFontList.restype = POINTER(FcFontSet)
105108
LinuxFonts._font_config.FcFontList.argtypes = [c_void_p, c_void_p, c_void_p]
106109

110+
# https://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcpatternget-type.html
107111
LinuxFonts._font_config.FcPatternGetString.restype = FC_RESULT
108112
LinuxFonts._font_config.FcPatternGetString.argtypes = [c_void_p, c_char_p, c_int, POINTER(c_char_p)]

find_system_fonts_filename/mac_fonts.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,23 @@ def _load_core_library():
6565

6666
CFIndex = c_long
6767

68+
# https://developer.apple.com/documentation/corefoundation/1521153-cfrelease
6869
MacFonts._core_foundation.CFRelease.restype = c_void_p
6970
MacFonts._core_foundation.CFRelease.argtypes = [c_void_p]
7071

72+
# https://developer.apple.com/documentation/corefoundation/1388772-cfarraygetcount?language=objc
7173
MacFonts._core_foundation.CFArrayGetCount.restype = CFIndex
7274
MacFonts._core_foundation.CFArrayGetCount.argtypes = [c_void_p]
7375

76+
# https://developer.apple.com/documentation/corefoundation/1388767-cfarraygetvalueatindex?language=objc
7477
MacFonts._core_foundation.CFArrayGetValueAtIndex.restype = c_void_p
7578
MacFonts._core_foundation.CFArrayGetValueAtIndex.argtypes = [c_void_p, CFIndex]
7679

80+
# https://developer.apple.com/documentation/corefoundation/1541515-cfurlgetfilesystemrepresentation?language=objc
7781
MacFonts._core_foundation.CFURLGetFileSystemRepresentation.restype = c_bool
7882
MacFonts._core_foundation.CFURLGetFileSystemRepresentation.argtypes = [c_void_p, c_bool, c_char_p, CFIndex]
7983

84+
# https://developer.apple.com/documentation/coretext/1499478-ctfontmanagercopyavailablefontur?language=objc
8085
MacFonts._core_text.CTFontManagerCopyAvailableFontURLs.restype = c_void_p
8186
MacFonts._core_text.CTFontManagerCopyAvailableFontURLs.argtypes = []
8287

@@ -97,4 +102,4 @@ def is_mac_version_or_greater(minimum_major: int, minimum_minor: int) -> bool:
97102
system_major = int(system_major)
98103
system_minor = int(system_minor)
99104

100-
return minimum_major > system_major or (system_major == minimum_major and system_minor >= minimum_minor)
105+
return system_major > minimum_major or (system_major == minimum_major and system_minor >= minimum_minor)

find_system_fonts_filename/windows_fonts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DWRITE_FONT_FILE_TYPE(IntEnum):
2323
DWRITE_FONT_FILE_TYPE_TYPE1_PFB = 5
2424
DWRITE_FONT_FILE_TYPE_VECTOR = 6
2525
DWRITE_FONT_FILE_TYPE_BITMAP = 7
26-
DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION = 8
26+
DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION = DWRITE_FONT_FILE_TYPE_OPENTYPE_COLLECTION
2727

2828

2929
class IDWriteFontFileLoader(IUnknown):
@@ -367,7 +367,6 @@ def _get_fonts_filename_windows_vista_sp2_or_more() -> Set[str]:
367367
fonts_filename.add(buffer.value)
368368

369369
return fonts_filename
370-
371370

372371
@staticmethod
373372
def _load_DWriteCreateFactory():

0 commit comments

Comments
 (0)