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
24 changes: 12 additions & 12 deletions src/SixLabors.Fonts/GlyphPositioningCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public bool TryGetGlyphMetricsAtOffset(
isVerticalSubstitution = false;
isDecomposed = false;

Tag vert = FeatureTags.VerticalAlternates;
Tag vrt2 = FeatureTags.VerticalAlternatesAndRotation;
Tag vrtr = FeatureTags.VerticalAlternatesForRotation;
Tag vert = KnownFeatureTags.VerticalAlternates;
Tag vrt2 = KnownFeatureTags.VerticalAlternatesAndRotation;
Tag vrtr = KnownFeatureTags.VerticalAlternatesForRotation;

for (int i = startIndex; i < this.glyphs.Count; i++)
{
Expand Down Expand Up @@ -171,9 +171,9 @@ public bool TryUpdate(Font font, GlyphSubstitutionCollection collection)
bool hasFallBacks = false;
List<int> orphans = [];

Tag vert = FeatureTags.VerticalAlternates;
Tag vrt2 = FeatureTags.VerticalAlternatesAndRotation;
Tag vrtr = FeatureTags.VerticalAlternatesForRotation;
Tag vert = KnownFeatureTags.VerticalAlternates;
Tag vrt2 = KnownFeatureTags.VerticalAlternatesAndRotation;
Tag vrtr = KnownFeatureTags.VerticalAlternatesForRotation;

for (int i = 0; i < this.glyphs.Count; i++)
{
Expand Down Expand Up @@ -268,9 +268,9 @@ public bool TryAdd(Font font, GlyphSubstitutionCollection collection)
LayoutMode layoutMode = this.TextOptions.LayoutMode;
ColorFontSupport colorFontSupport = this.TextOptions.ColorFontSupport;

Tag vert = FeatureTags.VerticalAlternates;
Tag vrt2 = FeatureTags.VerticalAlternatesAndRotation;
Tag vrtr = FeatureTags.VerticalAlternatesForRotation;
Tag vert = KnownFeatureTags.VerticalAlternates;
Tag vrt2 = KnownFeatureTags.VerticalAlternatesAndRotation;
Tag vrtr = KnownFeatureTags.VerticalAlternatesForRotation;

for (int i = 0; i < collection.Count; i++)
{
Expand Down Expand Up @@ -358,9 +358,9 @@ public void UpdatePosition(FontMetrics fontMetrics, int index)
public void Advance(FontMetrics fontMetrics, int index, ushort glyphId, short dx, short dy)
{
LayoutMode layoutMode = this.TextOptions.LayoutMode;
Tag vert = FeatureTags.VerticalAlternates;
Tag vrt2 = FeatureTags.VerticalAlternatesAndRotation;
Tag vrtr = FeatureTags.VerticalAlternatesForRotation;
Tag vert = KnownFeatureTags.VerticalAlternates;
Tag vrt2 = KnownFeatureTags.VerticalAlternatesAndRotation;
Tag vrtr = KnownFeatureTags.VerticalAlternatesForRotation;

GlyphPositioningData glyph = this.glyphs[index];
GlyphMetrics m = glyph.Metrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SixLabors.Fonts.Tables.AdvancedTypographic;
/// Provides enumeration for the different font features.
/// <see href="https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags"/>
/// </summary>
public enum FeatureTags : uint
public enum KnownFeatureTags : uint
{
/// <summary>
/// Access All Alternates. Shortcode: aalt.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private int DecomposeGlyph(GlyphSubstitutionCollection collection, GlyphShapingD
ii[1] = vjmo;
ii[0] = ljmo;

collection.Replace(index, ii, FeatureTags.GlyphCompositionDecomposition);
collection.Replace(index, ii, KnownFeatureTags.GlyphCompositionDecomposition);
collection.EnableShapingFeature(index, LjmoTag);
collection.EnableShapingFeature(index + 1, VjmoTag);
return index + 1;
Expand All @@ -320,7 +320,7 @@ private int DecomposeGlyph(GlyphSubstitutionCollection collection, GlyphShapingD
iii[1] = vjmo;
iii[0] = ljmo;

collection.Replace(index, iii, FeatureTags.GlyphCompositionDecomposition);
collection.Replace(index, iii, KnownFeatureTags.GlyphCompositionDecomposition);
collection.EnableShapingFeature(index, LjmoTag);
collection.EnableShapingFeature(index + 1, VjmoTag);
collection.EnableShapingFeature(index + 2, TjmoTag);
Expand Down Expand Up @@ -393,7 +393,7 @@ private int ComposeGlyph(GlyphSubstitutionCollection collection, int index, int
{
int del = prevType == V ? 3 : 2;
int idx = index - del + 1;
collection.Replace(idx, del - 1, id, FeatureTags.GlyphCompositionDecomposition);
collection.Replace(idx, del - 1, id, KnownFeatureTags.GlyphCompositionDecomposition);
collection[idx].CodePoint = s;
return idx;
}
Expand Down Expand Up @@ -496,7 +496,7 @@ private int InsertDottedCircle(GlyphSubstitutionCollection collection, GlyphShap
glyphs[0] = id;
}

collection.Replace(index, glyphs, FeatureTags.GlyphCompositionDecomposition);
collection.Replace(index, glyphs, KnownFeatureTags.GlyphCompositionDecomposition);
return index + 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private static void ComposeHebrewForms(GlyphSubstitutionCollection collection, F
if (composed != 0 && fontMetrics.TryGetGlyphId(new CodePoint(composed), out ushort composedGlyphId))
{
// Replace the two glyphs with the composed form.
collection.Replace(i - 1, 2, composedGlyphId, FeatureTags.GlyphCompositionDecomposition);
collection.Replace(i - 1, 2, composedGlyphId, KnownFeatureTags.GlyphCompositionDecomposition);
end--;
i--;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected override void AssignFeatures(IGlyphShapingCollection collection, int i

if (shouldDecompose)
{
substitutionCollection.Replace(i, ids, FeatureTags.GlyphCompositionDecomposition);
substitutionCollection.Replace(i, ids, KnownFeatureTags.GlyphCompositionDecomposition);
for (int j = 0; j < decompositions.Length; j++)
{
substitutionCollection[i + j].CodePoint = new(decompositions[j]);
Expand Down Expand Up @@ -382,7 +382,7 @@ private void InitialReorder(IGlyphShapingCollection collection, int index, int c
glyphs[0] = circleId;
glyphs[1] = current.GlyphId;

substitutionCollection.Replace(i, glyphs, FeatureTags.GlyphCompositionDecomposition);
substitutionCollection.Replace(i, glyphs, KnownFeatureTags.GlyphCompositionDecomposition);

// The dotted circle is now at position i (inherits original shaping info).
// Update it to be a dotted circle base.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private void InitialReorder(IGlyphShapingCollection collection, int index, int c
glyphs[0] = current.GlyphId;
glyphs[1] = circleId;

substitutionCollection.Replace(i, glyphs, FeatureTags.GlyphCompositionDecomposition);
substitutionCollection.Replace(i, glyphs, KnownFeatureTags.GlyphCompositionDecomposition);

// Update shaping info for newly inserted data.
GlyphShapingData dotted = substitutionCollection[i + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private static int PreprocessSaraAm(GlyphSubstitutionCollection collection, Font

// Decompose SARA AM into [NIKHAHIT, SARA AA].
// Replace puts NIKHAHIT at index i, SARA AA at index i+1.
collection.Replace(i, [nikhahitId, saraAAId], FeatureTags.GlyphCompositionDecomposition);
collection.Replace(i, [nikhahitId, saraAAId], KnownFeatureTags.GlyphCompositionDecomposition);
collection[i].CodePoint = new CodePoint(nikhahitCodepoint);
collection[i + 1].CodePoint = new CodePoint(saraAACodepoint);
end++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void DecomposeSplitVowels(IGlyphShapingCollection collection, int index,

if (shouldDecompose)
{
substitutionCollection.Replace(i, ids, FeatureTags.GlyphCompositionDecomposition);
substitutionCollection.Replace(i, ids, KnownFeatureTags.GlyphCompositionDecomposition);
for (int j = 0; j < decompositions.Length; j++)
{
substitutionCollection[i + j].CodePoint = new(decompositions[j]);
Expand Down Expand Up @@ -353,7 +353,7 @@ private void Reorder(IGlyphShapingCollection collection, int index, int count)
glyphs[0] = current.GlyphId;
glyphs[1] = circleId;

substitutionCollection.Replace(i, glyphs, FeatureTags.GlyphCompositionDecomposition);
substitutionCollection.Replace(i, glyphs, KnownFeatureTags.GlyphCompositionDecomposition);

// Update shaping info for newly inserted data.
GlyphShapingData dotted = substitutionCollection[i + 1];
Expand Down
4 changes: 2 additions & 2 deletions src/SixLabors.Fonts/Tables/AdvancedTypographic/Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ namespace SixLabors.Fonts.Tables.AdvancedTypographic;
public static implicit operator Tag(uint value) => new(value);

/// <summary>
/// Implicitly converts a <see cref="FeatureTags"/> to a <see cref="Tag"/>.
/// Implicitly converts a <see cref="KnownFeatureTags"/> to a <see cref="Tag"/>.
/// </summary>
/// <param name="value">The feature tag enum value.</param>
public static implicit operator Tag(FeatureTags value) => new((uint)value);
public static implicit operator Tag(KnownFeatureTags value) => new((uint)value);

/// <summary>
/// Determines whether two <see cref="Tag"/> instances are equal.
Expand Down
4 changes: 2 additions & 2 deletions src/SixLabors.Fonts/TextLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ private static void SubstituteBidiMirrors(FontMetrics fontMetrics, GlyphSubstitu

if (fontMetrics.TryGetGlyphId(mirror, out ushort glyphId))
{
collection.Replace(i, glyphId, FeatureTags.RightToLeftMirroredForms);
collection.Replace(i, glyphId, KnownFeatureTags.RightToLeftMirroredForms);
}
}

Expand All @@ -1087,7 +1087,7 @@ private static void SubstituteBidiMirrors(FontMetrics fontMetrics, GlyphSubstitu

if (fontMetrics.TryGetGlyphId(mirror, out ushort glyphId))
{
collection.Replace(i, glyphId, FeatureTags.VerticalAlternates);
collection.Replace(i, glyphId, KnownFeatureTags.VerticalAlternates);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void ContextualFractions_WithFractionSlash_Works()
int[] expectedGlyphIndices = [580, 404, 453];

// act
TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font) { FeatureTags = new Tag[] { FeatureTags.Numerators, FeatureTags.Denominators } });
TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font) { FeatureTags = new Tag[] { KnownFeatureTags.Numerators, KnownFeatureTags.Denominators } });

// assert
Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count);
Expand All @@ -101,7 +101,7 @@ public void ContextualFractions_WithSlash_Works()
int[] expectedGlyphIndices = [580, 404, 453];

// act
TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font) { FeatureTags = new Tag[] { FeatureTags.Fractions } });
TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font) { FeatureTags = new Tag[] { KnownFeatureTags.Fractions } });

// assert
Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count);
Expand Down Expand Up @@ -357,7 +357,7 @@ public void OldStyleFiguresFeature_Works()
// act
TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)
{
FeatureTags = new List<Tag> { FeatureTags.OldstyleFigures }
FeatureTags = new List<Tag> { KnownFeatureTags.OldstyleFigures }
});

// assert
Expand Down
2 changes: 1 addition & 1 deletion tests/SixLabors.Fonts.Tests/TextOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public void NonDefaultClone()
DecorationPositioningMode = DecorationPositioningMode.GlyphFont,
WrappingLength = 42F,
Tracking = 66F,
FeatureTags = new List<Tag> { FeatureTags.OldstyleFigures }
FeatureTags = new List<Tag> { KnownFeatureTags.OldstyleFigures }
};

TextOptions actual = new(expected);
Expand Down
Loading