Exemplo n.º 1
0
        public bool PrepareLetterDefinitions(string text)
        {
            List <char> newChars = new List <char>();

            FindNewCharacters(text, ref newChars);

            if (newChars.Count == 0)
            {
                return(false);
            }

            var newCharString = new string(newChars.ToArray());

            var glyphs      = _TextPaint.GetGlyphs(newCharString);
            var glyphWidths = _TextPaint.GetGlyphWidths(newCharString);

            for (int i = 0; i < glyphs.Length; i++)
            {
                FontLetterDefinition tempDef = new FontLetterDefinition();

                if (glyphs[i] == 0)
                {
                    _LetterDefinitions[newCharString[i]] = tempDef;
                }
                else
                {
                    tempDef.ValidDefinition = true;
                    tempDef.AdvanceX        = glyphWidths[i];

                    _LetterDefinitions[newCharString[i]] = tempDef;
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool GetLetterDefinitionForChar(char character, out FontLetterDefinition letterDefinition)
        {
            if (character == UnicodeCharacters.NoBreakSpace)
            {
                // change no-break space to regular space
                // reason: some fonts have issue with no-break space:
                //   * no letter definition
                //   * not normal big width
                character = UnicodeCharacters.Space;
            }

            if (_LetterDefinitions.TryGetValue(character, out letterDefinition))
            {
                return(letterDefinition.ValidDefinition);
            }

            return(false);
        }
Exemplo n.º 3
0
 public void AddLetterDefinition(char character, FontLetterDefinition letterDefinition)
 {
     _LetterDefinitions[character] = letterDefinition;
 }