@@ -12,8 +12,8 @@ namespace SixLabors.Fonts;
1212/// </summary>
1313public sealed class FontCollection : IFontCollection , IFontMetricsCollection
1414{
15- private readonly HashSet < string > searchDirectories = new ( ) ;
16- private readonly HashSet < FontMetrics > metricsCollection = new ( ) ;
15+ private readonly HashSet < string > searchDirectories = [ ] ;
16+ private readonly HashSet < FontMetrics > metricsCollection = [ ] ;
1717
1818 /// <summary>
1919 /// Initializes a new instance of the <see cref="FontCollection"/> class.
@@ -208,15 +208,15 @@ private FontFamily AddImpl(Stream stream, CultureInfo culture, out FontDescripti
208208 return ( ( IFontMetricsCollection ) this ) . AddMetrics ( metrics , culture ) ;
209209 }
210210
211- private IEnumerable < FontFamily > AddCollectionImpl (
211+ private HashSet < FontFamily > AddCollectionImpl (
212212 string path ,
213213 CultureInfo culture ,
214214 out IEnumerable < FontDescription > descriptions )
215215 {
216216 FileFontMetrics [ ] fonts = FileFontMetrics . LoadFontCollection ( path ) ;
217217
218218 FontDescription [ ] description = new FontDescription [ fonts . Length ] ;
219- HashSet < FontFamily > families = new ( ) ;
219+ HashSet < FontFamily > families = [ ] ;
220220 for ( int i = 0 ; i < fonts . Length ; i ++ )
221221 {
222222 description [ i ] = fonts [ i ] . Description ;
@@ -228,7 +228,7 @@ private IEnumerable<FontFamily> AddCollectionImpl(
228228 return families ;
229229 }
230230
231- private IEnumerable < FontFamily > AddCollectionImpl (
231+ private HashSet < FontFamily > AddCollectionImpl (
232232 Stream stream ,
233233 CultureInfo culture ,
234234 out IEnumerable < FontDescription > descriptions )
@@ -237,7 +237,7 @@ private IEnumerable<FontFamily> AddCollectionImpl(
237237 using BigEndianBinaryReader reader = new ( stream , true ) ;
238238 TtcHeader ttcHeader = TtcHeader . Read ( reader ) ;
239239 List < FontDescription > result = new ( ( int ) ttcHeader . NumFonts ) ;
240- HashSet < FontFamily > installedFamilies = new ( ) ;
240+ HashSet < FontFamily > installedFamilies = [ ] ;
241241 for ( int i = 0 ; i < ttcHeader . NumFonts ; ++ i )
242242 {
243243 stream . Position = startPos + ttcHeader . OffsetTable [ i ] ;
@@ -251,12 +251,11 @@ private IEnumerable<FontFamily> AddCollectionImpl(
251251 return installedFamilies ;
252252 }
253253
254- private IEnumerable < FontFamily > FamiliesByCultureImpl ( CultureInfo culture )
255- => this . metricsCollection
254+ private FontFamily [ ] FamiliesByCultureImpl ( CultureInfo culture )
255+ => [ .. this . metricsCollection
256256 . Select ( x => x . Description . FontFamily ( culture ) )
257257 . Distinct ( )
258- . Select ( x => new FontFamily ( x , this , culture ) )
259- . ToArray ( ) ;
258+ . Select ( x => new FontFamily ( x , this , culture ) ) ] ;
260259
261260 private bool TryGetImpl ( string name , CultureInfo culture , out FontFamily family )
262261 {
0 commit comments