Support loading fonts with names longer than 31 characters

This commit is contained in:
Yoshi Askharoun
2025-08-04 12:56:47 -05:00
parent a2b3addfc1
commit f3461ac81b
5 changed files with 12 additions and 15 deletions
+1 -1
View File
@@ -172,7 +172,7 @@ namespace Microsoft.Iris.Drawing
GCHandle gcHandle = GCHandle.Alloc(textFlow);
_currentlyMeasuringText = content != null ? content : string.Empty;
fixed (char* content1 = _currentlyMeasuringText)
fixed (char* chPtr = measureParams._textStyle.FontFace)
fixed (char* chPtr = measureParams._textStyle.TruncatedFontFace)
{
var style = new TextStyle.MarshalledData(measureParams._textStyle)
{
+3 -2
View File
@@ -35,7 +35,8 @@ namespace Microsoft.Iris.Drawing
public unsafe bool CanMeasure(string content, TextStyle textStyle)
{
bool fPossible;
fixed (char* chPtr = textStyle.FontFace)
fixed (char* chPtr = textStyle.TruncatedFontFace)
{
var style = new TextStyle.MarshalledData(textStyle)
{
@@ -70,7 +71,7 @@ namespace Microsoft.Iris.Drawing
}
IntPtr hGlyphRunInfo;
NativeApi.RasterizeRunPacket rasterizeRunPacket;
fixed (char* chPtr = textStyle.FontFace)
fixed (char* chPtr = textStyle.TruncatedFontFace)
{
var style = new TextStyle.MarshalledData(textStyle)
{
+4 -3
View File
@@ -164,9 +164,8 @@ namespace Microsoft.Iris.Drawing
EnableKerning = additional.EnableKerning;
if (additional._flags[256])
CharacterSpacing = additional.CharacterSpacing;
if (!additional._flags[64])
return;
Color = additional.Color;
if (additional._flags[64])
Color = additional.Color;
}
public bool HasColor => _flags[64];
@@ -225,6 +224,8 @@ namespace Microsoft.Iris.Drawing
info.AddValue("flags", _flags.Data);
}
internal string TruncatedFontFace => _fontFace.Length < 32 ? _fontFace : _fontFace.Substring(0, 31);
[Flags]
internal enum SetFlags
{
+3 -4
View File
@@ -290,10 +290,9 @@ namespace Microsoft.Iris.Markup.UIX
private static Result RangeValidateFontName(object value)
{
string str = (string)value;
if (str == null)
return Result.Fail("Script runtime failure: Invalid 'null' value for '{0}'", "FontName");
return str.Length > 31 ? Result.Fail("\"{0}\" cannot be longer than {1} characters", str, "31") : Result.Success;
return value is not string
? Result.Fail("Script runtime failure: Invalid '{0}' value for '{1}'", value ?? "null", "FontName")
: Result.Success;
}
public static void Pass1Initialize() => Type = new UIXTypeSchema(93, "Font", null, 153, typeof(Font), UIXTypeFlags.Immutable);
@@ -84,11 +84,7 @@ namespace Microsoft.Iris.Markup.UIX
private static object Construct() => new TextStyle();
private static Result RangeValidateFontFace(object value)
{
string str = (string)value;
return str.Length > 31 ? Result.Fail("\"{0}\" cannot be longer than {1} characters", str, "31") : Result.Success;
}
private static Result RangeValidateFontFace(object value) => Result.Success;
public static void Pass1Initialize() => Type = new UIXTypeSchema(220, "TextStyle", null, 153, typeof(TextStyle), UIXTypeFlags.None);