File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
modules/juce_gui_basics/widgets Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -817,8 +817,24 @@ float TextEditor::getYOffset() const
817817{
818818 const auto bottomY = getMaximumTextHeight ();
819819
820+ const auto juce7LineSpacingOffset = std::invoke ([&]
821+ {
822+ if (approximatelyEqual (lineSpacing, 1 .0f ) || textStorage->isEmpty ())
823+ return 0 .0f ;
824+
825+ const auto & lineMetrics = textStorage->front ().value ->getShapedText ().getLineMetricsForGlyphRange ();
826+
827+ if (lineMetrics.isEmpty ())
828+ return 0 .0f ;
829+
830+ const auto & line = lineMetrics.front ().value ;
831+
832+ jassert (lineSpacing >= 1 .0f );
833+ return line.maxAscent * (1 .0f / lineSpacing - 1 .0f );
834+ });
835+
820836 if (justification.testFlags (Justification::top) || isTextStorageHeightGreaterEqualThan ((float ) bottomY))
821- return 0 ;
837+ return juce7LineSpacingOffset ;
822838
823839 auto bottom = jmax (0 .0f , (float ) bottomY - getTextStorageHeight ());
824840
Original file line number Diff line number Diff line change @@ -202,6 +202,12 @@ class TextEditor::ParagraphsModel
202202
203203 bool isEmpty () const { return storage.empty (); }
204204
205+ ParagraphItem front () const
206+ {
207+ jassert (! ranges.isEmpty ());
208+ return { ranges.get (0 ), storage.front () };
209+ }
210+
205211 ParagraphItem back () const
206212 {
207213 jassert (! ranges.isEmpty ());
@@ -417,6 +423,7 @@ class TextEditor::TextEditorStorage
417423 auto end () const { return paragraphs.end (); }
418424
419425 auto isEmpty () const { return paragraphs.isEmpty (); }
426+ auto front () const { return paragraphs.front (); }
420427 auto back () const { return paragraphs.back (); }
421428
422429 std::optional<Font> getLastFont () const
You can’t perform that action at this time.
0 commit comments