Пример #1
0
        private void OnChangedFontWeight(FontWeightType enumType)
        {
            string strIOS = "NanumGothic";
            string strAnd = "fonts/NanumGothic.ttf#NanumGothic";

            if (enumType == FontWeightType.Bold)
            {
                strIOS = "NanumGothicBold";
                strAnd = "fonts/NanumGothicBold.ttf#NanumGothicBold";
            }
            else if (enumType == FontWeightType.Light)
            {
                strIOS = "NanumGothicLight";
                strAnd = "fonts/NanumGothicLight.ttf#NanumGothicLight";
            }
            else
            {
            }

            FontFamily = Device.OnPlatform(
                strIOS,
                strAnd,
                null
                );
        }
Пример #2
0
        public override string ToString()
        {
            string         str            = "Normal";
            FontWeightType fontWeightType = this.weight;

            if (fontWeightType <= FontWeightType.Medium)
            {
                if (fontWeightType <= FontWeightType.ExtraLight)
                {
                    if (fontWeightType == FontWeightType.Thin)
                    {
                        str = "Thin";
                    }
                    else if (fontWeightType == FontWeightType.ExtraLight)
                    {
                        str = "ExtraLight";
                    }
                }
                else if (fontWeightType == FontWeightType.Light)
                {
                    str = "Light";
                }
                else if (fontWeightType == FontWeightType.Normal)
                {
                    str = "Normal";
                }
                else if (fontWeightType == FontWeightType.Medium)
                {
                    str = "Medium";
                }
            }
            else if (fontWeightType <= FontWeightType.Bold)
            {
                if (fontWeightType == FontWeightType.SemiBold)
                {
                    str = "SemiBold";
                }
                else if (fontWeightType == FontWeightType.Bold)
                {
                    str = "Bold";
                }
            }
            else if (fontWeightType == FontWeightType.ExtraBold)
            {
                str = "ExtraBold";
            }
            else if (fontWeightType == FontWeightType.Black)
            {
                str = "Black";
            }
            else if (fontWeightType == FontWeightType.ExtraBlack)
            {
                str = "ExtraBlack";
            }
            return(str);
        }
Пример #3
0
        internal static FontWeight EnsureFontWeight(FontWeightType weight)
        {
            if ((int)weight == 0)
            {
                weight = FontWeightType.Normal;
            }
            FontWeightType fontWeightType = weight;

            if (fontWeightType <= FontWeightType.Medium)
            {
                if (fontWeightType > FontWeightType.ExtraLight)
                {
                    if (fontWeightType == FontWeightType.Light || fontWeightType == FontWeightType.Normal || fontWeightType == FontWeightType.Medium)
                    {
                        return(new FontWeight(weight));
                    }
                    throw new ArgumentOutOfRangeException("weight");
                }
                else
                {
                    if (fontWeightType == FontWeightType.Thin || fontWeightType == FontWeightType.ExtraLight)
                    {
                        return(new FontWeight(weight));
                    }
                    throw new ArgumentOutOfRangeException("weight");
                }
            }
            else if (fontWeightType <= FontWeightType.Bold)
            {
                if (fontWeightType == FontWeightType.SemiBold || fontWeightType == FontWeightType.Bold)
                {
                    return(new FontWeight(weight));
                }
                throw new ArgumentOutOfRangeException("weight");
            }
            else if (fontWeightType != FontWeightType.ExtraBold && fontWeightType != FontWeightType.Black && fontWeightType != FontWeightType.ExtraBlack)
            {
                throw new ArgumentOutOfRangeException("weight");
            }
            return(new FontWeight(weight));
        }
Пример #4
0
        public static string GetFontWeightString(FontWeightType fontWeightType)
        {
            string value = GetCamelCase(fontWeightType.ToString());

            return(string.IsNullOrEmpty(value) ? "none" : value);
        }
Пример #5
0
 internal static FontWeight EnsureFontWeight(FontWeightType weight)
 {
     if ((int)weight == 0)
     {
         weight = FontWeightType.Normal;
     }
     FontWeightType fontWeightType = weight;
     if (fontWeightType <= FontWeightType.Medium)
     {
         if (fontWeightType > FontWeightType.ExtraLight)
         {
             if (fontWeightType == FontWeightType.Light || fontWeightType == FontWeightType.Normal || fontWeightType == FontWeightType.Medium)
             {
                 return new FontWeight(weight);
             }
             throw new ArgumentOutOfRangeException("weight");
         }
         else
         {
             if (fontWeightType == FontWeightType.Thin || fontWeightType == FontWeightType.ExtraLight)
             {
                 return new FontWeight(weight);
             }
             throw new ArgumentOutOfRangeException("weight");
         }
     }
     else if (fontWeightType <= FontWeightType.Bold)
     {
         if (fontWeightType == FontWeightType.SemiBold || fontWeightType == FontWeightType.Bold)
         {
             return new FontWeight(weight);
         }
         throw new ArgumentOutOfRangeException("weight");
     }
     else if (fontWeightType != FontWeightType.ExtraBold && fontWeightType != FontWeightType.Black && fontWeightType != FontWeightType.ExtraBlack)
     {
         throw new ArgumentOutOfRangeException("weight");
     }
     return new FontWeight(weight);
 }
Пример #6
0
 public FontWeight(FontWeightType weight)
 {
     this.weight = weight;
 }
Пример #7
0
 /// <summary> Draw set font weight. </summary>
 /// <param name="wand"> The wand. </param>
 /// <param name="font_weight"> The font weight. </param>
 /// <returns> true if it succeeds, false if it fails. </returns>
 internal static bool DrawSetFontWeight(IntPtr wand, FontWeightType font_weight)
 {
     return(DrawSetFontWeightInternal(wand, (IntPtr)font_weight));
 }
 /// <summary> Draw set font weight. </summary>
 /// <param name="wand"> The wand. </param>
 /// <param name="font_weight"> The font weight. </param>
 /// <returns> true if it succeeds, false if it fails. </returns>
 internal static bool DrawSetFontWeight(IntPtr wand, FontWeightType font_weight)
 {
     return DrawSetFontWeightInternal(wand, (IntPtr)font_weight);
 }
 /// <summary> A MagickWand extension method that draw text. </summary>
 /// <param name="wand"> The wand to act on. </param>
 /// <param name="text"> The text. </param>
 /// <param name="x"> The x coordinate. </param>
 /// <param name="y"> The y coordinate. </param>
 /// <param name="fontName"> Name of the font. </param>
 /// <param name="fontSize"> Size of the font. </param>
 /// <param name="fontColor"> The font color. </param>
 /// <param name="fontWeight"> The font weight. </param>
 internal static void DrawText(this ImageWand wand, string text, double x, double y, string fontName, double fontSize, PixelWand fontColor, FontWeightType fontWeight)
 {
     using (var draw = new DrawingWand())
     {
         using (fontColor)
         {
             draw.FillColor = fontColor;
             draw.Font = fontName;
             draw.FontSize = fontSize;
             draw.FontWeight = fontWeight;
             draw.TextAntialias = true;
             draw.DrawAnnotation(x, y, text);
             wand.DrawImage(draw);
         }
     }
 }
 /// <summary> A MagickWand extension method that draw text. </summary>
 /// <param name="wand"> The wand to act on. </param>
 /// <param name="text"> The text. </param>
 /// <param name="x"> The x coordinate. </param>
 /// <param name="y"> The y coordinate. </param>
 /// <param name="fontName"> Name of the font. </param>
 /// <param name="fontSize"> Size of the font. </param>
 /// <param name="fontColor"> The font color. </param>
 /// <param name="fontWeight"> The font weight. </param>
 internal static void DrawText(this ImageWand wand, string text, double x, double y, string fontName, double fontSize, PixelWand fontColor, FontWeightType fontWeight)
 {
     using (var draw = new DrawingWand())
     {
         using (fontColor)
         {
             draw.FillColor     = fontColor;
             draw.Font          = fontName;
             draw.FontSize      = fontSize;
             draw.FontWeight    = fontWeight;
             draw.TextAntialias = true;
             draw.DrawAnnotation(x, y, text);
             wand.DrawImage(draw);
         }
     }
 }