示例#1
0
        /// <summary>
        /// Returns the line spacing, in pixels, of this font. The line spacing is the vertical distance
        /// between the base lines of two consecutive lines of text. Thus, the line spacing includes the
        /// blank space between lines along with the height of the character itself.
        /// </summary>
        public double GetHeight()
        {
            double value = CellSpace * _emSize / UnitsPerEm;

#if CORE || NETFX_CORE || UWP
            return(value);
#endif
#if GDI && !WPF
#if DEBUG_
            double gdiValue = Font.GetHeight();
            Debug.Assert(DoubleUtil.AreRoughlyEqual(gdiValue, value, 5));
#endif
            return(value);
#endif
#if WPF && !GDI
            return(value);
#endif
#if WPF && GDI  // Testing only
            return(value);
#endif
#if __IOS__ || __ANDROID__
            return(value);
#endif
#if PORTABLE
            return(0);
#endif
        }
示例#2
0
        //// Methods
        //public Font(Font prototype, FontStyle newStyle);
        //public Font(FontFamily family, float emSize);
        //public Font(string familyName, float emSize);
        //public Font(FontFamily family, float emSize, FontStyle style);
        //public Font(FontFamily family, float emSize, GraphicsUnit unit);
        //public Font(string familyName, float emSize, FontStyle style);
        //public Font(string familyName, float emSize, GraphicsUnit unit);
        //public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit);
        //public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit);
        ////public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet);
        ////public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet);
        ////public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont);
        ////public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont);


        //public object Clone();
        //private static FontFamily CreateFontFamilyWithFallback(string familyName);

        //private void Dispose(bool disposing);
        //public override bool Equals(object obj);
        //protected override void Finalize();
        //public static Font FromHdc(IntPtr hdc);
        //public static Font FromHfont(IntPtr hfont);
        //public static Font FromLogFont(object lf);
        //public static Font FromLogFont(object lf, IntPtr hdc);
        //public override int GetHashCode();

        /// <summary>
        /// Returns the line spacing, in pixels, of this font. The line spacing is the vertical distance
        /// between the base lines of two consecutive lines of text. Thus, the line spacing includes the
        /// blank space between lines along with the height of the character itself.
        /// </summary>
        public double GetHeight()
        {
#if GDI
            RealizeGdiFont();
            double gdiValue = this.font.GetHeight();
#if DEBUG
            float myValue = (float)(this.cellSpace * this.emSize / this.unitsPerEm);
            //Debug.Assert(DoubleUtil.AreClose((float)value, myValue), "Check formula.");
            Debug.Assert(DoubleUtil.AreRoughlyEqual(gdiValue, myValue, 5), "Check formula.");

            //// 2355*(0.3/2048)*96 = 33.11719
            //double myValue = this.cellSpace * (this.size / 72 / this.unitsPerEm) * 96;
            //double myValue2 = (float)(this.cellSpace * (this.size / /*72 /*/ this.unitsPerEm) /* 72*/);
            //Int64 i1 = (Int64)(value * 1000 + .5);
            //Int64 i2 = (Int64)(myValue2 * 1000 + .5);
            //Debug.Assert(i1 == i2, "??");
#endif
            return(gdiValue);
#endif
#if WPF
            double value = this.cellSpace * this.emSize / this.unitsPerEm;
            return(value);
#endif
#if __IOS__
            double value = this.cellSpace * this.emSize / this.unitsPerEm;
            return(value);
#endif
        }