public static Gdi32Font GetPoolingFont(string faceName, FontSizeUnit fontSizeUnit, float size, Gdi32FontStyleInfo fontStyle, byte charSet, Gdi32FontQuality fontQuality)
        {
            lock (FontCache)
            {
                var key = Gdi32Font.ToFontCacheKey(faceName, fontSizeUnit, size, fontStyle, charSet, fontQuality);

                var font = new Gdi32Font(key);

                for (var node = FontCache.First; node != null; node = node.Next)
                {
                    if (node.Value.Key == key)
                    {
                        if (FontCache.First != node)
                        {
                            FontCache.Remove(node);
                            FontCache.AddFirst(node);
                        }

                        return(font);
                    }
                }

                FontCache.AddFirst(new FontCacheEntry(key, font));

                while (FontCache.Count > 20)
                {
                    var lastNode = FontCache.Last;
                    lastNode.Value.Font.Dispose();
                    FontCache.Remove(lastNode);
                }

                return(font);
            }
        }
示例#2
0
文件: Font.cs 项目: d5nguyenvan/xwt
        /// <summary>
        /// Creates a new font description from a string representation in the form "[FAMILY] [SIZE]"
        /// </summary>
        /// <returns>
        /// The new font
        /// </returns>
        /// <param name='name'>
        /// Font description
        /// </param>
        public static Font FromName(string name)
        {
            name = name.Trim();
            string[] parts = name.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length == 0)
            {
                throw new ArgumentException("Font family name not specified");
            }
            double       size = 0;
            FontSizeUnit unit = FontSizeUnit.Points;

            if (parts.Length > 1)
            {
                var s = parts[parts.Length - 1];
                if (s.EndsWith("px"))
                {
                    s    = s.Substring(0, s.Length - 2);
                    unit = FontSizeUnit.Pixels;
                }
                if (!double.TryParse(s, out size))
                {
                    throw new ArgumentException("Invalid font size: " + s);
                }
            }
            return(new Font(handler.Create(parts[0], size, unit, FontStyle.Normal, FontWeight.Normal, FontStretch.Normal)));
        }
示例#3
0
        public object SetSize(object handle, double size, FontSizeUnit sizeUnit)
        {
            NSFont f      = (NSFont)handle;
            var    matrix = f.FontDescriptor.Matrix ?? new NSAffineTransform();

            return(NSFont.FromDescription(f.FontDescriptor.FontDescriptorWithSize((float)size), matrix));
        }
示例#4
0
        internal static FontCacheKey ToFontCacheKey(string faceName, FontSizeUnit fontSizeUnit, float size, Gdi32FontStyleInfo fontStyle, byte charSet, Gdi32FontQuality fontQuality)
        {
            int height;

            switch (fontSizeUnit)
            {
            case FontSizeUnit.Pixel:
                height = (int)Math.Ceiling(size);
                break;

            case FontSizeUnit.DpiScaledPoint:
                throw new NotSupportedException();

            //height = (int)Math.Ceiling((double)((float)WindowsGraphicsCacheManager.MeasurementGraphics.DeviceContext.DpiY * size / 72f));
            //break;
            case FontSizeUnit.NonDpiScaledPoint:
                height = (int)Math.Ceiling(96.0 * size / 72.0);
                break;

            default:
                throw new ArgumentException(nameof(FontSizeUnit));
            }

            return(new FontCacheKey(faceName, height, fontStyle, charSet, fontQuality));
        }
示例#5
0
        public object SetSize(object handle, double size, FontSizeUnit sizeUnit)
        {
            var font = (FontData)handle;

            font      = font.Clone();
            font.Size = size;
            return(font);
        }
示例#6
0
 public static bool TryGetGlyphMetrics(string fontFaceName, string text, FontSizeUnit fontSizeUnit, float size, out GlyphMetrics glyphMetrics)
 {
     return(Gdi32FontPool.GetPoolingFont(
                faceName: fontFaceName,
                fontSizeUnit: fontSizeUnit,
                size: size,
                weight: FW_NORMAL,
                italic: 0,
                underline: 0,
                strikeOut: 0,
                charSet: 1,
                fontQuality: Gdi32FontQuality.Default
                ).TryGetGlyphMetrics(text, out glyphMetrics));
 }
