Exemplo n.º 1
0
        AcquireCacheItem(
            GlyphTypeface glyphTypeface
            )
        {
            FEMCacheItem         manager = null;
            Uri                  fontUri;
            CodeAccessPermission uriDiscoveryPermission = glyphTypeface.CriticalUriDiscoveryPermission;

            if (uriDiscoveryPermission != null)
            {
                uriDiscoveryPermission.Assert();
            }

            try
            {
                fontUri = glyphTypeface.FontUri;
            }
            finally
            {
                if (uriDiscoveryPermission != null)
                {
                    CodeAccessPermission.RevertAssert();
                }
            }

            if (!_fontEmbeddingManagerCache.TryGetValue(fontUri, out manager))
            {
                manager = new FEMCacheItem(glyphTypeface, _packagingPolicy);
                _fontEmbeddingManagerCache.Add(fontUri, manager);
            }

            return(manager);
        }
Exemplo n.º 2
0
        AcquireCacheItem(
            GlyphTypeface glyphTypeface
            )
        {
            FEMCacheItem manager = null;
            Uri          fontUri = glyphTypeface.FontUri;

            if (!_fontEmbeddingManagerCache.TryGetValue(fontUri, out manager))
            {
                manager = new FEMCacheItem(glyphTypeface, _packagingPolicy);
                _fontEmbeddingManagerCache.Add(fontUri, manager);
            }

            return(manager);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }