ps1: fit whole cover in ICON0 frame, show full PIC0 title
- ICON0: scale the cover to fit the case slot (no cropping), centred with the frame's dark background behind the letterbox bars. - PIC0: shrink the title font until the full name fits instead of cutting it with an ellipsis (falls back to eliding only below 10px).
This commit is contained in:
+15
-6
@@ -885,7 +885,9 @@ def make_ps1_assets(cover_bytes, title="", description="", esrb=None):
|
|||||||
tmpl = tmpl.convertToFormat(QImage.Format_ARGB32)
|
tmpl = tmpl.convertToFormat(QImage.Format_ARGB32)
|
||||||
slot = _slot_rect(tmpl) or (0, 0, 80, 80)
|
slot = _slot_rect(tmpl) or (0, 0, 80, 80)
|
||||||
sx, sy, sw, sh = slot
|
sx, sy, sw, sh = slot
|
||||||
cover = art.scaled(sw, sh, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
|
# Fit the whole cover inside the slot (no cropping), centred with the
|
||||||
|
# frame's dark background showing through the letterbox bars.
|
||||||
|
cover = art.scaled(sw, sh, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||||
p.drawImage(sx + (sw - cover.width()) // 2, sy + (sh - cover.height()) // 2, cover)
|
p.drawImage(sx + (sw - cover.width()) // 2, sy + (sh - cover.height()) // 2, cover)
|
||||||
p.drawImage(0, 0, tmpl)
|
p.drawImage(0, 0, tmpl)
|
||||||
else:
|
else:
|
||||||
@@ -952,16 +954,23 @@ def _make_pic0(title, description, esrb, QImage, QPainter, QPainterPath, QColor,
|
|||||||
_draw_ps_glyphs(p, W - 34, 12, 22, QColor(200, 200, 205), QRectF, QPointF,
|
_draw_ps_glyphs(p, W - 34, 12, 22, QColor(200, 200, 205), QRectF, QPointF,
|
||||||
QPolygonF, QPen, Qt)
|
QPolygonF, QPen, Qt)
|
||||||
|
|
||||||
# Title (bold, upper-left), elided so long titles end with an ellipsis
|
# Title (bold, upper-left). Shrink the font until the whole title fits, so
|
||||||
# instead of clipping mid-character.
|
# long names are shown in full instead of being cut with an ellipsis.
|
||||||
f_title = QFont("DejaVu Sans")
|
f_title = QFont("DejaVu Sans")
|
||||||
f_title.setPixelSize(19)
|
|
||||||
f_title.setBold(True)
|
f_title.setBold(True)
|
||||||
p.setFont(f_title)
|
|
||||||
p.setPen(QColor(255, 255, 255))
|
p.setPen(QColor(255, 255, 255))
|
||||||
title_width = W - 70
|
title_width = W - 70
|
||||||
fm_title = QFontMetrics(f_title)
|
fm_title = QFontMetrics(f_title)
|
||||||
title_text = fm_title.elidedText(title or "", Qt.ElideRight, title_width)
|
full = (title or "").strip()
|
||||||
|
size = 19
|
||||||
|
while size > 10 and fm_title.horizontalAdvance(full) > title_width:
|
||||||
|
size -= 1
|
||||||
|
f_title.setPixelSize(size)
|
||||||
|
fm_title = QFontMetrics(f_title)
|
||||||
|
title_text = full
|
||||||
|
if fm_title.horizontalAdvance(full) > title_width:
|
||||||
|
title_text = fm_title.elidedText(full, Qt.ElideRight, title_width)
|
||||||
|
p.setFont(f_title)
|
||||||
p.drawText(QRectF(18, 16, title_width, 28), Qt.AlignLeft | Qt.AlignVCenter,
|
p.drawText(QRectF(18, 16, title_width, 28), Qt.AlignLeft | Qt.AlignVCenter,
|
||||||
title_text)
|
title_text)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user