示例#7
0
        public object SetSize(object handle, double size, FontSizeUnit sizeUnit)
        {
            FontDescription d = (FontDescription)handle;

            d = d.Copy();
            if (sizeUnit == FontSizeUnit.Points)
            {
                d.Size = (int)(size * Pango.Scale.PangoScale);
            }
            else
            {
                d.AbsoluteSize = (int)(size * Pango.Scale.PangoScale);
            }
            return(d);
        }
示例#8
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     Helper method to create a font for chart drawing.
        /// </summary>
        /// <param name="FontFamilyName">Font family name.</param>
        /// <param name="FontStyle">Font style.</param>
        /// <param name="FontSize">Font size per unit argument.</param>
        /// <param name="Unit">Font size unit.</param>
        /// <returns>.NET font</returns>
        ////////////////////////////////////////////////////////////////////
        public Font CreateFont
        (
            string FontFamilyName, // font family name
            FontStyle FontStyle,   // font style
            double FontSize,       // as per units below
            FontSizeUnit Unit      // unit of measure
        )
        {
            // calculate size
            var SizeInPixels = 0;

            switch (Unit)
            {
            case FontSizeUnit.Pixel:
                SizeInPixels = (int)(FontSize + 0.5);
                break;

            case FontSizeUnit.Point:
                SizeInPixels = (int)(FontSize * ImageControl.Resolution / 72.0 + 0.5);
                break;

            case FontSizeUnit.UserUnit:
                SizeInPixels = (int)(FontSize * ImageControl.Resolution * Document.ScaleFactor / 72.0 + 0.5);
                break;

            case FontSizeUnit.Inch:
                SizeInPixels = (int)(FontSize * ImageControl.Resolution + 0.5);
                break;

            case FontSizeUnit.cm:
                SizeInPixels = (int)(FontSize * ImageControl.Resolution / 2.54 + 0.5);
                break;

            case FontSizeUnit.mm:
                SizeInPixels = (int)(FontSize * ImageControl.Resolution / 25.4 + 0.5);
                break;
            }

            // create font
            return(new Font(FontFamilyName, SizeInPixels, FontStyle, GraphicsUnit.Pixel));
        }
示例#9
0
        public object Create(string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch)
        {
            string s = sizeUnit == FontSizeUnit.Points ? size.ToString() : size + "px";

            return(FontDescription.FromString(fontName + " " + s));
        }
示例#10
0
        public object Create(string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch)
        {
            object o = NSFont.FromFontName(fontName, (float)size);

            return(o);
        }
示例#11
0
        /// <summary>
        /// Compares two objects that implement ICardStyle.
        /// </summary>
        /// <param name="one">The first ICardStyle object one.</param>
        /// <param name="two">The second ICardStyle object.</param>
        /// <remarks>Documented by Dev03, 2008-09-26</remarks>
        private void CompareStyles(ICardStyle one, ICardStyle two)
        {
            if ((one == null) || (two == null))
            {
                Assert.IsTrue(IsEmptyStyle(one), "Both styles should be null! (one)");
                Assert.IsTrue(IsEmptyStyle(two), "Both styles should be null! (two)");
                return;
            }

            Type typeCardStyle = one.GetType();

            foreach (PropertyInfo property in typeCardStyle.GetProperties())
            {
                if (property.GetType().Equals(typeof(ITextStyle)))
                {
                    ITextStyle textStyleOne  = property.GetValue(one, null) as ITextStyle;
                    ITextStyle textStyleTwo  = property.GetValue(two, null) as ITextStyle;
                    Type       typeTextStyle = textStyleOne.GetType();
                    foreach (PropertyInfo prop in typeTextStyle.GetProperties())
                    {
                        if (prop.GetType().Equals(typeof(int)))
                        {
                            int valueOne = (int)prop.GetValue(textStyleOne, null);
                            int valueTwo = (int)prop.GetValue(textStyleTwo, null);
                            Assert.AreEqual(valueOne, valueOne, String.Format("Both values for {0} should be equal!", prop.Name));
                        }
                        else if (prop.GetType().Equals(typeof(string)))
                        {
                            string valueOne = (string)prop.GetValue(textStyleOne, null);
                            string valueTwo = (string)prop.GetValue(textStyleTwo, null);
                            Assert.AreEqual(valueOne, valueOne, String.Format("Both values for {0} should be equal!", prop.Name));
                        }
                        else if (prop.GetType().Equals(typeof(System.Drawing.Color)))
                        {
                            System.Drawing.Color valueOne = (System.Drawing.Color)prop.GetValue(textStyleOne, null);
                            System.Drawing.Color valueTwo = (System.Drawing.Color)prop.GetValue(textStyleTwo, null);
                            Assert.AreEqual(valueOne, valueOne, String.Format("Both values for {0} should be equal!", prop.Name));
                        }
                        else if (prop.GetType().Equals(typeof(System.Drawing.FontFamily)))
                        {
                            System.Drawing.FontFamily valueOne = (System.Drawing.FontFamily)prop.GetValue(textStyleOne, null);
                            System.Drawing.FontFamily valueTwo = (System.Drawing.FontFamily)prop.GetValue(textStyleTwo, null);
                            Assert.AreEqual(valueOne, valueOne, String.Format("Both values for {0} should be equal!", prop.Name));
                        }
                        else if (prop.GetType().Equals(typeof(FontSizeUnit)))
                        {
                            FontSizeUnit valueOne = (FontSizeUnit)prop.GetValue(textStyleOne, null);
                            FontSizeUnit valueTwo = (FontSizeUnit)prop.GetValue(textStyleTwo, null);
                            Assert.AreEqual(valueOne, valueOne, String.Format("Both values for {0} should be equal!", prop.Name));
                        }
                        else if (prop.GetType().Equals(typeof(CSSFontStyle)))
                        {
                            CSSFontStyle valueOne = (CSSFontStyle)prop.GetValue(textStyleOne, null);
                            CSSFontStyle valueTwo = (CSSFontStyle)prop.GetValue(textStyleTwo, null);
                            Assert.AreEqual(valueOne, valueOne, String.Format("Both values for {0} should be equal!", prop.Name));
                        }
                        else if (prop.GetType().Equals(typeof(HorizontalAlignment)))
                        {
                            HorizontalAlignment valueOne = (HorizontalAlignment)prop.GetValue(textStyleOne, null);
                            HorizontalAlignment valueTwo = (HorizontalAlignment)prop.GetValue(textStyleTwo, null);
                            Assert.AreEqual(valueOne, valueOne, String.Format("Both values for {0} should be equal!", prop.Name));
                        }
                        else if (prop.GetType().Equals(typeof(VerticalAlignment)))
                        {
                            VerticalAlignment valueOne = (VerticalAlignment)prop.GetValue(textStyleOne, null);
                            VerticalAlignment valueTwo = (VerticalAlignment)prop.GetValue(textStyleTwo, null);
                            Assert.AreEqual(valueOne, valueOne, String.Format("Both values for {0} should be equal!", prop.Name));
                        }
                        else if (prop.Name == "OtherElements")
                        {
                            SerializableDictionary <string, string> otherElementsOne = prop.GetValue(textStyleOne, null) as SerializableDictionary <string, string>;
                            SerializableDictionary <string, string> otherElementsTwo = prop.GetValue(textStyleTwo, null) as SerializableDictionary <string, string>;
                            foreach (string key in otherElementsOne.Keys)
                            {
                                Assert.IsTrue((otherElementsTwo.ContainsKey(key) && otherElementsOne[key].Equals(otherElementsTwo[key])), String.Format("Both values for {0}[{1}] should be equal!", prop.Name, key));
                            }
                        }
                    }
                }
            }
        }
示例#12
0
 public FontData(string family, double size, FontSizeUnit unit) :
     this(new FontFamily(family), size, unit)
 {
 }
示例#13
0
 public override object SetSize(object handle, double size, FontSizeUnit sizeUnit)
 {
     var font = (FontData)handle;
     font = font.Clone ();
     font.Size = size;
     return font;
 }
示例#14
0
 public FontData(string family, double size, FontSizeUnit unit)
     : this(new FontFamily (family), size, unit)
 {
 }
示例#15
0
 public object SetSize(object handle, double size, FontSizeUnit sizeUnit)
 {
     NSFont f = (NSFont) handle;
     return NSFont.FromDescription (f.FontDescriptor.FontDescriptorWithSize ((float)size), null);
 }
