Esempio n. 1
0
        private CachedFont CreateFont(ITextRunProps textRun, string key, byte charset, bool verticalFont, string fontFamily, float fontSize)
        {
            CachedFont cachedFont = new CachedFont();

            this.m_fontDict.Add(key, cachedFont);
            bool bold   = textRun.Bold;
            bool italic = textRun.Italic;

            RPLFormat.TextDecorations textDecoration = textRun.TextDecoration;
            bool lineThrough = textDecoration == RPLFormat.TextDecorations.LineThrough;

            cachedFont.Font = FontCache.CreateGdiPlusFont(fontFamily, textRun.FontSize, ref bold, ref italic, lineThrough, false);
            int num = 0;

            if (this.UseEmSquare)
            {
                int emHeight = cachedFont.Font.FontFamily.GetEmHeight(cachedFont.Font.Style);
                cachedFont.ScaleFactor = (float)emHeight / fontSize;
                num = emHeight;
            }
            else
            {
                num = (int)(fontSize + 0.5);
            }
            cachedFont.Hfont = this.CreateGdiFont(this.m_writingMode, num, bold, italic, lineThrough, charset, verticalFont, cachedFont.Font.FontFamily.Name);
            return(cachedFont);
        }
Esempio n. 2
0
        private string GetKey(ITextRunProps textRunProps, out string fontFamily, out float fontSize)
        {
            fontSize   = (float)(textRunProps.FontSize * this.m_dpi / 72.0);
            fontFamily = textRunProps.FontFamily;
            StringBuilder stringBuilder = new StringBuilder(fontFamily);

            stringBuilder.Append(fontSize.ToString(CultureInfo.InvariantCulture));
            stringBuilder.Append((char)(textRunProps.Bold ? 98 : 110));
            stringBuilder.Append((char)(textRunProps.Italic ? 105 : 110));
            RPLFormat.TextDecorations textDecoration = textRunProps.TextDecoration;
            if (this.UseEmSquare && textDecoration == RPLFormat.TextDecorations.Underline)
            {
                stringBuilder.Append('u');
            }
            else
            {
                switch (textDecoration)
                {
                case RPLFormat.TextDecorations.Overline:
                    stringBuilder.Append('o');
                    break;

                case RPLFormat.TextDecorations.LineThrough:
                    stringBuilder.Append('s');
                    break;

                default:
                    stringBuilder.Append('n');
                    break;
                }
            }
            return(stringBuilder.ToString());
        }
Esempio n. 3
0
 private bool RenderHyperlink(RPLAction action, RPLFormat.TextDecorations textDec, string color)
 {
     this.html5Renderer.WriteStream(HTMLElements.m_openA);
     this.html5Renderer.RenderTabIndex();
     this.html5Renderer.RenderActionHref(action, textDec, color);
     this.html5Renderer.WriteStream(HTMLElements.m_closeBracket);
     return(true);
 }
Esempio n. 4
0
        private void RenderTextDecoration(RPLFormat.TextDecorations textDecorations)
        {
            switch (textDecorations)
            {
            case RPLFormat.TextDecorations.Overline:
                break;

            case RPLFormat.TextDecorations.LineThrough:
                this.m_charFormat.AddSprm(2103, 1, null);
                break;

            case RPLFormat.TextDecorations.Underline:
                this.m_charFormat.AddSprm(10814, 1, null);
                break;
            }
        }
        private void SetTextDecoration(RPLFormat.TextDecorations decoration)
        {
            switch (decoration)
            {
            case RPLFormat.TextDecorations.Overline:
                break;

            case RPLFormat.TextDecorations.LineThrough:
                this.GetCurrentTextStyle().Strikethrough = true;
                break;

            case RPLFormat.TextDecorations.Underline:
                this.GetCurrentTextStyle().Underline = true;
                break;
            }
        }
Esempio n. 6
0
        public static string GetValue(RPLFormat.TextDecorations val)
        {
            switch (val)
            {
            case RPLFormat.TextDecorations.None:
                return("none");

            case RPLFormat.TextDecorations.Underline:
                return("underline");

            case RPLFormat.TextDecorations.Overline:
                return("overline");

            case RPLFormat.TextDecorations.LineThrough:
                return("line-through");

            default:
                return(null);
            }
        }
        public void BuildHeaderFooterString(StringBuilder str, RPLTextBoxProps textBox, ref string lastFont, ref double lastFontSize)
        {
            RPLElementStyle style = textBox.Style;
            string          text  = (string)style[20];

            if (!string.IsNullOrEmpty(text) && !text.Equals(lastFont))
            {
                str.Append("&").Append("\"");
                FormulaHandler.EncodeHeaderFooterString(str, text);
                str.Append("\"");
                lastFont = text;
            }
            string text2 = (string)style[21];

            if (!string.IsNullOrEmpty(text2))
            {
                double num = LayoutConvert.ToPoints(text2);
                if (num != 0.0 && num != lastFontSize)
                {
                    str.Append("&").Append((int)num);
                }
                lastFontSize = num;
            }
            StringBuilder stringBuilder = new StringBuilder();
            object        obj           = style[19];

            if (obj != null && (RPLFormat.FontStyles)obj == RPLFormat.FontStyles.Italic)
            {
                str.Append("&I");
                stringBuilder.Append("&I");
            }
            object obj2 = textBox.Style[22];

            if (obj2 != null && LayoutConvert.ToFontWeight((RPLFormat.FontWeights)obj2) >= 600)
            {
                str.Append("&B");
                stringBuilder.Append("&B");
            }
            object obj3 = textBox.Style[24];

            if (obj3 != null)
            {
                RPLFormat.TextDecorations num2 = (RPLFormat.TextDecorations)obj3;
                if (num2 == RPLFormat.TextDecorations.Underline)
                {
                    str.Append("&u");
                    stringBuilder.Append("&u");
                }
                if (num2 == RPLFormat.TextDecorations.LineThrough)
                {
                    str.Append("&s");
                    stringBuilder.Append("&s");
                }
            }
            string text3 = string.Empty;
            string text4 = ((RPLTextBoxPropsDef)textBox.Definition).Formula;

            if (text4 != null && text4.Length != 0)
            {
                if (text4.StartsWith("=", StringComparison.Ordinal))
                {
                    text4 = text4.Remove(0, 1);
                }
                text3 = FormulaHandler.ProcessHeaderFooterFormula(text4);
            }
            if (text3 != null && text3.Length != 0)
            {
                str.Append(text3);
            }
            else
            {
                string text5 = textBox.Value;
                if (text5 == null)
                {
                    text5 = ((RPLTextBoxPropsDef)textBox.Definition).Value;
                }
                if (text5 == null && textBox.OriginalValue != null)
                {
                    text5 = textBox.OriginalValue.ToString();
                }
                if (text5 != null)
                {
                    FormulaHandler.EncodeHeaderFooterString(str, text5.Trim());
                }
            }
            if (stringBuilder.Length > 0)
            {
                str.Append(stringBuilder);
            }
            str.Append(" ");
        }
