Archive for the ‘DirectWrite’ Category:

TouchMind 1.0.0 released

Saturday, December 31st, 2011

TouchMind 1.0.0 was released on December 12. I hope it’s stable. If you have any issues, please inform me.

Archive for the ‘DirectWrite’ Category:

TouchMind 1.0.0 released

Saturday, December 31st, 2011

New application ‘Game of Life 3D’ released.

Archive for the ‘DirectWrite’ Category:

TouchMind 1.0.0 released

Saturday, December 31st, 2011

I tested to add a ellipsis trimming sign to the text with DirectWrite. The key point is that I need to invoke CreateEllipsisTrimmingSign().

IDWriteInlineObject *inlineObject = nullptr;
m_pDWriteFactory->CreateEllipsisTrimmingSign(
  textLayout,
  &inlineObject);
DWRITE_TRIMMING trimming =
  {DWRITE_TRIMMING_GRANULARITY_CHARACTER, 0, 0};
textLayout->SetTrimming(&trimming, inlineObject);
sample 1
std::wstring text(L"aaaaaaaaaaaa");
m_pDWriteFactory->CreateTextLayout(
  text.c_str(),
  text.length(),
  textFormat,
  160.0f, 80.0f,
  &textLayout);

sample 2
std::wstring text(
  L"aaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaa");
...

sample 3
std::wstring text(
  L"aaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaa");
...
DWRITE_TRIMMING trimming =
  {DWRITE_TRIMMING_GRANULARITY_WORD, 0, 0};
textLayout->SetTrimming(&trimming, inlineObject);

Archive for the ‘DirectWrite’ Category:

TouchMind 1.0.0 released

Saturday, December 31st, 2011

I investigated what metrics I can get from DirectWrite text layout (IDWriteTextLayout).

IDWriteTextLayout::GetMaxWidth(), GetMaxHeight()

It seems that GetMaxWidth() and GetMaxHeight() simply return the layout width and height which are specified at IDWriteFactory::CreateTextLayout method().

IDWriteTextLayout::DetermineMinWidth(FLOAT)

DetermineMinWidth() returns the maximum width of the word in the text. If the layout width is smaller than this width, the word in the text is broken.

example 1:
std::wstring text(L"Aa Bbbbb");
m_pDWriteFactory->CreateTextLayout(
  text.c_str(),
  text.length(),
  textFormat,
  120.0f, 30.0f,
  &textLayout);
FLOAT width;
textLayout->DetermineMinWidth(&width);

example 2:
std::wstring text(L"Aaaaaa Bbb Cccc");
...

DWRITE_TEXT_METRICS layoutWidth/layoutHeight

layoutWidth and layoutHeight of a DWRITE_TEXT_METRICS structure are same as the layout width and height which are specified at IDWriteFactory::CreateTextLayout method().

DWRITE_TEXT_METRICS width/height

DWRITE_TEXT_METRICS.width indicates the width of the formatted text, while ignoring trailing whitespace at the end of each line.

DWRITE_TEXT_METRICS.height indicates the height of the formatted text.

example 1:
std::wstring text(L"Abc");
m_pDWriteFactory->CreateTextLayout(
  text.c_str(),
  text.length(),
  textFormat,
  120.0f, 30.0f,
  &textLayout);
DWRITE_TEXT_METRICS textMetrics;
textLayout->GetMetrics(&textMetrics);

example 2:
std::wstring text(L"  Abc  ");
...

example 3:
std::wstring text(L"Abc Def");
...

DWRITE_TEXT_METRICS widthIncludingTrailingWhitespace

DWRITE_TEXT_METRICS.widthIncludingTrailingWhitespace indicates the width of the formatted text, taking into account the trailing whitespace at the end of each line.

example 1:
std::wstring text(L"  Abc  ");