Exemple #1
0
        /// <summary>
        /// Constructs the composite font parser and parses the file.
        /// </summary>
        /// <param name="fileStream">File stream to parse.</param>
        private CompositeFontParser(Stream fileStream)
        {
            _compositeFontInfo = new CompositeFontInfo();

            _namespaceMap             = new Hashtable();
            _doubleTypeConverter      = TypeDescriptor.GetConverter(typeof(double));
            _xmlLanguageTypeConverter = new System.Windows.Markup.XmlLanguageConverter();

            _reader = CreateXmlReader(fileStream);

            try
            {
                if (IsStartElement(FontFamilyElement, CompositeFontNamespace))
                {
                    ParseFontFamilyElement();
                }
                else
                {
                    FailUnknownElement();
                }
            }
            catch (XmlException x)
            {
                FailNotWellFormed(x);
            }
            catch (XmlSyntaxException x)
            {
                FailNotWellFormed(x);
            }
            catch (FormatException x)
            {
                if (_reader.NodeType == XmlNodeType.Attribute)
                {
                    FailAttributeValue(x);
                }
                else
                {
                    Fail(x.Message, x);
                }
            }
            catch (ArgumentException x)
            {
                if (_reader.NodeType == XmlNodeType.Attribute)
                {
                    FailAttributeValue(x);
                }
                else
                {
                    Fail(x.Message, x);
                }
            }
            finally
            {
                _reader.Close();
                _reader = null;
            }
        }
        /// <summary>
        /// Constructs the composite font parser and parses the file.
        /// </summary>
        /// <param name="fileStream">File stream to parse.</param>
        private CompositeFontParser(Stream fileStream)
        {
            _compositeFontInfo = new CompositeFontInfo();

            _namespaceMap             = new Hashtable();
            _doubleTypeConverter      = TypeDescriptor.GetConverter(typeof(double));
            _xmlLanguageTypeConverter = new System.Windows.Markup.XmlLanguageConverter();

            _reader = CreateXmlReader(fileStream);

            try
            {
                if (IsStartElement(FontFamilyElement, CompositeFontNamespace))
                {
                    ParseFontFamilyElement();
                }
                // DevDiv:1158540
                // CompositeFont files have been modified to allow a family collection in order to select
                // a family based on OS versions.
                else if (IsStartElement(FontFamilyCollectionElement, CompositeFontNamespace))
                {
                    ParseFontFamilyCollectionElement();
                }
                else
                {
                    FailUnknownElement();
                }
            }
            catch (XmlException x)
            {
                FailNotWellFormed(x);
            }
            catch (Exception x) when(string.Equals(x.GetType().FullName, "System.Security.XmlSyntaxException", StringComparison.OrdinalIgnoreCase))
            {
                FailNotWellFormed(x);
            }
            catch (FormatException x)
            {
                if (_reader.NodeType == XmlNodeType.Attribute)
                {
                    FailAttributeValue(x);
                }
                else
                {
                    Fail(x.Message, x);
                }
            }
            catch (ArgumentException x)
            {
                if (_reader.NodeType == XmlNodeType.Attribute)
                {
                    FailAttributeValue(x);
                }
                else
                {
                    Fail(x.Message, x);
                }
            }
            finally
            {
                _reader.Close();
                _reader = null;
            }
        }
Exemple #3
0
 /// <summary>
 /// Construct a composite font family from composite font info
 /// </summary>
 internal CompositeFontFamily(CompositeFontInfo fontInfo)
 {
     _fontInfo = fontInfo;
 }
        /// <summary> 
        /// Constructs the composite font parser and parses the file.
        /// </summary> 
        /// <param name="fileStream">File stream to parse.</param>
        private CompositeFontParser(Stream fileStream)
        {
            _compositeFontInfo = new CompositeFontInfo(); 

            _namespaceMap = new Hashtable(); 
            _doubleTypeConverter = TypeDescriptor.GetConverter(typeof(double)); 
            _xmlLanguageTypeConverter = new System.Windows.Markup.XmlLanguageConverter();
 
            _reader = CreateXmlReader(fileStream);

            try
            { 
                if (IsStartElement(FontFamilyElement, CompositeFontNamespace))
                { 
                    ParseFontFamilyElement(); 
                }
                else 
                {
                    FailUnknownElement();
                }
            } 
            catch (XmlException x)
            { 
                FailNotWellFormed(x); 
            }
            catch (XmlSyntaxException x) 
            {
                FailNotWellFormed(x);
            }
            catch (FormatException x) 
            {
                if (_reader.NodeType == XmlNodeType.Attribute) 
                    FailAttributeValue(x); 
                else
                    Fail(x.Message, x); 
            }
            catch (ArgumentException x)
            {
                if (_reader.NodeType == XmlNodeType.Attribute) 
                    FailAttributeValue(x);
                else 
                    Fail(x.Message, x); 
            }
            finally 
            {
                _reader.Close();
                _reader = null;
            } 
        }