Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / MS / Internal / Shaping / GlyphingCache.cs / 1 / GlyphingCache.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: High level glyphing cache // // History: 5-19-2005 garyyang created // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Windows.Media; using System.Windows.Media.TextFormatting; using MS.Internal; using MS.Internal.TextFormatting; namespace MS.Internal.Shaping { ////// GlyphingCache stores the runtime state of shaping engines and the mapping between Unicode scalar /// value and the physical font being used to display it. This class is not thread-safe. The client is /// responsible for synchronizing access from multiple threads. It is generally recommended that the client /// manages a single instance of this class per text formatting session. /// /// It currently only caches one key-value pair: /// o Typeface - TypefaceMap /// /// This pair is cached in SizeLimitedCache which implement LRU algorithm through /// a linked list. When cache is full, the least used entry in the cache will be replaced /// by the latest entry. /// internal class GlyphingCache { private SizeLimitedCache_sizeLimitedCache; private ShapingEngineManager _shapeManager; internal GlyphingCache(int capacity) { _sizeLimitedCache = new SizeLimitedCache (capacity); _shapeManager = new ShapingEngineManager(); } internal void GetShapeableText( Typeface typeface, CharacterBufferReference characterBufferReference, int stringLength, TextRunProperties textRunProperties, CultureInfo digitCulture, bool rightToLeft, IList shapeableList, IShapeableTextCollector collector ) { if (!typeface.Symbol) { Lookup(typeface).GetShapeableText( characterBufferReference, stringLength, textRunProperties, digitCulture, rightToLeft, shapeableList, collector ); } else { // It's a non-Unicode ("symbol") font, where code points have non-standard meanings. We // therefore want to bypass the usual itemization and font linking. Instead, just map // everything to the default script and first GlyphTypeface. ShapeTypeface shapeTypeface = new ShapeTypeface( _shapeManager, typeface.TryGetGlyphTypeface(), null // device font ); collector.Add( shapeableList, new CharacterBufferRange(characterBufferReference, stringLength), textRunProperties, new Item(ScriptID.Default, ItemFlags.Default), shapeTypeface, 1.0, // scale in Em false // null shape ); } } /// /// Look up the font mapping data for a typeface. /// private TypefaceMap Lookup(Typeface key) { TypefaceMap typefaceMap = _sizeLimitedCache.Get(key); if (typefaceMap == null) { typefaceMap = new TypefaceMap( key.FontFamily, key.FallbackFontFamily, key.CanonicalStyle, key.CanonicalWeight, key.CanonicalStretch, key.NullFont, _shapeManager ); _sizeLimitedCache.Add( key, typefaceMap, false // is not permanent in the cache. ); } return typefaceMap; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: High level glyphing cache // // History: 5-19-2005 garyyang created // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Windows.Media; using System.Windows.Media.TextFormatting; using MS.Internal; using MS.Internal.TextFormatting; namespace MS.Internal.Shaping { ////// GlyphingCache stores the runtime state of shaping engines and the mapping between Unicode scalar /// value and the physical font being used to display it. This class is not thread-safe. The client is /// responsible for synchronizing access from multiple threads. It is generally recommended that the client /// manages a single instance of this class per text formatting session. /// /// It currently only caches one key-value pair: /// o Typeface - TypefaceMap /// /// This pair is cached in SizeLimitedCache which implement LRU algorithm through /// a linked list. When cache is full, the least used entry in the cache will be replaced /// by the latest entry. /// internal class GlyphingCache { private SizeLimitedCache_sizeLimitedCache; private ShapingEngineManager _shapeManager; internal GlyphingCache(int capacity) { _sizeLimitedCache = new SizeLimitedCache (capacity); _shapeManager = new ShapingEngineManager(); } internal void GetShapeableText( Typeface typeface, CharacterBufferReference characterBufferReference, int stringLength, TextRunProperties textRunProperties, CultureInfo digitCulture, bool rightToLeft, IList shapeableList, IShapeableTextCollector collector ) { if (!typeface.Symbol) { Lookup(typeface).GetShapeableText( characterBufferReference, stringLength, textRunProperties, digitCulture, rightToLeft, shapeableList, collector ); } else { // It's a non-Unicode ("symbol") font, where code points have non-standard meanings. We // therefore want to bypass the usual itemization and font linking. Instead, just map // everything to the default script and first GlyphTypeface. ShapeTypeface shapeTypeface = new ShapeTypeface( _shapeManager, typeface.TryGetGlyphTypeface(), null // device font ); collector.Add( shapeableList, new CharacterBufferRange(characterBufferReference, stringLength), textRunProperties, new Item(ScriptID.Default, ItemFlags.Default), shapeTypeface, 1.0, // scale in Em false // null shape ); } } /// /// Look up the font mapping data for a typeface. /// private TypefaceMap Lookup(Typeface key) { TypefaceMap typefaceMap = _sizeLimitedCache.Get(key); if (typefaceMap == null) { typefaceMap = new TypefaceMap( key.FontFamily, key.FallbackFontFamily, key.CanonicalStyle, key.CanonicalWeight, key.CanonicalStretch, key.NullFont, _shapeManager ); _sizeLimitedCache.Add( key, typefaceMap, false // is not permanent in the cache. ); } return typefaceMap; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- printdlgexmarshaler.cs
- PropertyIDSet.cs
- FontFamilyConverter.cs
- SchemaImporterExtensionElementCollection.cs
- HtmlInputText.cs
- SQLSingleStorage.cs
- WmfPlaceableFileHeader.cs
- LinkedList.cs
- UrlMappingCollection.cs
- KeyedHashAlgorithm.cs
- UIElement3DAutomationPeer.cs
- MulticastDelegate.cs
- RegexWriter.cs
- SerializationFieldInfo.cs
- EdmComplexTypeAttribute.cs
- _SingleItemRequestCache.cs
- OrderByExpression.cs
- PermissionListSet.cs
- FontWeights.cs
- RuleSet.cs
- future.cs
- MinMaxParagraphWidth.cs
- ServiceModelActivity.cs
- AddressHeader.cs
- ExportOptions.cs
- CharacterBuffer.cs
- WrappingXamlSchemaContext.cs
- InheritanceAttribute.cs
- StickyNoteAnnotations.cs
- SQLChars.cs
- UnmanagedMemoryStream.cs
- WindowsTooltip.cs
- ProxyWebPart.cs
- UpdateException.cs
- ValidateNames.cs
- TypedReference.cs
- MSHTMLHost.cs
- StrokeDescriptor.cs
- SchemaImporterExtensionElement.cs
- FontWeights.cs
- SocketAddress.cs
- QueryCreatedEventArgs.cs
- ViewPort3D.cs
- Int32Storage.cs
- ConnectionManagementElement.cs
- TabItemAutomationPeer.cs
- NotEqual.cs
- BoundColumn.cs
- VSDExceptions.cs
- VScrollProperties.cs
- ProcessModuleCollection.cs
- Int32Rect.cs
- CompilationLock.cs
- CodeNamespaceImportCollection.cs
- BuildProvidersCompiler.cs
- NavigationProperty.cs
- RecognizedPhrase.cs
- SizeValueSerializer.cs
- SafeFindHandle.cs
- CompiledXpathExpr.cs
- GridViewAutomationPeer.cs
- Panel.cs
- CachedBitmap.cs
- ToolStripManager.cs
- BlockUIContainer.cs
- XmlCollation.cs
- PointF.cs
- FunctionDescription.cs
- ObjectContext.cs
- FontUnit.cs
- MultipleViewPatternIdentifiers.cs
- XmlTextReaderImplHelpers.cs
- OrderPreservingPipeliningMergeHelper.cs
- EntityDataSourceDataSelection.cs
- ConsumerConnectionPoint.cs
- ChildDocumentBlock.cs
- RegexTree.cs
- AddInStore.cs
- DelegatedStream.cs
- ElementMarkupObject.cs
- HtmlEmptyTagControlBuilder.cs
- WebHttpElement.cs
- Fonts.cs
- XmlEntityReference.cs
- DataGridColumn.cs
- PropertyEntry.cs
- XmlEncoding.cs
- FreezableDefaultValueFactory.cs
- tibetanshape.cs
- EncoderFallback.cs
- CallbackBehaviorAttribute.cs
- Operator.cs
- DesignerActionUIStateChangeEventArgs.cs
- ScaleTransform3D.cs
- TemplateBaseAction.cs
- BindingCompleteEventArgs.cs
- InkCanvasSelectionAdorner.cs
- SystemUnicastIPAddressInformation.cs
- SQLCharsStorage.cs
- UrlAuthFailedErrorFormatter.cs