Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
szarvas committed Jun 10, 2024
1 parent c2b4610 commit 17611f7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
1 change: 0 additions & 1 deletion modules/juce_graphics/fonts/juce_JustifiedText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ JustifiedText::JustifiedText (const SimpleShapedText& t, const ShapedTextOptions
|| effectiveLength <= *options.getMaxWidth() + maxWidthTolerance)
return;

// TODO(ati) This should be (! isLtr) once we have a mechanism to determine the base writing direction
const auto cutoffAtFront = lastLineAlignment.value.getX() < 0.0f - maxWidthTolerance;

const auto getLastLineVisibleRange = [&] (float ellipsisLength)
Expand Down
25 changes: 1 addition & 24 deletions modules/juce_graphics/fonts/juce_SimpleShapedText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ SimpleShapedText::SimpleShapedText (const String* data,
shape (string, options);
}

// TODO(ati) This can probably be removed. Or we can do shaping using raw UTF8 pointers.
struct Utf8Lookup
{
Utf8Lookup (const String& s)
Expand Down Expand Up @@ -349,27 +348,8 @@ static std::vector<ShapedGlyph> lowLevelShape (const String& string,
hb_buffer_set_direction (buffer.get(),
direction == TextDirection::ltr ? HB_DIRECTION_LTR : HB_DIRECTION_RTL);

// TODO(ati) I lifted this from the Skia source comments. Unfortunately the bug tracker isn't
// externally available.
//
// Documentation for HB_BUFFER_FLAG_BOT/EOT at 763e5466c0a03a7c27020e1e2598e488612529a7.
// Currently BOT forces a dotted circle when first codepoint is a mark; EOT has no effect.
// Avoid adding dotted circle, re-evaluate if BOT/EOT change. See https://skbug.com/9618.
// hb_buffer_set_flags(buffer, HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT);
// const auto flags = HB_BUFFER_FLAG_DEFAULT
// | (byteRange.getStart() == 0 ? HB_BUFFER_FLAG_BOT : 0)
// | (byteRange.getEnd() == string.getNumBytesAsUTF8() ? HB_BUFFER_FLAG_EOT : 0);
//
// hb_buffer_set_flags (buffer.get(), (hb_buffer_flags_t) flags);

Utf8Lookup utf8Lookup { string };

// TODO(ati) Test this first. I wonder if visual linebreaks are forced by the SKIA technique,
// where they add the buffer contents in three separate calls to hb_buffer_add* and add
// precontext, text-to-shape and postcontext.
//
// I am afraid they just assume that it is safe to break at run boundaries, which doesn't quite
// hit all our imagined use-cases.
const auto preContextByteRange = utf8Lookup.getByteRange (Range<int64> { 0, range.getStart() });

hb_buffer_add_utf8 (buffer.get(),
Expand All @@ -384,7 +364,6 @@ static std::vector<ShapedGlyph> lowLevelShape (const String& string,
auto utf32Span = Span { string.toUTF32().getAddress() + (size_t) range.getStart(),
(size_t) range.getLength() };

// TODO(ati) This should be configurable in case someone wants to implement a "display whitespace" functionality
// We're using a word joiner (zero width non-breaking space) followed by a non-breaking space
// for visual representation. This is so that it's not possible to break the glyph representing
// the line breaking glyph on its own.
Expand Down Expand Up @@ -414,7 +393,7 @@ static std::vector<ShapedGlyph> lowLevelShape (const String& string,

for (int i = 0; i < numLineEndsToReplace; ++i)
{
// TODO(ati) The following gets cluster values right, but this does not follow clearly from harfbuzz documentation.
// The following gets cluster values right, but this does not follow clearly from harfbuzz documentation.
// Add at least a regression test checking the correctness of cluster values.
hb_buffer_add (buffer.get(),
static_cast<hb_codepoint_t> (*(crLf + (2 - numLineEndsToReplace) + i)),
Expand Down Expand Up @@ -530,7 +509,6 @@ struct SubSpanLookup
template <typename T>
static auto makeSubSpanLookup (Span<T> s) { return SubSpanLookup<T> { s }; }

// TODO(ati) Fix Unicode::WordBreakIterator
struct CanBreakBeforeIterator
{
explicit CanBreakBeforeIterator (Span<const Unicode::Codepoint> s)
Expand Down Expand Up @@ -616,7 +594,6 @@ struct IntegralCanBreakBeforeIterator
CanBreakBeforeIterator it;
Range<int64> restrictedTo { std::numeric_limits<int64>::min(), std::numeric_limits<int64>::max() };

// TODO(ati) Move this out of here into append(). We want to signal that the entire range can be consumed without breaking.
bool rangeEndReturned = false;
};

Expand Down

0 comments on commit 17611f7

Please sign in to comment.