Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/CoreText/CTFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2989,6 +2989,19 @@ public CTFontSymbolicTraits SymbolicTraits {
get { return CTFontGetSymbolicTraits (Handle); }
}

[DllImport (Constants.CoreTextLibrary)]
static extern CTFontUIFontType CTFontGetUIFontType (IntPtr font);

/// <summary>Gets the UI font type of the font.</summary>
/// <value>The UI font type, or <see cref="CTFontUIFontType.None" /> if the font is not a UI font.</value>
[SupportedOSPlatform ("ios26.4")]
[SupportedOSPlatform ("maccatalyst26.4")]
[SupportedOSPlatform ("macos26.4")]
[SupportedOSPlatform ("tvos26.4")]
public CTFontUIFontType UIFontType {
get { return CTFontGetUIFontType (GetCheckedHandle ()); }
}

[DllImport (Constants.CoreTextLibrary)]
static extern IntPtr CTFontCopyTraits (IntPtr font);
/// <summary>To be added.</summary>
Expand Down
10 changes: 10 additions & 0 deletions src/CoreText/CTFontDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@ public IEnumerable<string>? Languages {
set { Adapter.SetValue (Dictionary, CTFontDescriptorAttributeKey.Languages!, value); }
}

/// <summary>The language of the font descriptor.</summary>
[SupportedOSPlatform ("ios26.4")]
[SupportedOSPlatform ("maccatalyst26.4")]
[SupportedOSPlatform ("macos26.4")]
[SupportedOSPlatform ("tvos26.4")]
public string? Language {
get { return Adapter.GetStringValue (Dictionary, CTFontDescriptorAttributeKey.Language); }
set { Adapter.SetValue (Dictionary, CTFontDescriptorAttributeKey.Language!, value); }
}

// float represented as a CFNumber
/// <summary>The Baseline Adjustment.</summary>
/// <value>
Expand Down
4 changes: 4 additions & 0 deletions src/coretext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ interface CTFontDescriptorAttributeKey {
[iOS (13, 0), NoTV, MacCatalyst (13, 1), NoMac]
[Field ("kCTFontRegistrationUserInfoAttribute")]
NSString RegistrationUserInfo { get; }

[iOS (26, 4), TV (26, 4), Mac (26, 4), MacCatalyst (26, 4)]
[Field ("kCTFontDescriptorLanguageAttribute")]
NSString Language { get; }
}

/// <summary>A class whose static properties can be used as keys for the <see cref="Foundation.NSDictionary" /> used by <see cref="CoreText.CTTextTabOptions" />.</summary>
Expand Down
13 changes: 13 additions & 0 deletions tests/monotouch-test/CoreText/FontDescriptorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,18 @@ public void MatchFontDescriptors ()
Assert.IsTrue (rv, "Return value");
TestRuntime.RunAsync (TimeSpan.FromSeconds (30), tcs.Task);
}

[Test]
public void LanguageAttribute ()
{
TestRuntime.AssertXcodeVersion (26, 4);
var fda = new CTFontDescriptorAttributes () {
FamilyName = "Courier",
Language = "en",
};
using var fd = new CTFontDescriptor (fda);
var attrs = fd.GetAttributes ();
Assert.That (attrs.Language, Is.EqualTo ("en"), "Language");
}
}
}
16 changes: 16 additions & 0 deletions tests/monotouch-test/CoreText/FontTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,21 @@ public void GetVariationAxes ()
Assert.That (axes.Length, Is.EqualTo (0), "Length");
}
}

[Test]
public void UIFontType_SystemFont ()
{
TestRuntime.AssertXcodeVersion (26, 4);
using var font = new CTFont (CTFontUIFontType.System, 12, "en");
Assert.That (font.UIFontType, Is.EqualTo (CTFontUIFontType.System), "System");
}

[Test]
public void UIFontType_RegularFont ()
{
TestRuntime.AssertXcodeVersion (26, 4);
using var font = new CTFont ("HoeflerText-Regular", 10);
Assert.That (font.UIFontType, Is.EqualTo (CTFontUIFontType.None), "None");
}
}
}

This file was deleted.

2 changes: 0 additions & 2 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreText.todo

This file was deleted.

2 changes: 0 additions & 2 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreText.todo

This file was deleted.

2 changes: 0 additions & 2 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreText.todo

This file was deleted.

Loading