AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
WordWrap.h File Reference

greedy word wrap with pluggable width and break rules, unit tested in tests/cpp/test_word_wrap.cpp. More...

#include <cstddef>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  hpl

Typedefs

typedef std::vector< std::pair< size_t, size_t > > hpl::tWrapRows

Functions

template<class TWidth, class TCanBreak>
void hpl::WordWrapRows (const wchar_t *apText, size_t alLen, float afMaxWidth, TWidth afWidth, TCanBreak afCanBreak, tWrapRows &aRows)
 afWidth(start, end) gives the drawn width of s[start, end).

Detailed Description

greedy word wrap with pluggable width and break rules, unit tested in tests/cpp/test_word_wrap.cpp.

Used by iFontData::GetWordWrapRows when native CJK is on.

Break opportunities:

  • at a space (the space is dropped at the break),
  • before character i when afCanBreak(s[i-1], s[i]) (nothing dropped; CJK, 避頭尾),
  • '
    ' always ends a row (dropped). A row ends at the last opportunity that still fits; a single unit wider than the row stays whole on its own row (never split mid-word, never an empty row).

Definition in file WordWrap.h.