GlyphTypeface.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / GlyphTypeface.cs / 1407647 / GlyphTypeface.cs

                            //---------------------------------------------------------------------------- 
//
// 
//    Copyright (C) Microsoft Corporation.  All rights reserved.
//  
//
// 
// Description: GlyphTypeface implementation 
//
// History: 
//  06/04/2003 : mleonov - Moved GlyphTypeface from GlyphRun.cs
//  09/15/2008 : [....] - Changed GlyphTypeface to directly call methods
//                         in DWrite.Font and DWrite.FontFace rather than
//                         FontFaceLayoutInfo.cs. 
//
//--------------------------------------------------------------------------- 
using System; 
using System.Collections;
using System.Collections.Generic; 
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO; 
using System.Runtime.InteropServices;
using System.Security; 
using System.Security.Permissions; 

using System.Windows; 
using System.Windows.Media;
using System.Windows.Media.Composition;
using System.Windows.Media.TextFormatting;
using System.Windows.Markup; 

using MS.Internal; 
using MS.Internal.TextFormatting; 
using MS.Internal.FontCache;
using MS.Internal.FontFace; 
using MS.Internal.PresentationCore;
using UnsafeNativeMethods=MS.Win32.PresentationCore.UnsafeNativeMethods;

 
namespace System.Windows.Media
{ 
    ///  
    /// Physical font face corresponds to a font file on the disk
    ///  
    public class GlyphTypeface : ITypefaceMetrics, ISupportInitialize
    {
        //-----------------------------------------------------
        // 
        //  Constructors
        // 
        //----------------------------------------------------- 

        #region Constructors 

        /// 
        /// Creates an uninitialized GlyphTypeface object. Caller should call ISupportInitialize.BeginInit()
        /// to begin initializing the object and call ISupportInitialize.EndInit() to finish the initialization. 
        /// 
        public GlyphTypeface() 
        { 
        }
 
        /// 
        /// Creates a new GlyphTypeface object from a .otf, .ttf or .ttc font face specified by typefaceSource.
        /// The constructed GlyphTypeface does not use style simulations.
        ///  
        /// Specifies the URI of a font file used by the newly created GlyphTypeface.
        public GlyphTypeface(Uri typefaceSource) : this(typefaceSource, StyleSimulations.None) 
        {} 

        ///  
        /// Creates a new GlyphTypeface object from a .otf, .ttf or .ttc font face specified by typefaceSource.
        /// The constructed GlyphTypeface uses style simulations specified by styleSimulations parameter.
        /// 
        /// Specifies the URI of a font file used by the newly created GlyphTypeface. 
        /// Specifies style simulations to be applied to the newly created GlyphTypeface.
        public GlyphTypeface(Uri typefaceSource, StyleSimulations styleSimulations) 
        { 
            Initialize(typefaceSource, styleSimulations);
        } 

        /// 
        /// Creates a new GlyphTypeface object from a DWrite.Font object.
        ///  
        /// The DWrite.Font object.
        ///  
        /// Critical - as the instance of GlyphTypeface created with this constructor can 
        ///            expose font information.
        ///  
        [SecurityCritical]
        internal GlyphTypeface(MS.Internal.Text.TextInterface.Font font)
        {
            StyleSimulations styleSimulations = (StyleSimulations)font.SimulationFlags; 
            _font = font;
 
            string uriPath; 

            MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = _font.GetFontFace(); 
            try
            {
                using (MS.Internal.Text.TextInterface.FontFile fontFile = fontFaceDWrite.GetFileZero())
                { 
                    uriPath = fontFile.GetUriPath();
                } 
 
                // store the original Uri that contains the face index
                _originalUri = new SecurityCriticalDataClass(Util.CombineUriWithFaceIndex(uriPath, checked((int)fontFaceDWrite.Index))); 
            }
            finally
            {
                fontFaceDWrite.Release(); 
            }
 
            Uri typefaceSource = new Uri(uriPath); 
            _fileIOPermObj = new SecurityCriticalDataForSet(
                SecurityHelper.CreateUriReadPermission(typefaceSource) 
                );

            _fontFace = new FontFaceLayoutInfo(font);
            // We skip permission demands for FontSource because the above line already demands them for the right callers. 
            _fontSource = new FontSource(typefaceSource, true);
 
            Invariant.Assert(  styleSimulations == StyleSimulations.None 
                            || styleSimulations == StyleSimulations.ItalicSimulation
                            || styleSimulations == StyleSimulations.BoldSimulation 
                            || styleSimulations == StyleSimulations.BoldItalicSimulation);

            _styleSimulations = styleSimulations;
 
            _initializationState = InitializationState.IsInitialized; // fully initialized
        } 
 
        /// 
        /// Critical - this method calls into other critical method. 
        /// TreatAsSafe - Demands Uri read permission for the fonts Uri
        /// 
        [SecurityCritical, SecurityTreatAsSafe]
        private void Initialize(Uri typefaceSource, StyleSimulations styleSimulations) 
        {
            if (typefaceSource == null) 
                throw new ArgumentNullException("typefaceSource"); 

            if (!typefaceSource.IsAbsoluteUri) 
                throw new ArgumentException(SR.Get(SRID.UriNotAbsolute), "typefaceSource");

            // remember the original Uri that contains face index
            _originalUri = new SecurityCriticalDataClass(typefaceSource); 

            // split the Uri into the font source Uri and face index 
            Uri fontSourceUri; 
            int faceIndex;
            Util.SplitFontFaceIndex(typefaceSource, out fontSourceUri, out faceIndex); 

            _fileIOPermObj = new SecurityCriticalDataForSet(
                SecurityHelper.CreateUriReadPermission(fontSourceUri)
                ); 

            // This permission demand is here so that untrusted callers are unable to check for file existence using GlyphTypeface ctor. 
            // Sensitive font data is protected by demands as the user tries to access it. 
            DemandPermissionsForFontInformation();
 
            if (   styleSimulations != StyleSimulations.None
                && styleSimulations != StyleSimulations.ItalicSimulation
                && styleSimulations != StyleSimulations.BoldSimulation
                && styleSimulations != StyleSimulations.BoldItalicSimulation) 
            {
                throw new InvalidEnumArgumentException("styleSimulations", (int)styleSimulations, typeof(StyleSimulations)); 
            } 

            _styleSimulations = styleSimulations; 

            MS.Internal.Text.TextInterface.FontCollection fontCollection = DWriteFactory.GetFontCollectionFromFile(fontSourceUri);
            using (MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = DWriteFactory.Instance.CreateFontFace(fontSourceUri,
                                                                                                                  (uint)faceIndex, 
                                                                                                                  (MS.Internal.Text.TextInterface.FontSimulations)styleSimulations))
            { 
                // This is the same behavior as 3.*. If we pass, for example, a path to a composite font file then a 
                // FileFormatException will be thrown!
                if (fontFaceDWrite == null) 
                {
                    try
                    {
                        SecurityHelper.DemandUriDiscoveryPermission(typefaceSource); 
                        throw new System.IO.FileFormatException(typefaceSource);
                    } 
                    catch(SecurityException) 
                    {
                        throw new System.IO.FileFormatException(); 
                    }
                }
                _font = fontCollection.GetFontFromFontFace(fontFaceDWrite);
            } 

            _fontFace = new FontFaceLayoutInfo(_font); 
 
            // We skip permission demands for FontSource because the above line already demands them for the right callers.
            _fontSource = new FontSource(fontSourceUri, true); 


            _initializationState = InitializationState.IsInitialized; // fully initialized
        } 

        #endregion Constructors 
 
        //------------------------------------------------------
        // 
        //  Public Methods
        //
        //-----------------------------------------------------
 
        #region Public Methods
 
        ///  
        /// Return hash code for this GlyphTypeface.
        ///  
        /// Hash code.
        /// 
        /// Critical - as this accesses _originalUri.
        /// Safe - as this only does this to compute the hash code. 
        /// 
        [SecurityCritical] 
        public override int GetHashCode() 
        {
            CheckInitialized(); 
            return _originalUri.Value.GetHashCode() ^ (int)StyleSimulations;
        }

        ///  
        /// Compares this GlyphTypeface with another object.
        ///  
        /// Object to compare with. 
        /// Whether this object is equal to the input object.
        ///  
        /// Critical - as this accesses _originalUri.
        /// Safe - as this only does this to perform a comparison with another object.
        /// 
        [SecurityCritical] 
        public override bool Equals(object o)
        { 
            CheckInitialized(); 
            GlyphTypeface t = o as GlyphTypeface;
            if (t == null) 
                return false;

            return StyleSimulations == t.StyleSimulations
                && _originalUri.Value == t._originalUri.Value; 
        }
 
