mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Remove unused internal bidi features
This commit removes the possibility to construct BidiParagraph and BidiLine objects with non-zero offsets. We don't use these features, and the assumption that these offsets are always zero simplifies our visual ordering algorithm.
This commit is contained in:
parent
8a27eb3b7c
commit
69b2b3ff5d
2 changed files with 17 additions and 25 deletions
|
|
@ -887,8 +887,8 @@ struct Shaper
|
||||||
});
|
});
|
||||||
|
|
||||||
const BidiAlgorithm bidiAlgorithm { string32 };
|
const BidiAlgorithm bidiAlgorithm { string32 };
|
||||||
const auto bidiParagraph = bidiAlgorithm.createParagraph (0, options.getReadingDirection());
|
const auto bidiParagraph = bidiAlgorithm.createParagraph (options.getReadingDirection());
|
||||||
const auto bidiLine = bidiParagraph.createLine (0, bidiParagraph.getLength());
|
const auto bidiLine = bidiParagraph.createLine (bidiParagraph.getLength());
|
||||||
bidiLine.computeVisualOrder (visualOrder);
|
bidiLine.computeVisualOrder (visualOrder);
|
||||||
|
|
||||||
const auto bidiLevels = bidiParagraph.getResolvedLevels();
|
const auto bidiLevels = bidiParagraph.getResolvedLevels();
|
||||||
|
|
@ -1020,6 +1020,14 @@ struct Shaper
|
||||||
if (! result.empty())
|
if (! result.empty())
|
||||||
result.back().setTextRange (result.back().getTextRange().withEnd (startingCluster));
|
result.back().setTextRange (result.back().getTextRange().withEnd (startingCluster));
|
||||||
|
|
||||||
|
if ((int64) visualOrder.size() <= start->cluster)
|
||||||
|
{
|
||||||
|
// If this assertion is hit, the input string is probably invalid according to the
|
||||||
|
// Unicode parsing rules. If you know your string is a valid one, please reach out to us.
|
||||||
|
jassertfalse;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
result.push_back ({ glyphsIt->value,
|
result.push_back ({ glyphsIt->value,
|
||||||
Span<const ShapedGlyph> { start, (size_t) std::distance (start, end) },
|
Span<const ShapedGlyph> { start, (size_t) std::distance (start, end) },
|
||||||
{ startingCluster, nextSoftBreakBefore },
|
{ startingCluster, nextSoftBreakBefore },
|
||||||
|
|
|
||||||
|
|
@ -135,11 +135,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getOffset() const
|
|
||||||
{
|
|
||||||
return SBParagraphGetOffset (paragraph.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t getLength() const
|
size_t getLength() const
|
||||||
{
|
{
|
||||||
return SBParagraphGetLength (paragraph.get());
|
return SBParagraphGetLength (paragraph.get());
|
||||||
|
|
@ -150,12 +145,12 @@ public:
|
||||||
return { SBParagraphGetLevelsPtr (paragraph.get()), getLength() };
|
return { SBParagraphGetLevelsPtr (paragraph.get()), getLength() };
|
||||||
}
|
}
|
||||||
|
|
||||||
BidiLine createLine (size_t offset, size_t length) const
|
BidiLine createLine (size_t length) const
|
||||||
{
|
{
|
||||||
jassert (getOffset() <= offset);
|
jassert (SBParagraphGetOffset (paragraph.get()) == 0);
|
||||||
jassert (length <= getLength());
|
jassert (length <= getLength());
|
||||||
return BidiLine { ParagraphPtr { SBParagraphRetain (paragraph.get()) },
|
return BidiLine { ParagraphPtr { SBParagraphRetain (paragraph.get()) },
|
||||||
BidiLine::LinePtr { SBParagraphCreateLine (paragraph.get(), offset, length) } };
|
BidiLine::LinePtr { SBParagraphCreateLine (paragraph.get(), 0, length) } };
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -177,9 +172,9 @@ public:
|
||||||
return text.size();
|
return text.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
BidiParagraph createParagraph (size_t offset, std::optional<detail::TextDirection> d = {}) const
|
BidiParagraph createParagraph (std::optional<detail::TextDirection> d = {}) const
|
||||||
{
|
{
|
||||||
BidiParagraph::ParagraphPtr result { SBAlgorithmCreateParagraph (algorithm.get(), offset, text.size() - offset, [&]() -> SBLevel
|
BidiParagraph::ParagraphPtr result { SBAlgorithmCreateParagraph (algorithm.get(), 0, text.size(), [&]() -> SBLevel
|
||||||
{
|
{
|
||||||
if (! d.has_value())
|
if (! d.has_value())
|
||||||
return SBLevelDefaultLTR;
|
return SBLevelDefaultLTR;
|
||||||
|
|
@ -191,17 +186,6 @@ public:
|
||||||
return BidiParagraph { std::move (result) };
|
return BidiParagraph { std::move (result) };
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Fn>
|
|
||||||
void forEachParagraph (Fn&& callback, std::optional<detail::TextDirection> dir = {}) const
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < text.size();)
|
|
||||||
{
|
|
||||||
const auto paragraph = createParagraph (i, dir);
|
|
||||||
callback (paragraph);
|
|
||||||
i += paragraph.getLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<juce_wchar> text;
|
std::vector<juce_wchar> text;
|
||||||
AlgorithmPtr algorithm { [&]
|
AlgorithmPtr algorithm { [&]
|
||||||
|
|
@ -269,8 +253,8 @@ public:
|
||||||
chars.push_back (t);
|
chars.push_back (t);
|
||||||
|
|
||||||
BidiAlgorithm algorithm { chars };
|
BidiAlgorithm algorithm { chars };
|
||||||
auto paragraph = algorithm.createParagraph (0);
|
auto paragraph = algorithm.createParagraph();
|
||||||
auto line = paragraph.createLine (0, paragraph.getLength());
|
auto line = paragraph.createLine (paragraph.getLength());
|
||||||
|
|
||||||
std::vector<size_t> order;
|
std::vector<size_t> order;
|
||||||
line.computeVisualOrder (order);
|
line.computeVisualOrder (order);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue