コード例 #1
0
ファイル: XpsFontSubsetter.cs プロジェクト: hughbe/wpf
        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;
        }
コード例 #2
0
ファイル: XpsFontSubsetter.cs プロジェクト: hughbe/wpf
        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);
        }
コード例 #3
0
ファイル: XpsFontSubsetter.cs プロジェクト: hughbe/wpf
        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);
        }
コード例 #4
0
ファイル: XpsFontSubsetter.cs プロジェクト: hughbe/wpf
        AddRestrictedRelationship(
            )
        {
            FontEmbeddingAction action = XpsFontSubsetter.DetermineEmbeddingAction(_glyphTypeface);

            if (action != FontEmbeddingAction.ImageOnlyFont &&
                XpsFontSubsetter.IsRestrictedFont(_glyphTypeface))
            {
                _packagingPolicy.
                RelateRestrictedFontToCurrentDocument(
                    _fontResourceStream.Uri
                    );
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: XpsFontSubsetter.cs プロジェクト: hughbe/wpf
        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;
            }
        }