Esempio n. 8
0
        public static GDIFont GetOrCreateFont(Dictionary <string, GDIFont> gdiFonts, string fontFamily, float fontSize, RPLFormat.FontWeights fontWeight, RPLFormat.FontStyles fontStyle, RPLFormat.TextDecorations textDecoration)
        {
            string  key     = GDIFont.GetKey(fontFamily, fontSize, fontWeight, fontStyle, textDecoration);
            GDIFont gDIFont = default(GDIFont);

            if (gdiFonts.TryGetValue(key, out gDIFont))
            {
                return(gDIFont);
            }
            bool flag        = SharedRenderer.IsWeightBold(fontWeight);
            bool flag2       = fontStyle == RPLFormat.FontStyles.Italic;
            bool underLine   = false;
            bool lineThrough = false;

            switch (textDecoration)
            {
            case RPLFormat.TextDecorations.Underline:
                underLine = true;
                break;

            case RPLFormat.TextDecorations.LineThrough:
                lineThrough = true;
                break;
            }
            Font font = null;

            try
            {
                font    = FontCache.CreateGdiPlusFont(fontFamily, fontSize, ref flag, ref flag2, lineThrough, underLine);
                gDIFont = new GDIFont(key, font, fontSize);
                gdiFonts.Add(key, gDIFont);
                return(gDIFont);
            }
            catch
            {
                if (font != null && !gdiFonts.ContainsKey(key))
                {
                    font.Dispose();
                    font = null;
                }
                throw;
            }
        }
Esempio n. 9
0
        private static string GetKey(string fontFamily, float fontSize, RPLFormat.FontWeights fontWeight, RPLFormat.FontStyles fontStyle, RPLFormat.TextDecorations textDecoration)
        {
            StringBuilder stringBuilder = new StringBuilder("FO");

            stringBuilder.Append(fontFamily);
            stringBuilder.Append(fontSize.ToString(CultureInfo.InvariantCulture));
            if (SharedRenderer.IsWeightBold(fontWeight))
            {
                stringBuilder.Append('b');
            }
            else
            {
                stringBuilder.Append('n');
            }
            if (fontStyle == RPLFormat.FontStyles.Italic)
            {
                stringBuilder.Append('i');
            }
            else
            {
                stringBuilder.Append('n');
            }
            switch (textDecoration)
            {
            case RPLFormat.TextDecorations.Underline:
                stringBuilder.Append('u');
                break;

            case RPLFormat.TextDecorations.LineThrough:
                stringBuilder.Append('s');
                break;

            default:
                stringBuilder.Append('n');
                break;
            }
            return(stringBuilder.ToString());
        }
 public static void GetFontStyleInformation(RPLElementProps elementProperties, out RPLFormat.FontStyles fontStyle, out RPLFormat.FontWeights fontWeight, out RPLFormat.TextDecorations textDecoration, out float fontSize, out string fontFamily, ref bool fontStyleFromInstance)
 {
     fontSize       = (float)new RPLReportSize(SharedRenderer.GetStylePropertyValueString(elementProperties, (byte)21, ref fontStyleFromInstance)).ToPoints();
     fontStyle      = (RPLFormat.FontStyles)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)19, ref fontStyleFromInstance);
     fontWeight     = (RPLFormat.FontWeights)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)22, ref fontStyleFromInstance);
     textDecoration = (RPLFormat.TextDecorations)SharedRenderer.GetStylePropertyValueObject(elementProperties, (byte)24, ref fontStyleFromInstance);
     fontFamily     = SharedRenderer.GetStylePropertyValueString(elementProperties, (byte)20, ref fontStyleFromInstance);
 }
 internal static void GetFontStyleInformation(RPLElementProps elementProperties, out RPLFormat.FontStyles fontStyle, out RPLFormat.FontWeights fontWeight, out RPLFormat.TextDecorations textDecoration, out float fontSize, out string fontFamily, ref bool fontStyleFromInstance)
 {
     fontSize       = (float)new RPLReportSize(GetStylePropertyValueString(elementProperties, 21, ref fontStyleFromInstance)).ToPoints();
     fontStyle      = (RPLFormat.FontStyles)GetStylePropertyValueObject(elementProperties, 19, ref fontStyleFromInstance);
     fontWeight     = (RPLFormat.FontWeights)GetStylePropertyValueObject(elementProperties, 22, ref fontStyleFromInstance);
     textDecoration = (RPLFormat.TextDecorations)GetStylePropertyValueObject(elementProperties, 24, ref fontStyleFromInstance);
     fontFamily     = GetStylePropertyValueString(elementProperties, 20, ref fontStyleFromInstance);
 }