C++ LogFont 嵌入到 XPS 中
C++ LogFont Embed Into XPS
我正在尝试将几个 API 结合在一起以促进 XPS 打印。由于 True Type 字体有时会限制其使用方式,因此建议您查询 OS (Windows) 以获取与字体关联的许可证。我发现这样做的被禁止方法如下所示:
HDC hDC = CreateDC(L"DISPLAY", NULL, NULL, NULL);
// logfont is a valid instance of LOGFONTW
HGDIOBJ hfont = ::CreateFontIndirect(&logfont);
if (!SelectObject(hDC, hfont))
return;
ULONG privstatus = 0;
LONG ttStatus;
ttStatus = TTGetEmbeddingType(hDC, &privstatus);
此时 ttStatus 应该是 E_NONE
如果 TTGetEmbeddingType
成功并且 privstatus 应该是 {EMBED_PREVIEWPRINT, EMBED_EDITABLE, EMBED_INSTALLABLE, EMBED_NOEMBEDDING}
之一。星期五我有这个例子。今天,当我 运行 我的可执行文件 TTGetEmbeddingType returns 0x0A (E_NOTATRUETYPEFONT)
而不是 E_NONE
时。哇?我是否遗漏了一些关于 OS 确定是否可以嵌入字体的能力的基本知识?
您引用的错误信息文本(“环境不正确”)属于ERROR_BAD_ENVIRONMENT
系统错误码,其数值为10(0x0A ).但是,TTGetEmbeddingType()
不是 return 系统错误代码。 TTGetEmbeddingType()
documentation 状态:
If successful, returns E_NONE.
This function reads the embedding privileges stored in the font and transfers the privileges to pulPrivStatus.
Otherwise, returns an error code described in Embedding-Function Error Messages.
如果您查看 T2embapi.h
中的实际定义,0x000A
的 return 值是 E_NOTATRUETYPEFONT
The specified font is not a TrueType font.
我正在尝试将几个 API 结合在一起以促进 XPS 打印。由于 True Type 字体有时会限制其使用方式,因此建议您查询 OS (Windows) 以获取与字体关联的许可证。我发现这样做的被禁止方法如下所示:
HDC hDC = CreateDC(L"DISPLAY", NULL, NULL, NULL);
// logfont is a valid instance of LOGFONTW
HGDIOBJ hfont = ::CreateFontIndirect(&logfont);
if (!SelectObject(hDC, hfont))
return;
ULONG privstatus = 0;
LONG ttStatus;
ttStatus = TTGetEmbeddingType(hDC, &privstatus);
此时 ttStatus 应该是 E_NONE
如果 TTGetEmbeddingType
成功并且 privstatus 应该是 {EMBED_PREVIEWPRINT, EMBED_EDITABLE, EMBED_INSTALLABLE, EMBED_NOEMBEDDING}
之一。星期五我有这个例子。今天,当我 运行 我的可执行文件 TTGetEmbeddingType returns 0x0A (E_NOTATRUETYPEFONT)
而不是 E_NONE
时。哇?我是否遗漏了一些关于 OS 确定是否可以嵌入字体的能力的基本知识?
您引用的错误信息文本(“环境不正确”)属于ERROR_BAD_ENVIRONMENT
系统错误码,其数值为10(0x0A ).但是,TTGetEmbeddingType()
不是 return 系统错误代码。 TTGetEmbeddingType()
documentation 状态:
If successful, returns E_NONE.
This function reads the embedding privileges stored in the font and transfers the privileges to pulPrivStatus.
Otherwise, returns an error code described in Embedding-Function Error Messages.
如果您查看 T2embapi.h
中的实际定义,0x000A
的 return 值是 E_NOTATRUETYPEFONT
The specified font is not a TrueType font.