Skip to content

Commit

Permalink
Text alignment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SmilyOrg committed May 10, 2024
1 parent f991565 commit 297f29b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
14 changes: 7 additions & 7 deletions internal/layout/album.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ func LayoutAlbumEvent(layout Layout, rect render.Rect, event *AlbumEvent, scene
X: rect.X,
Y: rect.Y,
W: rect.W,
H: 30,
H: 40,
},
&font,
event.StartTime.Format(dateFormat),
)
text.VAlign = canvas.Bottom
scene.Texts = append(scene.Texts, text)
rect.Y += text.Sprite.Rect.H + 15
rect.Y += text.Sprite.Rect.H
}

font := scene.Fonts.Main.Face(50, canvas.Black, canvas.FontRegular, canvas.FontNormal)
Expand All @@ -53,21 +54,20 @@ func LayoutAlbumEvent(layout Layout, rect render.Rect, event *AlbumEvent, scene
X: rect.X,
Y: rect.Y,
W: rect.W,
H: 30,
H: 40,
},
&font,
time,
)
text.VAlign = canvas.Bottom
scene.Texts = append(scene.Texts, text)
rect.Y += text.Sprite.Rect.H + 10
rect.Y += text.Sprite.Rect.H

newBounds := addSectionToScene(&event.Section, scene, rect, layout, source)

rect.Y = newBounds.Y + newBounds.H
if event.LastOnDay {
rect.Y += 40
} else {
rect.Y += 6
rect.Y += 32
}
return rect
}
Expand Down
14 changes: 7 additions & 7 deletions internal/layout/timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ func LayoutTimelineEvent(layout Layout, rect render.Rect, event *TimelineEvent,

font := scene.Fonts.Main.Face(40, canvas.Black, canvas.FontRegular, canvas.FontNormal)

scene.Texts = append(scene.Texts,
render.NewTextFromRect(
textBounds,
&font,
headerText,
),
text := render.NewTextFromRect(
textBounds,
&font,
headerText,
)
rect.Y += textHeight + 15
text.VAlign = canvas.Bottom
scene.Texts = append(scene.Texts, text)
rect.Y += textHeight + 4

newBounds := addSectionToScene(&event.Section, scene, rect, layout, source)

Expand Down
1 change: 0 additions & 1 deletion internal/render/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func (text *Text) Draw(config *Render, c *canvas.Context, scales Scales) {
return
}

// textLine := canvas.NewTextLine(*text.Font, text.Text, canvas.Left)
textLine := canvas.NewTextBox(*text.Font, text.Text, text.Sprite.Rect.W, text.Sprite.Rect.H, text.HAlign, text.VAlign, 0, 0)
rect := text.Sprite.Rect
rect.Y -= rect.H
Expand Down

0 comments on commit 297f29b

Please sign in to comment.