Ejemplo n.º 1
0
        private FontData AddInternal(string familyName, float size, IEnumerable <Range <int> > characterRanges,
                                     FontStyle style, bool system)
        {
            if (characterRanges == null)
            {
                throw new ArgumentNullException(nameof(characterRanges));
            }
            if (size <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), "Size must be larger than 0.");
            }

            var key           = new FontData(familyName, size, style);
            var existingEntry = _atlasEntries.FirstOrDefault(e => e.Font == key);

            if (existingEntry != null)
            {
                existingEntry.AddCharacterRanges(characterRanges);
            }
            else
            {
                var entry = new FontAtlasEntry(key, characterRanges, system, _atlasEntries.Count);
                _atlasEntries.Add(entry);
            }

            return(key);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new <see cref="FontAtlasEntry"/>.
 /// </summary>
 /// <param name="font">Data of the font to use.</param>
 /// <param name="characterRanges">Characters to include in this entry.</param>
 /// <param name="isSystemFont">Indicates if the font is a system font.</param>
 /// <param name="index">Index of this entry in the list of entries.</param>
 public FontAtlasEntry(FontData font, IEnumerable <Range <int> > characterRanges, bool isSystemFont, int index)
 {
     Font            = font;
     CharacterRanges = characterRanges.ToList();
     IsSystemFont    = isSystemFont;
     Index           = index;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Get a glyph map by <see cref="FontData"/>.
 /// </summary>
 /// <param name="fontData">Font data to get the glyph map for.</param>
 public PixelGlyphMap this[FontData fontData] => _glyphMaps.First(g => FontMatchesFontData(g.Font, fontData));