Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / MS / Internal / FontCache / CachedFontFace.cs / 1 / CachedFontFace.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: The CachedFontFace class
//
// History:
// 03/04/2004 : mleonov - Cache layout and interface changes for font enumeration.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Windows;
using System.Windows.Media;
using MS.Win32;
using MS.Utility;
using MS.Internal;
using MS.Internal.FontFace;
namespace MS.Internal.FontCache
{
///
/// This structure exists because we need a common wrapper for enumeration, but we can't use original cache structures:
/// 1. C# doesn't allow IEnumerable/IEnumerator on pointer.
/// 2. The cache structures don't inherit from base class.
///
internal struct CachedFontFace
{
private FamilyCollection _familyCollection;
///
/// Critical: This is a pointer variable and hence not safe to expose.
///
[SecurityCritical]
private unsafe FamilyCollection.CachedFace * _face;
///
/// Critical: Determines value of CheckedPointer.Size, which is used for bounds checking.
///
[SecurityCritical]
private unsafe int _sizeInBytes;
///
/// Critical: This accesses a pointer and is unsafe; the sizeInBytes is critical because it
/// is used for bounds checking (via CheckedPointer)
///
[SecurityCritical]
public unsafe CachedFontFace(FamilyCollection familyCollection, FamilyCollection.CachedFace* face, int sizeInBytes)
{
_familyCollection = familyCollection;
_face = face;
_sizeInBytes = sizeInBytes;
}
///
/// Critical: This accesses a pointer and is unsafe
/// TreatAsSafe: This information is ok to return
///
public bool IsNull
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return _face == null;
}
}
}
///
/// Critical: This contructs a null object
/// TreatAsSafe: This is ok to execute
///
public static CachedFontFace Null
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return new CachedFontFace(null, null, 0);
}
}
}
///
/// Critical: This accesses unsafe code and returns a pointer
///
public unsafe FamilyCollection.CachedPhysicalFace* CachedPhysicalFace
{
[SecurityCritical]
get
{
return (FamilyCollection.CachedPhysicalFace *)_face;
}
}
///
/// Critical: This accesses unsafe code and returns a pointer
///
public unsafe FamilyCollection.CachedCompositeFace* CompositeFace
{
[SecurityCritical]
get
{
return (FamilyCollection.CachedCompositeFace *)_face;
}
}
///
/// Critical: Accesses critical fields and constructs a CheckedPointer which is a critical operation.
/// TreatAsSafe: The fields used to construct the CheckedPointer are marked critical and CheckedPointer
/// itself is safe to expose.
///
public CheckedPointer CheckedPointer
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
unsafe
{
return new CheckedPointer(_face, _sizeInBytes);
}
}
}
///
/// Critical: This accesses a pointer and is unsafe
/// TreatAsSafe: This information is ok to return
///
public FontStyle Style
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return _face->style;
}
}
}
///
/// Critical: This accesses a pointer and is unsafe
/// TreatAsSafe: This information is ok to return
///
public FontWeight Weight
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return _face->weight;
}
}
}
///
/// Critical: This accesses a pointer and is unsafe
/// TreatAsSafe: This information is ok to return
///
public FontStretch Stretch
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return _face->stretch;
}
}
}
///
/// Matching style
///
public MatchingStyle MatchingStyle
{
get
{
return new MatchingStyle(Style, Weight, Stretch);
}
}
///
/// Critical - as this accesses unsafe pointers and returns GlyphTypeface created from internal constructor
/// which exposes windows font information.
/// Safe - as this doesn't allow you to create a GlyphTypeface object for a specific
/// font and thus won't allow you to figure what fonts might be installed on
/// the machine.
///
[SecurityCritical, SecurityTreatAsSafe]
public GlyphTypeface CreateGlyphTypeface()
{
unsafe
{
return new GlyphTypeface(
_familyCollection.GetFontUri(CachedPhysicalFace),
CachedPhysicalFace->styleSimulations,
/* fromPublic = */ false
);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: The CachedFontFace class
//
// History:
// 03/04/2004 : mleonov - Cache layout and interface changes for font enumeration.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Windows;
using System.Windows.Media;
using MS.Win32;
using MS.Utility;
using MS.Internal;
using MS.Internal.FontFace;
namespace MS.Internal.FontCache
{
///
/// This structure exists because we need a common wrapper for enumeration, but we can't use original cache structures:
/// 1. C# doesn't allow IEnumerable/IEnumerator on pointer.
/// 2. The cache structures don't inherit from base class.
///
internal struct CachedFontFace
{
private FamilyCollection _familyCollection;
///
/// Critical: This is a pointer variable and hence not safe to expose.
///
[SecurityCritical]
private unsafe FamilyCollection.CachedFace * _face;
///
/// Critical: Determines value of CheckedPointer.Size, which is used for bounds checking.
///
[SecurityCritical]
private unsafe int _sizeInBytes;
///
/// Critical: This accesses a pointer and is unsafe; the sizeInBytes is critical because it
/// is used for bounds checking (via CheckedPointer)
///
[SecurityCritical]
public unsafe CachedFontFace(FamilyCollection familyCollection, FamilyCollection.CachedFace* face, int sizeInBytes)
{
_familyCollection = familyCollection;
_face = face;
_sizeInBytes = sizeInBytes;
}
///
/// Critical: This accesses a pointer and is unsafe
/// TreatAsSafe: This information is ok to return
///
public bool IsNull
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return _face == null;
}
}
}
///
/// Critical: This contructs a null object
/// TreatAsSafe: This is ok to execute
///
public static CachedFontFace Null
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return new CachedFontFace(null, null, 0);
}
}
}
///
/// Critical: This accesses unsafe code and returns a pointer
///
public unsafe FamilyCollection.CachedPhysicalFace* CachedPhysicalFace
{
[SecurityCritical]
get
{
return (FamilyCollection.CachedPhysicalFace *)_face;
}
}
///
/// Critical: This accesses unsafe code and returns a pointer
///
public unsafe FamilyCollection.CachedCompositeFace* CompositeFace
{
[SecurityCritical]
get
{
return (FamilyCollection.CachedCompositeFace *)_face;
}
}
///
/// Critical: Accesses critical fields and constructs a CheckedPointer which is a critical operation.
/// TreatAsSafe: The fields used to construct the CheckedPointer are marked critical and CheckedPointer
/// itself is safe to expose.
///
public CheckedPointer CheckedPointer
{
[SecurityCritical, SecurityTreatAsSafe]
get
{
unsafe
{
return new CheckedPointer(_face, _sizeInBytes);
}
}
}
///
/// Critical: This accesses a pointer and is unsafe
/// TreatAsSafe: This information is ok to return
///
public FontStyle Style
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return _face->style;
}
}
}
///
/// Critical: This accesses a pointer and is unsafe
/// TreatAsSafe: This information is ok to return
///
public FontWeight Weight
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return _face->weight;
}
}
}
///
/// Critical: This accesses a pointer and is unsafe
/// TreatAsSafe: This information is ok to return
///
public FontStretch Stretch
{
[SecurityCritical,SecurityTreatAsSafe]
get
{
unsafe
{
return _face->stretch;
}
}
}
///
/// Matching style
///
public MatchingStyle MatchingStyle
{
get
{
return new MatchingStyle(Style, Weight, Stretch);
}
}
///
/// Critical - as this accesses unsafe pointers and returns GlyphTypeface created from internal constructor
/// which exposes windows font information.
/// Safe - as this doesn't allow you to create a GlyphTypeface object for a specific
/// font and thus won't allow you to figure what fonts might be installed on
/// the machine.
///
[SecurityCritical, SecurityTreatAsSafe]
public GlyphTypeface CreateGlyphTypeface()
{
unsafe
{
return new GlyphTypeface(
_familyCollection.GetFontUri(CachedPhysicalFace),
CachedPhysicalFace->styleSimulations,
/* fromPublic = */ false
);
}
}
}
}
// 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
- GridViewColumnCollection.cs
- DiscardableAttribute.cs
- TypeSemantics.cs
- IDReferencePropertyAttribute.cs
- MenuDesigner.cs
- RegexMatchCollection.cs
- GACIdentityPermission.cs
- InternalConfigRoot.cs
- WebPartManager.cs
- PolyBezierSegment.cs
- CommandCollectionEditor.cs
- ScalarRestriction.cs
- HelpProvider.cs
- DoubleStorage.cs
- SqlRemoveConstantOrderBy.cs
- DesignerToolboxInfo.cs
- Nullable.cs
- SoapCommonClasses.cs
- CurrentChangingEventManager.cs
- Stroke.cs
- ContainerTracking.cs
- AndCondition.cs
- ParameterCollection.cs
- IgnoreFileBuildProvider.cs
- DynamicScriptObject.cs
- SecurityToken.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- ArgumentException.cs
- safelink.cs
- MsdtcWrapper.cs
- BamlBinaryReader.cs
- TokenBasedSet.cs
- TrustExchangeException.cs
- StackOverflowException.cs
- SmtpReplyReaderFactory.cs
- AbstractExpressions.cs
- KeyEventArgs.cs
- AxisAngleRotation3D.cs
- TreeView.cs
- NetStream.cs
- HttpModuleCollection.cs
- AssemblyUtil.cs
- contentDescriptor.cs
- ExpressionPrefixAttribute.cs
- FormViewPagerRow.cs
- BulletDecorator.cs
- RootProfilePropertySettingsCollection.cs
- BitVec.cs
- ExpandCollapsePattern.cs
- CollectionConverter.cs
- AutomationElementIdentifiers.cs
- SizeAnimationUsingKeyFrames.cs
- SynchronizationContext.cs
- IsolatedStorageFile.cs
- WebPartChrome.cs
- LinearKeyFrames.cs
- SafeFileHandle.cs
- LicenseManager.cs
- RequestTimeoutManager.cs
- MemberAccessException.cs
- MeasureItemEvent.cs
- OdbcDataAdapter.cs
- XPathNavigatorKeyComparer.cs
- XmlSignatureManifest.cs
- DataBindingValueUIHandler.cs
- MaterialCollection.cs
- odbcmetadatafactory.cs
- ApplicationFileCodeDomTreeGenerator.cs
- PlainXmlWriter.cs
- Message.cs
- ObjectSecurity.cs
- JapaneseLunisolarCalendar.cs
- DictionaryItemsCollection.cs
- PageCatalogPart.cs
- DataGridViewDataConnection.cs
- LocalizableResourceBuilder.cs
- CheckBoxList.cs
- ServiceReference.cs
- ProtocolElement.cs
- WebPartDisplayModeEventArgs.cs
- Switch.cs
- CategoryAttribute.cs
- NamedPipeProcessProtocolHandler.cs
- HttpFileCollectionWrapper.cs
- x509store.cs
- BufferedReadStream.cs
- WebPartHeaderCloseVerb.cs
- PathGradientBrush.cs
- EncryptedReference.cs
- RtfControls.cs
- MultiView.cs
- TypeUnloadedException.cs
- AssemblyBuilderData.cs
- ScrollItemProviderWrapper.cs
- CompilerState.cs
- CompositeDataBoundControl.cs
- PerspectiveCamera.cs
- EventSourceCreationData.cs
- SystemWebCachingSectionGroup.cs
- CngProvider.cs