From 4be5154df0daf4884939eb4a74e84ec4e148980b Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 19 Sep 2024 23:57:23 -0400 Subject: [PATCH] Add RecommendedHeight to TypeSetter --- typesetter.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/typesetter.go b/typesetter.go index fff5be4..409bd73 100644 --- a/typesetter.go +++ b/typesetter.go @@ -175,6 +175,14 @@ func (this *TypeSetter) PositionAt (index int) fixed.Point26_6 { return position } +// ReccomendedHeightFor returns the reccomended max height if the text were to +// have its maximum width set to the given width. This does not actually move +// any text, it only simulates it. +func (this *TypeSetter) RecommendedHeight (width fixed.Int26_6) fixed.Int26_6 { + this.needMeasurement() + return recommendHeight(this.tokens, this.face, width) +} + // SetAlign sets the horizontal and vertical alignment of the text. func (this *TypeSetter) SetAlign (x, y Align) { if this.xAlign == x && this.yAlign == y { return }