/// <summary> /// Function to build the list of glyphs for the font. /// </summary> /// <param name="glyphData">The glyph data used to create the glyphs.</param> /// <param name="kerningData">The kerning information used to handle spacing adjustment between glyphs.</param> private void GenerateGlyphs(Dictionary <char, GlyphInfo> glyphData, Dictionary <char, ABC> kerningData) { foreach (KeyValuePair <char, GlyphInfo> glyph in glyphData) { int advance = 0; if (kerningData.TryGetValue(glyph.Key, out ABC kernData)) { advance = kernData.A + (int)kernData.B + kernData.C; } // For whitespace, we add a dummy glyph (no texture, offset, etc...). if (char.IsWhiteSpace(glyph.Key)) { Glyphs.Add(new GorgonGlyph(glyph.Key, glyph.Value.Region.Width) { Offset = DX.Point.Zero }); continue; } var newGlyph = new GorgonGlyph(glyph.Key, advance) { Offset = glyph.Value.Offset, OutlineOffset = HasOutline ? glyph.Value.OutlineOffset : DX.Point.Zero }; // Assign the texture to each glyph (and its outline if needed). newGlyph.UpdateTexture(glyph.Value.Texture, glyph.Value.Region, HasOutline ? glyph.Value.OutlineRegion : DX.Rectangle.Empty, glyph.Value.TextureArrayIndex); Glyphs.Add(newGlyph); } }
/// <summary> /// Function to retrieve the glyph used for the default character assigned in the font <see cref="Info"/>. /// </summary> /// <param name="glyph">The default glyph, or <b>null</b> if not found.</param> /// <returns><b>true</b> if the glyph was found, or <b>false</b> if not.</returns> /// <remarks> /// <para> /// The default character is assigned to the <see cref="IGorgonFontInfo.DefaultCharacter"/> property of the <see cref="IGorgonFontInfo"/> type passed to the constructor of the font. /// </para> /// </remarks> /// <seealso cref="IGorgonFontInfo"/> /// <seealso cref="GorgonGlyph"/> public bool TryGetDefaultGlyph(out GorgonGlyph glyph) => Glyphs.TryGetValue(Info.DefaultCharacter, out glyph);