示例#16
0
 public override object Create(string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch)
 {
     string s = sizeUnit == FontSizeUnit.Points ? size.ToString () : size + "px";
     return FontDescription.FromString (fontName + " " + s);
 }
示例#17
0
 public static Gdi32Font GetPoolingFont(string faceName, FontSizeUnit fontSizeUnit, float size, int weight, byte italic, byte underline, byte strikeOut, byte charSet, Gdi32FontQuality fontQuality)
 {
     return(GetPoolingFont(faceName, fontSizeUnit, size, new Gdi32FontStyleInfo(weight, italic, underline, strikeOut), charSet, fontQuality));
 }
示例#18
0
 public override object SetSize(object handle, double size, FontSizeUnit sizeUnit)
 {
     NSFont f = (NSFont) handle;
     return NSFontManager.SharedFontManager.ConvertFont (f, (float)size);
 }
示例#19
0
文件: XmlCardStyle.cs 项目: hmehr/OSS
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
        /// <remarks>Documented by Dev05, 2007-10-29</remarks>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            bool wasEmpty = reader.IsEmptyElement;

            if (wasEmpty)
                return;

            Name = reader.GetAttribute("name");
            halign = (HorizontalAlignment)Helper.GetValue(typeof(HorizontalAlignment), reader.GetAttribute("hAlign"));
            valign = (VerticalAlignment)Helper.GetValue(typeof(VerticalAlignment), reader.GetAttribute("vAlign"));

            reader.Read();

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                switch (reader.Name)
                {
                    case "color":
                        try { forecolor = (Color)Helper.GetValue(typeof(Color), reader.GetAttribute("fore")); }
                        catch { }
                        try { backcolor = (Color)Helper.GetValue(typeof(Color), reader.GetAttribute("back")); }
                        catch { }
                        reader.Read();
                        break;
                    case "font":
                        try { fontSize = Convert.ToInt32(reader.GetAttribute("size")); }
                        catch { }
                        try { fontSizeUnit = (FontSizeUnit)Enum.Parse(typeof(FontSizeUnit), reader.GetAttribute("unit")); }
                        catch { }

                        reader.Read();

                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            switch (reader.Name)
                            {
                                case "font-family":
                                    string fontFamilyString = reader.ReadElementContentAsString();
                                    try { fontFamily = new FontFamily(fontFamilyString); } //[ML-1252] Missing FontFamily causes an ArgumentException
                                    catch { }
                                    break;
                                case "font-style":
                                    string fontStyleString = reader.ReadElementContentAsString();
                                    try { fontStyle = (CSSFontStyle)Enum.Parse(typeof(CSSFontStyle), fontStyleString); }
                                    catch { }
                                    break;
                            }
                        }
                        reader.Read();
                        break;
                    case "OtherElements":
                        otherElements = (SerializableDictionary<string, string>)otherElementsSerializer.Deserialize(reader);
                        break;
                    default:
                        reader.Read();
                        break;
                }
            }

            reader.Read();
        }
示例#20
0
 public override object SetSize(object handle, double size, FontSizeUnit sizeUnit)
 {
     FontDescription d = (FontDescription) handle;
     d = d.Copy ();
     if (sizeUnit == FontSizeUnit.Points)
         d.Size = (int) (size * Pango.Scale.PangoScale);
     else
         d.AbsoluteSize = (int) (size * Pango.Scale.PangoScale);
     return d;
 }
示例#21
0
        /// <summary>
        /// Determines whether [is empty style] [the specified style].
        /// </summary>
        /// <param name="style">The style.</param>
        /// <returns>
        ///     <c>true</c> if [is empty style] [the specified style]; otherwise, <c>false</c>.
        /// </returns>
        /// <remarks>Documented by Dev03, 2008-09-29</remarks>
        private bool IsEmptyStyle(ICardStyle style)
        {
            if (style == null)
            {
                return(true);
            }
            bool result = true;

            Type typeCardStyle = style.GetType();

            foreach (PropertyInfo property in typeCardStyle.GetProperties())
            {
                if (property.GetType().Equals(typeof(ITextStyle)))
                {
                    ITextStyle textStyle     = property.GetValue(style, null) as ITextStyle;
                    Type       typeTextStyle = textStyle.GetType();
                    foreach (PropertyInfo prop in typeTextStyle.GetProperties())
                    {
                        if (prop.GetType().Equals(typeof(int)))
                        {
                            int value = (int)prop.GetValue(textStyle, null);
                            result = result && (value == 0);
                        }
                        else if (prop.GetType().Equals(typeof(string)))
                        {
                            string value = (string)prop.GetValue(textStyle, null);
                            result = result && (value.Length == 0);
                        }
                        else if (prop.GetType().Equals(typeof(System.Drawing.Color)))
                        {
                            System.Drawing.Color value = (System.Drawing.Color)prop.GetValue(textStyle, null);
                            result = result && (value == System.Drawing.Color.Empty);
                        }
                        else if (prop.GetType().Equals(typeof(System.Drawing.FontFamily)))
                        {
                            System.Drawing.FontFamily value = (System.Drawing.FontFamily)prop.GetValue(textStyle, null);
                            result = result && (value == null);
                        }
                        else if (prop.GetType().Equals(typeof(FontSizeUnit)))
                        {
                            FontSizeUnit value = (FontSizeUnit)prop.GetValue(textStyle, null);
                            result = result && (value == FontSizeUnit.Pixel);
                        }
                        else if (prop.GetType().Equals(typeof(CSSFontStyle)))
                        {
                            CSSFontStyle value = (CSSFontStyle)prop.GetValue(textStyle, null);
                            result = result && (value == CSSFontStyle.None);
                        }
                        else if (prop.GetType().Equals(typeof(HorizontalAlignment)))
                        {
                            HorizontalAlignment value = (HorizontalAlignment)prop.GetValue(textStyle, null);
                            result = result && (value == HorizontalAlignment.None);
                        }
                        else if (prop.GetType().Equals(typeof(VerticalAlignment)))
                        {
                            VerticalAlignment value = (VerticalAlignment)prop.GetValue(textStyle, null);
                            result = result && (value == VerticalAlignment.None);
                        }
                        else if (prop.Name == "OtherElements")
                        {
                            SerializableDictionary <string, string> otherElements = prop.GetValue(textStyle, null) as SerializableDictionary <string, string>;
                            result = result && (otherElements.Count == 0);
                        }
                    }
                }
            }
            return(result);
        }
示例#22
0
文件: Font.cs 项目: garuma/xwt
        /// <summary>
        /// Creates a new font description from a string representation in the form "[FAMILY] [SIZE]"
        /// </summary>
        /// <returns>
        /// The new font
        /// </returns>
        /// <param name='name'>
        /// Font description
        /// </param>
        public static Font FromName(string name)
        {
            var toolkit = Toolkit.CurrentEngine;
            var handler = toolkit.FontBackendHandler;

            name = name.Trim ();
            if (name.Length == 0)
                throw new ArgumentException ("Font family name not specified");
            int sizeIndex = name.LastIndexOf (' ');
            double size = 0;
            FontSizeUnit unit = FontSizeUnit.Points;
            if (sizeIndex != -1) {
                var s = name.Substring (sizeIndex + 1);
                name = name.Substring (0, sizeIndex);
                if (s.EndsWith ("px")) {
                    s = s.Substring (0, s.Length - 2);
                    unit = FontSizeUnit.Pixels;
                }
                if (!double.TryParse (s, out size))
                    throw new ArgumentException ("Invalid font size: " + s);
            }
            return new Font (handler.Create (name, size, unit, FontStyle.Normal, FontWeight.Normal, FontStretch.Normal), toolkit);
        }
示例#23
0
 public FontData(FontFamily family, double size, FontSizeUnit unit)
 {
     Unit = unit;
     Family = family;
     Size = size;
 }
示例#24
0
 public object Create(string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch)
 {
     object o  = NSFont.FromFontName (fontName, (float)size);
     return o;
 }
示例#25
0
 public override object Create(string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch)
 {
     return new FontData (new FontFamily (fontName), size, sizeUnit);
 }
示例#26
0
 public abstract object SetSize(object handle, double size, FontSizeUnit unit);
示例#27
0
 public FontData(FontFamily family, double size, FontSizeUnit unit)
 {
     Unit   = unit;
     Family = family;
     Size   = size;
 }
示例#28
0
 public Gdi32Font(string faceName, FontSizeUnit fontSizeUnit, float size, int weight, byte italic, byte underline, byte strikeOut, byte charSet, Gdi32FontQuality fontQuality)
     : this(ToFontCacheKey(faceName, fontSizeUnit, size, new Gdi32FontStyleInfo(weight, italic, underline, strikeOut), charSet, fontQuality))
 {
 }
示例#29
0
 public object Create(string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch)
 {
     return(new FontData(new FontFamily(fontName), size, sizeUnit));
 }
示例#30
0
 /// <summary>
 /// Creates a new font description from a string representation in the form "[FAMILY] [SIZE]"
 /// </summary>
 /// <returns>
 /// The new font
 /// </returns>
 /// <param name='name'>
 /// Font description
 /// </param>
 public static Font FromName(string name)
 {
     name = name.Trim ();
     string[] parts = name.Split (new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
     if (parts.Length == 0)
         throw new ArgumentException ("Font family name not specified");
     double size = 0;
     FontSizeUnit unit = FontSizeUnit.Points;
     if (parts.Length > 1) {
         var s = parts[parts.Length - 1];
         if (s.EndsWith ("px")) {
             s = s.Substring (0, s.Length - 2);
             unit = FontSizeUnit.Pixels;
         }
         if (!double.TryParse (s, out size))
             throw new ArgumentException ("Invalid font size: " + s);
     }
     return new Font (handler.Create (parts[0], size, unit, FontStyle.Normal, FontWeight.Normal, FontStretch.Normal));
 }
示例#31
0
 public object SetSize(object handle, double size, FontSizeUnit sizeUnit)
 {
     NSFont f = (NSFont) handle;
     var matrix = f.FontDescriptor.Matrix ?? new NSAffineTransform ();
     return NSFont.FromDescription (f.FontDescriptor.FontDescriptorWithSize ((float)size), matrix);
 }
示例#32
0
 public Gdi32Font(string faceName, FontSizeUnit fontSizeUnit, float size, Gdi32FontStyleInfo fontStyle, byte charSet, Gdi32FontQuality fontQuality)
     : this(ToFontCacheKey(faceName, fontSizeUnit, size, fontStyle, charSet, fontQuality))
 {
 }
示例#33
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Helper method to create a font for chart drawing.
        /// </summary>
        /// <param name="FontFamilyName">Font family name.</param>
        /// <param name="FontStyle">Font style.</param>
        /// <param name="FontSize">Font size per unit argument.</param>
        /// <param name="Unit">Font size unit.</param>
        /// <returns>.NET font</returns>
        ////////////////////////////////////////////////////////////////////
        public Font CreateFont(
			String		FontFamilyName,	// font family name
			FontStyle	FontStyle,		// font style
			Double		FontSize,		// as per units below
			FontSizeUnit Unit			// unit of measure
			)
        {
            // calculate size
            Int32 SizeInPixels = 0;
            switch(Unit)
            {
            case FontSizeUnit.Pixel:
                SizeInPixels = (Int32) (FontSize + 0.5);
                break;

            case FontSizeUnit.Point:
                SizeInPixels = (Int32) (FontSize * Resolution / 72.0 + 0.5);
                break;

            case FontSizeUnit.UserUnit:
                SizeInPixels = (Int32) (FontSize * Resolution * Document.ScaleFactor / 72.0 + 0.5);
                break;

            case FontSizeUnit.Inch:
                SizeInPixels = (Int32) (FontSize * Resolution + 0.5);
                break;

            case FontSizeUnit.cm:
                SizeInPixels = (Int32) (FontSize * Resolution / 2.54 + 0.5);
                break;

            case FontSizeUnit.mm:
                SizeInPixels = (Int32) (FontSize * Resolution / 25.4 + 0.5);
                break;
            }

            // create font
            return(new Font(FontFamilyName, SizeInPixels, FontStyle, GraphicsUnit.Pixel));
        }
示例#34
0
 public abstract object Create(string fontName, double size, FontSizeUnit sizeUnit, FontStyle style, FontWeight weight, FontStretch stretch);