Exemplo n.º 1
0
        public static RenderFont GetRenderFont(StyleInfo styleInfo)
        {
            //face name
            RenderFont renderFont = new RenderFont();
            renderFont.FaceName = getFontNameNormalized(styleInfo.FontFamily);

            //font style
            switch (renderFont.FaceName)
            {
                //this font only have one file with italic style
                case "Monotype Corsiva":
                    if (styleInfo.IsFontBold())
                        renderFont.SimulateBold = true;
                    break;

                //standard fonts
                default:
                    if (styleInfo.IsFontBold() && styleInfo.FontStyle == FontStyleEnum.Italic)
                        renderFont.Style = RenderFont.FontStyle.BoldItalic;
                    else if (styleInfo.IsFontBold())
                        renderFont.Style = RenderFont.FontStyle.Bold;
                    else if (styleInfo.FontStyle == FontStyleEnum.Italic)
                        renderFont.Style = RenderFont.FontStyle.Italic;
                    break;
            }

            return renderFont;
        }
Exemplo n.º 2
0
        private void DoStyle(Style style, Row row)
        {
            if (style == null)
            {
                return;
            }

            StyleInfo si = style.GetStyleInfo(r, row);

//            tw.Write(@"\plain");        // reset current attributes

            // Handle the font
            if (!_Fonts.Contains(si.FontFamily))
            {
                _Fonts.Add(si.FontFamily);
            }
            int fc = _Fonts.IndexOf(si.FontFamily);

            tw.Write(@"\f{0} ", fc);

            if (si.IsFontBold())
            {
                tw.Write(@"\b");
            }
            if (si.FontStyle == FontStyleEnum.Italic)
            {
                tw.Write(@"\i");
            }
            switch (si.TextDecoration)
            {
            case TextDecorationEnum.Underline:
                tw.Write(@"\ul");
                break;

            case TextDecorationEnum.LineThrough:
                tw.Write(@"\strike");
                break;

            default:
                break;
            }

            tw.Write(@"\fs{0}", (int)Math.Round(si.FontSize * 2, 0));        // font size

            // Handle the color
            int ic;

            if (!_Colors.Contains(si.Color))
            {
                _Colors.Add(si.Color);
            }
            ic = _Colors.IndexOf(si.Color) + 1;

            tw.Write(@"\cf{0} ", ic);
        }
Exemplo n.º 3
0
        public static RenderFont GetRenderFont(StyleInfo styleInfo)
        {
            //face name
            RenderFont renderFont = new RenderFont();

            renderFont.FaceName = getFontNameNormalized(styleInfo.FontFamily);

            //font style
            switch (renderFont.FaceName)
            {
            //this font only have one file with italic style
            case "Monotype Corsiva":
                if (styleInfo.IsFontBold())
                {
                    renderFont.SimulateBold = true;
                }
                break;

            //standard fonts
            default:
                if (styleInfo.IsFontBold() && styleInfo.FontStyle == FontStyleEnum.Italic)
                {
                    renderFont.Style = RenderFont.FontStyle.BoldItalic;
                }
                else if (styleInfo.IsFontBold())
                {
                    renderFont.Style = RenderFont.FontStyle.Bold;
                }
                else if (styleInfo.FontStyle == FontStyleEnum.Italic)
                {
                    renderFont.Style = RenderFont.FontStyle.Italic;
                }
                break;
            }

            return(renderFont);
        }