예제 #1
0
        //public string GetName(int language);

        /// <summary>
        /// Indicates whether the specified FontStyle enumeration is available.
        /// </summary>
        public bool IsStyleAvailable(XFontStyle style)
        {
            XGdiFontStyle xStyle = ((XGdiFontStyle)style) & XGdiFontStyle.BoldItalic;

#if CORE
            throw new InvalidOperationException("In CORE build it is the responsibility of the developer to provide all required font faces.");
#endif
#if GDI && !WPF
            if (GdiFamily != null)
            {
                return(GdiFamily.IsStyleAvailable((GdiFontStyle)xStyle));
            }
            return(false);
#endif
#if WPF && !GDI
            if (WpfFamily != null)
            {
                return(FontHelper.IsStyleAvailable(this, xStyle));
            }
            return(false);
#endif
#if WPF && GDI
#if DEBUG
            //bool gdiResult = _gdiFamily.IsStyle Available((FontStyle)style);
            //bool wpfResult = FontHelper.IsStyle Available(this, style);
            //// TODOWPF: check when fails
            //Debug.Assert(gdiResult == wpfResult, "GDI+ and WPF provide different values.");
#endif
            return(FontHelper.IsStyleAvailable(this, xStyle));
#endif
#if NETFX_CORE || UWP || DNC10
            throw new InvalidOperationException("In NETFX_CORE build it is the responsibility of the developer to provide all required font faces.");
#endif
        }
예제 #2
0
        //public string GetName(int language);

        /// <summary>
        /// Indicates whether the specified FontStyle enumeration is available.
        /// </summary>
        public bool IsStyleAvailable(XFontStyle style)
        {
            XGdiFontStyle xStyle = ((XGdiFontStyle)style) & XGdiFontStyle.BoldItalic;

#if CORE
            throw new InvalidOperationException("In CORE build it is the responsibility of the developer to provide all required font faces.");
#endif
#if GDI && !WPF
            if (GdiFamily != null)
            {
                return(GdiFamily.IsStyleAvailable((GdiFontStyle)xStyle));
            }
            return(false);
#endif
        }
예제 #3
0
        /// <summary>
        /// Determines whether the style is available as a glyph type face in the specified font family, i.e. the specified style is not simulated.
        /// </summary>
        public static bool IsStyleAvailable(XFontFamily family, XGdiFontStyle style)
        {
            style &= XGdiFontStyle.BoldItalic;
#if !SILVERLIGHT
            // TODOWPF: check for correctness
            // FontDescriptor descriptor = FontDescriptorCache.GetOrCreateDescriptor(family.Name, style);
            //XFontMetrics metrics = descriptor.FontMetrics;

            // style &= XFontStyle.Regular | XFontStyle.Bold | XFontStyle.Italic | XFontStyle.BoldItalic; // same as XFontStyle.BoldItalic
            List <WpfTypeface> typefaces = new List <WpfTypeface>(family.WpfFamily.GetTypefaces());
            foreach (WpfTypeface typeface in typefaces)
            {
                bool bold   = typeface.Weight == FontWeights.Bold;
                bool italic = typeface.Style == FontStyles.Italic;
                switch (style)
                {
                case XGdiFontStyle.Regular:
                    if (!bold && !italic)
                    {
                        return(true);
                    }
                    break;

                case XGdiFontStyle.Bold:
                    if (bold && !italic)
                    {
                        return(true);
                    }
                    break;

                case XGdiFontStyle.Italic:
                    if (!bold && italic)
                    {
                        return(true);
                    }
                    break;

                case XGdiFontStyle.BoldItalic:
                    if (bold && italic)
                    {
                        return(true);
                    }
                    break;
                }
                //////                typeface.sty
                //////                bool available = false;
                //////                GlyphTypeface glyphTypeface;
                //////                if (typeface.TryGetGlyphTypeface(out glyphTypeface))
                //////                {
                //////#if DEBUG_
                //////                    glyphTypeface.GetType();
                //////#endif
                //////                    available = true;
                //////                }
                //////                if (available)
                //////                    return true;
            }
            return(false);
#else
            return(true); // AGHACK
#endif
        }
예제 #4
0
        /// <summary>
        /// Determines whether the style is available as a glyph type face in the specified font family, i.e. the specified style is not simulated.
        /// </summary>
        public static bool IsStyleAvailable(XFontFamily family, XGdiFontStyle style)
        {
            style &= XGdiFontStyle.BoldItalic;
#if !SILVERLIGHT
            // TODOWPF: check for correctness
            // FontDescriptor descriptor = FontDescriptorCache.GetOrCreateDescriptor(family.Name, style);
            //XFontMetrics metrics = descriptor.FontMetrics;

            // style &= XFontStyle.Regular | XFontStyle.Bold | XFontStyle.Italic | XFontStyle.BoldItalic; // same as XFontStyle.BoldItalic
            List<WpfTypeface> typefaces = new List<WpfTypeface>(family.WpfFamily.GetTypefaces());
            foreach (WpfTypeface typeface in typefaces)
            {
                bool bold = typeface.Weight == FontWeights.Bold;
                bool italic = typeface.Style == FontStyles.Italic;
                switch (style)
                {
                    case XGdiFontStyle.Regular:
                        if (!bold && !italic)
                            return true;
                        break;

                    case XGdiFontStyle.Bold:
                        if (bold && !italic)
                            return true;
                        break;

                    case XGdiFontStyle.Italic:
                        if (!bold && italic)
                            return true;
                        break;

                    case XGdiFontStyle.BoldItalic:
                        if (bold && italic)
                            return true;
                        break;
                }
                //////                typeface.sty
                //////                bool available = false;
                //////                GlyphTypeface glyphTypeface;
                //////                if (typeface.TryGetGlyphTypeface(out glyphTypeface))
                //////                {
                //////#if DEBUG_
                //////                    glyphTypeface.GetType();
                //////#endif
                //////                    available = true;
                //////                }
                //////                if (available)
                //////                    return true;
            }
            return false;
#else
            return true; // AGHACK
#endif
        }
        //public string GetName(int language);

        /// <summary>
        /// Indicates whether the specified FontStyle enumeration is available.
        /// </summary>
        public bool IsStyleAvailable(XFontStyle style)
        {
            XGdiFontStyle xStyle = ((XGdiFontStyle)style) & XGdiFontStyle.BoldItalic;

            return(false);
        }