예제 #1
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);
        }
예제 #2
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);
        }