Exemplo n.º 1
0
        private static System.Drawing.FontStyle ToGdiStyle(TKGameUtilities.Graphics.Font.FontStyle style)
        {
            if (style == FontStyle.Regular)
            {
                return(System.Drawing.FontStyle.Regular);
            }

            System.Drawing.FontStyle result = 0;

            result |= ((style & FontStyle.Bold) > 0 ? System.Drawing.FontStyle.Bold : 0);
            result |= ((style & FontStyle.Italic) > 0 ? System.Drawing.FontStyle.Italic : 0);
            result |= ((style & FontStyle.Strikeout) > 0 ? System.Drawing.FontStyle.Strikeout : 0);
            result |= ((style & FontStyle.Underline) > 0 ? System.Drawing.FontStyle.Underline : 0);

            return(result);
        }
Exemplo n.º 2
0
        public Font(string fileName, float size, TKGameUtilities.Graphics.Font.FontStyle style = TKGameUtilities.Graphics.Font.FontStyle.Regular, int fromUnicode = 0, int toUnicode = 255, bool antialiasing = true)
        {
            m_fromUnicode     = fromUnicode;
            m_toUnicode       = toUnicode;
            m_antialiasing    = antialiasing;
            m_tabulatorFactor = new Point2(4, 4);
            m_glyphs          = new GlyphInfo[m_toUnicode - m_fromUnicode + 1];

            m_fontCollection = new PrivateFontCollection();
            m_fontCollection.AddFontFile(fileName);
            m_gdiFont = new System.Drawing.Font(m_fontCollection.Families[0], size, ToGdiStyle(style));

            m_tempBitmap   = new Bitmap(1, 1);
            m_tempGraphics = System.Drawing.Graphics.FromImage(m_tempBitmap);

            ObtainMetrics();
            //ObtainKerning();
            RenderGlyphs();

            m_tempBitmap.Dispose();
            m_tempGraphics.Dispose();
        }