        ///  
        /// Returns a geometry describing the path for a single glyph in the font.
        /// The path represents the glyph 
        /// without grid fitting applied for rendering at a specific resolution.
        /// 
        /// Index of the glyph to get outline for.
        /// Font size in drawing surface units. 
        /// Size to hint for in points.
        ///  
        [CLSCompliant(false)] 
        public Geometry GetGlyphOutline(ushort glyphIndex, double renderingEmSize, double hintingEmSize)
        { 
            CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
            // NOTE: This parameter is unused, and should be deleted. Not worth a breaking change just for this though.
            return ComputeGlyphOutline(glyphIndex, false, renderingEmSize);
        } 

        ///  
        /// Returns the binary image of font subset. 
        /// 
        /// Collection of glyph indices to be included into the subset. 
        /// Binary image of font subset.
        /// 
        ///     Callers must have UnmanagedCode permission to call this API.
        ///     Callers must have FileIOPermission or WebPermission to font location to call this API. 
        /// 
        ///  
        ///     Critical - returns raw font data. 
        ///     Safe - (1) unmanaged code demand.  This ensures PT callers can't directly access the TrueType subsetter in V1.
        ///            (2) fileIO or web permission demand for location of font.  This ensures that even brokered access 
        ///                    via print dialog (which asserts unmanaged code) only succeeds if user has access to font source location.
        /// 
        [SecurityCritical]
        [CLSCompliant(false)] 
        public byte[] ComputeSubset(ICollection glyphs)
        { 
            SecurityHelper.DemandUnmanagedCode(); 
            DemandPermissionsForFontInformation();
            CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 

            if (glyphs == null)
                throw new ArgumentNullException("glyphs");
 
            if (glyphs.Count <= 0)
                throw new ArgumentException(SR.Get(SRID.CollectionNumberOfElementsMustBeGreaterThanZero), "glyphs"); 
 
            if (glyphs.Count > ushort.MaxValue)
                throw new ArgumentException(SR.Get(SRID.CollectionNumberOfElementsMustBeLessOrEqualTo, ushort.MaxValue), "glyphs"); 

            UnmanagedMemoryStream pinnedFontSource = FontSource.GetUnmanagedStream();

            try 
            {
                TrueTypeFontDriver trueTypeDriver = new TrueTypeFontDriver(pinnedFontSource, _originalUri.Value); 
                trueTypeDriver.SetFace(FaceIndex); 

                return trueTypeDriver.ComputeFontSubset(glyphs); 
            }
            catch (SEHException e)
            {
                throw Util.ConvertInPageException(FontSource, e); 
            }
            finally 
            { 
                pinnedFontSource.Close();
            } 
        }

        /// 
        /// Returns a font file stream represented by this GlyphTypeface. 
        /// 
        /// A font file stream represented by this GlyphTypeface. 
        ///  
        ///     Critical - returns raw font data.
        ///     Safe - does a demand before it gives out the information asked. 
        /// 
        [SecurityCritical]
        public Stream GetFontStream()
        { 
            CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
            DemandPermissionsForFontInformation(); 
            return FontSource.GetStream(); 
        }
 
        /// 
        /// Exposed to allow printing code to access GetFontStream() in partial trust
        /// 
        ///  
        ///     Critical - returns a permission allowing access to GetFontStream in partial trust.
        ///                Caller must make sure there is no font data leak 
        ///  
        [FriendAccessAllowed]
        internal CodeAccessPermission CriticalFileReadPermission 
        {
            [SecurityCritical]
            get
            { 
                CheckInitialized();
                return _fileIOPermObj.Value; 
            } 
        }
 
        /// 
        /// Exposed to allow printing code to access FontUri in partial trust
        /// 
        ///  
        ///     Critical - returns a permission allowing access to FontUri
        ///                Caller must make sure there is no data leak 
        ///  
        [FriendAccessAllowed]
        internal CodeAccessPermission CriticalUriDiscoveryPermission 
        {
            [SecurityCritical]
            get
            { 
                CheckInitialized();
                return SecurityHelper.CreateUriDiscoveryPermission(_originalUri.Value); 
            } 
        }
 
        #endregion Public Methods

        //------------------------------------------------------
        // 
        //  Public Properties
        // 
        //------------------------------------------------------ 

        #region Public Properties 

        /// 
        /// Returns the original Uri of this glyph typeface object.
        ///  
        /// The Uri glyph typeface was constructed with.
        ///  
        ///     Callers must have FileIOPermission(FileIOPermissionAccess.PathDiscovery) for the given Uri to call this API. 
        /// 
        ///  
        /// Critical - as this obtains Uri that can reveal local file system information.
        /// Safe - as this does a discovery demand before it gives out the information asked.
        /// 
        public Uri FontUri 
        {
            [SecurityCritical] 
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                SecurityHelper.DemandUriDiscoveryPermission(_originalUri.Value);
                return _originalUri.Value;
            }
            [SecurityCritical] 
            set
            { 
                CheckInitializing(); // This can only be called in initialization 

                if (value == null) 
                    throw new ArgumentNullException("value");

                if (!value.IsAbsoluteUri)
                    throw new ArgumentException(SR.Get(SRID.UriNotAbsolute), "value"); 

                _originalUri = new SecurityCriticalDataClass(value); 
            } 
        }
 
