1
0
Fork 0
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:
attila 2025-05-09 17:51:02 +02:00 committed by Attila Szarvas
parent 8a27eb3b7c
commit 69b2b3ff5d
2 changed files with 17 additions and 25 deletions

View file

@ -887,8 +887,8 @@ struct Shaper
});
const BidiAlgorithm bidiAlgorithm { string32 };
const auto bidiParagraph = bidiAlgorithm.createParagraph (0, options.getReadingDirection());
const auto bidiLine = bidiParagraph.createLine (0, bidiParagraph.getLength());
const auto bidiParagraph = bidiAlgorithm.createParagraph (options.getReadingDirection());
const auto bidiLine = bidiParagraph.createLine (bidiParagraph.getLength());
bidiLine.computeVisualOrder (visualOrder);
const auto bidiLevels = bidiParagraph.getResolvedLevels();
@ -1020,6 +1020,14 @@ struct Shaper
if (! result.empty())
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,
Span<const ShapedGlyph> { start, (size_t) std::distance (start, end) },
{ startingCluster, nextSoftBreakBefore },

View file

@ -135,11 +135,6 @@ public:
{
}
size_t getOffset() const
{
return SBParagraphGetOffset (paragraph.get());
}
size_t getLength() const
{
return SBParagraphGetLength (paragraph.get());
@ -150,12 +145,12 @@ public:
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());
return BidiLine { ParagraphPtr { SBParagraphRetain (paragraph.get()) },
BidiLine::LinePtr { SBParagraphCreateLine (paragraph.get(), offset, length) } };
BidiLine::LinePtr { SBParagraphCreateLine (paragraph.get(), 0, length) } };
}
private:
@ -177,9 +172,9 @@ public:
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())
return SBLevelDefaultLTR;
@ -191,17 +186,6 @@ public:
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:
std::vector<juce_wchar> text;
AlgorithmPtr algorithm { [&]
@ -269,8 +253,8 @@ public:
chars.push_back (t);
BidiAlgorithm algorithm { chars };
auto paragraph = algorithm.createParagraph (0);
auto line = paragraph.createLine (0, paragraph.getLength());
auto paragraph = algorithm.createParagraph();
auto line = paragraph.createLine (paragraph.getLength());
std::vector<size_t> order;
line.computeVisualOrder (order);