CSReportPaint.cGlobals.addFontIfRequired C# (CSharp) Method

addFontIfRequired() public static method

public static addFontIfRequired ( cReportFont font, Font &m_fnt ) : int
font CSReportDll.cReportFont
m_fnt System.Drawing.Font
return int
        public static int addFontIfRequired(cReportFont font, ref Font[] m_fnt)
        {
            for(int i = 0; i < m_fnt.Length; i++) {
                if(font.getName() == m_fnt[i].Name 
                    && font.getBold() == m_fnt[i].Bold 
                    && font.getItalic() == m_fnt[i].Italic 
                    && font.getUnderline() == m_fnt[i].Underline 
                    && font.getSize() == m_fnt[i].Size 
                    && font.getStrike() == m_fnt[i].Strikeout) {
                    return i;
                }
            }

            redimPreserve(ref m_fnt, m_fnt.Length + 1);

            FontStyle fontStyle = FontStyle.Regular;
            if (font.getBold()) fontStyle = fontStyle | FontStyle.Bold;
            if (font.getItalic()) fontStyle = fontStyle | FontStyle.Italic;
            if (font.getUnderline()) fontStyle = fontStyle | FontStyle.Underline;
            if (font.getStrike()) fontStyle = fontStyle | FontStyle.Strikeout;

            Font afont = new Font(font.getName(), ((font.getSize() > 0) ? font.getSize() : 3), fontStyle);

            m_fnt[m_fnt.Length - 1] = afont;

            return m_fnt.Length - 1;
        }
    }