Exemple #1
0
        /// <summary>
        /// Tries to create a new font given the Excel data.
        /// </summary>
        /// <param name="Fx">FlexCel font with the font information.</param>
        /// <param name="Adj">An adjustment parameter to multiply the FontSize.</param>
        public static Font CreateFont(TFlxFont Fx, real Adj)
        {
            Font Result = new Font();

            Result.Family    = new FontFamily(Fx.Name);
            Result.SizeInPix = Fx.Size20 / 20.0 * FlxConsts.PixToPoints * Adj; //fontsize is in pixels, not points
            if ((Fx.Style & TFlxFontStyles.Italic) != 0)
            {
                Result.Style = FontStyles.Italic;
            }
            else
            {
                Result.Style = FontStyles.Normal;
            }
            if ((Fx.Style & TFlxFontStyles.Bold) != 0)
            {
                Result.Weight = FontWeights.Bold;
            }
            else
            {
                Result.Weight = FontWeights.Normal;
            }

            Result.Decorations = new TextDecorationCollection();
            if ((Fx.Style & TFlxFontStyles.StrikeOut) != 0)
            {
                Result.Decorations.Add(TextDecorations.Strikethrough);
            }
            if (Fx.Underline != TFlxUnderline.None)
            {
                Result.Decorations.Add(TextDecorations.Underline);
            }
            if (Fx.Underline == TFlxUnderline.Double || Fx.Underline == TFlxUnderline.DoubleAccounting)
            {
                Result.Decorations.Add(TextDecorations.Baseline);
            }

            Result.Freeze();
            return(Result);
        }