XpsFont 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 XpsDocument 中的字体。
public ref class XpsFont : System::Windows::Xps::Packaging::XpsResource
public class XpsFont : System.Windows.Xps.Packaging.XpsResource
type XpsFont = class
inherit XpsResource
Public Class XpsFont
Inherits XpsResource
- 继承
示例
以下示例演示如何向 添加字体 XpsDocument。
// -------------------------- AddPageResources ----------------------------
Dictionary<System::String^,List<XpsResource^>^>^ AddPageResources (IXpsFixedPageWriter^ fixedPageWriter)
{
// Collection of all resources for this page.
// Key: "XpsImage", "XpsFont"
// Value: List of XpsImage or XpsFont
Dictionary<System::String^,List<XpsResource^>^>^ resources = gcnew Dictionary<System::String^,List<XpsResource^>^>();
// Collections of images and fonts used in the current page.
List<XpsResource^>^ xpsImages = gcnew List<XpsResource^>();
List<XpsResource^>^ xpsFonts = gcnew List<XpsResource^>();
try
{
XpsImage^ xpsImage;
XpsFont^ xpsFont;
// Add, Write, and Commit image1 to the current page.
xpsImage = fixedPageWriter->AddImage(XpsImageType::JpegImageType);
WriteToStream(xpsImage->GetStream(), image1);
xpsImage->Commit();
xpsImages->Add(xpsImage); // Add image1 as a required resource.
// Add, Write, and Commit font 1 to the current page.
xpsFont = fixedPageWriter->AddFont();
WriteObfuscatedStream(xpsFont->Uri->ToString(), xpsFont->GetStream(), font1);
xpsFont->Commit();
xpsFonts->Add(xpsFont); // Add font1 as a required resource.
// Add, Write, and Commit image2 to the current page.
xpsImage = fixedPageWriter->AddImage(XpsImageType::TiffImageType);
WriteToStream(xpsImage->GetStream(), image2);
xpsImage->Commit();
xpsImages->Add(xpsImage); // Add image2 as a required resource.
// Add, Write, and Commit font2 to the current page.
xpsFont = fixedPageWriter->AddFont(false);
WriteToStream(xpsFont->GetStream(), font2);
xpsFont->Commit();
xpsFonts->Add(xpsFont); // Add font2 as a required resource.
// Return the image and font resources in a combined collection.
resources->Add("XpsImage", xpsImages);
resources->Add("XpsFont", xpsFonts);
return resources;
} catch (XpsPackagingException^ xpsException)
{
throw xpsException;
}
};// end:AddPageResources()
// -------------------------- AddPageResources ----------------------------
private Dictionary<string, List<XpsResource>>
AddPageResources(IXpsFixedPageWriter fixedPageWriter)
{
// Collection of all resources for this page.
// Key: "XpsImage", "XpsFont"
// Value: List of XpsImage or XpsFont
Dictionary<string, List<XpsResource>> resources =
new Dictionary<string, List<XpsResource>>();
// Collections of images and fonts used in the current page.
List<XpsResource> xpsImages = new List<XpsResource>();
List<XpsResource> xpsFonts = new List<XpsResource>();
try
{
XpsImage xpsImage;
XpsFont xpsFont;
// Add, Write, and Commit image1 to the current page.
xpsImage = fixedPageWriter.AddImage(XpsImageType.JpegImageType);
WriteToStream(xpsImage.GetStream(), image1);
xpsImage.Commit();
xpsImages.Add(xpsImage); // Add image1 as a required resource.
// Add, Write, and Commit font 1 to the current page.
xpsFont = fixedPageWriter.AddFont();
WriteObfuscatedStream(
xpsFont.Uri.ToString(), xpsFont.GetStream(), font1);
xpsFont.Commit();
xpsFonts.Add(xpsFont); // Add font1 as a required resource.
// Add, Write, and Commit image2 to the current page.
xpsImage = fixedPageWriter.AddImage(XpsImageType.TiffImageType);
WriteToStream(xpsImage.GetStream(), image2);
xpsImage.Commit();
xpsImages.Add(xpsImage); // Add image2 as a required resource.
// Add, Write, and Commit font2 to the current page.
xpsFont = fixedPageWriter.AddFont(false);
WriteToStream(xpsFont.GetStream(), font2);
xpsFont.Commit();
xpsFonts.Add(xpsFont); // Add font2 as a required resource.
// Return the image and font resources in a combined collection.
resources.Add("XpsImage", xpsImages);
resources.Add("XpsFont", xpsFonts);
return resources;
}
catch (XpsPackagingException xpsException)
{
throw xpsException;
}
}// end:AddPageResources()
' -------------------------- AddPageResources ----------------------------
Private Function AddPageResources(ByVal fixedPageWriter As IXpsFixedPageWriter) As Dictionary(Of String, List(Of XpsResource))
' Collection of all resources for this page.
' Key: "XpsImage", "XpsFont"
' Value: List of XpsImage or XpsFont
Dim resources As New Dictionary(Of String, List(Of XpsResource))()
' Collections of images and fonts used in the current page.
Dim xpsImages As New List(Of XpsResource)()
Dim xpsFonts As New List(Of XpsResource)()
Try
Dim xpsImage As XpsImage
Dim xpsFont As XpsFont
' Add, Write, and Commit image1 to the current page.
xpsImage = fixedPageWriter.AddImage(XpsImageType.JpegImageType)
WriteToStream(xpsImage.GetStream(), image1)
xpsImage.Commit()
xpsImages.Add(xpsImage) ' Add image1 as a required resource.
' Add, Write, and Commit font 1 to the current page.
xpsFont = fixedPageWriter.AddFont()
WriteObfuscatedStream(xpsFont.Uri.ToString(), xpsFont.GetStream(), font1)
xpsFont.Commit()
xpsFonts.Add(xpsFont) ' Add font1 as a required resource.
' Add, Write, and Commit image2 to the current page.
xpsImage = fixedPageWriter.AddImage(XpsImageType.TiffImageType)
WriteToStream(xpsImage.GetStream(), image2)
xpsImage.Commit()
xpsImages.Add(xpsImage) ' Add image2 as a required resource.
' Add, Write, and Commit font2 to the current page.
xpsFont = fixedPageWriter.AddFont(False)
WriteToStream(xpsFont.GetStream(), font2)
xpsFont.Commit()
xpsFonts.Add(xpsFont) ' Add font2 as a required resource.
' Return the image and font resources in a combined collection.
resources.Add("XpsImage", xpsImages)
resources.Add("XpsFont", xpsFonts)
Return resources
Catch xpsException As XpsPackagingException
Throw xpsException
End Try
End Function ' end:AddPageResources()
注解
类 XpsFont 没有公共构造函数。
AddFont使用 方法可添加字体并在新文档中获取对它的引用。
GetFont使用 方法获取现有文档中的字体引用。
根据 XpsSerializationManager 和 XpsPackagingPolicy的设置PackageInterleavingOrderFontSubsetterCommitPolicies,类的 方法XpsFont的Commit刷新操作可能会延迟,直到整个XpsDocument关闭。
属性
IsObfuscated |
获取一个值,该值指示是否对字体进行了模糊处理。 |
IsRestricted |
获取或设置一个指示使用此字体的文本是否可以修改的值。 |
Uri |
获取或设置部件的统一资源标识符 (URI)。 (继承自 XpsPartBase) |
方法
Commit() |
向文档包提交所有更改并刷新资源。 (继承自 XpsResource) |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetStream() |
在派生类中重写时,返回用于读取或写入资源的 I/O 流。 (继承自 XpsResource) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ObfuscateFontData(Byte[], Guid) |
对字体数据进行模糊处理。 |
RelativeUri(Uri) |
返回资源相对于指定的绝对 URI 的 URI。 (继承自 XpsResource) |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |
显式接口实现
IDisposable.Dispose() |
此成员支持 Windows Presentation Foundation 基础结构,且不应在代码中直接使用。 (继承自 XpsResource) |