Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e7944a9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Implement getMinLineWidth for LineWidthDelegate"

parents e5b0f9f7 12996283
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -67,6 +67,18 @@ class JNILineBreakerLineWidth : public minikin::LineBreaker::LineWidthDelegate {
            return width - get(mIndents, lineNo);
        }

        float getMinLineWidth() override {
            // A simpler algorithm would have been simply looping until the larger of
            // mFirstLineCount and mIndents.size()-mOffset, but that does unnecessary calculations
            // when mFirstLineCount is large. Instead, we measure the first line, all the lines that
            // have an indent, and the first line after firstWidth ends and restWidth starts.
            float minWidth = std::min(getLineWidth(0), getLineWidth(mFirstLineCount));
            for (size_t lineNo = 1; lineNo + mOffset < mIndents.size(); lineNo++) {
                minWidth = std::min(minWidth, getLineWidth(lineNo));
            }
            return minWidth;
        }

        float getLeftPadding(size_t lineNo) override {
            return get(mLeftPaddings, lineNo);
        }