Exemple #1
0
 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);
        }
Exemple #3
0
        signalReleaseToFontService(
            Type writerType
            )
        {
            bool subsetComplete = false;
            int  refCnt         = DecrementRefCntByType(writerType);

            // signal the font sub-setter that we completed a node
            if (_resourcePolicy != null)
            {
                XpsFontSerializationService fontService = (XpsFontSerializationService)_resourcePolicy.GetService(typeof(XpsFontSerializationService));
                //
                // The font subsetter will determine if based on this
                // signal we have completed a subset
                //
                if (fontService != null && refCnt == 0)
                {
                    subsetComplete = fontService.SignalCommit(writerType);
                }
            }
        }
Exemple #4
0
        ReleaseXmlWriter(
            Type writerType
            )
        {
            Toolbox.EmitEvent(EventTrace.Event.WClientDRXReleaseWriterStart);

            bool subsetComplete = false;
            int  refCnt         = DecrementRefCntByType(writerType);

            //
            // signal the font sub-setter that we completed a node
            if (_resourcePolicy != null)
            {
                XpsFontSerializationService fontService = (XpsFontSerializationService)_resourcePolicy.GetService(typeof(XpsFontSerializationService));
                //
                // The font subsetter will determine if based on this
                // signal we have completed a subset
                //
                if (fontService != null && refCnt == 0)
                {
                    subsetComplete = fontService.SignalCommit(writerType);
                }
            }


            //
            // Allow the packaging policy to release the stream
            //
            if (_packagingPolicy != null)
            {
                if (writerType == typeof(FixedDocumentSequence))
                {
                    _packagingPolicy.ReleaseXmlWriterForFixedDocumentSequence();
                }
                else if (writerType == typeof(FixedDocument))
                {
                    _packagingPolicy.ReleaseXmlWriterForFixedDocument();
                }
                else if (writerType == typeof(FixedPage))
                {
                    _packagingPolicy.ReleaseXmlWriterForFixedPage();
                }
                else if (writerType == typeof(Visual))
                {
                    _packagingPolicy.ReleaseXmlWriterForFixedPage();
                }
                else
                {
                    throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NotSupported));
                }
            }

            //
            // If the subsetting is complete we need to notify the interleaving policy
            // so it can flush.
            //
            if (subsetComplete && refCnt == 0)
            {
                XpsPackagingPolicy xpsPackagingPolicy = _packagingPolicy as  XpsPackagingPolicy;
                if (xpsPackagingPolicy != null)
                {
                    xpsPackagingPolicy.InterleavingPolicy.SignalSubsetComplete();
                }
            }

            Toolbox.EmitEvent(EventTrace.Event.WClientDRXReleaseWriterEnd);
        }