DetermineEmbeddingAction( FontEmbeddingRight fsType ) { FontEmbeddingAction action = FontEmbeddingAction.ObfuscateSubsetFont; switch (fsType) { case FontEmbeddingRight.RestrictedLicense: case FontEmbeddingRight.PreviewAndPrintButWithBitmapsOnly: case FontEmbeddingRight.PreviewAndPrintButNoSubsettingAndWithBitmapsOnly: case FontEmbeddingRight.EditableButWithBitmapsOnly: case FontEmbeddingRight.EditableButNoSubsettingAndWithBitmapsOnly: case FontEmbeddingRight.InstallableButWithBitmapsOnly: case FontEmbeddingRight.InstallableButNoSubsettingAndWithBitmapsOnly: action = FontEmbeddingAction.ImageOnlyFont; break; case FontEmbeddingRight.PreviewAndPrint: case FontEmbeddingRight.Editable: case FontEmbeddingRight.Installable: action = FontEmbeddingAction.ObfuscateSubsetFont; break; case FontEmbeddingRight.EditableButNoSubsetting: case FontEmbeddingRight.PreviewAndPrintButNoSubsetting: case FontEmbeddingRight.InstallableButNoSubsetting: action = FontEmbeddingAction.ObfuscateOnlyFont; break; } return(action); }
private bool FontIsEmbeddable(FontEmbeddingRight rights) { switch (rights) { case FontEmbeddingRight.Editable: case FontEmbeddingRight.EditableButNoSubsetting: case FontEmbeddingRight.Installable: case FontEmbeddingRight.InstallableButNoSubsetting: case FontEmbeddingRight.PreviewAndPrint: case FontEmbeddingRight.PreviewAndPrintButNoSubsetting: return(true); } return(false); }
IsRestrictedFont( FontEmbeddingRight fsType ) { bool isRestrictedFont = false; switch (fsType) { case FontEmbeddingRight.PreviewAndPrintButNoSubsetting: case FontEmbeddingRight.PreviewAndPrint: isRestrictedFont = true; break; } return(isRestrictedFont); }
ComputeFontSubset( GlyphRun glyphRun ) { if (null == glyphRun) { throw new ArgumentNullException("glyphRun"); } FontEmbeddingRight embeddingRights = glyphRun.GlyphTypeface.EmbeddingRights; Uri fontUri = null; if (DetermineEmbeddingAction(embeddingRights) == FontEmbeddingAction.ImageOnlyFont) { // // Aquire a bit map stream to embedd the Glyph Run image // fontUri = _packagingPolicy.AcquireResourceStreamForXpsImage(XpsS0Markup.ImageUriPlaceHolder).Uri; } else { FEMCacheItem cacheItem = AcquireCacheItem( glyphRun.GlyphTypeface ); if (cacheItem != null) { cacheItem.CurrentPageReferences = true; if (_commitPolicy == FontSubsetterCommitPolicies.None && !cacheItem.IsStreamWritten) { fontUri = cacheItem.CopyFontStream(); } else { fontUri = cacheItem.AddGlyphRunUsage(glyphRun); } } } return(fontUri); }
IsRestrictedFont(GlyphTypeface glyphTypeface) { FontEmbeddingRight fsType = FontEmbeddingRight.RestrictedLicense; CodeAccessPermission fontReadPermission = glyphTypeface.CriticalFileReadPermission; if (fontReadPermission != null) { fontReadPermission.Assert(); } try { fsType = glyphTypeface.EmbeddingRights; } finally { if (fontReadPermission != null) { CodeAccessPermission.RevertAssert(); } } return(IsRestrictedFont(fsType)); }
ComputeFontSubset( GlyphRun glyphRun ) { FontEmbeddingRight embeddingRights = FontEmbeddingRight.RestrictedLicense; if (null == glyphRun) { throw new ArgumentNullException("glyphRun"); } Uri fontUri = null; CodeAccessPermission fontReadPermission = glyphRun.GlyphTypeface.CriticalFileReadPermission; if (fontReadPermission != null) { fontReadPermission.Assert(); } try { embeddingRights = glyphRun.GlyphTypeface.EmbeddingRights; } finally { if (fontReadPermission != null) { CodeAccessPermission.RevertAssert(); } } if (DetermineEmbeddingAction(embeddingRights) == FontEmbeddingAction.ImageOnlyFont) { // // Aquire a bit map stream to embedd the Glyph Run image // fontUri = _packagingPolicy.AcquireResourceStreamForXpsImage(XpsS0Markup.ImageUriPlaceHolder).Uri; } else { FEMCacheItem cacheItem = AcquireCacheItem( glyphRun.GlyphTypeface ); if (cacheItem != null) { cacheItem.CurrentPageReferences = true; if (_commitPolicy == FontSubsetterCommitPolicies.None && !cacheItem.IsStreamWritten) { fontUri = cacheItem.CopyFontStream(); } else { fontUri = cacheItem.AddGlyphRunUsage(glyphRun); } } } return(fontUri); }