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 / DigitShape.cs / 1 / DigitShape.cs
//+------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2001
//
// File: DigitShape.cs
//
// Contents: DIgits shaping engine
//
// Contact: nbeal
//
// Created: 10-27-2005
//
//-----------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using MS.Internal.FontCache;
using MS.Internal.FontFace;
using MS.Internal.TextFormatting;
using System.Security;
using System.Security.Permissions;
using MS.Internal.PresentationCore;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
namespace MS.Internal.Shaping
{
///
/// Default implementation of digit shape
///
///
/// All items containing digit come here. The shape of the digit is
/// dictated by the specified language.
///
internal class DigitShape : BaseShape
{
//
// required positioning features
//
protected static readonly Feature[] _digitPositioningFeatures = new Feature[]
{
new Feature(0,ushort.MaxValue,(uint)FeatureTags.Kerning,1)
};
internal DigitShape()
{
}
public override ScriptTags[] SupportedScripts
{
get { return new ScriptTags[]{ Script.TagDigit }; }
}
///
/// DigitShape.GetGlyphs
/// helper for the IShaper method. The function call is used to
/// shape the Latin unicode characters.
///
/// shaping currentRun
/// Text item
/// number of glyphs
///
/// Critical - calls critical code, uses unsafe accessors
///
[SecurityCritical]
unsafe protected override int GetGlyphs ( ref ShapingWorkspace currentRun, Item item )
{
DigitMap digitMap = new DigitMap(item.DigitCulture);
char currChar;
while (currentRun.GetNextChar (out currChar))
{
char digitChar = (char)digitMap[currChar];
currentRun.SetGlyphPropertiesUsingChar( CharShapeInfo.IsStartOfCluster,
digitChar);
// If no glyph, perhaps we have a second choice.
if (currentRun.CurrentGlyph == 0)
{
digitChar = (char)DigitMap.GetFallbackCharacter(digitChar);
if (digitChar != 0)
{
currentRun.CurrentGlyph = currentRun.CharConverter.ToGlyph(digitChar);
}
}
}
return currentRun.GlyphsCount;
}
///
/// DigitShape.InitializeFontClient -IShaper methods helper.
///
///
/// This function is called from GetGlyphs and GetGlyphPlacements
/// (IShaper methods) to do the necessary shaper initialization
///
///
/// Critical - this method calls critical methods.
/// Safe - this method doesn't expose anything unsafe to the world.
///
[SecurityCritical, SecurityTreatAsSafe]
protected override ShaperFontClient InitializeFontClient ( Item item,
CultureInfo culture,
GlyphTypeface fontFace,
OpenTypeTags featureType,
object shapeFontInfo )
{
Item digitItem = item;
ShaperFontClient fontClient = shapeFontInfo as ShaperFontClient;
if ( fontClient != null )
{
ScriptTags scriptTag = ScriptTags.Latin; // use Latin script for digits
if (OpenTypeLayout.FindScript(fontClient,(uint)scriptTag) != TagInfoFlags.None)
{
fontClient.IsScriptSupportedByFont = true;
digitItem = new Item(ScriptID.Latin, item.Flags);
digitItem.DigitCulture = item.DigitCulture;
}
}
return base.InitializeFontClient ( digitItem,
culture,
fontFace,
featureType,
fontClient );
}
///
/// DigitShape.OnLoadFont - IShapingEngine method override.
///
///
/// We override the base implementation because this shaper
/// has work to do regardless of the script.
///
/// Script of interest.
/// Font face being loaded
/// always returns null
/// True if font supports script.
///
/// Critical - This method reads into raw font table bits.
/// Safe - This method doesn't expose any critical data.
///
[SecurityCritical, SecurityTreatAsSafe]
public override bool OnLoadFont(
ScriptTags scriptTag,
GlyphTypeface fontFace,
out object shapeState
)
{
// create the font client for this font/script
ShaperFontClient fontClient = new ShaperFontClient( fontFace );
// Now check if script support does exist in font
if (OpenTypeLayout.FindScript(fontClient,(uint)scriptTag) != TagInfoFlags.None)
{
fontClient.IsScriptSupportedByFont = true;
}
shapeState = fontClient;
return true;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//+------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation, 2001
//
// File: DigitShape.cs
//
// Contents: DIgits shaping engine
//
// Contact: nbeal
//
// Created: 10-27-2005
//
//-----------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using MS.Internal.FontCache;
using MS.Internal.FontFace;
using MS.Internal.TextFormatting;
using System.Security;
using System.Security.Permissions;
using MS.Internal.PresentationCore;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
namespace MS.Internal.Shaping
{
///
/// Default implementation of digit shape
///
///
/// All items containing digit come here. The shape of the digit is
/// dictated by the specified language.
///
internal class DigitShape : BaseShape
{
//
// required positioning features
//
protected static readonly Feature[] _digitPositioningFeatures = new Feature[]
{
new Feature(0,ushort.MaxValue,(uint)FeatureTags.Kerning,1)
};
internal DigitShape()
{
}
public override ScriptTags[] SupportedScripts
{
get { return new ScriptTags[]{ Script.TagDigit }; }
}
///
/// DigitShape.GetGlyphs
/// helper for the IShaper method. The function call is used to
/// shape the Latin unicode characters.
///
/// shaping currentRun
/// Text item
/// number of glyphs
///
/// Critical - calls critical code, uses unsafe accessors
///
[SecurityCritical]
unsafe protected override int GetGlyphs ( ref ShapingWorkspace currentRun, Item item )
{
DigitMap digitMap = new DigitMap(item.DigitCulture);
char currChar;
while (currentRun.GetNextChar (out currChar))
{
char digitChar = (char)digitMap[currChar];
currentRun.SetGlyphPropertiesUsingChar( CharShapeInfo.IsStartOfCluster,
digitChar);
// If no glyph, perhaps we have a second choice.
if (currentRun.CurrentGlyph == 0)
{
digitChar = (char)DigitMap.GetFallbackCharacter(digitChar);
if (digitChar != 0)
{
currentRun.CurrentGlyph = currentRun.CharConverter.ToGlyph(digitChar);
}
}
}
return currentRun.GlyphsCount;
}
///
/// DigitShape.InitializeFontClient -IShaper methods helper.
///
///
/// This function is called from GetGlyphs and GetGlyphPlacements
/// (IShaper methods) to do the necessary shaper initialization
///
///
/// Critical - this method calls critical methods.
/// Safe - this method doesn't expose anything unsafe to the world.
///
[SecurityCritical, SecurityTreatAsSafe]
protected override ShaperFontClient InitializeFontClient ( Item item,
CultureInfo culture,
GlyphTypeface fontFace,
OpenTypeTags featureType,
object shapeFontInfo )
{
Item digitItem = item;
ShaperFontClient fontClient = shapeFontInfo as ShaperFontClient;
if ( fontClient != null )
{
ScriptTags scriptTag = ScriptTags.Latin; // use Latin script for digits
if (OpenTypeLayout.FindScript(fontClient,(uint)scriptTag) != TagInfoFlags.None)
{
fontClient.IsScriptSupportedByFont = true;
digitItem = new Item(ScriptID.Latin, item.Flags);
digitItem.DigitCulture = item.DigitCulture;
}
}
return base.InitializeFontClient ( digitItem,
culture,
fontFace,
featureType,
fontClient );
}
///
/// DigitShape.OnLoadFont - IShapingEngine method override.
///
///
/// We override the base implementation because this shaper
/// has work to do regardless of the script.
///
/// Script of interest.
/// Font face being loaded
/// always returns null
/// True if font supports script.
///
/// Critical - This method reads into raw font table bits.
/// Safe - This method doesn't expose any critical data.
///
[SecurityCritical, SecurityTreatAsSafe]
public override bool OnLoadFont(
ScriptTags scriptTag,
GlyphTypeface fontFace,
out object shapeState
)
{
// create the font client for this font/script
ShaperFontClient fontClient = new ShaperFontClient( fontFace );
// Now check if script support does exist in font
if (OpenTypeLayout.FindScript(fontClient,(uint)scriptTag) != TagInfoFlags.None)
{
fontClient.IsScriptSupportedByFont = true;
}
shapeState = fontClient;
return true;
}
}
}
// 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
- NativeObjectSecurity.cs
- MatchAllMessageFilter.cs
- CommandBinding.cs
- BoolLiteral.cs
- TreeNodeStyle.cs
- ProcessRequestArgs.cs
- BooleanConverter.cs
- DescendantQuery.cs
- QueryOperationResponseOfT.cs
- PagesSection.cs
- FileCodeGroup.cs
- Transaction.cs
- VerificationAttribute.cs
- RuntimeWrappedException.cs
- RadioButtonAutomationPeer.cs
- TextEditorThreadLocalStore.cs
- Not.cs
- TypedTableBase.cs
- SponsorHelper.cs
- AssemblyAttributes.cs
- InternalControlCollection.cs
- AsymmetricCryptoHandle.cs
- ListControlConvertEventArgs.cs
- ZipIOCentralDirectoryFileHeader.cs
- FederatedMessageSecurityOverHttpElement.cs
- DockPattern.cs
- QueryableDataSourceEditData.cs
- TextSchema.cs
- DataServiceResponse.cs
- CurrentChangingEventArgs.cs
- EventHandlerService.cs
- WCFServiceClientProxyGenerator.cs
- TouchFrameEventArgs.cs
- PaperSource.cs
- Int64.cs
- RegexMatchCollection.cs
- ImplicitInputBrush.cs
- StreamGeometryContext.cs
- XamlBrushSerializer.cs
- SelectorAutomationPeer.cs
- _SingleItemRequestCache.cs
- PropertyMap.cs
- SessionStateSection.cs
- ContractComponent.cs
- ThreadAttributes.cs
- PerformanceCounterManager.cs
- CustomActivityDesigner.cs
- EmbeddedMailObject.cs
- ActivityFunc.cs
- Publisher.cs
- EntityDataSourceWizardForm.cs
- DataSourceHelper.cs
- InlinedAggregationOperatorEnumerator.cs
- IdnElement.cs
- _LocalDataStoreMgr.cs
- ScriptRef.cs
- SecurityKeyType.cs
- XmlSchemaObjectTable.cs
- TickBar.cs
- EventSinkHelperWriter.cs
- SoapElementAttribute.cs
- UrlAuthorizationModule.cs
- DomainUpDown.cs
- InputMethodStateChangeEventArgs.cs
- ToolStripGripRenderEventArgs.cs
- XamlFigureLengthSerializer.cs
- XmlWhitespace.cs
- SetStateDesigner.cs
- util.cs
- DataGridViewControlCollection.cs
- RadialGradientBrush.cs
- InlineObject.cs
- NoResizeHandleGlyph.cs
- WebPartVerb.cs
- CheckBoxStandardAdapter.cs
- DoubleAnimationUsingPath.cs
- SoapInteropTypes.cs
- XsltArgumentList.cs
- ViewCellSlot.cs
- EventQueueState.cs
- ControlValuePropertyAttribute.cs
- PersonalizationDictionary.cs
- GenerateTemporaryTargetAssembly.cs
- DefaultSettingsSection.cs
- mediapermission.cs
- ResourceKey.cs
- BinaryCommonClasses.cs
- ShaderRenderModeValidation.cs
- Inflater.cs
- ColumnReorderedEventArgs.cs
- CompressStream.cs
- Item.cs
- ImplicitInputBrush.cs
- FixedStringLookup.cs
- ValidationVisibilityAttribute.cs
- BuildProviderAppliesToAttribute.cs
- SBCSCodePageEncoding.cs
- EmissiveMaterial.cs
- WebPartTransformer.cs
- Attributes.cs