[CoreText] Make P/Invokes in CTFontDescriptor, CTFramesetter and CTParagraphStyle have blittable signatures. (#20426)
Contributes towards #15684.
This commit is contained in:
Родитель
b176e4a1ae
Коммит
64ddb8781c
|
@ -735,20 +735,24 @@ namespace CoreText {
|
|||
return Runtime.GetNSObject<NSObject> (CTFontDescriptorCopyAttribute (Handle, attribute.Handle), true);
|
||||
}
|
||||
|
||||
[DllImport (Constants.CoreTextLibrary)]
|
||||
static extern IntPtr CTFontDescriptorCopyLocalizedAttribute (IntPtr descriptor, IntPtr attribute, IntPtr language);
|
||||
public NSObject? GetLocalizedAttribute (NSString attribute)
|
||||
{
|
||||
return Runtime.GetNSObject<NSObject> (CTFontDescriptorCopyLocalizedAttribute (Handle, attribute.Handle, IntPtr.Zero), true);
|
||||
unsafe {
|
||||
return Runtime.GetNSObject<NSObject> (CTFontDescriptorCopyLocalizedAttribute (Handle, attribute.Handle, null), true);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Constants.CoreTextLibrary)]
|
||||
static extern IntPtr CTFontDescriptorCopyLocalizedAttribute (IntPtr descriptor, IntPtr attribute, out IntPtr language);
|
||||
unsafe static extern IntPtr CTFontDescriptorCopyLocalizedAttribute (IntPtr descriptor, IntPtr attribute, IntPtr* language);
|
||||
public NSObject? GetLocalizedAttribute (NSString attribute, out NSString? language)
|
||||
{
|
||||
var o = Runtime.GetNSObject<NSObject> (CTFontDescriptorCopyLocalizedAttribute (Handle, attribute.Handle, out var lang), true);
|
||||
IntPtr handle;
|
||||
IntPtr lang;
|
||||
unsafe {
|
||||
handle = CTFontDescriptorCopyLocalizedAttribute (Handle, attribute.Handle, &lang);
|
||||
}
|
||||
language = Runtime.GetNSObject<NSString> (lang, true);
|
||||
return o;
|
||||
return Runtime.GetNSObject<NSObject> (handle, true);
|
||||
}
|
||||
#endregion
|
||||
#if NET
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using ObjCRuntime;
|
||||
|
@ -90,14 +91,17 @@ namespace CoreText {
|
|||
|
||||
#region Frame Sizing
|
||||
[DllImport (Constants.CoreTextLibrary)]
|
||||
static extern CGSize CTFramesetterSuggestFrameSizeWithConstraints (
|
||||
IntPtr framesetter, NSRange stringRange, IntPtr frameAttributes, CGSize constraints, out NSRange fitRange);
|
||||
unsafe static extern CGSize CTFramesetterSuggestFrameSizeWithConstraints (
|
||||
IntPtr framesetter, NSRange stringRange, IntPtr frameAttributes, CGSize constraints, NSRange* fitRange);
|
||||
public CGSize SuggestFrameSize (NSRange stringRange, CTFrameAttributes? frameAttributes, CGSize constraints, out NSRange fitRange)
|
||||
{
|
||||
return CTFramesetterSuggestFrameSizeWithConstraints (
|
||||
Handle, stringRange,
|
||||
frameAttributes.GetHandle (),
|
||||
constraints, out fitRange);
|
||||
fitRange = default;
|
||||
unsafe {
|
||||
return CTFramesetterSuggestFrameSizeWithConstraints (
|
||||
Handle, stringRange,
|
||||
frameAttributes.GetHandle (),
|
||||
constraints, (NSRange*) Unsafe.AsPointer<NSRange> (ref fitRange));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#if NET
|
||||
|
|
|
@ -399,13 +399,12 @@ namespace CoreText {
|
|||
|
||||
#region Paragraph Style Access
|
||||
[DllImport (Constants.CoreTextLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
static extern unsafe bool CTParagraphStyleGetValueForSpecifier (IntPtr paragraphStyle, CTParagraphStyleSpecifier spec, nuint valueBufferSize, void* valueBuffer);
|
||||
static extern unsafe byte CTParagraphStyleGetValueForSpecifier (IntPtr paragraphStyle, CTParagraphStyleSpecifier spec, nuint valueBufferSize, void* valueBuffer);
|
||||
|
||||
public unsafe CTTextTab? []? GetTabStops ()
|
||||
{
|
||||
IntPtr cfArrayRef;
|
||||
if (!CTParagraphStyleGetValueForSpecifier (Handle, CTParagraphStyleSpecifier.TabStops, (uint) IntPtr.Size, (void*) &cfArrayRef))
|
||||
if (CTParagraphStyleGetValueForSpecifier (Handle, CTParagraphStyleSpecifier.TabStops, (uint) IntPtr.Size, (void*) &cfArrayRef) == 0)
|
||||
throw new InvalidOperationException ("Unable to get property value.");
|
||||
if (cfArrayRef == IntPtr.Zero)
|
||||
return Array.Empty<CTTextTab> ();
|
||||
|
@ -419,7 +418,7 @@ namespace CoreText {
|
|||
unsafe byte GetByteValue (CTParagraphStyleSpecifier spec)
|
||||
{
|
||||
byte value;
|
||||
if (!CTParagraphStyleGetValueForSpecifier (Handle, spec, sizeof (byte), &value))
|
||||
if (CTParagraphStyleGetValueForSpecifier (Handle, spec, sizeof (byte), &value) == 0)
|
||||
throw new InvalidOperationException ("Unable to get property value.");
|
||||
return value;
|
||||
}
|
||||
|
@ -447,7 +446,7 @@ namespace CoreText {
|
|||
#endif
|
||||
{
|
||||
nfloat value;
|
||||
if (!CTParagraphStyleGetValueForSpecifier (Handle, spec, (nuint) sizeof (nfloat), &value))
|
||||
if (CTParagraphStyleGetValueForSpecifier (Handle, spec, (nuint) sizeof (nfloat), &value) == 0)
|
||||
throw new InvalidOperationException ("Unable to get property value.");
|
||||
#if NET
|
||||
return value;
|
||||
|
|
|
@ -64,7 +64,6 @@ namespace Cecil.Tests {
|
|||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSend(System.IntPtr,System.IntPtr)",
|
||||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper_stret(System.IntPtr,System.IntPtr)",
|
||||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper(System.IntPtr,System.IntPtr)",
|
||||
"CoreGraphics.CGSize CoreText.CTFramesetter::CTFramesetterSuggestFrameSizeWithConstraints(System.IntPtr,Foundation.NSRange,System.IntPtr,CoreGraphics.CGSize,Foundation.NSRange&)",
|
||||
"CoreVideo.CVReturn CoreVideo.CVDisplayLink::CVDisplayLinkCreateWithActiveCGDisplays(System.IntPtr&)",
|
||||
"CoreVideo.CVReturn CoreVideo.CVDisplayLink::CVDisplayLinkCreateWithCGDisplay(System.UInt32,System.IntPtr&)",
|
||||
"CoreVideo.CVReturn CoreVideo.CVDisplayLink::CVDisplayLinkCreateWithCGDisplays(System.UInt32[],System.IntPtr,System.IntPtr&)",
|
||||
|
@ -166,7 +165,6 @@ namespace Cecil.Tests {
|
|||
"System.Boolean CoreText.CTFontManager::CTFontManagerUnregisterFontsForURL(System.IntPtr,CoreText.CTFontManagerScope,System.IntPtr&)",
|
||||
"System.Boolean CoreText.CTFontManager::CTFontManagerUnregisterFontsForURLs(System.IntPtr,CoreText.CTFontManagerScope,System.IntPtr&)",
|
||||
"System.Boolean CoreText.CTFontManager::CTFontManagerUnregisterGraphicsFont(System.IntPtr,System.IntPtr&)",
|
||||
"System.Boolean CoreText.CTParagraphStyle::CTParagraphStyleGetValueForSpecifier(System.IntPtr,CoreText.CTParagraphStyleSpecifier,System.UIntPtr,System.Void*)",
|
||||
"System.Boolean CoreVideo.CVBuffer::CVBufferHasAttachment(System.IntPtr,System.IntPtr)",
|
||||
"System.Boolean CoreVideo.CVDisplayLink::CVDisplayLinkIsRunning(System.IntPtr)",
|
||||
"System.Boolean CoreVideo.CVImageBuffer::CVImageBufferIsFlipped(System.IntPtr)",
|
||||
|
@ -269,7 +267,6 @@ namespace Cecil.Tests {
|
|||
"System.Int32 Security.SecCertificate::SecCertificateCopyEmailAddresses(System.IntPtr,System.IntPtr&)",
|
||||
"System.Int32 Security.SslContext::SSLCopyALPNProtocols(System.IntPtr,System.IntPtr&)",
|
||||
"System.Int32 Security.SslContext::SSLSetSessionTicketsEnabled(System.IntPtr,System.Boolean)",
|
||||
"System.IntPtr CoreText.CTFontDescriptor::CTFontDescriptorCopyLocalizedAttribute(System.IntPtr,System.IntPtr,System.IntPtr&)",
|
||||
"System.IntPtr CoreText.CTFontManager::CTFontManagerCopyRegisteredFontDescriptors(CoreText.CTFontManagerScope,System.Boolean)",
|
||||
"System.IntPtr CoreText.CTRunDelegate::CTRunDelegateCreate(CoreText.CTRunDelegateCallbacks&,System.IntPtr)",
|
||||
"System.IntPtr CoreVideo.CVBuffer::CVBufferCopyAttachment(System.IntPtr,System.IntPtr,CoreVideo.CVAttachmentMode&)",
|
||||
|
|
Загрузка…
Ссылка в новой задаче