/// <summary> /// Gets the glyphs for the given codepoint. /// </summary> /// <param name="codePoint">The code point of the character.</param> /// <param name="support">Options for enabling color font support during layout and rendering.</param> /// <returns>Returns the glyph</returns> public IEnumerable <Glyph> GetGlyphs(CodePoint codePoint, ColorFontSupport support) { foreach (GlyphMetrics metrics in this.FontMetrics.GetGlyphMetrics(codePoint, support)) { yield return(new(metrics, this.Size)); } }
public GlyphInstance[] GetGlyphLayers(int codePoint, ColorFontSupport colorFontOptions) { GlyphInstance glyph = this.MainFont.GetGlyph(codePoint); if (glyph.GlyphType == GlyphType.Fallback) { foreach (var f in this.FallbackFonts) { var g = f.GetGlyph(codePoint); if (g.GlyphType != GlyphType.Fallback) { glyph = g; break; } } } if (glyph == null) { return(Array.Empty <GlyphInstance>()); } if (colorFontOptions == ColorFontSupport.MicrosoftColrFormat) { if (glyph.Font.TryGetColoredVectors(glyph.Index, out var layers)) { return(layers); } } return(new[] { glyph }); }
public void CanLoadMacintoshGlyphs() { Font font = new FontCollection() .AddCollection(TestFonts.HelveticaTTCFile) .First(x => x.GetAvailableStyles().Contains(FontStyle.Regular)).CreateFont(12); const ColorFontSupport support = ColorFontSupport.None; Glyph[] a = font.GetGlyphs(new CodePoint('A'), support).ToArray(); Glyph[] x = font.GetGlyphs(new CodePoint('x'), support).ToArray(); Glyph ga = Assert.Single(a); Glyph gx = Assert.Single(x); Assert.NotEqual(ga, gx); Assert.Equal(1366, ga.GlyphMetrics.AdvanceWidth); Assert.Equal(2048, ga.GlyphMetrics.AdvanceHeight); Assert.Equal(1024, gx.GlyphMetrics.AdvanceWidth); Assert.Equal(2048, gx.GlyphMetrics.AdvanceHeight); }
/// <summary> /// Gets the glyph metrics for a given code point and glyph id. /// </summary> /// <param name="codePoint">The Unicode codepoint.</param> /// <param name="glyphId"> /// The previously matched or substituted glyph id for the codepoint in the face. /// If this value equals <value>0</value> the default fallback metrics are returned. /// </param> /// <param name="support">Options for enabling color font support during layout and rendering.</param> /// <returns>The <see cref="IEnumerable{GlyphMetrics}"/>.</returns> internal abstract IEnumerable <GlyphMetrics> GetGlyphMetrics(CodePoint codePoint, ushort glyphId, ColorFontSupport support);
/// <summary> /// Gets the glyph metrics for a given code point. /// </summary> /// <param name="codePoint">The Unicode code point to get the glyph for.</param> /// <param name="support">Options for enabling color font support during layout and rendering.</param> /// <returns>The glyph metrics to find.</returns> public abstract IEnumerable <GlyphMetrics> GetGlyphMetrics(CodePoint codePoint, ColorFontSupport support);
/// <inheritdoc /> public override IEnumerable <GlyphMetrics> GetGlyphMetrics(CodePoint codePoint, ColorFontSupport support) => this.metrics.Value.GetGlyphMetrics(codePoint, support);
/// <inheritdoc /> internal override IEnumerable <GlyphMetrics> GetGlyphMetrics(CodePoint codePoint, ushort glyphId, ColorFontSupport support) => this.metrics.Value.GetGlyphMetrics(codePoint, glyphId, support);
/// <inheritdoc/> internal override IEnumerable <GlyphMetrics> GetGlyphMetrics(CodePoint codePoint, ushort glyphId, ColorFontSupport support) { GlyphType glyphType = GlyphType.Standard; if (glyphId == 0) { // A glyph was not found in this face for the previously matched // codepoint. Set to fallback. glyphType = GlyphType.Fallback; } if (support == ColorFontSupport.MicrosoftColrFormat && this.TryGetColoredVectors(codePoint, glyphId, out GlyphMetrics[]? metrics))
/// <inheritdoc/> public override IEnumerable <GlyphMetrics> GetGlyphMetrics(CodePoint codePoint, ColorFontSupport support) { this.TryGetGlyphId(codePoint, out ushort glyphId); return(this.GetGlyphMetrics(codePoint, glyphId, support)); }