From ba53d8cc3df1126b0303afb51d617d17ba22f4c1 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 25 Sep 2023 20:10:31 +1000 Subject: [PATCH] Use overloads while passing culture --- README.md | 5 ++--- src/SixLabors.Fonts/FontCollection.cs | 22 ++++++++++----------- src/SixLabors.Fonts/SixLabors.Fonts.csproj | 2 +- src/SixLabors.Fonts/SystemFontCollection.cs | 2 +- src/SixLabors.Fonts/SystemFonts.cs | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3e54b9dd..3e58ea98 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ SixLabors.Fonts [![Build Status](https://img.shields.io/github/actions/workflow/status/SixLabors/Fonts/build-and-test.yml?branch=main)](https://github.com/SixLabors/Fonts/actions) [![codecov](https://codecov.io/gh/SixLabors/Fonts/branch/main/graph/badge.svg)](https://codecov.io/gh/SixLabors/Fonts) -[![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) - +[![License: Six Labors Split](https://img.shields.io/badge/license-Six%20Labors%20Split-%23e30183)](https://github.com/SixLabors/Fonts/blob/main/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/SixLabors/Fonts.svg)](https://github.com/SixLabors/Fonts/issues) [![GitHub stars](https://img.shields.io/github/stars/SixLabors/Fonts.svg)](https://github.com/SixLabors/Fonts/stargazers) [![GitHub forks](https://img.shields.io/github/forks/SixLabors/Fonts.svg)](https://github.com/SixLabors/Fonts/network) @@ -92,7 +91,7 @@ git submodule update --init --recursive - Loading [WOFF fonts](https://www.w3.org/Submission/WOFF/). - Loading [WOFF2 fonts](https://www.w3.org/TR/WOFF2). - Load all compatible fonts from local machine store. -- Suppord for line breaking based on [UAX 14](https://www.unicode.org/reports/tr14/) +- Support for line breaking based on [UAX 14](https://www.unicode.org/reports/tr14/) - Support for rendering left to right, right to left and bidirectional text. - Support for ligatures. - Support for advanced OpenType features glyph substitution ([GSUB](https://docs.microsoft.com/en-us/typography/opentype/spec/gsub)) and glyph positioning ([GPOS](https://docs.microsoft.com/en-us/typography/opentype/spec/gpos)) diff --git a/src/SixLabors.Fonts/FontCollection.cs b/src/SixLabors.Fonts/FontCollection.cs index 28bcb7f7..e3815e43 100644 --- a/src/SixLabors.Fonts/FontCollection.cs +++ b/src/SixLabors.Fonts/FontCollection.cs @@ -78,11 +78,11 @@ public IEnumerable AddCollection(Stream stream, out IEnumerable public FontFamily Get(string name) - => this.GetImpl(name, CultureInfo.InvariantCulture); + => this.Get(name, CultureInfo.InvariantCulture); /// public bool TryGet(string name, out FontFamily family) - => this.TryGetImpl(name, CultureInfo.InvariantCulture, out family); + => this.TryGet(name, CultureInfo.InvariantCulture, out family); /// public FontFamily Add(string path, CultureInfo culture) @@ -195,14 +195,14 @@ internal void AddSearchDirectories(IEnumerable directories) private FontFamily AddImpl(string path, CultureInfo culture, out FontDescription description) { - var instance = new FileFontMetrics(path); + FileFontMetrics instance = new(path); description = instance.Description; return ((IFontMetricsCollection)this).AddMetrics(instance, culture); } private FontFamily AddImpl(Stream stream, CultureInfo culture, out FontDescription description) { - var metrics = StreamFontMetrics.LoadFont(stream); + StreamFontMetrics metrics = StreamFontMetrics.LoadFont(stream); description = metrics.Description; return ((IFontMetricsCollection)this).AddMetrics(metrics, culture); @@ -215,8 +215,8 @@ private IEnumerable AddCollectionImpl( { FileFontMetrics[] fonts = FileFontMetrics.LoadFontCollection(path); - var description = new FontDescription[fonts.Length]; - var families = new HashSet(); + FontDescription[] description = new FontDescription[fonts.Length]; + HashSet families = new(); for (int i = 0; i < fonts.Length; i++) { description[i] = fonts[i].Description; @@ -234,14 +234,14 @@ private IEnumerable AddCollectionImpl( out IEnumerable descriptions) { long startPos = stream.Position; - var reader = new BigEndianBinaryReader(stream, true); - var ttcHeader = TtcHeader.Read(reader); - var result = new List((int)ttcHeader.NumFonts); - var installedFamilies = new HashSet(); + BigEndianBinaryReader reader = new(stream, true); + TtcHeader ttcHeader = TtcHeader.Read(reader); + List result = new((int)ttcHeader.NumFonts); + HashSet installedFamilies = new(); for (int i = 0; i < ttcHeader.NumFonts; ++i) { stream.Position = startPos + ttcHeader.OffsetTable[i]; - var instance = StreamFontMetrics.LoadFont(stream); + StreamFontMetrics instance = StreamFontMetrics.LoadFont(stream); installedFamilies.Add(((IFontMetricsCollection)this).AddMetrics(instance, culture)); FontDescription fontDescription = instance.Description; result.Add(fontDescription); diff --git a/src/SixLabors.Fonts/SixLabors.Fonts.csproj b/src/SixLabors.Fonts/SixLabors.Fonts.csproj index 7173c3b6..0cf7745d 100644 --- a/src/SixLabors.Fonts/SixLabors.Fonts.csproj +++ b/src/SixLabors.Fonts/SixLabors.Fonts.csproj @@ -12,7 +12,7 @@ font;truetype;opentype;woff;woff2 A cross-platform library for loading and laying out fonts for processing and measuring; written in C# - 2.0.0.0 + 3.0.0.0 diff --git a/src/SixLabors.Fonts/SystemFontCollection.cs b/src/SixLabors.Fonts/SystemFontCollection.cs index f13ba8ba..877b2cac 100644 --- a/src/SixLabors.Fonts/SystemFontCollection.cs +++ b/src/SixLabors.Fonts/SystemFontCollection.cs @@ -108,7 +108,7 @@ public SystemFontCollection() public IEnumerable SearchDirectories => this.searchDirectories; /// - public FontFamily Get(string name) => this.collection.Get(name); + public FontFamily Get(string name) => this.Get(name, CultureInfo.InvariantCulture); /// public bool TryGet(string name, out FontFamily family) diff --git a/src/SixLabors.Fonts/SystemFonts.cs b/src/SixLabors.Fonts/SystemFonts.cs index fb26497a..86f7e142 100644 --- a/src/SixLabors.Fonts/SystemFonts.cs +++ b/src/SixLabors.Fonts/SystemFonts.cs @@ -23,7 +23,7 @@ public static class SystemFonts public static IEnumerable Families => Collection.Families; /// - public static FontFamily Get(string name) => LazySystemFonts.Value.Get(name); + public static FontFamily Get(string name) => Get(name, CultureInfo.InvariantCulture); /// public static bool TryGet(string fontFamily, out FontFamily family)