From e872b71d63e9ea4f58e9c4185608ebc7a425e1fb Mon Sep 17 00:00:00 2001 From: Evan Jarrett Date: Thu, 18 Dec 2025 14:30:18 -0600 Subject: [PATCH] fix word wrapping --- pkg/appview/handlers/opengraph.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/appview/handlers/opengraph.go b/pkg/appview/handlers/opengraph.go index 57ec827..ce1c210 100644 --- a/pkg/appview/handlers/opengraph.go +++ b/pkg/appview/handlers/opengraph.go @@ -70,16 +70,25 @@ func (h *RepoOGHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { card.DrawAvatarOrPlaceholder(avatarURL, layout.IconX, layout.IconY, ogcard.AvatarSize, strings.ToUpper(string(repository[0]))) - // Draw owner handle and repo name on same line: @owner / repo + // Draw owner handle and repo name - wrap to new line if too long ownerText := "@" + user.Handle + " / " - card.DrawText(ownerText, layout.TextX, layout.TextY, ogcard.FontTitle, ogcard.ColorMuted, ogcard.AlignLeft, false) - - // Measure owner text width to position repo name ownerWidth := card.MeasureText(ownerText, ogcard.FontTitle, false) - card.DrawText(repository, layout.TextX+float64(ownerWidth), layout.TextY, ogcard.FontTitle, ogcard.ColorText, ogcard.AlignLeft, true) + repoWidth := card.MeasureText(repository, ogcard.FontTitle, true) + combinedWidth := ownerWidth + repoWidth - // Draw description (if present, with wrapping) textY := layout.TextY + if combinedWidth > layout.MaxWidth { + // Too long - put repo name on new line + card.DrawText("@"+user.Handle+" /", layout.TextX, textY, ogcard.FontTitle, ogcard.ColorMuted, ogcard.AlignLeft, false) + textY += ogcard.LineSpacingLarge + card.DrawText(repository, layout.TextX, textY, ogcard.FontTitle, ogcard.ColorText, ogcard.AlignLeft, true) + } else { + // Fits on one line + card.DrawText(ownerText, layout.TextX, textY, ogcard.FontTitle, ogcard.ColorMuted, ogcard.AlignLeft, false) + card.DrawText(repository, layout.TextX+float64(ownerWidth), textY, ogcard.FontTitle, ogcard.ColorText, ogcard.AlignLeft, true) + } + + // Track current Y position for description if description != "" { textY += ogcard.LineSpacingSmall card.DrawTextWrapped(description, layout.TextX, textY, ogcard.FontDescription, ogcard.ColorMuted, layout.MaxWidth, false)