Browse Source
Merge pull request #4381 from Gillibald/fixes/FontStyleConversion
Fixes SKFontStyleSlant to FontStyle conversion
repro/carousel-not-materializing-content
danwalmsley
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
21 additions and
5 deletions
src/Avalonia.Visuals/ApiCompatBaseline.txt
src/Avalonia.Visuals/Media/FontStyle.cs
src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs
src/Skia/Avalonia.Skia/SkiaSharpExtensions.cs
@ -0,0 +1,4 @@
Compat issues with assembly Avalonia.Visuals:
EnumValuesMustMatch : Enum value 'Avalonia.Media.FontStyle Avalonia.Media.FontStyle.Italic' is (System.Int32)1 in the implementation but (System.Int32)2 in the contract.
EnumValuesMustMatch : Enum value 'Avalonia.Media.FontStyle Avalonia.Media.FontStyle.Oblique' is (System.Int32)2 in the implementation but (System.Int32)1 in the contract.
Total Issues: 2
@ -11,13 +11,13 @@ namespace Avalonia.Media
Normal ,
/// <summary>
/// An oblique font.
/// An italic font.
/// </summary>
Oblique ,
Italic ,
/// <summary>
/// An italic font.
/// An oblique font.
/// </summary>
Italic ,
Oblique
}
}
@ -56,7 +56,8 @@ namespace Avalonia.Skia
continue ;
}
var key = new FontKey ( fontFamily . Name , ( FontStyle ) typeface . FontSlant , ( FontWeight ) typeface . FontWeight ) ;
var key = new FontKey ( fontFamily . Name , typeface . FontSlant . ToAvalonia ( ) ,
( FontWeight ) typeface . FontWeight ) ;
typeFaceCollection . AddTypeface ( key , typeface ) ;
}
@ -138,6 +138,17 @@ namespace Avalonia.Skia
}
}
public static FontStyle ToAvalonia ( this SKFontStyleSlant slant )
{
return slant switch
{
SKFontStyleSlant . Upright = > FontStyle . Normal ,
SKFontStyleSlant . Italic = > FontStyle . Italic ,
SKFontStyleSlant . Oblique = > FontStyle . Oblique ,
_ = > throw new ArgumentOutOfRangeException ( nameof ( slant ) , slant , null )
} ;
}
public static SKPath Clone ( this SKPath src )
{
return src ! = null ? new SKPath ( src ) : null ;