Beispiel #1
0
        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);
        }
Beispiel #2
0
 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);
 }
Beispiel #3
0
        IsRestrictedFont(
            FontEmbeddingRight fsType
            )
        {
            bool isRestrictedFont = false;

            switch (fsType)
            {
            case FontEmbeddingRight.PreviewAndPrintButNoSubsetting:
            case FontEmbeddingRight.PreviewAndPrint:
                isRestrictedFont = true;
                break;
            }
            return(isRestrictedFont);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        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);
        }