mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
SimpleShapedText: Reorganise function declarations
This commit is contained in:
parent
2abd6f2f71
commit
de4696d891
1 changed files with 42 additions and 42 deletions
|
|
@ -210,6 +210,48 @@ static std::vector<hb_feature_t> getHarfbuzzFeatures (Span<const FontFeatureSett
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Increment b by the requested number of steps, or to e, whichever is reached first. */
|
||||||
|
template <typename CharPtr>
|
||||||
|
static auto incrementCharPtr (CharPtr b, CharPtr e, int64 steps)
|
||||||
|
{
|
||||||
|
while (b != e && steps > 0)
|
||||||
|
{
|
||||||
|
++b;
|
||||||
|
--steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<juce_wchar> sanitiseString (const String& stringIn, Range<int64> lineRange)
|
||||||
|
{
|
||||||
|
std::vector<juce_wchar> result;
|
||||||
|
|
||||||
|
const auto end = stringIn.end();
|
||||||
|
const auto beginOfRange = incrementCharPtr (stringIn.begin(), end, lineRange.getStart());
|
||||||
|
const auto endOfRange = incrementCharPtr (beginOfRange, end, lineRange.getLength());
|
||||||
|
|
||||||
|
result.reserve (beginOfRange.lengthUpTo (endOfRange));
|
||||||
|
|
||||||
|
for (auto it = beginOfRange; it != endOfRange; ++it)
|
||||||
|
{
|
||||||
|
result.push_back (std::invoke ([&]
|
||||||
|
{
|
||||||
|
const auto cc = findControlCharacter (it, end);
|
||||||
|
|
||||||
|
if (! cc.has_value())
|
||||||
|
return *it;
|
||||||
|
|
||||||
|
constexpr juce_wchar wordJoiner = 0x2060;
|
||||||
|
constexpr juce_wchar nonBreakingSpace = 0x00a0;
|
||||||
|
|
||||||
|
return cc == ControlCharacter::crFollowedByLf ? wordJoiner : nonBreakingSpace;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns glyphs in logical order as that favours wrapping. */
|
/* Returns glyphs in logical order as that favours wrapping. */
|
||||||
static std::vector<ShapedGlyph> lowLevelShape (Span<const juce_wchar> string,
|
static std::vector<ShapedGlyph> lowLevelShape (Span<const juce_wchar> string,
|
||||||
Range<int64> range,
|
Range<int64> range,
|
||||||
|
|
@ -839,48 +881,6 @@ static auto rangedValuesWithOffset (detail::RangedValues<T> rv, int64 offset = 0
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment b by the requested number of steps, or to e, whichever is reached first. */
|
|
||||||
template <typename CharPtr>
|
|
||||||
static auto incrementCharPtr (CharPtr b, CharPtr e, int64 steps)
|
|
||||||
{
|
|
||||||
while (b != e && steps > 0)
|
|
||||||
{
|
|
||||||
++b;
|
|
||||||
--steps;
|
|
||||||
}
|
|
||||||
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<juce_wchar> sanitiseString (const String& stringIn, Range<int64> lineRange)
|
|
||||||
{
|
|
||||||
std::vector<juce_wchar> result;
|
|
||||||
|
|
||||||
const auto end = stringIn.end();
|
|
||||||
const auto beginOfRange = incrementCharPtr (stringIn.begin(), end, lineRange.getStart());
|
|
||||||
const auto endOfRange = incrementCharPtr (beginOfRange, end, lineRange.getLength());
|
|
||||||
|
|
||||||
result.reserve (beginOfRange.lengthUpTo (endOfRange));
|
|
||||||
|
|
||||||
for (auto it = beginOfRange; it != endOfRange; ++it)
|
|
||||||
{
|
|
||||||
result.push_back (std::invoke ([&]
|
|
||||||
{
|
|
||||||
const auto cc = findControlCharacter (it, end);
|
|
||||||
|
|
||||||
if (! cc.has_value())
|
|
||||||
return *it;
|
|
||||||
|
|
||||||
constexpr juce_wchar wordJoiner = 0x2060;
|
|
||||||
constexpr juce_wchar nonBreakingSpace = 0x00a0;
|
|
||||||
|
|
||||||
return cc == ControlCharacter::crFollowedByLf ? wordJoiner : nonBreakingSpace;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Shaper
|
struct Shaper
|
||||||
{
|
{
|
||||||
Shaper (const String& stringIn, Range<int64> lineRange, const ShapedTextOptions& options)
|
Shaper (const String& stringIn, Range<int64> lineRange, const ShapedTextOptions& options)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue