Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / MS / Internal / Shaping / GlyphingCache.cs / 1 / GlyphingCache.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: High level glyphing cache // // History: 5-19-2005 [....] 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CollectionBase.cs
- XpsPackagingPolicy.cs
- ToolStripDropDownItemDesigner.cs
- Matrix3DStack.cs
- cookie.cs
- SpecialNameAttribute.cs
- WindowClosedEventArgs.cs
- ImportedPolicyConversionContext.cs
- HelpEvent.cs
- FileClassifier.cs
- TaskExceptionHolder.cs
- FilteredXmlReader.cs
- CacheChildrenQuery.cs
- ShaderEffect.cs
- TcpHostedTransportConfiguration.cs
- SetterBase.cs
- ConstructorNeedsTagAttribute.cs
- BinaryConverter.cs
- Point.cs
- ScalarOps.cs
- StrongNameIdentityPermission.cs
- DbDataAdapter.cs
- MessagePropertyFilter.cs
- FileNotFoundException.cs
- XmlElementCollection.cs
- BitmapMetadataEnumerator.cs
- ProfileGroupSettingsCollection.cs
- MexBindingBindingCollectionElement.cs
- TextStore.cs
- DesignOnlyAttribute.cs
- _BufferOffsetSize.cs
- SizeConverter.cs
- GroupLabel.cs
- StorageScalarPropertyMapping.cs
- XPathChildIterator.cs
- MimeReturn.cs
- MetadataCache.cs
- IndexedString.cs
- HyperLink.cs
- PathTooLongException.cs
- XmlLoader.cs
- ProbeDuplexAsyncResult.cs
- SubclassTypeValidatorAttribute.cs
- DivideByZeroException.cs
- CommandConverter.cs
- FormsIdentity.cs
- EditorPartDesigner.cs
- WebBrowserContainer.cs
- ConfigurationStrings.cs
- SystemIPv4InterfaceProperties.cs
- CodeTypeParameter.cs
- PropertyTabAttribute.cs
- EncryptedData.cs
- TextLineResult.cs
- XPathBinder.cs
- SqlGatherConsumedAliases.cs
- Accessible.cs
- Function.cs
- BamlResourceDeserializer.cs
- StyleHelper.cs
- EncodingInfo.cs
- RoutedEventHandlerInfo.cs
- CheckBoxFlatAdapter.cs
- mediapermission.cs
- XmlExpressionDumper.cs
- CodeComment.cs
- HttpListenerPrefixCollection.cs
- SamlSecurityToken.cs
- NamedElement.cs
- WeakReferenceKey.cs
- DataGridViewRowStateChangedEventArgs.cs
- WebPartTracker.cs
- CollectionEditorDialog.cs
- InternalRelationshipCollection.cs
- CodePageUtils.cs
- LinkTarget.cs
- CaseExpr.cs
- WriteableBitmap.cs
- DefinitionProperties.cs
- XmlIlTypeHelper.cs
- QueryExpr.cs
- XmlMembersMapping.cs
- LockRecoveryTask.cs
- XhtmlBasicListAdapter.cs
- UriTemplateCompoundPathSegment.cs
- EmptyStringExpandableObjectConverter.cs
- BooleanAnimationBase.cs
- StateInitialization.cs
- XmlStringTable.cs
- TextWriterEngine.cs
- EmbeddedObject.cs
- WebPartsPersonalizationAuthorization.cs
- EdmSchemaError.cs
- WebServiceResponseDesigner.cs
- ClientBuildManager.cs
- ToolboxItemFilterAttribute.cs
- ReturnType.cs
- DecimalConstantAttribute.cs
- __Filters.cs
- Oid.cs