mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
[macOS/iOS] Fix system font family descriptor leak.
This commit is contained in:
parent
cae3d722a3
commit
c5dcecc6f7
2 changed files with 34 additions and 28 deletions
|
|
@ -534,6 +534,7 @@ Vector<String> OS_IOS::get_system_font_path_for_text(const String &p_font_name,
|
|||
CTFontDescriptorRef font = CTFontDescriptorCreateWithAttributes(attributes);
|
||||
if (font) {
|
||||
CTFontRef family = CTFontCreateWithFontDescriptor(font, 0, nullptr);
|
||||
if (family) {
|
||||
CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, p_text.utf8().get_data(), kCFStringEncodingUTF8);
|
||||
CFRange range = CFRangeMake(0, CFStringGetLength(string));
|
||||
CTFontRef fallback_family = CTFontCreateForString(family, string, range);
|
||||
|
|
@ -551,6 +552,8 @@ Vector<String> OS_IOS::get_system_font_path_for_text(const String &p_font_name,
|
|||
CFRelease(fallback_family);
|
||||
}
|
||||
CFRelease(string);
|
||||
CFRelease(family);
|
||||
}
|
||||
CFRelease(font);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -544,6 +544,7 @@ Vector<String> OS_MacOS::get_system_font_path_for_text(const String &p_font_name
|
|||
CTFontDescriptorRef font = CTFontDescriptorCreateWithAttributes(attributes);
|
||||
if (font) {
|
||||
CTFontRef family = CTFontCreateWithFontDescriptor(font, 0, nullptr);
|
||||
if (family) {
|
||||
CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, p_text.utf8().get_data(), kCFStringEncodingUTF8);
|
||||
CFRange range = CFRangeMake(0, CFStringGetLength(string));
|
||||
CTFontRef fallback_family = CTFontCreateForString(family, string, range);
|
||||
|
|
@ -561,6 +562,8 @@ Vector<String> OS_MacOS::get_system_font_path_for_text(const String &p_font_name
|
|||
CFRelease(fallback_family);
|
||||
}
|
||||
CFRelease(string);
|
||||
CFRelease(family);
|
||||
}
|
||||
CFRelease(font);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue