コード例 #1
0
        internal static byte Translate(FontWeights aValue)
        {
            switch (aValue)
            {
            case FontWeights.Bold:
                return(6);

            case FontWeights.ExtraBold:
                return(7);

            case FontWeights.ExtraLight:
                return(2);

            case FontWeights.Heavy:
                return(8);

            case FontWeights.Light:
                return(3);

            case FontWeights.Medium:
                return(4);

            case FontWeights.SemiBold:
                return(5);

            case FontWeights.Thin:
                return(1);

            default:
                return(0);
            }
        }
コード例 #2
0
 public void Draw()
 {
     this.Text.set_Text("");
     if (this.m_tl != null)
     {
         this.Text.set_Text((this.m_tl.Text.Length > 0) ? this.m_tl.Text : this.m_tl.ID);
         this.Text.set_Foreground(new SolidColorBrush(SilverlightHelper.ConvertToColor(this.m_tl.TextForeColor)));
         this.Text.set_FontFamily(new FontFamily(this.m_tl.FontName));
         this.Text.set_FontSize((double)(this.m_tl.FontSize + 3f));
         if ((this.m_tl.FontStyle & 1) == 1)
         {
             this.Text.set_FontWeight(FontWeights.get_Bold());
         }
         if ((this.m_tl.FontStyle & 2) == 2)
         {
             this.Text.set_FontStyle(FontStyles.get_Italic());
         }
         if ((this.m_tl.FontStyle & 4) == 4)
         {
             this.Text.set_TextDecorations(TextDecorations.get_Underline());
         }
         RotateTransform transform = new RotateTransform();
         transform.set_Angle((double)this.m_tl.Escapement);
         this.Text.set_RenderTransform(transform);
     }
 }
コード例 #3
0
        public FontFamilyDemoWindowViewModel()
        {
            var tempFontWeights      = new Dictionary <string, FontWeight>();
            var fontWeightProperties =
                typeof(System.Windows.FontWeights).GetProperties(BindingFlags.Public | BindingFlags.Static);

            foreach (var propertyInfo in fontWeightProperties)
            {
                tempFontWeights.Add(propertyInfo.Name, (FontWeight)propertyInfo.GetValue(null));
            }

            FontWeights        = tempFontWeights;
            SelectedFontWeight = FontWeights
                                 .FirstOrDefault(s => s.Key.Equals("Normal", StringComparison.OrdinalIgnoreCase));

            var tempFontStyles       = new Dictionary <string, FontStyle>();
            var fontStylesProperties =
                typeof(System.Windows.FontStyles).GetProperties(BindingFlags.Public | BindingFlags.Static);

            foreach (var propertyInfo in fontStylesProperties)
            {
                tempFontStyles.Add(propertyInfo.Name, (FontStyle)propertyInfo.GetValue(null));
            }

            FontStyles        = tempFontStyles;
            SelectedFontStyle = FontStyles
                                .FirstOrDefault(s => s.Key.Equals("Normal", StringComparison.OrdinalIgnoreCase));

            var tempFontStretches      = new Dictionary <string, FontStretch>();
            var FontStretchsProperties =
                typeof(System.Windows.FontStretches).GetProperties(BindingFlags.Public | BindingFlags.Static);

            foreach (var propertyInfo in FontStretchsProperties)
            {
                tempFontStretches.Add(propertyInfo.Name, (FontStretch)propertyInfo.GetValue(null));
            }

            FontStretches       = tempFontStretches;
            SelectedFontStretch = FontStretches
                                  .FirstOrDefault(s => s.Key.Equals("Normal", StringComparison.OrdinalIgnoreCase));

            var tempSystemFontFamilies = new List <FontFamily>();

            //增加自定义字体
            var aileron = new FontFamily(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                      @"FontFamilyDemo\FontFiles\#Aileron"));

            var aliFont = new FontFamily(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                      @"FontFamilyDemo\FontFiles\#阿里巴巴普惠体 R"));

            tempSystemFontFamilies.Add(aileron);
            tempSystemFontFamilies.Add(aliFont);

            foreach (var systemFontFamily in Fonts.SystemFontFamilies)
            {
                tempSystemFontFamilies.Add(systemFontFamily);
            }

            SystemFontFamilies = tempSystemFontFamilies;
        }
コード例 #4
0
        public void CreateGDIFont(string family, ReportSize size, FontStyles style, FontWeights weight, TextDecorations decoration)
        {
            double num   = 12.0;
            bool   flag  = this.IsBold(weight);
            bool   flag2 = style == FontStyles.Italic;

            if (size != null)
            {
                num = size.ToPoints();
            }
            string fontFamilyName = "Arial";

            if (family != null)
            {
                fontFamilyName = family;
            }
            bool lineThrough = false;
            bool underLine   = false;

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

            case TextDecorations.LineThrough:
                lineThrough = true;
                break;
            }
            this.m_gdiFont = FontCache.CreateGdiPlusFont(fontFamilyName, (float)num, ref flag, ref flag2, lineThrough, underLine);
        }
コード例 #5
0
        public static FontStyle GetStyleFontStyle(FontStyles style, FontWeights weight, TextDecorations textDecoration)
        {
            FontStyle fontStyle = FontStyle.Regular;

            if (style == FontStyles.Italic)
            {
                fontStyle = FontStyle.Italic;
            }
            switch (weight)
            {
            case FontWeights.SemiBold:
            case FontWeights.Bold:
            case FontWeights.ExtraBold:
            case FontWeights.Heavy:
                fontStyle |= FontStyle.Bold;
                break;
            }
            switch (textDecoration)
            {
            case TextDecorations.LineThrough:
                fontStyle |= FontStyle.Strikeout;
                break;

            case TextDecorations.Underline:
                fontStyle |= FontStyle.Underline;
                break;
            }
            return(fontStyle);
        }
コード例 #6
0
 public int GetFontWeight(AdaptiveFontStyle fontStyle, AdaptiveTextWeight requestedWeight)
 {
     return(FontStyles.GetFontStyle(fontStyle).FontWeights.GetFontWeight(requestedWeight)
            ?? FontStyles.Default.FontWeights.GetFontWeight(requestedWeight)
            ?? FontWeights.GetFontWeight(requestedWeight)
            ?? FontWeightsConfig.GetDefaultFontWeight(requestedWeight));
 }
コード例 #7
0
 private bool IsBold(FontWeights fontWeight)
 {
     if (fontWeight != FontWeights.Bold && fontWeight != FontWeights.ExtraBold && fontWeight != FontWeights.Heavy)
     {
         return(false);
     }
     return(true);
 }
コード例 #8
0
        private double DrawCurveTitle(Rectangle rc, PointData dpt1, PointData dpt2, string title, bool draw)
        {
            Point     point3;
            Point     point4;
            PointData data;
            Point     point  = this.PointData2Point(dpt1, rc);
            Point     point2 = this.PointData2Point(dpt2, rc);

            if (point.get_X() < point2.get_X())
            {
                point3 = point;
                point4 = point2;
                data   = dpt1;
            }
            else
            {
                point3 = point2;
                point4 = point;
                data   = dpt2;
            }
            Color color = SilverlightHelper.ConvertToColor(dpt2.Color);

            if (dpt1.DateTime > dpt2.DateTime)
            {
                color = SilverlightHelper.ConvertToColor(dpt1.Color);
            }
            double    rotationAngle = SilverlightHelper.GetRotationAngle(point3, point4);
            TextBlock block         = new TextBlock();
            int       num2          = 100;
            double    num3          = 5.0;

            block.SetValue(Canvas.TopProperty, point3.get_Y() + num3);
            block.SetValue(Canvas.LeftProperty, point3.get_X() + num3);
            block.SetValue(FrameworkElement.WidthProperty, (double)num2);
            block.SetValue(FrameworkElement.HeightProperty, 50.0);
            block.set_Width((double)num2);
            block.set_Text(title);
            block.set_FontSize(12.0);
            block.set_FontFamily(new FontFamily("Arial"));
            block.set_Foreground(new SolidColorBrush(color));
            block.set_FontStyle(FontStyles.get_Normal());
            block.set_FontWeight(FontWeights.get_Bold());
            RotateTransform transform = new RotateTransform();

            transform.set_Angle(-rotationAngle);
            block.set_RenderTransform(transform);
            block.set_TextAlignment(1);
            if (draw)
            {
                this.CanvasRoot.get_Children().Add(block);
            }
            return(block.get_ActualWidth() + num3);
        }
コード例 #9
0
        private void CreateFont(string family, ReportSize size, FontStyles style, FontWeights weight, TextDecorations decoration, TextAlignments alignment, VerticalAlignments verticalAlignment, Directions direction, WritingModes writingMode)
        {
            this.CreateGDIFont(family, size, style, weight, decoration);
            StringAlignment textStringAlignment  = this.CreateTextStringAlignment(alignment);
            bool            directionRightToLeft = false;

            if (direction == Directions.RTL)
            {
                directionRightToLeft = true;
            }
            this.SetWritingMode(writingMode);
            StringAlignment lineStringAlignment = this.CreateLineStringAlignment(verticalAlignment);

            this.CreateFormatString(textStringAlignment, lineStringAlignment, directionRightToLeft);
        }
コード例 #10
0
        internal void PopulateStyleInstance(ICompiledStyleInstance styleInstance, bool isParagraphStyle)
        {
            if (isParagraphStyle)
            {
                TextAlignments textAlign = TextAlign;
                if (textAlign != 0)
                {
                    styleInstance.TextAlign = textAlign;
                }
                return;
            }
            ReportColor color = Color;

            if (color != null)
            {
                styleInstance.Color = color;
            }
            string fontFamily = FontFamily;

            if (!string.IsNullOrEmpty(fontFamily))
            {
                styleInstance.FontFamily = fontFamily;
            }
            ReportSize fontSize = FontSize;

            if (fontSize != null)
            {
                styleInstance.FontSize = fontSize;
            }
            FontStyles fontStyle = FontStyle;

            if (fontStyle != 0)
            {
                styleInstance.FontStyle = fontStyle;
            }
            FontWeights fontWeight = FontWeight;

            if (fontWeight != 0)
            {
                styleInstance.FontWeight = fontWeight;
            }
            TextDecorations textDecoration = TextDecoration;

            if (textDecoration != 0)
            {
                styleInstance.TextDecoration = textDecoration;
            }
        }
コード例 #11
0
        public FontFamilyDemoWindowViewModel()
        {
            var tempFontWeights      = new Dictionary <string, FontWeight>();
            var fontWeightProperties = typeof(System.Windows.FontWeights).GetProperties(BindingFlags.Public | BindingFlags.Static);

            foreach (var propertyInfo in fontWeightProperties)
            {
                tempFontWeights.Add(propertyInfo.Name, (FontWeight)propertyInfo.GetValue(null));
            }

            FontWeights        = tempFontWeights;
            SelectedFontWeight = FontWeights
                                 .FirstOrDefault(s => s.Key.Equals("Normal", StringComparison.OrdinalIgnoreCase));

            var tempFontStyles       = new Dictionary <string, FontStyle>();
            var fontStylesProperties = typeof(System.Windows.FontStyles).GetProperties(BindingFlags.Public | BindingFlags.Static);

            foreach (var propertyInfo in fontStylesProperties)
            {
                tempFontStyles.Add(propertyInfo.Name, (FontStyle)propertyInfo.GetValue(null));
            }

            FontStyles        = tempFontStyles;
            SelectedFontStyle = FontStyles
                                .FirstOrDefault(s => s.Key.Equals("Normal", StringComparison.OrdinalIgnoreCase));

            var tempFontStretches      = new Dictionary <string, FontStretch>();
            var FontStretchsProperties = typeof(System.Windows.FontStretches).GetProperties(BindingFlags.Public | BindingFlags.Static);

            foreach (var propertyInfo in FontStretchsProperties)
            {
                tempFontStretches.Add(propertyInfo.Name, (FontStretch)propertyInfo.GetValue(null));
            }

            FontStretches       = tempFontStretches;
            SelectedFontStretch = FontStretches
                                  .FirstOrDefault(s => s.Key.Equals("Normal", StringComparison.OrdinalIgnoreCase));

            var tempSystemFontFamilies = new List <FontFamily>();

            foreach (var systemFontFamily in Fonts.SystemFontFamilies)
            {
                tempSystemFontFamilies.Add(systemFontFamily);
            }

            SystemFontFamilies = tempSystemFontFamilies;
        }
コード例 #12
0
ファイル: Convert.cs プロジェクト: robertmuehsig/OmniGUI
        public static Windows.UI.Text.FontWeight ToWin2D(this FontWeights fontWeight)
        {
            switch (fontWeight)
            {
            case FontWeights.Normal:
                return(Windows.UI.Text.FontWeights.Normal);

            case FontWeights.Bold:
                return(Windows.UI.Text.FontWeights.Bold);

            case FontWeights.ExtraBold:
                return(Windows.UI.Text.FontWeights.ExtraBold);

            default:
                throw new ArgumentOutOfRangeException(nameof(fontWeight), fontWeight, null);
            }
        }
コード例 #13
0
ファイル: Layout.cs プロジェクト: belsoft/traingraph
        private void DrawStation(Station e)
        {
            TextBlock block = new TextBlock();

            block.set_Text((e.ShortName.Length > 0) ? e.ShortName : e.ID);
            block.set_FontSize(12.0);
            block.set_FontFamily(m_fontStation);
            block.set_FontWeight(FontWeights.get_Bold());
            Color midnightBlue = ColorConstants.MidnightBlue;

            block.set_Foreground(new SolidColorBrush(midnightBlue));
            RotateTransform transform = new RotateTransform();

            transform.set_Angle((double)e.Escapement);
            block.set_RenderTransform(transform);
            block.SetValue(Canvas.LeftProperty, e.PointBase.get_X());
            block.SetValue(Canvas.TopProperty, (e.PointBase.get_Y() + 15.0) - (block.get_ActualHeight() / 2.0));
            this.g.get_Children().Add(block);
        }
コード例 #14
0
ファイル: SkiaUtils.cs プロジェクト: MarkoMajamaki/XamKit
        public static SKFontStyleWeight ConvertToSKFontWeight(FontWeights fontWeight)
        {
            switch (fontWeight)
            {
            case FontWeights.Normal:
                return(SKFontStyleWeight.Normal);

            case FontWeights.SemiBold:
                return(SKFontStyleWeight.SemiBold);

            case FontWeights.Bold:
                return(SKFontStyleWeight.Bold);

            case FontWeights.Thin:
                return(SKFontStyleWeight.Light);

            default:
                return(SKFontStyleWeight.Normal);
            }
        }
コード例 #15
0
 public TrainControl()
 {
     this.m_ID                     = "";
     this.m_DisplayID              = "";
     this.m_Tooltip                = "";
     this.m_BodyColorHi            = Colors.get_Blue();
     this.m_BodyColorLo            = Colors.get_Blue();
     this.m_Direction              = 0;
     this.m_Small                  = false;
     this.m_train                  = null;
     this.m_fntTrainSmall          = new FontFamily("Arial");
     this.m_fntTrainBigImpact      = new FontFamily("Impact");
     this.m_fntTrainBigNormal      = new FontFamily("Arial");
     this.m_fntTrainSmallSize      = 11;
     this.m_fntTrainBigImpactSize  = 13;
     this.m_fntTrainBigNormalSize  = 15;
     this.m_fntTrainSmallStyle     = FontWeights.get_Bold();
     this.m_fntTrainBigImpactStyle = FontWeights.get_Normal();
     this.m_fntTrainBigNormalStyle = FontWeights.get_Bold();
     this.InitializeComponent();
 }
コード例 #16
0
        public Font GetFont(Style style, StyleInstance styleInstance, bool hasScope)
        {
            if (style == null)
            {
                return(this.m_mapMapper.GetDefaultFontFromCache(0));
            }
            string text = MappingHelper.DefaultFontFamily;

            if (this.m_mapMapper.GetDefaultFont() != null)
            {
                text = this.m_mapMapper.GetDefaultFont().Name;
            }
            if (!MappingHelper.IsPropertyExpression(style.FontFamily) || hasScope)
            {
                text = MappingHelper.GetStyleFontFamily(style, styleInstance, text);
            }
            float           fontSize       = (MappingHelper.IsPropertyExpression(style.FontSize) && !hasScope) ? MappingHelper.DefaultFontSize : MappingHelper.GetStyleFontSize(style, styleInstance);
            FontStyles      fontStyle      = (MappingHelper.IsPropertyExpression(style.FontStyle) && !hasScope) ? FontStyles.Normal : MappingHelper.GetStyleFontStyle(style, styleInstance);
            FontWeights     fontWeight     = (MappingHelper.IsPropertyExpression(style.FontWeight) && !hasScope) ? FontWeights.Normal : MappingHelper.GetStyleFontWeight(style, styleInstance);
            TextDecorations textDecoration = (MappingHelper.IsPropertyExpression(style.TextDecoration) && !hasScope) ? TextDecorations.None : MappingHelper.GetStyleFontTextDecoration(style, styleInstance);

            return(this.m_mapMapper.GetFontFromCache(0, text, fontSize, fontStyle, fontWeight, textDecoration));
        }
コード例 #17
0
        internal static FontStyle GetStyleFontStyle(FontStyles style, FontWeights weight, TextDecorations textDecoration)
        {
            FontStyle fontStyle = FontStyle.Regular;

            if (style == FontStyles.Italic)
            {
                fontStyle = FontStyle.Italic;
            }
            if ((uint)(weight - 2) > 3u && (uint)(weight - 6) <= 3u)
            {
                fontStyle |= FontStyle.Bold;
            }
            switch (textDecoration)
            {
            case TextDecorations.LineThrough:
                fontStyle |= FontStyle.Strikeout;
                break;

            case TextDecorations.Underline:
                fontStyle |= FontStyle.Underline;
                break;
            }
            return(fontStyle);
        }
コード例 #18
0
ファイル: CompositeFontParser.cs プロジェクト: beda2280/wpf-1
        /// <summary>
        /// Parses the attributes of the FamilyTypeface element and sets the corresponding
        /// properties on the specified FamilyTypeface object. On return, the reader remains
        /// positioned on the element.
        /// </summary>
        private void ParseFamilyTypefaceAttributes(FamilyTypeface face)
        {
            // Iterate over the attributes.
            if (_reader.MoveToFirstAttribute())
            {
                do
                {
                    // Process attributes in the composite font namespace; ignore any others.
                    if (IsCompositeFontAttribute())
                    {
                        string name = _reader.LocalName;

                        if (name == StyleAttribute)
                        {
                            FontStyle fontStyle = new FontStyle();
                            if (!FontStyles.FontStyleStringToKnownStyle(GetAttributeValue(), CultureInfo.InvariantCulture, ref fontStyle))
                            {
                                FailAttributeValue();
                            }

                            face.Style = fontStyle;
                        }
                        else if (name == WeightAttribute)
                        {
                            FontWeight fontWeight = new FontWeight();
                            if (!FontWeights.FontWeightStringToKnownWeight(GetAttributeValue(), CultureInfo.InvariantCulture, ref fontWeight))
                            {
                                FailAttributeValue();
                            }

                            face.Weight = fontWeight;
                        }
                        else if (name == StretchAttribute)
                        {
                            FontStretch fontStretch = new FontStretch();
                            if (!FontStretches.FontStretchStringToKnownStretch(GetAttributeValue(), CultureInfo.InvariantCulture, ref fontStretch))
                            {
                                FailAttributeValue();
                            }

                            face.Stretch = fontStretch;
                        }
                        else if (name == UnderlinePositionAttribute)
                        {
                            face.UnderlinePosition = GetAttributeAsDouble();
                        }
                        else if (name == UnderlineThicknessAttribute)
                        {
                            face.UnderlineThickness = GetAttributeAsDouble();
                        }
                        else if (name == StrikethroughPositionAttribute)
                        {
                            face.StrikethroughPosition = GetAttributeAsDouble();
                        }
                        else if (name == StrikethroughThicknessAttribute)
                        {
                            face.StrikethroughThickness = GetAttributeAsDouble();
                        }
                        else if (name == CapsHeightAttribute)
                        {
                            face.CapsHeight = GetAttributeAsDouble();
                        }
                        else if (name == XHeightAttribute)
                        {
                            face.XHeight = GetAttributeAsDouble();
                        }
                        else if (name == DeviceFontNameAttribute)
                        {
                            face.DeviceFontName = GetAttributeValue();
                        }
                        else
                        {
                            FailUnknownAttribute();
                        }
                    }
                    else if (!IsIgnorableAttribute())
                    {
                        FailUnknownAttribute();
                    }
                } while (_reader.MoveToNextAttribute());

                _reader.MoveToElement();
            }
        }
コード例 #19
0
 /// <summary>Sets font weight.</summary>
 /// <param name="weight">
 /// integer form 100 to 900. See
 /// <see cref="iText.IO.Font.Constants.FontWeights"/>
 /// .
 /// </param>
 protected internal virtual void SetFontWeight(int weight)
 {
     this.weight = FontWeights.NormalizeFontWeight(weight);
 }
コード例 #20
0
        public static bool TranslateFontWeight(string styleString, out FontWeights fontWieght)
        {
            fontWieght = FontWeights.Normal;
            if (!string.IsNullOrEmpty(styleString))
            {
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Normal", styleString))
                {
                    fontWieght = FontWeights.Normal;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Bold", styleString))
                {
                    fontWieght = FontWeights.Bold;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Bolder", styleString))
                {
                    fontWieght = FontWeights.Bold;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("100", styleString))
                {
                    fontWieght = FontWeights.Thin;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("200", styleString))
                {
                    fontWieght = FontWeights.ExtraLight;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("300", styleString))
                {
                    fontWieght = FontWeights.Light;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("400", styleString))
                {
                    fontWieght = FontWeights.Normal;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("500", styleString))
                {
                    fontWieght = FontWeights.Medium;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("600", styleString))
                {
                    fontWieght = FontWeights.SemiBold;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("700", styleString))
                {
                    fontWieght = FontWeights.Bold;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("800", styleString))
                {
                    fontWieght = FontWeights.ExtraBold;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("900", styleString))
                {
                    fontWieght = FontWeights.Heavy;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Thin", styleString))
                {
                    fontWieght = FontWeights.Thin;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("ExtraLight", styleString))
                {
                    fontWieght = FontWeights.ExtraLight;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Light", styleString))
                {
                    fontWieght = FontWeights.Light;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Lighter", styleString))
                {
                    fontWieght = FontWeights.Light;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Medium", styleString))
                {
                    fontWieght = FontWeights.Medium;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("SemiBold", styleString))
                {
                    fontWieght = FontWeights.SemiBold;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("ExtraBold", styleString))
                {
                    fontWieght = FontWeights.ExtraBold;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Heavy", styleString))
                {
                    fontWieght = FontWeights.Heavy;
                    goto IL_01b6;
                }
                if (RichTextStyleTranslator.CompareWithInvariantCulture("Default", styleString))
                {
                    fontWieght = FontWeights.Normal;
                    goto IL_01b6;
                }
                return(false);
            }
            return(false);

IL_01b6:
            return(true);
        }
コード例 #21
0
        protected internal virtual void Process()
        {
            RandomAccessFileOrArray raf = fontParser.GetMetricsFile();
            String line;
            bool   startKernPairs = false;

            while (!startKernPairs && (line = raf.ReadLine()) != null)
            {
                StringTokenizer tok = new StringTokenizer(line, " ,\n\r\t\f");
                if (!tok.HasMoreTokens())
                {
                    continue;
                }
                String ident = tok.NextToken();
                switch (ident)
                {
                case "FontName": {
                    fontNames.SetFontName(tok.NextToken("\u00ff").Substring(1));
                    break;
                }

                case "FullName": {
                    String fullName = tok.NextToken("\u00ff").Substring(1);
                    fontNames.SetFullName(new String[][] { new String[] { "", "", "", fullName } });
                    break;
                }

                case "FamilyName": {
                    String familyName = tok.NextToken("\u00ff").Substring(1);
                    fontNames.SetFamilyName(new String[][] { new String[] { "", "", "", familyName } });
                    break;
                }

                case "Weight": {
                    fontNames.SetFontWeight(FontWeights.FromType1FontWeight(tok.NextToken("\u00ff").Substring(1)));
                    break;
                }

                case "ItalicAngle": {
                    fontMetrics.SetItalicAngle(float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture)
                                               );
                    break;
                }

                case "IsFixedPitch": {
                    fontMetrics.SetIsFixedPitch(tok.NextToken().Equals("true"));
                    break;
                }

                case "CharacterSet": {
                    characterSet = tok.NextToken("\u00ff").Substring(1);
                    break;
                }

                case "FontBBox": {
                    int llx = (int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
                    int lly = (int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
                    int urx = (int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
                    int ury = (int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
                    fontMetrics.SetBbox(llx, lly, urx, ury);
                    break;
                }

                case "UnderlinePosition": {
                    fontMetrics.SetUnderlinePosition((int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture
                                                                      ));
                    break;
                }

                case "UnderlineThickness": {
                    fontMetrics.SetUnderlineThickness((int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture
                                                                       ));
                    break;
                }

                case "EncodingScheme": {
                    encodingScheme = tok.NextToken("\u00ff").Substring(1).Trim();
                    break;
                }

                case "CapHeight": {
                    fontMetrics.SetCapHeight((int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture
                                                              ));
                    break;
                }

                case "XHeight": {
                    fontMetrics.SetXHeight((int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture
                                                            ));
                    break;
                }

                case "Ascender": {
                    fontMetrics.SetTypoAscender((int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture
                                                                 ));
                    break;
                }

                case "Descender": {
                    fontMetrics.SetTypoDescender((int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture
                                                                  ));
                    break;
                }

                case "StdHW": {
                    fontMetrics.SetStemH((int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture));
                    break;
                }

                case "StdVW": {
                    fontMetrics.SetStemV((int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture));
                    break;
                }

                case "StartCharMetrics": {
                    startKernPairs = true;
                    break;
                }
                }
            }
            if (!startKernPairs)
            {
                String metricsPath = fontParser.GetAfmPath();
                if (metricsPath != null)
                {
                    throw new iText.IO.IOException("startcharmetrics is missing in {0}.").SetMessageParams(metricsPath);
                }
                else
                {
                    throw new iText.IO.IOException("startcharmetrics is missing in the metrics file.");
                }
            }
            avgWidth = 0;
            int widthCount = 0;

            while ((line = raf.ReadLine()) != null)
            {
                StringTokenizer tok = new StringTokenizer(line);
                if (!tok.HasMoreTokens())
                {
                    continue;
                }
                String ident = tok.NextToken();
                if (ident.Equals("EndCharMetrics"))
                {
                    startKernPairs = false;
                    break;
                }
                int    C  = -1;
                int    WX = 250;
                String N  = "";
                int[]  B  = null;
                tok = new StringTokenizer(line, ";");
                while (tok.HasMoreTokens())
                {
                    StringTokenizer tokc = new StringTokenizer(tok.NextToken());
                    if (!tokc.HasMoreTokens())
                    {
                        continue;
                    }
                    ident = tokc.NextToken();
                    switch (ident)
                    {
                    case "C": {
                        C = Convert.ToInt32(tokc.NextToken());
                        break;
                    }

                    case "WX": {
                        WX = (int)float.Parse(tokc.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    }

                    case "N": {
                        N = tokc.NextToken();
                        break;
                    }

                    case "B": {
                        B = new int[] { Convert.ToInt32(tokc.NextToken()), Convert.ToInt32(tokc.NextToken()), Convert.ToInt32(tokc
                                                                                                                              .NextToken()), Convert.ToInt32(tokc.NextToken()) };
                        break;
                    }
                    }
                }
                int   unicode = AdobeGlyphList.NameToUnicode(N);
                Glyph glyph   = new Glyph(C, WX, unicode, B);
                if (C >= 0)
                {
                    codeToGlyph.Put(C, glyph);
                }
                if (unicode != -1)
                {
                    unicodeToGlyph.Put(unicode, glyph);
                }
                avgWidth += WX;
                widthCount++;
            }
            if (widthCount != 0)
            {
                avgWidth /= widthCount;
            }
            if (startKernPairs)
            {
                String metricsPath = fontParser.GetAfmPath();
                if (metricsPath != null)
                {
                    throw new iText.IO.IOException("endcharmetrics is missing in {0}.").SetMessageParams(metricsPath);
                }
                else
                {
                    throw new iText.IO.IOException("endcharmetrics is missing in the metrics file.");
                }
            }
            // From AdobeGlyphList:
            // nonbreakingspace;00A0
            // space;0020
            if (!unicodeToGlyph.ContainsKey(0x00A0))
            {
                Glyph space = unicodeToGlyph.Get(0x0020);
                if (space != null)
                {
                    unicodeToGlyph.Put(0x00A0, new Glyph(space.GetCode(), space.GetWidth(), 0x00A0, space.GetBbox()));
                }
            }
            bool endOfMetrics = false;

            while ((line = raf.ReadLine()) != null)
            {
                StringTokenizer tok = new StringTokenizer(line);
                if (!tok.HasMoreTokens())
                {
                    continue;
                }
                String ident = tok.NextToken();
                if (ident.Equals("EndFontMetrics"))
                {
                    endOfMetrics = true;
                    break;
                }
                else
                {
                    if (ident.Equals("StartKernPairs"))
                    {
                        startKernPairs = true;
                        break;
                    }
                }
            }
            if (startKernPairs)
            {
                while ((line = raf.ReadLine()) != null)
                {
                    StringTokenizer tok = new StringTokenizer(line);
                    if (!tok.HasMoreTokens())
                    {
                        continue;
                    }
                    String ident = tok.NextToken();
                    if (ident.Equals("KPX"))
                    {
                        String first     = tok.NextToken();
                        String second    = tok.NextToken();
                        int?   width     = (int)float.Parse(tok.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
                        int    firstUni  = AdobeGlyphList.NameToUnicode(first);
                        int    secondUni = AdobeGlyphList.NameToUnicode(second);
                        if (firstUni != -1 && secondUni != -1)
                        {
                            long record = ((long)firstUni << 32) + secondUni;
                            kernPairs.Put(record, width);
                        }
                    }
                    else
                    {
                        if (ident.Equals("EndKernPairs"))
                        {
                            startKernPairs = false;
                            break;
                        }
                    }
                }
            }
            else
            {
                if (!endOfMetrics)
                {
                    String metricsPath = fontParser.GetAfmPath();
                    if (metricsPath != null)
                    {
                        throw new iText.IO.IOException("endfontmetrics is missing in {0}.").SetMessageParams(metricsPath);
                    }
                    else
                    {
                        throw new iText.IO.IOException("endfontmetrics is missing in the metrics file.");
                    }
                }
            }
            if (startKernPairs)
            {
                String metricsPath = fontParser.GetAfmPath();
                if (metricsPath != null)
                {
                    throw new iText.IO.IOException("endkernpairs is missing in {0}.").SetMessageParams(metricsPath);
                }
                else
                {
                    throw new iText.IO.IOException("endkernpairs is missing in the metrics file.");
                }
            }
            raf.Close();
            isFontSpecific = !(encodingScheme.Equals("AdobeStandardEncoding") || encodingScheme.Equals("StandardEncoding"
                                                                                                       ));
        }
コード例 #22
0
        private void DrawScales(Rectangle rc, List <MarkerData> s, double lastRightStationPosition, double firstLeftStationXPos)
        {
            DateTime timeStart = this.m_tgd.TimeStart;
            TimeSpan span      = TimeSpan.FromMinutes(1.0);
            double   num       = 16.0;
            double   num2      = 18.0;
            double   num3      = 5.0;

            while (timeStart <= this.m_tgd.TimeStop)
            {
                double y = this.DateTime2PointY(timeStart, rc);
                if ((timeStart.Minute == 0) || ((timeStart.Minute % 10) == 0))
                {
                    this.DrawHorScaleLine(rc, y);
                    this.DrawStationTimeScale(y, s, true);
                    TextBlock block = new TextBlock();
                    block.SetValue(Canvas.TopProperty, y - (num2 / 2.0));
                    block.SetValue(Canvas.LeftProperty, ((firstLeftStationXPos - num) - num3) - 1.0);
                    block.SetValue(FrameworkElement.WidthProperty, num);
                    block.SetValue(FrameworkElement.HeightProperty, num2);
                    block.set_TextAlignment(0);
                    TextBlock block2 = new TextBlock();
                    block2.SetValue(Canvas.TopProperty, y - (num2 / 2.0));
                    block2.SetValue(Canvas.LeftProperty, (lastRightStationPosition + num3) + 2.0);
                    block2.SetValue(FrameworkElement.WidthProperty, num);
                    block2.SetValue(FrameworkElement.HeightProperty, num2);
                    block2.set_TextAlignment(0);
                    if (timeStart.Minute == 0)
                    {
                        block.set_Text(timeStart.Hour.ToString("00"));
                        block.set_FontSize(15.0);
                        block.set_FontFamily(new FontFamily("Arial"));
                        block.set_Foreground(new SolidColorBrush(Colors.get_Black()));
                        block.set_FontStyle(FontStyles.get_Normal());
                        block.set_FontWeight(FontWeights.get_Bold());
                    }
                    else if ((timeStart.Minute % 10) == 0)
                    {
                        block.set_Text(timeStart.Minute.ToString());
                        block.set_FontSize(13.0);
                        block.set_FontFamily(new FontFamily("Arial"));
                        block.set_Foreground(new SolidColorBrush(Colors.get_Gray()));
                        block.set_FontStyle(FontStyles.get_Normal());
                        block.set_FontWeight(FontWeights.get_Normal());
                    }
                    block2.set_Text(block.get_Text());
                    block2.set_FontStyle(block.get_FontStyle());
                    block2.set_FontWeight(block.get_FontWeight());
                    block2.set_FontSize(block.get_FontSize());
                    block2.set_FontFamily(block.get_FontFamily());
                    block2.set_Foreground(block.get_Foreground());
                    this.CanvasRoot.get_Children().Add(block);
                    this.CanvasRoot.get_Children().Add(block2);
                }
                else
                {
                    this.DrawStationTimeScale(y, s, false);
                }
                timeStart = timeStart.Add(span);
            }
        }
コード例 #23
0
 public CanvasFont(string family, ReportSize size, FontStyles style, FontWeights weight, TextDecorations decoration, TextAlignments alignment, VerticalAlignments verticalAlignment, Directions direction, WritingModes writingMode)
 {
     this.CreateFont(family, size, style, weight, decoration, alignment, verticalAlignment, direction, writingMode);
 }
コード例 #24
0
 private void DrawCurve(TrainCurveData c, Rectangle rc, List <Line> rectangles, int startIndex)
 {
     if ((c != null) && (c.Points != null))
     {
         PointData data;
         PointData data2;
         int       num           = 0;
         int       num2          = -1;
         Line      item          = new Line();
         Color     color         = Colors.get_Black();
         double    widthRequires = 0.0;
         if (c.Points.Count > 0)
         {
             widthRequires = this.DrawCurveTitle(rc, c.Points[0], c.Points[0], c.Caption, false);
         }
         for (int i = startIndex; i < (c.Points.Count - 1); i++)
         {
             data  = c.Points[i];
             data2 = c.Points[i + 1];
             if (!c.Regular)
             {
                 TimeSpan span = (TimeSpan)(data.DateTime - data2.DateTime);
                 if (this.IsGap((double)(data.Position - data2.Position), span.TotalMinutes))
                 {
                     c.CaptionHasDrawn   = false;
                     c.CaptionStartIndex = i + 1;
                     continue;
                 }
             }
             color = SilverlightHelper.ConvertToColor(data2.Color);
             Line line2 = new Line();
             line2.set_X1(this.Position2PointX(data.Position, rc));
             line2.set_Y1(this.DateTime2PointY(data.DateTime, rc));
             line2.set_X2(this.Position2PointX(data2.Position, rc));
             line2.set_Y2(this.DateTime2PointY(data2.DateTime, rc));
             line2.set_Width(1251.0);
             line2.set_Height(this.CanvasRoot_ActualHeight);
             line2.set_StrokeThickness(2.0);
             line2.set_Stroke(new SolidColorBrush(color));
             this.CanvasRoot.get_Children().Add(line2);
             if (c.Regular && (c.Caption.Length > 0))
             {
                 if (!this.HasInsersection(rectangles, line2))
                 {
                     int num5 = data2.Position - data.Position;
                     if (num5 > num)
                     {
                         num  = num5;
                         num2 = i;
                         item = this.LineClone(line2);
                     }
                 }
             }
             else if (!c.CaptionHasDrawn)
             {
                 int  num6;
                 int  num7;
                 int  num8;
                 bool flag;
                 if (this.GetGoodPointsForTitle(c, c.CaptionStartIndex, rc, widthRequires, out num6, out num7, out num8, out flag))
                 {
                     c.CaptionHasDrawn = true;
                     this.DrawCurveTitle(rc, c.Points[num6], c.Points[num7], c.Caption, true);
                 }
                 else if (flag)
                 {
                     c.CaptionStartIndex = num8;
                 }
             }
         }
         if ((c.Regular && (c.Caption.Length > 0)) && (num2 != -1))
         {
             data  = c.Points[num2];
             data2 = c.Points[num2 + 1];
             color = SilverlightHelper.ConvertToColor(data2.Color);
             if (rectangles != null)
             {
                 rectangles.Add(item);
             }
             Point point  = new Point();
             Point point2 = new Point();
             point.set_X(this.Position2PointX(data.Position, rc));
             point.set_Y(this.DateTime2PointY(data.DateTime, rc));
             point2.set_X(this.Position2PointX(data2.Position, rc));
             point2.set_Y(this.DateTime2PointY(data2.DateTime, rc));
             double    rotationAngle = SilverlightHelper.GetRotationAngle(point, point2);
             double    num10         = point2.get_X() - point.get_X();
             TextBlock block         = new TextBlock();
             block.SetValue(Canvas.TopProperty, point.get_Y() + 5.0);
             block.SetValue(Canvas.LeftProperty, point.get_X());
             block.SetValue(FrameworkElement.WidthProperty, num10);
             block.SetValue(FrameworkElement.HeightProperty, 50.0);
             block.set_Width(num10);
             block.set_Text(c.Caption);
             block.set_FontSize(17.0);
             block.set_FontFamily(new FontFamily("Arial"));
             block.set_Foreground(new SolidColorBrush(color));
             block.set_FontStyle(FontStyles.get_Normal());
             block.set_FontWeight(FontWeights.get_Bold());
             RotateTransform transform = new RotateTransform();
             transform.set_Angle(-rotationAngle);
             block.set_RenderTransform(transform);
             block.set_TextAlignment(0);
             this.CanvasRoot.get_Children().Add(block);
         }
     }
 }
コード例 #25
0
 public Font GetFontFromCache(int id, string fontFamily, float fontSize, FontStyles fontStyle, FontWeights fontWeight, TextDecorations textDecoration)
 {
     return(this.m_fontCache.GetFontFromCache(id, fontFamily, fontSize, MappingHelper.GetStyleFontStyle(fontStyle, fontWeight, textDecoration)));
 }
コード例 #26
0
 internal static bool TranslateFontWeight(string styleString, out FontWeights fontWieght)
 {
     fontWieght = FontWeights.Normal;
     if (!string.IsNullOrEmpty(styleString))
     {
         if (CompareWithInvariantCulture("Normal", styleString))
         {
             fontWieght = FontWeights.Normal;
         }
         else if (CompareWithInvariantCulture("Bold", styleString))
         {
             fontWieght = FontWeights.Bold;
         }
         else if (CompareWithInvariantCulture("Bolder", styleString))
         {
             fontWieght = FontWeights.Bold;
         }
         else if (CompareWithInvariantCulture("100", styleString))
         {
             fontWieght = FontWeights.Thin;
         }
         else if (CompareWithInvariantCulture("200", styleString))
         {
             fontWieght = FontWeights.ExtraLight;
         }
         else if (CompareWithInvariantCulture("300", styleString))
         {
             fontWieght = FontWeights.Light;
         }
         else if (CompareWithInvariantCulture("400", styleString))
         {
             fontWieght = FontWeights.Normal;
         }
         else if (CompareWithInvariantCulture("500", styleString))
         {
             fontWieght = FontWeights.Medium;
         }
         else if (CompareWithInvariantCulture("600", styleString))
         {
             fontWieght = FontWeights.SemiBold;
         }
         else if (CompareWithInvariantCulture("700", styleString))
         {
             fontWieght = FontWeights.Bold;
         }
         else if (CompareWithInvariantCulture("800", styleString))
         {
             fontWieght = FontWeights.ExtraBold;
         }
         else if (CompareWithInvariantCulture("900", styleString))
         {
             fontWieght = FontWeights.Heavy;
         }
         else if (CompareWithInvariantCulture("Thin", styleString))
         {
             fontWieght = FontWeights.Thin;
         }
         else if (CompareWithInvariantCulture("ExtraLight", styleString))
         {
             fontWieght = FontWeights.ExtraLight;
         }
         else if (CompareWithInvariantCulture("Light", styleString))
         {
             fontWieght = FontWeights.Light;
         }
         else if (CompareWithInvariantCulture("Lighter", styleString))
         {
             fontWieght = FontWeights.Light;
         }
         else if (CompareWithInvariantCulture("Medium", styleString))
         {
             fontWieght = FontWeights.Medium;
         }
         else if (CompareWithInvariantCulture("SemiBold", styleString))
         {
             fontWieght = FontWeights.SemiBold;
         }
         else if (CompareWithInvariantCulture("ExtraBold", styleString))
         {
             fontWieght = FontWeights.ExtraBold;
         }
         else if (CompareWithInvariantCulture("Heavy", styleString))
         {
             fontWieght = FontWeights.Heavy;
         }
         else
         {
             if (!CompareWithInvariantCulture("Default", styleString))
             {
                 return(false);
             }
             fontWieght = FontWeights.Normal;
         }
         return(true);
     }
     return(false);
 }
コード例 #27
0
 private void SetStyleValues(bool isParagraph)
 {
     if (this.m_currentHtmlElement.CssStyle != null)
     {
         string     text       = default(string);
         ReportSize reportSize = default(ReportSize);
         if (isParagraph && base.m_allowMultipleParagraphs)
         {
             if (this.m_currentHtmlElement.CssStyle.TryGetValue("text-align", out text))
             {
                 TextAlignments textAlign = default(TextAlignments);
                 if (RichTextStyleTranslator.TranslateTextAlign(text, out textAlign))
                 {
                     base.m_currentStyle.TextAlign = textAlign;
                 }
                 else
                 {
                     base.m_richTextLogger.RegisterInvalidValueWarning("text-align", text, this.m_currentHtmlElement.CharacterPosition);
                 }
             }
             if (this.m_currentHtmlElement.CssStyle.TryGetValue("text-indent", out text))
             {
                 if (ReportSize.TryParse(text, true, out reportSize))
                 {
                     base.m_currentParagraph.HangingIndent = reportSize;
                 }
                 else
                 {
                     base.m_richTextLogger.RegisterInvalidSizeWarning("text-indent", text, this.m_currentHtmlElement.CharacterPosition);
                 }
             }
             ReportSize generalPadding = null;
             if (this.m_currentHtmlElement.CssStyle.TryGetValue("padding", out text))
             {
                 if (ReportSize.TryParse(text, out reportSize))
                 {
                     generalPadding = reportSize;
                 }
                 else
                 {
                     base.m_richTextLogger.RegisterInvalidSizeWarning("padding", text, this.m_currentHtmlElement.CharacterPosition);
                 }
             }
             ReportSize size = default(ReportSize);
             if (this.HasPaddingValue("padding-top", generalPadding, out size))
             {
                 base.m_currentParagraph.AddSpaceBefore(size);
             }
             if (this.HasPaddingValue("padding-bottom", generalPadding, out size))
             {
                 base.m_currentParagraph.AddSpaceAfter(size);
             }
             if (this.HasPaddingValue("padding-left", generalPadding, out size))
             {
                 base.m_currentParagraph.AddLeftIndent(size);
             }
             if (this.HasPaddingValue("padding-right", generalPadding, out size))
             {
                 base.m_currentParagraph.AddRightIndent(size);
             }
         }
         if (this.m_currentHtmlElement.CssStyle.TryGetValue("font-family", out text))
         {
             base.m_currentStyle.FontFamily = text;
         }
         if (this.m_currentHtmlElement.CssStyle.TryGetValue("font-size", out text))
         {
             if (ReportSize.TryParse(text, out reportSize))
             {
                 base.m_currentStyle.FontSize = reportSize;
             }
             else
             {
                 base.m_richTextLogger.RegisterInvalidSizeWarning("font-size", text, this.m_currentHtmlElement.CharacterPosition);
             }
         }
         if (this.m_currentHtmlElement.CssStyle.TryGetValue("font-weight", out text))
         {
             FontWeights fontWeight = default(FontWeights);
             if (RichTextStyleTranslator.TranslateFontWeight(text, out fontWeight))
             {
                 base.m_currentStyle.FontWeight = fontWeight;
             }
             else
             {
                 base.m_richTextLogger.RegisterInvalidValueWarning("font-weight", text, this.m_currentHtmlElement.CharacterPosition);
             }
         }
         if (this.m_currentHtmlElement.CssStyle.TryGetValue("color", out text))
         {
             ReportColor color = default(ReportColor);
             if (ReportColor.TryParse(RichTextStyleTranslator.TranslateHtmlColor(text), out color))
             {
                 base.m_currentStyle.Color = color;
             }
             else
             {
                 base.m_richTextLogger.RegisterInvalidColorWarning("color", text, this.m_currentHtmlElement.CharacterPosition);
             }
         }
     }
 }