Beispiel #1
0
        public static string GetCharString(FontVariant variant)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendJoin(string.Empty, variant.GetCharacters().Select(c => c.Char));
            return(sb.ToString());
        }
Beispiel #2
0
        private static void PrepareSearchMap(FontVariant variant, List <GlyphNameMap> names)
        {
            if (variant.SearchMap == null)
            {
                var idxs = variant.GetIndexes();
                var rng  = variant.FontFace.GetGlyphIndices(idxs);

                Dictionary <Character, GlyphNameMap> map = new Dictionary <Character, GlyphNameMap>();

                var list = variant.GetCharacters();
                for (int i = 0; i < list.Count; i++)
                {
                    var c       = list[i];
                    var mapping = names[rng[i]];
                    mapping.Name = mapping.Name.Replace("-", " ").Replace("_", " ");
                    map.Add(c, mapping);
                }

                variant.SearchMap = map;
            }
        }
Beispiel #3
0
        private static void PrepareSearchMap(FontVariant variant, IReadOnlyDictionary <int, string> names)
        {
            if (variant.SearchMap == null)
            {
                uint[] uni = variant.GetGlyphUnicodeIndexes();
                int[]  gly = variant.FontFace.GetGlyphIndices(uni);
                IReadOnlyList <Character> chars = variant.GetCharacters();

                Dictionary <Character, string> map = new Dictionary <Character, string>();

                for (int i = 0; i < chars.Count; i++)
                {
                    Character c = chars[i];
                    if (names.TryGetValue(gly[i], out string mapping) && !string.IsNullOrEmpty(mapping))
                    {
                        map.Add(c, mapping);
                    }
                }

                variant.SearchMap = map;
            }
        }