AddRelationship( ) { if (!_curPageRelAdded && CurrentPageReferences) { FontEmbeddingAction action = XpsFontSubsetter.DetermineEmbeddingAction(_glyphTypeface); switch (action) { case FontEmbeddingAction.ImageOnlyFont: break; case FontEmbeddingAction.ObfuscateOnlyFont: case FontEmbeddingAction.ObfuscateSubsetFont: _packagingPolicy. RelateResourceToCurrentPage( _fontResourceStream.Uri, XpsS0Markup.ResourceRelationshipName); break; } } // Now we are finished with the current page // and need flag the need for relationship on the next _curPageRelAdded = false; }
AddGlyphRunUsage( GlyphRun glyphRun ) { Uri fontUri = null; FontEmbeddingAction action = XpsFontSubsetter.DetermineEmbeddingAction(_glyphTypeface); switch (action) { // // Provide an empty image stream. The Glyphs serializer // will check content type and render adn serialize an // image into this stream based on content type // case FontEmbeddingAction.ImageOnlyFont: break; case FontEmbeddingAction.ObfuscateOnlyFont: fontUri = _fontResourceStream.Uri; // nothing to do here since the entire font will be added break; case FontEmbeddingAction.ObfuscateSubsetFont: _fontEmbeddingManager.RecordUsage(glyphRun); fontUri = _fontResourceStream.Uri; break; } return(fontUri); }
SetFontSubsettingCountPolicy(int countPolicy) { IServiceProvider resourceServiceProvider = (IServiceProvider)ResourcePolicy; XpsFontSerializationService fontService = (XpsFontSerializationService)resourceServiceProvider.GetService(typeof(XpsFontSerializationService)); if (fontService != null) { XpsFontSubsetter fontSubsetter = fontService.FontSubsetter; fontSubsetter.SetSubsetCommitCountPolicy(countPolicy); } }
ConvertTo( ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType ) { if (context == null) { throw new ArgumentNullException("context"); } Toolbox.EmitEvent(EventTrace.Event.WClientDRXConvertFontBegin); if (!IsSupportedType(destinationType)) { throw new NotSupportedException(SR.Get(SRID.Converter_ConvertToNotSupported)); } PackageSerializationManager manager = (PackageSerializationManager)context.GetService(typeof(XpsSerializationManager)); // // Ensure that we have a valid GlyphRun instance // GlyphRun fontGlyphRun = (GlyphRun)value; if (fontGlyphRun == null) { throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "GlyphRun")); } // // Obtain the font serialization service from the serlialization manager. // IServiceProvider resourceServiceProvider = manager.ResourcePolicy; XpsFontSerializationService fontService = (XpsFontSerializationService)resourceServiceProvider.GetService(typeof(XpsFontSerializationService)); if (fontService == null) { throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NoFontService)); } // // Retrieve the current font subsetter // XpsFontSubsetter fontSubsetter = fontService.FontSubsetter; // // Add the font subset to the font subsetter and retrieve a Uri // to the font within the Xps package. // Uri resourceUri = fontSubsetter.ComputeFontSubset(fontGlyphRun); Toolbox.EmitEvent(EventTrace.Event.WClientDRXConvertFontEnd); return(resourceUri); }
AddRestrictedRelationship( ) { FontEmbeddingAction action = XpsFontSubsetter.DetermineEmbeddingAction(_glyphTypeface); if (action != FontEmbeddingAction.ImageOnlyFont && XpsFontSubsetter.IsRestrictedFont(_glyphTypeface)) { _packagingPolicy. RelateRestrictedFontToCurrentDocument( _fontResourceStream.Uri ); } }
AddGlyphRunUsage( GlyphRun glyphRun ) { Uri fontUri = null; FontEmbeddingAction action = XpsFontSubsetter.DetermineEmbeddingAction(_glyphTypeface); switch (action) { // // Provide an empty image stream. The Glyphs serializer // will check content type and render adn serialize an // image into this stream based on content type // case FontEmbeddingAction.ImageOnlyFont: break; case FontEmbeddingAction.ObfuscateOnlyFont: fontUri = _fontResourceStream.Uri; // nothing to do here since the entire font will be added break; case FontEmbeddingAction.ObfuscateSubsetFont: CodeAccessPermission uriDiscoveryPermission = glyphRun.GlyphTypeface.CriticalUriDiscoveryPermission; if (uriDiscoveryPermission != null) { uriDiscoveryPermission.Assert(); } try { _fontEmbeddingManager.RecordUsage(glyphRun); } finally { if (uriDiscoveryPermission != null) { CodeAccessPermission.RevertAssert(); } } fontUri = _fontResourceStream.Uri; break; } return(fontUri); }
Commit( ) { FontEmbeddingAction action = XpsFontSubsetter.DetermineEmbeddingAction(_glyphTypeface); switch (action) { case FontEmbeddingAction.ImageOnlyFont: // nothing to do here since the glyph runs have already been converted break; case FontEmbeddingAction.ObfuscateOnlyFont: CopyFontStream(); break; case FontEmbeddingAction.ObfuscateSubsetFont: SubSetFont( _fontEmbeddingManager.GetUsedGlyphs(_fontUri), _fontResourceStream.Stream ); break; } }
XpsFontSerializationService( BasePackagingPolicy packagingPolicy ) { _fontSubsetter = new XpsFontSubsetter(packagingPolicy); }