        /// 
        /// This property is indexed by a Culture Identifier.
        /// It returns the family name in the specified language, or,
        /// if the font does not provide a name for the specified language, 
        /// it returns the family name in English.
        /// The family name excludes weight, style and stretch. 
        ///  
        /// 
        /// Critical - calls into critical DWrite.Font methods 
        /// TreatAsSafe - it is safe to expose the localized family names.
        /// 
        public IDictionary FamilyNames
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                MS.Internal.Text.TextInterface.LocalizedStrings localizedStrings; 
                if (
                   _font.GetInformationalStrings(MS.Internal.Text.TextInterface.InformationalStringID.PreferredFamilyNames, out localizedStrings)
                   ||
                   _font.GetInformationalStrings(MS.Internal.Text.TextInterface.InformationalStringID.WIN32FamilyNames, out localizedStrings) 
                   )
                { 
                    return localizedStrings; 
                }
                else 
                {
                    return null;
                }
            } 
        }
 
        ///  
        /// This property is indexed by a Culture Identifier.
        /// It returns the face name in the specified language, or, 
        /// if the font does not provide a name for the specified language,
        /// it returns the face name in English.
        /// The face name may identify weight, style and/or stretch.
        ///  
        /// 
        /// Critical - calls into critical DWrite.Font methods 
        /// TreatAsSafe - it is safe to expose the localized face names. 
        /// 
        public IDictionary FaceNames 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                MS.Internal.Text.TextInterface.LocalizedStrings localizedStrings; 
                if ( 
                   _font.GetInformationalStrings(MS.Internal.Text.TextInterface.InformationalStringID.PreferredSubFamilyNames, out localizedStrings)
                   || 
                   _font.GetInformationalStrings(MS.Internal.Text.TextInterface.InformationalStringID.Win32SubFamilyNames, out localizedStrings)
                   )
                {
                    return localizedStrings; 
                }
                else 
                { 
                    return null;
                } 
            }
        }

        ///  
        /// This property is indexed by a Culture Identifier.
        /// It returns the family name in the specified language, or, 
        /// if the font does not provide a name for the specified language, 
        /// it returns the family name in English.
        /// The Win32FamilyName name excludes regular or bold weights and style, 
        /// but includes other weights and stretch.
        /// 
        public IDictionary Win32FamilyNames
        { 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.WIN32FamilyNames);
            } 
        }

        /// 
        /// This property is indexed by a Culture Identifier. 
        /// It returns the face name in the specified language, or,
        /// if the font does not provide a name for the specified language, 
        /// it returns the face name in English. 
        /// The face name may identify weight, style and/or stretch.
        ///  
        /// 
        /// Critical - calls into critical DWrite.Font methods
        /// TreatAsSafe - it is safe to expose the localized face names for a font.
        ///  
        IDictionary ITypefaceMetrics.AdjustedFaceNames
        { 
            [SecurityCritical, SecurityTreatAsSafe] 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface

                IDictionary adjustedFaceNames = _font.FaceNames;
                IDictionary adjustedLanguageFaceNames = new Dictionary(adjustedFaceNames.Count); 

                foreach (KeyValuePair pair in adjustedFaceNames) 
                { 
                    adjustedLanguageFaceNames[XmlLanguage.GetLanguage(pair.Key.IetfLanguageTag)] = pair.Value;
                } 

                return adjustedLanguageFaceNames;
            }
        } 

        ///  
        /// This property is indexed by a Culture Identifier. 
        /// It returns the face name in the specified language, or,
        /// if the font does not provide a name for the specified language, 
        /// it returns the face name in English.
        /// The Win32Face name may identify weights other than regular or bold and/or style,
        /// but may not identify stretch or other weights.
        ///  
        public IDictionary Win32FaceNames
        { 
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.Win32SubFamilyNames);
            }
        }
 
        /// 
        /// This property is indexed by a Culture Identifier. 
        /// Version string in the fonts NAME table. 
        /// Version strings vary significantly in format - to obtain the version
        /// as a numeric value use the 'Version' property, 
        /// do not attempt to parse the VersionString.
        /// 
        /// 
        /// Critical - as this accesses _fontFace which can reveal Windows font information. 
        /// Safe - as this does a demand before it gives out the information asked.
        ///  
        public IDictionary VersionStrings 
        {
            [SecurityCritical] 
            get
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                DemandPermissionsForFontInformation(); 
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.VersionStrings);
            } 
        } 

        ///  
        /// This property is indexed by a Culture Identifier.
        /// Copyright notice.
        /// 
        ///  
        /// Critical - as this accesses _fontFace which can reveal Windows font information.
        /// Safe - as this does a demand before it gives out the information asked. 
        ///  
        public IDictionary Copyrights
        { 
            [SecurityCritical]
            get
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                DemandPermissionsForFontInformation();
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.CopyrightNotice); 
            } 
        }
 
        /// 
        /// This property is indexed by a Culture Identifier.
        /// Manufacturer Name.
        ///  
        /// 
        /// Critical - as this accesses _fontFace which can reveal Windows font information. 
        /// Safe - as this does a demand before it gives out the information asked. 
        /// 
        public IDictionary ManufacturerNames 
        {
            [SecurityCritical]
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                DemandPermissionsForFontInformation(); 
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.Manufacturer); 
            }
        } 

        /// 
        /// This property is indexed by a Culture Identifier.
        /// This is used to save any trademark notice/information for this font. 
        /// Such information should be based on legal advice.
        /// This is distinctly separate from the copyright. 
        ///  
        /// 
        /// Critical - as this accesses _fontFace which can reveal Windows font information. 
        /// Safe - as this does a demand before it gives out the information asked.
        /// 
        public IDictionary Trademarks
        { 
            [SecurityCritical]
            get 
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                DemandPermissionsForFontInformation(); 
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.Trademark);
            }
        }
 
        /// 
        /// This property is indexed by a Culture Identifier. 
        /// Name of the designer of the typeface. 
        /// 
        ///  
        /// Critical - as this accesses _fontFace which can reveal Windows font information.
        /// Safe - as this does a demand before it gives out the information asked.
        /// 
        public IDictionary DesignerNames 
        {
            [SecurityCritical] 
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                DemandPermissionsForFontInformation();
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.Designer);
            }
        } 

        ///  
        /// This property is indexed by a Culture Identifier. 
        /// Description of the typeface. Can contain revision information,
        /// usage recommendations, history, features, etc. 
        /// 
        /// 
        /// Critical - as this accesses _fontFace which can reveal Windows font information.
        /// Safe - as this does a demand before it gives out the information asked. 
        /// 
        public IDictionary Descriptions 
        { 
            [SecurityCritical]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                DemandPermissionsForFontInformation();
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.Description); 
            }
        } 
 
        /// 
        /// This property is indexed by a Culture Identifier. 
        /// URL of font vendor (with protocol, e.g., `http://, `ftp://).
        /// If a unique serial number is embedded in the URL,
        /// it can be used to register the font.
        ///  
        /// 
        /// Critical - as this accesses _fontFace which can reveal Windows font information. 
        /// Safe - as this does a demand before it gives out the information asked. 
        /// 
        public IDictionary VendorUrls 
        {
            [SecurityCritical]
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                DemandPermissionsForFontInformation(); 
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.FontVendorURL); 
            }
        } 

        /// 
        /// This property is indexed by a Culture Identifier.
        /// URL of typeface designer (with protocol, e.g., `http://, `ftp://). 
        /// 
        ///  
        /// Critical - as this accesses _fontFace which can reveal Windows font information. 
        /// Safe - as this does a demand before it gives out the information asked.
        ///  
        public IDictionary DesignerUrls
        {
            [SecurityCritical]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                DemandPermissionsForFontInformation(); 
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.DesignerURL);
            } 
        }

        /// 
        /// This property is indexed by a Culture Identifier. 
        /// Description of how the font may be legally used,
        /// or different example scenarios for licensed use. 
        /// This field should be written in plain language, not legalese. 
        /// 
        ///  
        /// Critical - as this accesses _fontFace which can reveal Windows font information.
        /// Safe - as this does a demand before it gives out the information asked.
        /// 
        public IDictionary LicenseDescriptions 
        {
            [SecurityCritical] 
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                DemandPermissionsForFontInformation();
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.LicenseDescription);
            }
        } 

        ///  
        /// This property is indexed by a Culture Identifier. 
        /// This can be the font name, or any other text that the designer
        /// thinks is the best sample to display the font in. 
        /// 
        /// 
        /// Critical - as this accesses _fontFace which can reveal Windows font information.
        /// Safe - as this does a demand before it gives out the information asked. 
        /// 
        public IDictionary SampleTexts 
        { 
            [SecurityCritical]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                DemandPermissionsForFontInformation();
                return GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID.SampleText); 
            }
        } 
 
        /// 
        /// Returns designed style (regular/italic/oblique) of this font face 
        /// 
        /// Designed style of this font face.
        /// 
        /// Critical - this accesses critical DWrite.Font properties. 
        /// TreatAsSafe - this data is safe to expose.
        ///  
        public FontStyle Style 
        {
            [SecurityCritical, SecurityTreatAsSafe] 
            get
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return new FontStyle((int)_font.Style); 
            }
        } 
 
        /// 
        /// Returns designed weight of this font face. 
        /// 
        /// Designed weight of this font face.
        /// 
        /// Critical - this accesses critical DWrite.Font properties. 
        /// TreatAsSafe - this data is safe to expose.
        ///  
        public FontWeight Weight 
        {
            [SecurityCritical, SecurityTreatAsSafe] 
            get
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return new FontWeight((int)_font.Weight); 
            }
        } 
 
        /// 
        /// Returns designed stretch of this font face. 
        /// 
        /// Designed stretch of this font face.
        /// 
        /// Critical - this accesses critical DWrite.Font properties. 
        /// TreatAsSafe - this data is safe to expose.
        ///  
        public FontStretch Stretch 
        {
            [SecurityCritical, SecurityTreatAsSafe] 
            get
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return new FontStretch((int)_font.Stretch); 
            }
        } 
 
        /// 
        /// Font face version interpreted from the font's 'NAME' table. 
        /// 
        /// 
        /// Critical - as this accesses _fontFace which can reveal Windows font information.
        /// Safe - as this does a demand before it gives out the information asked. 
        /// 
        public double Version 
        { 
            [SecurityCritical]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                DemandPermissionsForFontInformation();
                return _font.Version; 
            }
        } 
 
        /// 
        /// Height of character cell relative to em size. 
        /// 
        /// 
        /// Critical - this accesses critical DWrite.Font properties.
        /// TreatAsSafe - this data is safe to expose. 
        /// 
        public double Height 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return (double)(_font.Metrics.Ascent + _font.Metrics.Descent) / _font.Metrics.DesignUnitsPerEm;
            } 
        }
 
        ///  
        /// Distance from cell top to English baseline relative to em size.
        ///  
        /// 
        /// Critical - this accesses critical DWrite.Font properties.
        /// TreatAsSafe - this data is safe to expose.
        ///  
        public double Baseline
        { 
            [SecurityCritical, SecurityTreatAsSafe] 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return (double)_font.Metrics.Ascent / _font.Metrics.DesignUnitsPerEm;
            }
        } 

        ///  
        /// Distance from baseline to top of English ----, relative to em size. 
        /// 
        ///  
        /// Critical - this accesses critical DWrite.Font properties.
        /// TreatAsSafe - this data is safe to expose.
        /// 
        public double CapsHeight 
        {
            [SecurityCritical, SecurityTreatAsSafe] 
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return (double)_font.Metrics.CapHeight / _font.Metrics.DesignUnitsPerEm;
            }
        }
 
        /// 
        /// Western x-height relative to em size. 
        ///  
        /// 
        /// Critical - this accesses critical DWrite.Font properties. 
        /// TreatAsSafe - this data is safe to expose.
        /// 
        public double XHeight
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return (double)_font.Metrics.XHeight / _font.Metrics.DesignUnitsPerEm; 
            }
        }

        ///  
        /// Returns true if this font does not conform to Unicode encoding:
        /// it may be considered as a simple collection of symbols indexed by a codepoint. 
        ///  
        /// 
        /// Critical - this accesses critical DWrite.Font properties. 
        /// TreatAsSafe - this data is safe to expose.
        /// 
        public bool Symbol
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return _font.IsSymbolFont; 
            }
        }

        ///  
        /// Position of underline relative to baseline relative to em size.
        /// The value is usually negative, to place the underline below the baseline. 
        ///  
        /// 
        /// Critical - this accesses critical DWrite.Font properties. 
        /// TreatAsSafe - this data is safe to expose.
        /// 
        public double UnderlinePosition
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return (double)_font.Metrics.UnderlinePosition / _font.Metrics.DesignUnitsPerEm; 
            }
        }

        ///  
        /// Thickness of underline relative to em size.
        ///  
        ///  
        /// Critical - this accesses critical DWrite.Font properties.
        /// TreatAsSafe - this data is safe to expose. 
        /// 
        public double UnderlineThickness
        {
            [SecurityCritical, SecurityTreatAsSafe] 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return (double)_font.Metrics.UnderlineThickness / _font.Metrics.DesignUnitsPerEm;
            } 
        }

        /// 
        /// Position of strikeThrough relative to baseline relative to em size. 
        /// The value is usually positive, to place the Strikethrough above the baseline.
        ///  
        ///  
        /// Critical - this accesses critical DWrite.Font properties.
        /// TreatAsSafe - this data is safe to expose. 
        /// 
        public double StrikethroughPosition
        {
            [SecurityCritical, SecurityTreatAsSafe] 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return (double)_font.Metrics.StrikethroughPosition / _font.Metrics.DesignUnitsPerEm;
            } 
        }

        /// 
        /// Thickness of Strikethrough relative to em size. 
        /// 
        ///  
        /// Critical - this accesses critical DWrite.Font properties. 
        /// TreatAsSafe - this data is safe to expose.
        ///  
        public double StrikethroughThickness
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return (double)_font.Metrics.StrikethroughThickness / _font.Metrics.DesignUnitsPerEm; 
            }
        } 

        /// 
        /// EmbeddingRights property describes font embedding permissions
        /// specified in this glyph typeface. 
        /// 
        ///  
        /// Critical - as this accesses _fontFace which can reveal Windows font information. 
        /// Safe - as this does a demand before it gives out the information asked.
        ///  
        public FontEmbeddingRight EmbeddingRights
        {
            [SecurityCritical]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                DemandPermissionsForFontInformation(); 
                return _fontFace.EmbeddingRights;
            } 
        }

        #region ITypefaceMetrics implementation
 
        /// 
        /// Distance from baseline to top of English ----, relative to em size. 
        ///  
        double ITypefaceMetrics.CapsHeight
        { 
            get
            {
                return CapsHeight;
            } 
        }
 
        ///  
        /// Western x-height relative to em size.
        ///  
        double ITypefaceMetrics.XHeight
        {
            get
            { 
                return XHeight;
            } 
        } 

        ///  
        /// Returns true if this font does not conform to Unicode encoding:
        /// it may be considered as a simple collection of symbols indexed by a codepoint.
        /// 
        bool ITypefaceMetrics.Symbol 
        {
            get 
            { 
                return Symbol;
            } 
        }

        /// 
        /// Position of underline relative to baseline relative to em size. 
        /// The value is usually negative, to place the underline below the baseline.
        ///  
        double ITypefaceMetrics.UnderlinePosition 
        {
            get 
            {
                return UnderlinePosition;
            }
        } 

        ///  
        /// Thickness of underline relative to em size. 
        /// 
        double ITypefaceMetrics.UnderlineThickness 
        {
            get
            {
                return UnderlineThickness; 
            }
        } 
 
        /// 
        /// Position of strikeThrough relative to baseline relative to em size. 
        /// The value is usually positive, to place the Strikethrough above the baseline.
        /// 
        double ITypefaceMetrics.StrikethroughPosition
        { 
            get
            { 
                return StrikethroughPosition; 
            }
        } 

        /// 
        /// Thickness of Strikethrough relative to em size.
        ///  
        double ITypefaceMetrics.StrikethroughThickness
        { 
            get 
            {
                return StrikethroughThickness; 
            }
        }

        #endregion 

 
        // The next several properties return non CLS-compliant types.  This is 
        // tracked by bug 1792236.  For now, suppress the compiler warning.
        // 
        #pragma warning disable 3003

        /// 
        /// Returns advance width for a given glyph. 
        /// 
        public IDictionary AdvanceWidths 
        { 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return CreateGlyphIndexer(this.GetAdvanceWidth);
            }
        } 

        ///  
        /// Returns Advance height for a given glyph (Used for example in vertical layout). 
        /// 
        public IDictionary AdvanceHeights 
        {
            get
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return CreateGlyphIndexer(this.GetAdvanceHeight);
            } 
        } 

        ///  
        /// Distance from leading end of advance vector to left edge of black box.
        /// Positive when left edge of black box is within the alignment rectangle
        /// defined by the advance width and font cell height.
        /// Negative when left edge of black box overhangs the alignment rectangle. 
        /// 
        public IDictionary LeftSideBearings 
        { 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return CreateGlyphIndexer(this.GetLeftSidebearing);
            }
        } 

        ///  
        /// Distance from right edge of black box to right end of advance vector. 
        /// Positive when trailing edge of black box is within the alignment rectangle
        /// defined by the advance width and font cell height. 
        /// Negative when right edge of black box overhangs the alignment rectangle.
        /// 
        public IDictionary RightSideBearings
        { 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return CreateGlyphIndexer(this.GetRightSidebearing);
            } 
        }

        /// 
        /// Distance from top end of (vertical) advance vector to top edge of black box. 
        /// Positive when top edge of black box is within the alignment rectangle
        /// defined by the advance height and font cell height. 
        /// (The font cell height is a horizontal dimension in vertical layout). 
        /// Negative when top edge of black box overhangs the alignment rectangle.
        ///  
        public IDictionary TopSideBearings
        {
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return CreateGlyphIndexer(this.GetTopSidebearing); 
            } 
        }
 
        /// 
        /// Distance from bottom edge of black box to bottom end of advance vector.
        /// Positive when bottom edge of black box is within the alignment rectangle
        /// defined by the advance width and font cell height. 
        /// (The font cell height is a horizontal dimension in vertical layout).
        /// Negative when bottom edge of black box overhangs the alignment rectangle. 
        ///  
        public IDictionary BottomSideBearings
        { 
            get
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return CreateGlyphIndexer(this.GetBottomSidebearing); 
            }
        } 
 
        /// 
        /// Offset down from horizontal Western baseline to bottom  of glyph black box. 
        /// 
        public IDictionary DistancesFromHorizontalBaselineToBlackBoxBottom
        {
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return CreateGlyphIndexer(this.GetBaseline); 
            }
        } 

        /// 
        /// Returns nominal mapping of Unicode codepoint to glyph index as defined by the font 'CMAP' table.
        ///  
        /// 
        ///   Critical: May potentially leak a writeable cmap. 
        ///   Safe: The cmap IDictionary exposure is read only. 
        ///  
        public IDictionary CharacterToGlyphMap 
        {
            [SecurityCritical]
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return _fontFace.CharacterMap; 
            } 
        }
 
        #pragma warning restore 3003

        /// 
        /// Returns algorithmic font style simulations to be applied to the GlyphTypeface. 
        /// 
        public StyleSimulations StyleSimulations 
        { 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return _styleSimulations;
            }
            set 
            {
                CheckInitializing(); 
                _styleSimulations = value; 
            }
        } 

        /// 
        /// Obtains the number of glyphs in the glyph typeface.
        ///  
        /// The number of glyphs in the glyph typeface.
        ///  
        /// Critical - Accesses critical DWrite.FontFace property 
        /// Safe - This information is safe to expose.
        ///  
        public int GlyphCount
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                int glyphCount; 

                MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = _font.GetFontFace(); 
                try
                {
                    glyphCount = fontFaceDWrite.GlyphCount;
                } 
                finally
                { 
                    fontFaceDWrite.Release(); 
                }
 
                return glyphCount;
            }
        }
 
        #endregion Public Properties
 
        //----------------------------------------------------- 
        //
        //  Internal Methods 
        //
        //------------------------------------------------------

        #region Internal Methods 

 
        internal MS.Internal.Text.TextInterface.Font FontDWrite 
        {
            ///  
            ///   Critical: Exposes security critical font object that gives access to font data.
            ///  
            [SecurityCritical]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
                return _font; 
            }
        } 

        /// 
        /// Returns the nominal advance width for a glyph.
        /// 
        /// PERFORMANCE WARNING: This function will make a call through the MC++ interop layer
        /// into DWrite. If called repetitively the call overhead can be significant. If you have 
        /// a lot of glyphs you need to get metrics for, use the array based equivalent instead. 
        ///
        ///  
        /// Glyph index in the font.
        /// The nominal advance width for the glyph relative to the em size of the font.
        /// 
        /// Critical - as this has unsafe block. 
        /// Safe - as this only gives width information which is safe to give out.
        ///  
        [SecurityCritical, SecurityTreatAsSafe] 
        internal double GetAdvanceWidth(ushort             glyph,
                                        TextFormattingMode textFormattingMode, 
                                        bool               isSideways)
        {
            CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
 
            // We manually expand GetGlyphMetrics call because GetAdvanceWidth is a very frequently used function.
            // When we get to using GetAdvanceHeight for vertical writing, we need to consider doing the same optimization there. 
            unsafe 
            {
                MS.Internal.Text.TextInterface.GlyphMetrics glyphMetrics = GlyphMetrics(glyph, DesignEmHeight, textFormattingMode, isSideways); 

                return (double)glyphMetrics.AdvanceWidth / DesignEmHeight;
            }
        } 

        ///  
        /// This function will demand appropriate permissions depending on what 
        /// the source of the font information is.  The value of _fileIOPermObj
        /// is set correctly whenever _originalUri gets set. 
        /// Critical - Performs a demand. Transparent methods should not be responsible
        ///            for verifying the security of an operation, and therefore should not
        ///            demand permissions.
        /// Safe - It is safe to perform a demand. 
        /// 
        [SecuritySafeCritical] 
        internal void DemandPermissionsForFontInformation() 
        {
            if (_fileIOPermObj.Value != null) 
            {
                _fileIOPermObj.Value.Demand();
            }
        } 

        private double GetAdvanceHeight(ushort glyph, 
            TextFormattingMode textFormattingMode, 
            bool isSideways)
        { 
            double aw, ah, lsb, rsb, tsb, bsb, baseline;
            GetGlyphMetrics(
                glyph,
                1.0, 
                1.0,
                textFormattingMode, 
                isSideways, 
                out aw,
                out ah, 
                out lsb,
                out rsb,
                out tsb,
                out bsb, 
                out baseline
            ); 
            return ah; 
        }
 
        /// 
        /// Critical - Calls critical DWrite.FontFace methods
        /// 
        [SecurityCritical] 
        private unsafe MS.Internal.Text.TextInterface.GlyphMetrics GlyphMetrics(ushort             glyphIndex,
                                                                                double             emSize, 
                                                                                TextFormattingMode textFormattingMode, 
                                                                                bool               isSideways)
        { 
            MS.Internal.Text.TextInterface.GlyphMetrics glyphMetrics;

            MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = _font.GetFontFace();
            try 
            {
                if (glyphIndex >= fontFaceDWrite.GlyphCount) 
                    throw new ArgumentOutOfRangeException("glyphIndex", SR.Get(SRID.GlyphIndexOutOfRange, glyphIndex)); 

                glyphMetrics = new MS.Internal.Text.TextInterface.GlyphMetrics(); 

                if (textFormattingMode == TextFormattingMode.Ideal)
                {
                    // We can safely pass pointers to glyphIndex and glyphMetrics since both are value types and are allocated on the stack. 
                    fontFaceDWrite.GetDesignGlyphMetrics(&glyphIndex, 1, &glyphMetrics);
                } 
                else 
                {
                    // We can safely pass pointers to glyphIndex and glyphMetrics since both are value types and are allocated on the stack. 
                    fontFaceDWrite.GetDisplayGlyphMetrics(&glyphIndex, 1, &glyphMetrics, checked((float)emSize), textFormattingMode != TextFormattingMode.Display, isSideways, Util.PixelsPerDip);
                }
            }
            finally 
            {
                fontFaceDWrite.Release(); 
            } 

            return glyphMetrics; 
        }

        /// 
        /// Critical - Calls critical DWrite.FontFace methods 
        /// 
        [SecurityCritical] 
        private unsafe void GlyphMetrics(ushort* pGlyphIndices, int characterCount, MS.Internal.Text.TextInterface.GlyphMetrics* pGlyphMetrics, double emSize, TextFormattingMode textFormattingMode, bool isSideways) 
        {
            MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = _font.GetFontFace(); 
            try
            {
                if (textFormattingMode == TextFormattingMode.Ideal)
                { 
                    fontFaceDWrite.GetDesignGlyphMetrics(pGlyphIndices, checked((uint)characterCount), pGlyphMetrics);
                } 
                else 
                {
                    fontFaceDWrite.GetDisplayGlyphMetrics(pGlyphIndices, checked((uint)characterCount), pGlyphMetrics, checked((float)emSize), textFormattingMode != TextFormattingMode.Display, isSideways, Util.PixelsPerDip); 
                }
            }
            finally
            { 
                fontFaceDWrite.Release();
            } 
        } 

        ///  
        /// Critical - Calls critical GlyphMetrics
        /// TreatAsSafe - This information is safe to expose.
        /// 
        [SecurityCritical, SecurityTreatAsSafe] 
        private double GetLeftSidebearing(ushort         glyph,
                                          TextFormattingMode textFormattingMode, 
                                          bool           isSideways) 
        {
            return ((double)GlyphMetrics(glyph, DesignEmHeight, textFormattingMode, isSideways).LeftSideBearing) / DesignEmHeight; 
        }

        /// 
        /// Critical - Calls critical GlyphMetrics 
        /// TreatAsSafe - This information is safe to expose.
        ///  
        [SecurityCritical, SecurityTreatAsSafe] 
        private double GetRightSidebearing(ushort         glyph,
                                           TextFormattingMode textFormattingMode, 
                                           bool           isSideways)
        {
            return ((double)GlyphMetrics(glyph, DesignEmHeight, textFormattingMode, isSideways).RightSideBearing) / DesignEmHeight;
        } 

        ///  
        /// Critical - Calls critical GlyphMetrics 
        /// TreatAsSafe - This information is safe to expose.
        ///  
        [SecurityCritical, SecurityTreatAsSafe]
        private double GetTopSidebearing(ushort         glyph,
                                         TextFormattingMode textFormattingMode,
                                         bool           isSideways) 
        {
            return ((double)GlyphMetrics(glyph, DesignEmHeight, textFormattingMode, isSideways).TopSideBearing) / DesignEmHeight; 
        } 

        ///  
        /// Critical - Calls critical GlyphMetrics
        /// TreatAsSafe - This information is safe to expose.
        /// 
        [SecurityCritical, SecurityTreatAsSafe] 
        private double GetBottomSidebearing(ushort         glyph,
                                            TextFormattingMode textFormattingMode, 
                                            bool           isSideways) 
        {
            return ((double)GlyphMetrics(glyph, DesignEmHeight, textFormattingMode, isSideways).BottomSideBearing) / DesignEmHeight; 
        }

        /// 
        /// Critical - Calls critical GlyphMetrics 
        /// TreatAsSafe - This information is safe to expose.
        ///  
        [SecurityCritical, SecurityTreatAsSafe] 
        private double GetBaseline(ushort glyph,
                                   TextFormattingMode textFormattingMode, 
                                   bool isSideways)
        {
            MS.Internal.Text.TextInterface.GlyphMetrics glyphMetrics = GlyphMetrics(glyph, DesignEmHeight, textFormattingMode, isSideways);
            return BaselineHelper(glyphMetrics) / DesignEmHeight; 
        }
 
        internal static double BaselineHelper(MS.Internal.Text.TextInterface.GlyphMetrics metrics) 
        {
            return  -1 * ((double)metrics.BottomSideBearing + metrics.VerticalOriginY - metrics.AdvanceHeight); 
        }

        /// 
        /// Optimized version of obtaining all of glyph metrics from font cache at once 
        /// without repeated checks and divisions.
        /// 
        /// PERFORMANCE WARNING: This function will make a call through the MC++ interop layer 
        /// into DWrite. If called repetitively the call overhead can be significant. If you have
        /// a lot of glyphs you need to get metrics for, use the array based equivalent instead. 
        ///
        /// 
        /// 
        /// Critical - as this uses unsafe code. 
        /// Safe - as this only gives information which is safe to give out.
        ///  
        [SecurityCritical, SecurityTreatAsSafe] 
        internal void GetGlyphMetrics(
            ushort glyph, 
            double renderingEmSize,
            double scalingFactor,
            TextFormattingMode textFormattingMode,
            bool isSideways, 
            out double aw,
            out double ah, 
            out double lsb, 
            out double rsb,
            out double tsb, 
            out double bsb,
            out double baseline
            )
        { 
            CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
 
            unsafe 
            {
                MS.Internal.Text.TextInterface.GlyphMetrics glyphMetrics = GlyphMetrics(glyph, renderingEmSize, textFormattingMode, isSideways); 

                double designToEm = renderingEmSize / DesignEmHeight;

                if (TextFormattingMode.Display == textFormattingMode) 
                {
                    aw = TextFormatterImp.RoundDipForDisplayMode(designToEm * glyphMetrics.AdvanceWidth) * scalingFactor; 
                    ah = TextFormatterImp.RoundDipForDisplayMode(designToEm * glyphMetrics.AdvanceHeight) * scalingFactor; 
                    lsb = TextFormatterImp.RoundDipForDisplayMode(designToEm * glyphMetrics.LeftSideBearing) * scalingFactor;
                    rsb = TextFormatterImp.RoundDipForDisplayMode(designToEm * glyphMetrics.RightSideBearing) * scalingFactor; 
                    tsb = TextFormatterImp.RoundDipForDisplayMode(designToEm * glyphMetrics.TopSideBearing) * scalingFactor;
                    bsb = TextFormatterImp.RoundDipForDisplayMode(designToEm * glyphMetrics.BottomSideBearing) * scalingFactor;
                    baseline = TextFormatterImp.RoundDipForDisplayMode(designToEm * BaselineHelper(glyphMetrics)) * scalingFactor;
                } 
                else
                { 
                    aw = designToEm * glyphMetrics.AdvanceWidth * scalingFactor; 
                    ah = designToEm * glyphMetrics.AdvanceHeight * scalingFactor;
                    lsb = designToEm * glyphMetrics.LeftSideBearing * scalingFactor; 
                    rsb = designToEm * glyphMetrics.RightSideBearing * scalingFactor;
                    tsb = designToEm * glyphMetrics.TopSideBearing * scalingFactor;
                    bsb = designToEm * glyphMetrics.BottomSideBearing * scalingFactor;
                    baseline = designToEm * BaselineHelper(glyphMetrics) * scalingFactor; 
                }
            } 
        } 

        ///  
        /// Optimized version of obtaining all of glyph metrics from font cache at once
        /// without repeated checks and divisions.
        /// 
        ///  
        /// Critical - as this uses unsafe code.
        /// Safe - as this only gives information which is safe to give out. 
        ///  
        [SecurityCritical, SecurityTreatAsSafe]
        internal void GetGlyphMetrics( 
            ushort[] glyphs,
            int glyphsLength,
            double renderingEmSize,
            TextFormattingMode textFormattingMode, 
            bool isSideways,
            MS.Internal.Text.TextInterface.GlyphMetrics[] glyphMetrics 
            ) 
        {
            CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 

            unsafe
            {
                fixed (MS.Internal.Text.TextInterface.GlyphMetrics* pGlyphMetrics = glyphMetrics) 
                {
                    fixed (ushort* pGlyphs = &glyphs[0]) 
                    { 
                        GlyphMetrics(pGlyphs, glyphsLength, pGlyphMetrics, renderingEmSize, textFormattingMode, isSideways);
                    } 
                }
            }
        }
 
        /// 
        /// Returns a geometry describing the path for a single glyph in the font. 
        /// The path represents the glyph 
        /// without grid fitting applied for rendering at a specific resolution.
        ///  
        /// Index of the glyph to get outline for.
        /// Specifies whether the glyph should be rotated sideways.
        /// Font size in drawing surface units.
        /// Geometry containing glyph outline. 
        /// 
        /// Critical - as this calls GetGlyphs() which is critical. 
        /// Safe - as this doesn't expose font information but just gives out a Geometry. 
        /// 
        [SecurityCritical, SecurityTreatAsSafe] 
        internal Geometry ComputeGlyphOutline(ushort glyphIndex,
                                              bool sideways,
                                              double renderingEmSize)
        { 
            CheckInitialized();
 
            unsafe 
            {
                byte* pMilPathGeometry; 
                UInt32 size;
                FillRule fillRule;

                MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = _font.GetFontFace(); 
                try
                { 
                    HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MilGlyphRun_GetGlyphOutline( 
                        fontFaceDWrite.DWriteFontFaceAddRef, // Released in this native code function
                        glyphIndex, 
                        sideways,
                        renderingEmSize,
                        out pMilPathGeometry,
                        out size, 
                        out fillRule
                        )); 
                } 
                finally
                { 
                    fontFaceDWrite.Release();
                }

                Geometry.PathGeometryData pathGeoData = new Geometry.PathGeometryData(); 
                byte[] data = new byte[size];
                Marshal.Copy(new IntPtr(pMilPathGeometry), data, 0, checked((int)size)); 
 
                // Delete the memory we allocated in native code.
                HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MilGlyphRun_ReleasePathGeometryData( 
                    pMilPathGeometry
                    ));

                pathGeoData.SerializedData = data; 
                pathGeoData.FillRule = fillRule;
                pathGeoData.Matrix = CompositionResourceManager.MatrixToMilMatrix3x2D(Matrix.Identity); 
 
                PathStreamGeometryContext ctx = new PathStreamGeometryContext(fillRule, null);
                PathGeometry.ParsePathGeometryData(pathGeoData, ctx); 

                return ctx.GetPathGeometry();
            }
        } 

        ///  
        /// Get advance widths of unshaped characters 
        /// 
        /// character string 
        /// character length
        /// character em size
        /// This is the factor by which we will scale up
        /// the metrics. Typically this value to used to convert metrics from the real 
        /// space to the ideal space
        /// unshaped advance widths  
        /// true if all characters map to missing glyph 
        /// array of character advance widths
        ///  
        /// Critical - takes unsafe char string and returns information in an unsafe int array
        /// 
        [SecurityCritical]
        internal unsafe void GetAdvanceWidthsUnshaped( 
            char*              unsafeCharString,
            int                stringLength, 
            double             emSize, 
            double             scalingFactor,
            int*               advanceWidthsUnshaped, 
            bool               nullFont,
            TextFormattingMode textFormattingMode,
            bool               isSideways
            ) 
        {
            CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 
            Invariant.Assert(stringLength > 0); 

            if (!nullFont) 
            {
                CharacterBufferRange charBufferRange = new CharacterBufferRange(unsafeCharString, stringLength);
                MS.Internal.Text.TextInterface.GlyphMetrics[] glyphMetrics = BufferCache.GetGlyphMetrics(stringLength);
 
                GetGlyphMetricsOptimized(charBufferRange,
                                         emSize, 
                                         textFormattingMode, 
                                         isSideways,
                                         glyphMetrics 
                                         );

                if (TextFormattingMode.Display == textFormattingMode)
                { 
                    double designToEm = emSize / DesignEmHeight;
                    for (int i = 0; i < stringLength; i++) 
                    { 
                        advanceWidthsUnshaped[i] = (int)Math.Round(TextFormatterImp.RoundDipForDisplayMode(glyphMetrics[i].AdvanceWidth * designToEm) * scalingFactor);
                    } 
                }
                else
                {
                    double designToEm = emSize * scalingFactor / DesignEmHeight; 
                    for (int i = 0; i < stringLength; i++)
                    { 
                        advanceWidthsUnshaped[i] = (int)Math.Round(glyphMetrics[i].AdvanceWidth * designToEm); 
                    }
                } 

                BufferCache.ReleaseGlyphMetrics(glyphMetrics);
            }
            else 
            {
                int missingGlyphWidth = (int)Math.Round(TextFormatterImp.RoundDip(emSize * GetAdvanceWidth(0, textFormattingMode, isSideways), textFormattingMode) * scalingFactor); 
                for (int i = 0; i < stringLength; i++) 
                {
                    advanceWidthsUnshaped[i] = missingGlyphWidth; 
                }
            }
        }
 
        /// 
        /// Compute an unshaped glyphrun object from specified character-based info 
        ///  
        internal GlyphRun ComputeUnshapedGlyphRun(
            Point origin, 
            CharacterBufferRange charBufferRange,
            IList charWidths,
            double emSize,
            double emHintingSize, 
            bool nullGlyph,
            CultureInfo cultureInfo, 
            string deviceFontName, 
            TextFormattingMode textFormattingMode
            ) 
        {
            Debug.Assert(charBufferRange.Length > 0);

            CheckInitialized(); // This can only be called on fully initialized GlyphTypeface 

            ushort[] nominalGlyphs = new ushort[charBufferRange.Length]; 
 
            // compute glyph positions
 
            if (nullGlyph)
            {
                for (int i = 0; i < charBufferRange.Length; i++)
                { 
                    nominalGlyphs[i] = 0;
                } 
            } 
            else
            { 
                GetGlyphIndicesOptimized(charBufferRange, nominalGlyphs);
            }

            return GlyphRun.TryCreate( 
                this,
                0,      // bidiLevel 
                false,  // sideway 
                emSize,
                nominalGlyphs, 
                origin,
                charWidths,
                null,   // glyphOffsets
                new PartialList(charBufferRange.CharacterBuffer, charBufferRange.OffsetToFirstChar, charBufferRange.Length), 
                deviceFontName,   // device font
                null,   // 1:1 mapping 
                null,   // caret stops at every codepoint 
                XmlLanguage.GetLanguage(cultureInfo.IetfLanguageTag),
                textFormattingMode 
                );
        }

        ///  
        /// GetGlyphIndicesOptimized will return the glyph indices in a ushort[] array
        /// It should not be used if both indices and advance widths are required. In that 
        /// case use GetGlyphMetricsOptimized to get both. 
        /// 
        internal void GetGlyphIndicesOptimized(CharacterBufferRange characters, ushort[] glyphIndices) 
        {
            // We don't need to pass real emSize, widths, TextFormattingMode and isSideways parameters, because
            // they only matter for advance widths and we're only interested in getting glyph indices
            GetGlyphMetricsOptimized(characters, 0.0f, glyphIndices, null, TextFormattingMode.Ideal, false); 
        }
 
        ///  
        /// Returns GlyphMetrics for a run of characters.  Heap allocation is typically avoided.
        ///  
        internal void GetGlyphMetricsOptimized(CharacterBufferRange characters,
            double emSize,
            TextFormattingMode textFormattingMode,
            bool isSideways, 
            MS.Internal.Text.TextInterface.GlyphMetrics[] glyphMetrics)
        { 
            GetGlyphMetricsOptimized(characters, emSize, null, glyphMetrics, textFormattingMode, isSideways); 
        }
 
        /// 
        /// Returns GlyphMetics and/or glyph indices matching a run of characters.  Heap allocation is typically avoided.
        /// 
        [SecurityCritical, SecurityTreatAsSafe] 
        internal void GetGlyphMetricsOptimized(CharacterBufferRange characters,
            double emSize, 
            ushort[] glyphIndices, 
            MS.Internal.Text.TextInterface.GlyphMetrics[] glyphMetrics,
            TextFormattingMode textFormattingMode, 
            bool isSideways)
        {
            Debug.Assert(glyphIndices != null || glyphMetrics != null);
 
            if (characters.Length * sizeof(uint) < GlyphRun.MaxStackAlloc)
            { 
                unsafe 
                {
                    uint *pCodepoints = stackalloc uint[characters.Length]; 
                    for (int i = 0; i < characters.Length; i++)
                    {
                        pCodepoints[i] = characters[i];
                    } 
                    GetGlyphMetricsAndIndicesOptimized(pCodepoints, characters.Length, emSize, glyphIndices, glyphMetrics, textFormattingMode, isSideways);
                } 
            } 
            else
            { 
                uint[] codepoints = new uint[characters.Length];
                for (int i = 0; i < characters.Length; i++)
                {
                    codepoints[i] = characters[i]; 
                }
                unsafe 
                { 
                    fixed (uint *pCodepoints = &codepoints[0])
                    { 
                        GetGlyphMetricsAndIndicesOptimized(pCodepoints, characters.Length, emSize, glyphIndices, glyphMetrics, textFormattingMode, isSideways);
                    }
                }
            } 
        }
 
        [SecurityCritical] 
        private unsafe void GetGlyphMetricsAndIndicesOptimized(uint *pCodepoints,
                                                               int characterCount, 
                                                               double emSize,
                                                               ushort[] glyphIndices,
                                                               MS.Internal.Text.TextInterface.GlyphMetrics[] glyphMetrics,
                                                               TextFormattingMode textFormattingMode, 
                                                               bool isSideways)
        { 
            bool releaseIndices = false; 

            if (glyphIndices == null) 
            {
                glyphIndices = BufferCache.GetUShorts(characterCount);
                releaseIndices = true;
            } 

            fixed (ushort *pGlyphIndices = &glyphIndices[0]) 
            { 
                _fontFace.CharacterMap.TryGetValues(pCodepoints, checked((uint)characterCount), pGlyphIndices);
 
                if (glyphMetrics != null)
                {
                    fixed (MS.Internal.Text.TextInterface.GlyphMetrics* pGlyphMetrics = &glyphMetrics[0])
                    { 
                        GlyphMetrics(pGlyphIndices, characterCount, pGlyphMetrics, emSize, textFormattingMode, isSideways);
                    } 
                } 
            }
 
            if (releaseIndices)
            {
                BufferCache.ReleaseUShorts(glyphIndices);
            } 
        }
 
        #endregion Internal Methods 

        //----------------------------------------------------- 
        //
        //  Internal Properties
        //
        //----------------------------------------------------- 

        #region Internal Properties 
 
        internal FontSource FontSource
        { 
            get
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return _fontSource; 
            }
        } 
 
        /// 
        /// 0 for TTF files 
        /// Face index within TrueType font collection for TTC files
        /// 
        /// 
        /// Critical - Accesses critical DWrite.FontFace property 
        /// 
        internal int FaceIndex 
        { 
            [SecurityCritical]
            get 
            {
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                int faceIndex;
 
                MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = _font.GetFontFace();
                try 
                { 
                    faceIndex = checked((int)fontFaceDWrite.Index);
                } 
                finally
                {
                    fontFaceDWrite.Release();
                } 

                return faceIndex; 
            } 
        }
 
        internal FontFaceLayoutInfo FontFaceLayoutInfo
        {
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return _fontFace; 
            } 
        }
 
        internal ushort BlankGlyphIndex
        {
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return _fontFace.BlankGlyph; 
            } 
        }
 
        internal FontTechnology FontTechnology
        {
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return _fontFace.FontTechnology; 
            } 
        }
 
        /// 
        /// Critical - this accesses critical DWrite.Font properties.
        /// TreatAsSafe - this data is safe to expose.
        ///  
        internal ushort DesignEmHeight
        { 
            [SecurityCritical, SecurityTreatAsSafe] 
            get
            { 
                CheckInitialized(); // This can only be called on fully initialized GlyphTypeface
                return _font.Metrics.DesignUnitsPerEm;
            }
        } 

        // 
        // Need ability to add ref and get pointer to the DWrite font face for the rendering 
        // thread to access
        // 
        unsafe internal IntPtr GetDWriteFontAddRef
        {
            [SecurityCritical]
            get 
            {
                CheckInitialized(); 
                return _font.DWriteFontAddRef; 
            }
        } 

        #endregion Internal Properties

        //----------------------------------------------------- 
        //
        //  Private Methods 
        // 
        //------------------------------------------------------
 
        #region Private Methods

        /// 
        /// Critical - calls into critical DWrite.Font methods 
        /// TreatAsSafe - it is safe to expose the localized strings for the font.
        ///  
        [SecurityCritical, SecurityTreatAsSafe] 
        private IDictionary GetFontInfo(MS.Internal.Text.TextInterface.InformationalStringID informationalStringID)
        { 
            MS.Internal.Text.TextInterface.LocalizedStrings localizedStrings;
            if (_font.GetInformationalStrings(informationalStringID, out localizedStrings))
            {
                return localizedStrings; 
            }
            else 
            { 
                return new MS.Internal.Text.TextInterface.LocalizedStrings();
            } 
        }

        #endregion Private Methods
 
        #region ISupportInitialize interface
 
        void ISupportInitialize.BeginInit() 
        {
            if (_initializationState == InitializationState.IsInitialized) 
            {
                // Cannot initialize a GlyphRun this is completely initialized.
                throw new InvalidOperationException(SR.Get(SRID.OnlyOneInitialization));
            } 

            if (_initializationState == InitializationState.IsInitializing) 
            { 
                // Cannot initialize a GlyphRun this already being initialized.
                throw new InvalidOperationException(SR.Get(SRID.InInitialization)); 
            }

            _initializationState = InitializationState.IsInitializing;
        } 

        ///  
        /// Critical - This method calls critical getter _originalUri.Value. 
        /// TreatAsSafe - Does not expose critical data
        ///  
        [SecurityCritical, SecurityTreatAsSafe]
        void ISupportInitialize.EndInit()
        {
            if (_initializationState != InitializationState.IsInitializing) 
            {
                // Cannot EndInit a GlyphRun that is not being initialized. 
                throw new InvalidOperationException(SR.Get(SRID.NotInInitialization)); 
            }
 
            Initialize(
                (_originalUri == null) ? null : _originalUri.Value,
                 _styleSimulations
                 ); 
        }
 
        private void CheckInitialized() 
        {
            if (_initializationState != InitializationState.IsInitialized) 
            {
                throw new InvalidOperationException(SR.Get(SRID.InitializationIncomplete));
            }
        } 

        private void CheckInitializing() 
        { 
            if (_initializationState != InitializationState.IsInitializing)
            { 
                throw new InvalidOperationException(SR.Get(SRID.NotInInitialization));
            }
        }
 
        /// 
        /// Allocates a GlyphIndexer for the specified accessor. 
        ///  
        /// 
        /// Critical - Accesses critical DWrite.FontFace property 
        /// Safe - This information is safe to expose.
        /// 
        [SecurityCritical, SecurityTreatAsSafe]
        private GlyphIndexer CreateGlyphIndexer(GlyphAccessor accessor) 
        {
            GlyphIndexer indexer; 
 
            MS.Internal.Text.TextInterface.FontFace fontFaceDWrite = _font.GetFontFace();
            try 
            {
                indexer = new GlyphIndexer(accessor, fontFaceDWrite.GlyphCount);
            }
            finally 
            {
                fontFaceDWrite.Release(); 
            } 

            return indexer; 
        }

        #endregion
 
        //-----------------------------------------------------
        // 
        //  Private Nested Classes 
        //
        //------------------------------------------------------ 

        #region Private Nested Classes

        private delegate double GlyphAccessor(ushort glyphIndex, TextFormattingMode textFormattingMode, bool isSideways); 

        ///  
        /// This class is a helper to implement named indexers 
        /// for glyph metrics.
        ///  
        private class GlyphIndexer : IDictionary
        {
            internal GlyphIndexer(GlyphAccessor accessor, ushort numberOfGlyphs)
            { 
                _accessor = accessor;
                _numberOfGlyphs = numberOfGlyphs; 
            } 

            #region IDictionary Members 

            public void Add(ushort key, double value)
            {
                throw new NotSupportedException(); 
            }
 
            public bool ContainsKey(ushort key) 
            {
                return (key < _numberOfGlyphs); 
            }

            public ICollection Keys
            { 
                get { return new SequentialUshortCollection(_numberOfGlyphs); }
            } 
 
            public bool Remove(ushort key)
            { 
                throw new NotSupportedException();
            }

            public bool TryGetValue(ushort key, out double value) 
            {
                if (ContainsKey(key)) 
                { 
                    value = this[key];
                    return true; 
                }
                else
                {
                    value = new double(); 
                    return false;
                } 
            } 

            public ICollection Values 
            {
                get { return new ValueCollection(this); }
            }
 
            public double this[ushort key]
            { 
                get 
                {
                    return _accessor(key, TextFormattingMode.Ideal, false); 
                }
                set
                {
                    throw new NotSupportedException(); 
                }
            } 
 
            #endregion
 
            #region ICollection> Members

            public void Add(KeyValuePair item)
            { 
                throw new NotSupportedException();
            } 
 
            public void Clear()
            { 
                throw new NotSupportedException();
            }

            public bool Contains(KeyValuePair item) 
            {
                return ContainsKey(item.Key); 
            } 

            public void CopyTo(KeyValuePair[] array, int arrayIndex) 
            {
                if (array == null)
                {
                    throw new ArgumentNullException("array"); 
                }
 
                if (array.Rank != 1) 
                {
                    throw new ArgumentException(SR.Get(SRID.Collection_BadRank)); 
                }

                // The extra "arrayIndex >= array.Length" check in because even if _collection.Count
                // is 0 the index is not allowed to be equal or greater than the length 
                // (from the MSDN ICollection docs)
                if (arrayIndex < 0 || arrayIndex >= array.Length || (arrayIndex + Count) > array.Length) 
                { 
                    throw new ArgumentOutOfRangeException("arrayIndex");
                } 

                for (ushort i = 0; i < Count; ++i)
                    array[arrayIndex + i] = new KeyValuePair(i, this[i]);
            } 

            public int Count 
            { 
                get { return _numberOfGlyphs; }
            } 

            public bool IsReadOnly
            {
                get { return true; } 
            }
 
            public bool Remove(KeyValuePair item) 
            {
                throw new NotSupportedException(); 
            }

            #endregion
 
            #region IEnumerable> Members
 
            public IEnumerator> GetEnumerator() 
            {
                for (ushort i = 0; i < Count; ++i) 
                    yield return new KeyValuePair(i, this[i]);
            }

            #endregion 

            #region IEnumerable Members 
 
            IEnumerator IEnumerable.GetEnumerator()
            { 
                return ((IEnumerable>)this).GetEnumerator();
            }

            #endregion 

            private class ValueCollection : ICollection 
            { 
                public ValueCollection(GlyphIndexer glyphIndexer)
                { 
                    _glyphIndexer = glyphIndexer;
                }

                #region ICollection Members 

                public void Add(double item) 
                { 
                    throw new NotSupportedException();
                } 

                public void Clear()
                {
                    throw new NotSupportedException(); 
                }
 
                public bool Contains(double item) 
                {
                    foreach (double d in this) 
                    {
                        if (d == item)
                            return true;
                    } 
                    return false;
                } 
 
                public void CopyTo(double[] array, int arrayIndex)
                { 
                    if (array == null)
                    {
                        throw new ArgumentNullException("array");
                    } 

                    if (array.Rank != 1) 
                    { 
                        throw new ArgumentException(SR.Get(SRID.Collection_BadRank));
                    } 

                    // The extra "arrayIndex >= array.Length" check in because even if _collection.Count
                    // is 0 the index is not allowed to be equal or greater than the length
                    // (from the MSDN ICollection docs) 
                    if (arrayIndex < 0 || arrayIndex >= array.Length || (arrayIndex + Count) > array.Length)
                    { 
                        throw new ArgumentOutOfRangeException("arrayIndex"); 
                    }
 
                    for (ushort i = 0; i < Count; ++i)
                        array[arrayIndex + i] = _glyphIndexer[i];
                }
 
                public int Count
                { 
                    get { return _glyphIndexer._numberOfGlyphs; } 
                }
 
                public bool IsReadOnly
                {
                    get { return true; }
                } 

                public bool Remove(double item) 
                { 
                    throw new NotSupportedException();
                } 

                #endregion

                #region IEnumerable Members 

                public IEnumerator GetEnumerator() 
                { 
                    for (ushort i = 0; i < Count; ++i)
                        yield return _glyphIndexer[i]; 
                }

                #endregion
 
                #region IEnumerable Members
 
                IEnumerator IEnumerable.GetEnumerator() 
                {
                    return ((IEnumerable)this).GetEnumerator(); 
                }

                #endregion
 
                private GlyphIndexer _glyphIndexer;
            } 
 
            private GlyphAccessor _accessor;
            private ushort _numberOfGlyphs; 
        }

        #endregion Private Nested Classes
 
        //------------------------------------------------------
        // 
        //  Private Fields 
        //
        //----------------------------------------------------- 

        #region Private Fields

        private FontFaceLayoutInfo          _fontFace; 

        private StyleSimulations            _styleSimulations; 
 
        private MS.Internal.Text.TextInterface.Font     _font;
 
        private FontSource                  _fontSource;


        ///  
        /// The Uri that was passed in to constructor.
        ///  
        ///  
        ///     This is critical as we do a demand based on this value public functions.
        ///     Only setting this Uri is critical, getting is fine.  Hence using the 
        ///     SecurityCriticalDataForSet object.  Note that the object itself does not
        ///     need to be Critical, it's just setting it that makes it Critical.
        /// 
        private SecurityCriticalDataClass _originalUri; 

        ///  
        /// Critical - as this object controls the Demand that'll be made before accessing the 
        ///            security sensitive contents of the font file.  This also only Critical
        ///            for set.  This should be correctly whenever _originalUri is set. 
        ///
        /// Caching object for perf reasons.
        /// 
        private SecurityCriticalDataForSet _fileIOPermObj; 

        private const double CFFConversionFactor = 1.0 / 65536.0; 
 
        private InitializationState _initializationState;
 
        /// 
        /// Initialization states of GlyphTypeface object.
        /// 
        private enum InitializationState 
        {
            ///  
            /// The state in which the GlyphTypeface has not been initialized. 
            /// At this state, all operations on the object would cause InvalidOperationException.
            /// The object can only transit to 'IsInitializing' state with BeginInit() call. 
            /// 
            Uninitialized,

            ///  
            /// The state in which the GlyphTypeface is being initialized. At this state, user can
            /// set values into the required properties. The object can only transit to 'IsInitialized' state 
            /// with EndInit() call. 
            /// 
            IsInitializing, 

            /// 
            /// The state in which the GlyphTypeface object is fully initialized. At this state the object
            /// is fully functional. There is no valid transition out of the state. 
            /// 
            IsInitialized, 
        } 

        #endregion Private Fields 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK