- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我从这个 page 得到了下面的例子在 MS 中,但由于此消息,代码未链接:
错误 LNK2019:未解析的外部符号 __imp__DWriteCreateFactory@12 在函数 _wmain 中引用
我重复下面的代码以方便阅读:
#include <dwrite.h>
#include <string.h>
#include <stdio.h>
#include <new>
// SafeRelease inline function.
template <class T> inline void SafeRelease(T **ppT)
{
if (*ppT)
{
(*ppT)->Release();
*ppT = NULL;
}
}
void wmain()
{
IDWriteFactory* pDWriteFactory = NULL;
HRESULT hr = DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED,
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(&pDWriteFactory)
);
IDWriteFontCollection* pFontCollection = NULL;
// Get the system font collection.
if (SUCCEEDED(hr))
{
hr = pDWriteFactory->GetSystemFontCollection(&pFontCollection);
}
UINT32 familyCount = 0;
// Get the number of font families in the collection.
if (SUCCEEDED(hr))
{
familyCount = pFontCollection->GetFontFamilyCount();
}
for (UINT32 i = 0; i < familyCount; ++i)
{
IDWriteFontFamily* pFontFamily = NULL;
// Get the font family.
if (SUCCEEDED(hr))
{
hr = pFontCollection->GetFontFamily(i, &pFontFamily);
}
IDWriteLocalizedStrings* pFamilyNames = NULL;
// Get a list of localized strings for the family name.
if (SUCCEEDED(hr))
{
hr = pFontFamily->GetFamilyNames(&pFamilyNames);
}
UINT32 index = 0;
BOOL exists = false;
wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
if (SUCCEEDED(hr))
{
// Get the default locale for this user.
int defaultLocaleSuccess = GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH);
// If the default locale is returned, find that locale name, otherwise use "en-us".
if (defaultLocaleSuccess)
{
hr = pFamilyNames->FindLocaleName(localeName, &index, &exists);
}
if (SUCCEEDED(hr) && !exists) // if the above find did not find a match, retry with US English
{
hr = pFamilyNames->FindLocaleName(L"en-us", &index, &exists);
}
}
// If the specified locale doesn't exist, select the first on the list.
if (!exists)
index = 0;
UINT32 length = 0;
// Get the string length.
if (SUCCEEDED(hr))
{
hr = pFamilyNames->GetStringLength(index, &length);
}
// Allocate a string big enough to hold the name.
wchar_t* name = new (std::nothrow) wchar_t[length+1];
if (name == NULL)
{
hr = E_OUTOFMEMORY;
}
// Get the family name.
if (SUCCEEDED(hr))
{
hr = pFamilyNames->GetString(index, name, length+1);
}
if (SUCCEEDED(hr))
{
// Print out the family name.
wprintf(L"%s\n", name);
}
SafeRelease(&pFontFamily);
SafeRelease(&pFamilyNames);
delete [] name;
}
SafeRelease(&pFontCollection);
SafeRelease(&pDWriteFactory);
}
因为这是我在 DirectWrite 中的第一步,所以我对上面提到的错误消息一无所知。
最佳答案
MSDN page on DWriteCreateFactory声明您必须包含 dwrite.h
(假设您在代码编译后已经完成)和链接 dwrite.lib
。
您必须将该库明确添加到您的 VisualStudio 项目中。
关于c++ - 我无法从 DirectWrite 获取此示例以在 V2015 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36068398/
我想将 DirectWrite 用于混合颜色文本格式(准确地说是语法突出显示),但似乎无法在 Layout 或 Typography 选项中找到方法。唯一的选择是在渲染文本时传递一个画笔,这对我不起作
我正在考虑将 DirectWrite 用于将在 DirectX 11 版本和 OpenGL 3.1+ 版本中推出的项目。 据了解,DirectWrite 使用位于 Direct3D 10.1 之上的
我正在尝试将我必须绘制的文本居中对齐。我用 ID2D1RenderTarget::DrawTextLayout method .问题是,如果我将文本水平对齐方式设置为 DWRITE_TEXT_ALIG
我使用 CreateTextLayout 和 CreateTextFormat 通过 DirectWrite (C++) 绘制文本,文本是混合的希伯来语/英语,有没有办法使用不同的字体/字体拉丁字符和
我的目标: 我想获取 IDWriteTextFormat 字体的高度,这样我就可以计算出在特定高度的 IDWriteTextLayout 中可以容纳多少行文本。 我的问题: 现在我正在使用这段代码来计
我正在使用 DirectWrite 将一些文本呈现到窗口中。使用不同的字体大小时,除了定位外,一切似乎都有效:我希望 2 个文本的字体大小为 v1 和 v2,并且都带有 (x, y) = (0, 0)
DirectWrite ScriptAnalysis包含一个 UINT16 数字,它是编写系统脚本的从零开始的索引表示。 我怎么知道脚本的名字?例如,在英语中该数字等于 49,而在俄语中该数字等于 2
CreateTextFormat 的文档没有提到字体回退选择,但如果选择了默认(NULL = 系统)集合,那么 DirectWrite 清楚地实现了字体回退。例如,如果我将 Gabriola 字体中未
使用 HitTestTextPosition样式 API 来自 IDWriteTextLayout我没有设法正确处理“ti”、“ffi”或其他带有 Calibri 等字体的连字中的文本位置。它总是在连
我已经知道亚像素定位会导致DirectWrite text rendering to be blurry compared to GDI。 但是,我的问题更为根本:为什么不能使用DirectWrite
使用 DirectWrite 和 Direct2D1,我试图模仿 Illustrator CS6 对区域文本框所做的渲染。 CS6 有一个选项,其中基线可以放置在距离区域文本框顶部的距离等于字体的“e
DirectWrite 通过 IDWriteTextAnalysisSink::SetLineBreakpoints() 提供换行信息。但是,我还需要根据 Unicode Annex #29: Uni
ID2D1RenderTarget::DrawGlyphRun 采用以下参数: D2D1_POINT_2F baselineOrigin, __in CONST DWRITE_GLYPH_RUN *g
我正在使用 Embarcadero RAD Studio XE7 编译器(C++ Builder),我正在尝试提供的 Direct2D API。我的目的是创建提供与 GDI 完全相同的渲染的应用程序,
我正在尝试了解 DirectWrite API,这样我就可以获得一个灵活的解决方案来解决从任何文化中呈现文本的问题,并有可能使用它来将富文本编辑合并到一个比“固定的”编辑/显示文本的方式。 PadWr
我使用 IDWriteTextAnalysisSink/AnalyzeScript 在 DirectWrite (C++) 中显示混合的 LTR(英语)和 RTL(希伯来语)文本,并根据以下公式计算文
已关闭。此问题旨在寻求有关书籍、工具、软件库等的建议。不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以
我只是在使用 C++ 中的 DirectWrite 工作,这似乎解决了我在不同渲染目标(屏幕和打印机)中具有相同布局的需求。 我仔细检查了 HelloWorld 示例 ( http://msdn.mi
我需要将使用 GDI 和 GDI+ 的现有 C++ 代码中的一些文本到位图渲染例程转换为使用 DirectWrite(需要 CFF 支持和 OTF 功能支持)。 我是 DirectWrite 的新手。
在 IE10 以上的几乎所有方面我都更喜欢谷歌浏览器,但我讨厌的一件事是字体在 IE10 中看起来好多了。这在使用小型数学字体时尤其明显。它们在 IE10 中看起来像 pdf 质量。 稍微查找了一下,
我是一名优秀的程序员,十分优秀!