[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);
|
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)
|
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)]
|
[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)
|
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);
|
language = Runtime.GetNSObject<NSString> (lang, true);
|
||||||
return o;
|
return Runtime.GetNSObject<NSObject> (handle, true);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#if NET
|
#if NET
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using ObjCRuntime;
|
using ObjCRuntime;
|
||||||
|
@ -90,14 +91,17 @@ namespace CoreText {
|
||||||
|
|
||||||
#region Frame Sizing
|
#region Frame Sizing
|
||||||
[DllImport (Constants.CoreTextLibrary)]
|
[DllImport (Constants.CoreTextLibrary)]
|
||||||
static extern CGSize CTFramesetterSuggestFrameSizeWithConstraints (
|
unsafe static extern CGSize CTFramesetterSuggestFrameSizeWithConstraints (
|
||||||
IntPtr framesetter, NSRange stringRange, IntPtr frameAttributes, CGSize constraints, out NSRange fitRange);
|
IntPtr framesetter, NSRange stringRange, IntPtr frameAttributes, CGSize constraints, NSRange* fitRange);
|
||||||
public CGSize SuggestFrameSize (NSRange stringRange, CTFrameAttributes? frameAttributes, CGSize constraints, out NSRange fitRange)
|
public CGSize SuggestFrameSize (NSRange stringRange, CTFrameAttributes? frameAttributes, CGSize constraints, out NSRange fitRange)
|
||||||
{
|
{
|
||||||
return CTFramesetterSuggestFrameSizeWithConstraints (
|
fitRange = default;
|
||||||
Handle, stringRange,
|
unsafe {
|
||||||
frameAttributes.GetHandle (),
|
return CTFramesetterSuggestFrameSizeWithConstraints (
|
||||||
constraints, out fitRange);
|
Handle, stringRange,
|
||||||
|
frameAttributes.GetHandle (),
|
||||||
|
constraints, (NSRange*) Unsafe.AsPointer<NSRange> (ref fitRange));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#if NET
|
#if NET
|
||||||
|
|
|
@ -399,13 +399,12 @@ namespace CoreText {
|
||||||
|
|
||||||
#region Paragraph Style Access
|
#region Paragraph Style Access
|
||||||
[DllImport (Constants.CoreTextLibrary)]
|
[DllImport (Constants.CoreTextLibrary)]
|
||||||
[return: MarshalAs (UnmanagedType.I1)]
|
static extern unsafe byte CTParagraphStyleGetValueForSpecifier (IntPtr paragraphStyle, CTParagraphStyleSpecifier spec, nuint valueBufferSize, void* valueBuffer);
|
||||||
static extern unsafe bool CTParagraphStyleGetValueForSpecifier (IntPtr paragraphStyle, CTParagraphStyleSpecifier spec, nuint valueBufferSize, void* valueBuffer);
|
|
||||||
|
|
||||||
public unsafe CTTextTab? []? GetTabStops ()
|
public unsafe CTTextTab? []? GetTabStops ()
|
||||||
{
|
{
|
||||||
IntPtr cfArrayRef;
|
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.");
|
throw new InvalidOperationException ("Unable to get property value.");
|
||||||
if (cfArrayRef == IntPtr.Zero)
|
if (cfArrayRef == IntPtr.Zero)
|
||||||
return Array.Empty<CTTextTab> ();
|
return Array.Empty<CTTextTab> ();
|
||||||
|
@ -419,7 +418,7 @@ namespace CoreText {
|
||||||
unsafe byte GetByteValue (CTParagraphStyleSpecifier spec)
|
unsafe byte GetByteValue (CTParagraphStyleSpecifier spec)
|
||||||
{
|
{
|
||||||
byte value;
|
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.");
|
throw new InvalidOperationException ("Unable to get property value.");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -447,7 +446,7 @@ namespace CoreText {
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
nfloat value;
|
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.");
|
throw new InvalidOperationException ("Unable to get property value.");
|
||||||
#if NET
|
#if NET
|
||||||
return value;
|
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_msgSend(System.IntPtr,System.IntPtr)",
|
||||||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper_stret(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)",
|
"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::CVDisplayLinkCreateWithActiveCGDisplays(System.IntPtr&)",
|
||||||
"CoreVideo.CVReturn CoreVideo.CVDisplayLink::CVDisplayLinkCreateWithCGDisplay(System.UInt32,System.IntPtr&)",
|
"CoreVideo.CVReturn CoreVideo.CVDisplayLink::CVDisplayLinkCreateWithCGDisplay(System.UInt32,System.IntPtr&)",
|
||||||
"CoreVideo.CVReturn CoreVideo.CVDisplayLink::CVDisplayLinkCreateWithCGDisplays(System.UInt32[],System.IntPtr,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::CTFontManagerUnregisterFontsForURL(System.IntPtr,CoreText.CTFontManagerScope,System.IntPtr&)",
|
||||||
"System.Boolean CoreText.CTFontManager::CTFontManagerUnregisterFontsForURLs(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.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.CVBuffer::CVBufferHasAttachment(System.IntPtr,System.IntPtr)",
|
||||||
"System.Boolean CoreVideo.CVDisplayLink::CVDisplayLinkIsRunning(System.IntPtr)",
|
"System.Boolean CoreVideo.CVDisplayLink::CVDisplayLinkIsRunning(System.IntPtr)",
|
||||||
"System.Boolean CoreVideo.CVImageBuffer::CVImageBufferIsFlipped(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.SecCertificate::SecCertificateCopyEmailAddresses(System.IntPtr,System.IntPtr&)",
|
||||||
"System.Int32 Security.SslContext::SSLCopyALPNProtocols(System.IntPtr,System.IntPtr&)",
|
"System.Int32 Security.SslContext::SSLCopyALPNProtocols(System.IntPtr,System.IntPtr&)",
|
||||||
"System.Int32 Security.SslContext::SSLSetSessionTicketsEnabled(System.IntPtr,System.Boolean)",
|
"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.CTFontManager::CTFontManagerCopyRegisteredFontDescriptors(CoreText.CTFontManagerScope,System.Boolean)",
|
||||||
"System.IntPtr CoreText.CTRunDelegate::CTRunDelegateCreate(CoreText.CTRunDelegateCallbacks&,System.IntPtr)",
|
"System.IntPtr CoreText.CTRunDelegate::CTRunDelegateCreate(CoreText.CTRunDelegateCallbacks&,System.IntPtr)",
|
||||||
"System.IntPtr CoreVideo.CVBuffer::CVBufferCopyAttachment(System.IntPtr,System.IntPtr,CoreVideo.CVAttachmentMode&)",
|
"System.IntPtr CoreVideo.CVBuffer::CVBufferCopyAttachment(System.IntPtr,System.IntPtr,CoreVideo.CVAttachmentMode&)",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче