[macOS/iOS] Fix system font family descriptor leak.
(cherry picked from commit c5dcecc6f7)
This commit is contained in:
committed by
Rémi Verschelde
parent
ab037eada2
commit
efb3cf1db4
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user