Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / MS / Internal / FontFace / FontDifferentiator.cs / 1305600 / FontDifferentiator.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: FontDifferentiator class handles parsing font family and face names // and adjusting stretch, weight and style values. // // History: // 11/10/2005 : mleonov - Started integration from a prototype application created by DBrown. // 1/21/2009 : [....] - removed unused code. // //--------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Globalization; using System.Text; using System.Windows; using System.Windows.Markup; // for XmlLanguage namespace MS.Internal.FontFace { ////// FontDifferentiator class handles parsing font family and face names /// and adjusting stretch, weight and style values. /// internal static class FontDifferentiator { internal static IDictionaryConstructFaceNamesByStyleWeightStretch( FontStyle style, FontWeight weight, FontStretch stretch) { string faceName = BuildFaceName(style, weight, stretch); // Default comparer calls CultureInfo.Equals, which works for our purposes. Dictionary faceNames = new Dictionary (1); faceNames.Add(XmlLanguage.GetLanguage("en-us"), faceName); return faceNames; } private static string BuildFaceName( FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch ) { string parsedStyleName = null; string parsedWeightName = null; string parsedStretchName = null; string regularFaceName = "Regular"; if (fontWeight != FontWeights.Normal) parsedWeightName = ((IFormattable)fontWeight).ToString(null, CultureInfo.InvariantCulture); if (fontStretch != FontStretches.Normal) parsedStretchName = ((IFormattable)fontStretch).ToString(null, CultureInfo.InvariantCulture); if (fontStyle != FontStyles.Normal) parsedStyleName = ((IFormattable)fontStyle).ToString(null, CultureInfo.InvariantCulture); // Build correct face string. // Set the initial capacity to be able to hold the word "Regular". StringBuilder faceNameBuilder = new StringBuilder(7); if (parsedStretchName != null) { faceNameBuilder.Append(parsedStretchName); } if (parsedWeightName != null) { if (faceNameBuilder.Length > 0) { faceNameBuilder.Append(" "); } faceNameBuilder.Append(parsedWeightName); } if (parsedStyleName != null) { if (faceNameBuilder.Length > 0) { faceNameBuilder.Append(" "); } faceNameBuilder.Append(parsedStyleName); } if (faceNameBuilder.Length == 0) { faceNameBuilder.Append(regularFaceName); } return faceNameBuilder.ToString(); } } } // 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
- WebPartHelpVerb.cs
- TripleDES.cs
- SecureStringHasher.cs
- HTMLTextWriter.cs
- UInt32Storage.cs
- followingsibling.cs
- UpdateProgress.cs
- JulianCalendar.cs
- RewritingProcessor.cs
- XmlEnumAttribute.cs
- HwndSource.cs
- PerSessionInstanceContextProvider.cs
- ToolStripArrowRenderEventArgs.cs
- TextChangedEventArgs.cs
- FontFamilyConverter.cs
- DetailsViewUpdatedEventArgs.cs
- FrameworkElement.cs
- SiteMapProvider.cs
- UserNameSecurityTokenProvider.cs
- EntityContainer.cs
- GridViewPageEventArgs.cs
- XmlWrappingWriter.cs
- CannotUnloadAppDomainException.cs
- DataSourceBooleanViewSchemaConverter.cs
- PerfCounters.cs
- ForEachAction.cs
- remotingproxy.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- XpsFixedDocumentSequenceReaderWriter.cs
- WebServiceEndpoint.cs
- CleanUpVirtualizedItemEventArgs.cs
- SafeMILHandle.cs
- WebConvert.cs
- DataGridViewRowConverter.cs
- IndentedTextWriter.cs
- ContextStack.cs
- ForceCopyBuildProvider.cs
- TypeConverterHelper.cs
- SpeakProgressEventArgs.cs
- TextSelectionHighlightLayer.cs
- IntSecurity.cs
- DefaultPropertyAttribute.cs
- CodeDomLoader.cs
- SignerInfo.cs
- ScriptServiceAttribute.cs
- SecureEnvironment.cs
- XPathAncestorQuery.cs
- VBCodeProvider.cs
- ServiceEndpointElement.cs
- HatchBrush.cs
- TransformProviderWrapper.cs
- RowSpanVector.cs
- RowCache.cs
- TextSelection.cs
- EmptyElement.cs
- SqlProfileProvider.cs
- ViewStateException.cs
- DateTimeSerializationSection.cs
- CryptoHelper.cs
- EditorPartCollection.cs
- Setter.cs
- RegistrationServices.cs
- MultiBindingExpression.cs
- CheckBoxRenderer.cs
- ScriptingSectionGroup.cs
- Util.cs
- MultiBindingExpression.cs
- DownloadProgressEventArgs.cs
- SqlInternalConnectionTds.cs
- ProtectedConfigurationProviderCollection.cs
- ControlEvent.cs
- DoubleAnimationBase.cs
- SqlWebEventProvider.cs
- Separator.cs
- UnknownWrapper.cs
- DataViewManager.cs
- CapiHashAlgorithm.cs
- ImpersonationContext.cs
- OnOperation.cs
- CharAnimationUsingKeyFrames.cs
- XamlClipboardData.cs
- ObjectStateEntryDbDataRecord.cs
- Environment.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- PreservationFileReader.cs
- localization.cs
- FileSystemEventArgs.cs
- TemplateManager.cs
- RemotingConfigParser.cs
- MatrixCamera.cs
- EnvironmentPermission.cs
- TextBoxRenderer.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- CodeDesigner.cs
- TableCellCollection.cs
- DataDocumentXPathNavigator.cs
- StrongNameIdentityPermission.cs
- DataControlFieldHeaderCell.cs
- GradientSpreadMethodValidation.cs
- ObjectCacheHost.cs