Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / System / Windows / Media / FontEmbeddingManager.cs / 1 / FontEmbeddingManager.cs
//---------------------------------------------------------------------------- // //// Copyright (c) Microsoft Corporation. All rights reserved. // // // // Description: The FontEmbeddingManager class handles physical and composite font embedding. // // See spec at [....]/text/DesignDocsAndSpecs/Font%20embedding%20APIs.htm // // // History: // 01/27/2004 : [....] - Created // //--------------------------------------------------------------------------- using System; using System.Text; using System.IO; using System.Globalization; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Windows; using MS.Internal.FontCache; using MS.Internal.FontFace; using MS.Internal.Shaping; using System.Security; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; // Allow suppression of presharp warnings #pragma warning disable 1634, 1691 namespace System.Windows.Media { ////// The FontEmbeddingManager class handles physical and composite font embedding. /// public class FontEmbeddingManager { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// Creates a new instance of font usage manager. /// public FontEmbeddingManager() { _collectedGlyphTypefaces = new Dictionary>(_uriComparer); } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods /// /// Collects information about glyph typeface and index used by a glyph run. /// /// Glyph run to obtain typeface and index information from. public void RecordUsage(GlyphRun glyphRun) { if (glyphRun == null) throw new ArgumentNullException("glyphRun"); // Suppress PRESharp parameter validation warning about glyphRun.GlyphTypeface because // GlyphRun.GlyphTypeface property cannot be null. #pragma warning suppress 56506 Uri glyphTypeface = glyphRun.GlyphTypeface.FontUri; DictionaryglyphSet; if (_collectedGlyphTypefaces.ContainsKey(glyphTypeface)) glyphSet = _collectedGlyphTypefaces[glyphTypeface]; else glyphSet = _collectedGlyphTypefaces[glyphTypeface] = new Dictionary (); foreach(ushort glyphIndex in glyphRun.GlyphIndices) { glyphSet[glyphIndex] = true; } } /// /// Returns the collection of glyph typefaces used by the previously added glyph runs. /// ///The collection of glyph typefaces used by the previously added glyph runs. [CLSCompliant(false)] public ICollectionGlyphTypefaceUris { get { return _collectedGlyphTypefaces.Keys; } } /// /// Obtain the list of glyphs used by the glyph typeface specified by a Uri. /// /// Specifies the Uri of a glyph typeface to obtain usage data for. ///A collection of glyph indices recorded previously. ////// Glyph typeface Uri does not point to a previously recorded glyph typeface. /// [CLSCompliant(false)] public ICollectionGetUsedGlyphs(Uri glyphTypeface) { Dictionary glyphsUsed = _collectedGlyphTypefaces[glyphTypeface]; if (glyphsUsed == null) { throw new ArgumentException(SR.Get(SRID.GlyphTypefaceNotRecorded), "glyphTypeface"); } return glyphsUsed.Keys; } #endregion Public Methods private class UriComparer : IEqualityComparer { #region IEqualityComparer Members public bool Equals(Uri x, Uri y) { // We don't use Uri.Equals because it doesn't compare Fragment parts, // and we use Fragment part to store font face index. return String.Equals(x.ToString(), y.ToString(), StringComparison.OrdinalIgnoreCase); } public int GetHashCode(Uri obj) { return obj.GetHashCode(); } #endregion } //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields /// /// bool values in the dictionary don't matter, /// we'll switch to Set class when it becomes available. /// private Dictionary> _collectedGlyphTypefaces; private static UriComparer _uriComparer = new UriComparer(); #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- jithelpers.cs
- BindingBase.cs
- DeviceSpecificDialogCachedState.cs
- VarRemapper.cs
- ToolStripOverflowButton.cs
- HttpHeaderCollection.cs
- RegexNode.cs
- MenuItemStyleCollection.cs
- Transactions.cs
- CacheSection.cs
- StrokeNodeOperations.cs
- SpellerHighlightLayer.cs
- ButtonBase.cs
- ServicePointManagerElement.cs
- bindurihelper.cs
- ColorConverter.cs
- CompiledIdentityConstraint.cs
- LogRecordSequence.cs
- PopOutPanel.cs
- CTreeGenerator.cs
- X509Extension.cs
- URL.cs
- TypeForwardedToAttribute.cs
- AnonymousIdentificationModule.cs
- ResourcesGenerator.cs
- HierarchicalDataSourceControl.cs
- IconBitmapDecoder.cs
- Duration.cs
- AnnouncementEndpoint.cs
- HttpApplicationFactory.cs
- TextFormatterImp.cs
- MediaElementAutomationPeer.cs
- StreamFormatter.cs
- ErrorFormatterPage.cs
- DataListItemCollection.cs
- ObjectStateFormatter.cs
- Button.cs
- ResXDataNode.cs
- ChildrenQuery.cs
- CheckBoxRenderer.cs
- HttpModulesSection.cs
- OdbcConnectionString.cs
- AsyncPostBackTrigger.cs
- BufferCache.cs
- PathSegmentCollection.cs
- GuidTagList.cs
- MemberHolder.cs
- RevocationPoint.cs
- TextLine.cs
- PropertyFilterAttribute.cs
- DbMetaDataCollectionNames.cs
- ParallelEnumerableWrapper.cs
- FloaterParagraph.cs
- RequestCacheValidator.cs
- TextHintingModeValidation.cs
- SliderAutomationPeer.cs
- ClonableStack.cs
- Utils.cs
- ValueProviderWrapper.cs
- AttributeEmitter.cs
- UrlPropertyAttribute.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- BitmapMetadataEnumerator.cs
- TextWriterEngine.cs
- DragEvent.cs
- ArrayElementGridEntry.cs
- Span.cs
- UncommonField.cs
- FixedNode.cs
- OleDbReferenceCollection.cs
- EntityStoreSchemaFilterEntry.cs
- CompositionAdorner.cs
- DataFieldConverter.cs
- CompiledAction.cs
- AlternateViewCollection.cs
- DataContractSerializer.cs
- contentDescriptor.cs
- LZCodec.cs
- metadatamappinghashervisitor.cs
- SiteMapNodeCollection.cs
- CodeComment.cs
- HtmlTableCell.cs
- SqlDataSourceView.cs
- FreeFormDragDropManager.cs
- SerialErrors.cs
- Int16Storage.cs
- Visitor.cs
- PropertyHelper.cs
- IgnoreSection.cs
- StreamResourceInfo.cs
- _BasicClient.cs
- RIPEMD160.cs
- Set.cs
- CacheHelper.cs
- FacetValues.cs
- RenderOptions.cs
- RuleEngine.cs
- FileStream.cs
- xmlfixedPageInfo.cs
- SystemFonts.cs