shithub: mycel

Download patch

ref: 5d0deebfe6f6b3a12358cea6ac40dbf1f96dbd0f
parent: 312c959f10a0d5394aa2f56af489fc144b6c8862
author: Philip Silva <philip.silva@protonmail.com>
date: Tue Jun 29 14:28:43 EDT 2021

Improved lineheight

--- a/browser/duitx/label.go
+++ b/browser/duitx/label.go
@@ -22,6 +22,7 @@
 
 import (
 	"image"
+	"math"
 
 	"9fans.net/go/draw"
 	"github.com/mjl-/duit"
@@ -78,10 +79,14 @@
 		ui.lines = append(ui.lines, ui.Text[s:])
 		xmax = maximum(xmax, x)
 	}
-	ui.size = image.Pt(xmax, len(ui.lines)*font.Height*12/10)
+	ui.size = image.Pt(xmax, len(ui.lines)*ui.lineHeight(font))
 	self.R = rect(ui.size)
 }
 
+func (ui *Label) lineHeight(font *draw.Font) int {
+	return int(math.Ceil(float64(font.Height)*1.2))
+}
+
 func (ui *Label) Draw(dui *duit.DUI, self *duit.Kid, img *draw.Image, orig image.Point, m draw.Mouse, force bool) {
 	debugDraw(dui, self)
 
@@ -89,7 +94,7 @@
 	font := ui.font(dui)
 	for _, line := range ui.lines {
 		img.String(p, dui.Regular.Normal.Text, image.ZP, font, line)
-		p.Y += font.Height*12/10
+		p.Y += ui.lineHeight(font)
 	}
 }