Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches:
- main
- release/*
types: [ labeled, opened, synchronize, reopened ]
types: [ opened, synchronize, reopened ]
jobs:
# Prime a single LFS cache and expose the exact key for the matrix
WarmLFS:
Expand Down
2 changes: 1 addition & 1 deletion src/SixLabors.Fonts/StreamFontMetrics.Cff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private GlyphMetrics CreateCffGlyphMetrics(
this,
glyphId,
codePoint,
new SvgGlyphSource(svg),
this.GetOrCreateSvgGlyphSource(svg),
bounds,
advanceWidth,
advancedHeight,
Expand Down
2 changes: 1 addition & 1 deletion src/SixLabors.Fonts/StreamFontMetrics.TrueType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private GlyphMetrics CreateTrueTypeGlyphMetrics(
this,
glyphId,
codePoint,
new SvgGlyphSource(svg),
this.GetOrCreateSvgGlyphSource(svg),
bounds,
advanceWidth,
advancedHeight,
Expand Down
17 changes: 13 additions & 4 deletions src/SixLabors.Fonts/StreamFontMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using SixLabors.Fonts.Tables.General;
using SixLabors.Fonts.Tables.General.Kern;
using SixLabors.Fonts.Tables.General.Post;
using SixLabors.Fonts.Tables.General.Svg;
using SixLabors.Fonts.Tables.TrueType;
using SixLabors.Fonts.Tables.TrueType.Hinting;
using SixLabors.Fonts.Unicode;
Expand All @@ -34,6 +35,7 @@ internal partial class StreamFontMetrics : FontMetrics
private readonly ConcurrentDictionary<(int CodePoint, ushort Id, TextAttributes Attributes, ColorFontSupport ColorSupport, bool IsVerticalLayout), GlyphMetrics> glyphCache;
private readonly ConcurrentDictionary<(int CodePoint, int NextCodePoint), (bool Success, ushort GlyphId, bool SkipNextCodePoint)> glyphIdCache;
private readonly ConcurrentDictionary<ushort, (bool Success, CodePoint CodePoint)> codePointCache;
private SvgGlyphSource? svgGlyphSource;
private readonly FontDescription description;
private readonly HorizontalMetrics horizontalMetrics;
private readonly VerticalMetrics verticalMetrics;
Expand Down Expand Up @@ -104,7 +106,8 @@ private StreamFontMetrics(
TrueTypeFontTables tables,
GlyphVariationProcessor processor,
ConcurrentDictionary<(int CodePoint, int NextCodePoint), (bool Success, ushort GlyphId, bool SkipNextCodePoint)> sharedGlyphIdCache,
ConcurrentDictionary<ushort, (bool Success, CodePoint CodePoint)> sharedCodePointCache)
ConcurrentDictionary<ushort, (bool Success, CodePoint CodePoint)> sharedCodePointCache,
SvgGlyphSource? svgGlyphSource)
{
this.trueTypeFontTables = tables;
this.outlineType = OutlineType.TrueType;
Expand All @@ -113,6 +116,7 @@ private StreamFontMetrics(
this.glyphIdCache = sharedGlyphIdCache;
this.codePointCache = sharedCodePointCache;
this.glyphCache = new();
this.svgGlyphSource = svgGlyphSource;

(HorizontalMetrics HorizontalMetrics, VerticalMetrics VerticalMetrics) metrics = this.Initialize(tables);
this.horizontalMetrics = metrics.HorizontalMetrics;
Expand All @@ -130,7 +134,8 @@ private StreamFontMetrics(
CompactFontTables tables,
GlyphVariationProcessor processor,
ConcurrentDictionary<(int CodePoint, int NextCodePoint), (bool Success, ushort GlyphId, bool SkipNextCodePoint)> sharedGlyphIdCache,
ConcurrentDictionary<ushort, (bool Success, CodePoint CodePoint)> sharedCodePointCache)
ConcurrentDictionary<ushort, (bool Success, CodePoint CodePoint)> sharedCodePointCache,
SvgGlyphSource? svgGlyphSource)
{
this.compactFontTables = tables;
this.outlineType = OutlineType.CFF;
Expand All @@ -139,6 +144,7 @@ private StreamFontMetrics(
this.glyphIdCache = sharedGlyphIdCache;
this.codePointCache = sharedCodePointCache;
this.glyphCache = new();
this.svgGlyphSource = svgGlyphSource;

(HorizontalMetrics HorizontalMetrics, VerticalMetrics VerticalMetrics) metrics = this.Initialize(tables);
this.horizontalMetrics = metrics.HorizontalMetrics;
Expand Down Expand Up @@ -519,7 +525,7 @@ internal StreamFontMetrics CreateVariationInstance(FontVariation[] variations)
tables.Cvar,
userCoordinates);

return new StreamFontMetrics(tables, processor, this.glyphIdCache, this.codePointCache);
return new StreamFontMetrics(tables, processor, this.glyphIdCache, this.codePointCache, this.svgGlyphSource);
}
else
{
Expand All @@ -535,7 +541,7 @@ internal StreamFontMetrics CreateVariationInstance(FontVariation[] variations)
tables.MVar,
userCoordinates: userCoordinates);

return new StreamFontMetrics(tables, processor, this.glyphIdCache, this.codePointCache);
return new StreamFontMetrics(tables, processor, this.glyphIdCache, this.codePointCache, this.svgGlyphSource);
}
}

Expand Down Expand Up @@ -825,4 +831,7 @@ private GlyphMetrics CreateGlyphMetrics(
OutlineType.CFF => this.CreateCffGlyphMetrics(in codePoint, glyphId, glyphType, textAttributes, textDecorations, colorSupport, isVerticalLayout, paletteIndex),
_ => throw new NotSupportedException(),
};

private SvgGlyphSource GetOrCreateSvgGlyphSource(SvgTable svgTable)
=> this.svgGlyphSource ??= new SvgGlyphSource(svgTable);
}
Loading
Loading