Skip to content

Commit

Permalink
fix: only init ranges working without latest NET runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
agaertner committed Apr 27, 2024
1 parent 10a2b0b commit 812500e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
20 changes: 20 additions & 0 deletions Blish HUD/GameServices/ContentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using SpriteFontPlus;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -104,8 +105,27 @@ public enum FontStyle {

public DatAssetCache DatAssetCache { get; private set; }

internal IReadOnlyList<CharacterRange> Gw2CharacterRanges { get; private set; }

internal ContentService() {
SetServiceModules(this.DatAssetCache = new DatAssetCache(this));

Gw2CharacterRanges = new List<CharacterRange> {
CharacterRange.BasicLatin,
CharacterRange.Latin1Supplement,
CharacterRange.LatinExtendedA,
new CharacterRange('₣', '₾'), // Currency Symbols
new CharacterRange('←', '⇿'), // Arrows
new CharacterRange('∀', '⋿'), // Mathematical Operators
new CharacterRange('①', '⓿'), // Enclosed Alphanumerics
new CharacterRange('─', '╿'), // Box Drawing
new CharacterRange('■', '◿'), // Geometric Shapes
// Cause crash with only windows shipped .NET Runtime.
//new CharacterRange('\u2000', '\u206F'), // General Punctuation
//new CharacterRange('℀', '⅏'), // Letterlike Symbols
//new CharacterRange('⌀', '⏺'), // Miscellaneous Technical
//new CharacterRange('☀', '♪'), // Miscellaneous Symbols
};
}

protected override void Initialize() {
Expand Down
8 changes: 2 additions & 6 deletions Blish HUD/GameServices/Modules/Managers/ContentsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,8 @@ public SpriteFont GetSpriteFont(string fontPath, int fontSize, int textureSize =
if (fontDataLength > 0) {
using var ctx = GameService.Graphics.LendGraphicsDeviceContext();
try {
var result = TtfFontBaker.Bake(fontData, fontSize, textureSize, textureSize,
new[] {
CharacterRange.BasicLatin,
CharacterRange.Latin1Supplement,
CharacterRange.LatinExtendedA
}).CreateSpriteFont(ctx.GraphicsDevice);
var result = TtfFontBaker.Bake(fontData, fontSize, textureSize, textureSize,
GameService.Content.Gw2CharacterRanges).CreateSpriteFont(ctx.GraphicsDevice);
Logger.Debug("Successfully loaded font {dataReaderFilePath}.", _reader.GetPathRepresentation(fontPath));
return result;
} catch (Exception e) {
Expand Down

0 comments on commit 812500e

Please sign in to comment.