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
- ToolStripItemEventArgs.cs
- DesignerActionItemCollection.cs
- StreamWriter.cs
- PartialArray.cs
- HttpDictionary.cs
- UTF7Encoding.cs
- DataErrorValidationRule.cs
- BindingExpressionBase.cs
- Button.cs
- RoleGroup.cs
- ServiceBehaviorElementCollection.cs
- QilXmlWriter.cs
- SemanticValue.cs
- XPathDocument.cs
- InternalCompensate.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- RefreshInfo.cs
- TaiwanLunisolarCalendar.cs
- ListViewGroupConverter.cs
- SqlCharStream.cs
- ValidationSummaryDesigner.cs
- IgnoreSectionHandler.cs
- TableCell.cs
- DataBindingExpressionBuilder.cs
- XmlILConstructAnalyzer.cs
- ToolBarOverflowPanel.cs
- MetadataHelper.cs
- PackageFilter.cs
- TreeViewImageGenerator.cs
- ISAPIWorkerRequest.cs
- CssTextWriter.cs
- Label.cs
- HtmlHistory.cs
- EndpointConfigContainer.cs
- ADMembershipProvider.cs
- FileClassifier.cs
- RangeValuePatternIdentifiers.cs
- HtmlSelect.cs
- ControlParameter.cs
- XmlSchemaCompilationSettings.cs
- BoundField.cs
- StateElementCollection.cs
- Rfc2898DeriveBytes.cs
- DataBindingHandlerAttribute.cs
- PathNode.cs
- updateconfighost.cs
- CollectionsUtil.cs
- SettingsPropertyIsReadOnlyException.cs
- OptionUsage.cs
- ComboBoxDesigner.cs
- StrokeRenderer.cs
- DockPattern.cs
- TextCompositionEventArgs.cs
- ApplicationId.cs
- ExtractorMetadata.cs
- Error.cs
- QueryExecutionOption.cs
- AnimationStorage.cs
- WindowsTreeView.cs
- XmlTypeMapping.cs
- EventKeyword.cs
- SiteMapNodeItem.cs
- NameValueCollection.cs
- StyleSheetRefUrlEditor.cs
- Parameter.cs
- WebRequestModulesSection.cs
- HostedNamedPipeTransportManager.cs
- DataGridViewRowConverter.cs
- DataMember.cs
- WindowsToolbar.cs
- Hyperlink.cs
- Rules.cs
- XPathPatternParser.cs
- RegexReplacement.cs
- KeyGestureValueSerializer.cs
- MemberExpression.cs
- HttpPostProtocolReflector.cs
- HandleDictionary.cs
- TableCell.cs
- AccessKeyManager.cs
- _DisconnectOverlappedAsyncResult.cs
- UniqueEventHelper.cs
- VariableAction.cs
- EntityParameter.cs
- BamlVersionHeader.cs
- ValidatorCollection.cs
- ComponentConverter.cs
- InstanceLockedException.cs
- ContentFileHelper.cs
- XsdDateTime.cs
- ClientBuildManagerCallback.cs
- CodeLabeledStatement.cs
- DBSchemaRow.cs
- control.ime.cs
- DeclarativeCatalogPart.cs
- SerialReceived.cs
- ResourceDescriptionAttribute.cs
- CaseInsensitiveComparer.cs
- AuthorizationRuleCollection.cs
- TraceInternal.cs