Add an option to use bold fonts on the spine

Specially for JSWolf
This commit is contained in:
Kovid Goyal 2026-01-19 22:11:51 +05:30
parent 6e06d92ab1
commit 42a6fe793a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 16 additions and 3 deletions

View File

@ -526,6 +526,7 @@ def create_defs():
}
defs['bookshelf_min_font_multiplier'] = 0.75
defs['bookshelf_max_font_multiplier'] = 1.3
defs['bookshelf_bold_font'] = False
# Migrate beta bookshelf_thumbnail
if isinstance(btv := gprefs.get('bookshelf_thumbnail'), bool):

View File

@ -1538,7 +1538,7 @@ class BookshelfView(MomentumScrollMixin, QAbstractScrollArea):
self.template_inited = False
self.min_font_size = max(0.1, min(gprefs['bookshelf_min_font_multiplier'], 1)) * self.base_font_size_pts
self.max_font_size = max(1, min(gprefs['bookshelf_max_font_multiplier'], 3)) * self.base_font_size_pts
_, fm, _ = self.get_sized_font(self.min_font_size)
_, fm, _ = self.get_sized_font(self.min_font_size, bold=gprefs['bookshelf_bold_font'])
self.min_line_height = math.ceil(fm.height())
self.calculate_shelf_geometry()
self.palette_changed()
@ -2086,11 +2086,12 @@ class BookshelfView(MomentumScrollMixin, QAbstractScrollArea):
first_rect, second_rect = calculate_rects(bool(second_line))
nfl, nsl, font, was_wrapped = self.get_text_metrics(
first_line, second_line, first_rect.transposed().size(), allow_wrap=True)
first_line, second_line, first_rect.transposed().size(), allow_wrap=True, bold=gprefs['bookshelf_bold_font'])
if not nfl and not nsl: # two lines dont fit
second_line = ''
first_rect = QRect(rect.left(), first_rect.top(), rect.width(), first_rect.height())
nfl, nsl, font, _ = self.get_text_metrics(first_line, second_line, first_rect.transposed().size())
nfl, nsl, font, _ = self.get_text_metrics(
first_line, second_line, first_rect.transposed().size(), bold=gprefs['bookshelf_bold_font'])
elif was_wrapped:
first_rect, second_rect = calculate_rects(True)
first_line, second_line, = nfl, nsl

View File

@ -80,6 +80,7 @@ class BookshelfTab(QTabWidget, LazyConfigWidgetBase, Ui_Form):
r('bookshelf_make_space_for_second_line', gprefs)
r('bookshelf_min_font_multiplier', gprefs)
r('bookshelf_max_font_multiplier', gprefs)
r('bookshelf_bold_font', gprefs)
r('bookshelf_divider_text_right', gprefs)
r('bookshelf_start_with_divider', gprefs)

View File

@ -458,6 +458,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="opt_bookshelf_bold_font">
<property name="toolTip">
<string>&lt;p&gt;Use a bold font to draw text on the book spine</string>
</property>
<property name="text">
<string>Use &amp;bold font</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">