CustomFontRenderingForm.FontInfo.addKerning C# (CSharp) Method

addKerning() public method

public addKerning ( KerningInfo info ) : void
info KerningInfo
return void
        public void addKerning(KerningInfo info)
        {
            if (!kerning.ContainsKey(info.character1))
            {
                kerning[info.character1] = new Dictionary<char, KerningInfo>();
            }
            kerning[info.character1][info.character2] = info;
        }

Usage Example

コード例 #1
0
        private void getKernWidthHeight(Face face, FontInfo info, out int width, out int maxHeight, out int firstAdjust)
        {
            width       = 0;
            maxHeight   = 0;
            firstAdjust = 0;

            for (int i = 0; i < characters.Length; i++)
            {
                char character1 = characters[i];
                uint index1     = face.GetCharIndex(character1);

                face.LoadGlyph(index1, LoadFlags.Default, LoadTarget.Normal);
                GlyphMetrics metrics = face.Glyph.Metrics;

                int yoffset = metrics.VerticalAdvance.ToInt32() - metrics.HorizontalBearingY.ToInt32();
                int nheight = yoffset + metrics.Height.ToInt32();
                int height  = metrics.Height.ToInt32();
                if (height > maxHeight)
                {
                    maxHeight   = height;                   //nheight;
                    firstAdjust = yoffset;
                }

                for (int j = 0; j < characters.Length; j++)
                {
                    char character2 = characters[j];
                    uint index2     = face.GetCharIndex(character2);

                    FTVector26Dot6 kern  = face.GetKerning(index1, index2, KerningMode.Default);
                    int            kernX = kern.X.ToInt32();
                    int            kernY = kern.Y.ToInt32();
                    if (kernX != 0 || kernY != 0)
                    {
                        info.addKerning(new KerningInfo(character1, character2, kernX, kernY));
                    }
                }

                if (i + 1 == characters.Length)
                {
                    width += metrics.Width.ToInt32() + metrics.HorizontalBearingX.ToInt32() + padX;
                }
                else
                {
                    width += metrics.HorizontalAdvance.ToInt32() + padX;
                }
            }
        }
All Usage Examples Of CustomFontRenderingForm.FontInfo::addKerning