Ejemplo n.º 1
0
 /// <summary>
 /// Sets all characters in the given string to the specified kerning rule.
 /// </summary>
 /// <param name="chars"></param>
 /// <param name="rule"></param>
 public void BatchSetCharacterKerningRule(String chars, GLFontCharacterKerningRule rule)
 {
     foreach (var c in chars)
     {
         CharacterKerningRules[c] = rule;
     }
 }
Ejemplo n.º 2
0
        private static int Kerning(GLFontGlyph g1, GLFontGlyph g2, XLimits[] lim1, XLimits[] lim2, GLFontKerningConfiguration config)
        {
            int yOffset1 = g1.YOffset;
            int yOffset2 = g2.YOffset;

            int startY = Math.Max(yOffset1, yOffset2);
            int endY   = Math.Min(g1.Rect.Height + yOffset1, g2.Rect.Height + yOffset2);

            int w1 = g1.Rect.Width;

            int worstCase = w1;

            //TODO - offset startY, endY by yOffset1 so that lim1[j-yOffset1] can be written as lim1[j], will need another var for yOffset2

            for (int j = startY; j < endY; j++)
            {
                worstCase = Math.Min(worstCase, w1 - lim1[j - yOffset1].Max + lim2[j - yOffset2].Min);
            }

            worstCase = Math.Min(worstCase, g1.Rect.Width);
            worstCase = Math.Min(worstCase, g2.Rect.Width);

            //modify by character kerning rules
            GLFontCharacterKerningRule kerningRule = config.GetOverridingCharacterKerningRuleForPair("" + g1.Character + g2.Character);

            if (kerningRule == GLFontCharacterKerningRule.Zero)
            {
                return(0);
            }
            else if (kerningRule == GLFontCharacterKerningRule.NotMoreThanHalf)
            {
                return((int)Math.Min(Math.Min(g1.Rect.Width, g2.Rect.Width) * 0.5f, worstCase));
            }

            return(worstCase);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the specified character kerning rule.
 /// </summary>
 /// <param name="c"></param>
 /// <param name="rule"></param>
 public void SetCharacterKerningRule(char c, GLFontCharacterKerningRule rule)
 {
     CharacterKerningRules[c] = rule;
 }