Skip to content

Commit

Permalink
tweak font rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiko2k committed Jan 30, 2025
1 parent 4df0124 commit 424f249
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/tauon/t_modules/t_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ def __draw_text_cairo(
max_x = round(max_x)

alpha_bg = self.alpha_bg
force_gray = self.force_gray
#real_bg = True

if bg[3] < 200:
alpha_bg = True
force_gray = True

x = round(location[0])
y = round(location[1])
Expand Down Expand Up @@ -599,15 +605,16 @@ def __draw_text_cairo(
data = ctypes.c_buffer(b"\x00" * (h * (w * 4)))

if real_bg:
box = sdl3.SDL_FRect(x, y - self.get_y_offset(text, font, max_x, wrap), w, h)
box = sdl3.SDL_Rect(x, y - self.get_y_offset(text, font, max_x, wrap), w, h)

if align == 1:
box.x = x - box.w

elif align == 2:
box.x -= int(box.w / 2)

sdl3.SDL_RenderReadPixels(self.renderer, box, sdl3.SDL_PIXELFORMAT_RGB888, ctypes.pointer(data), (w * 4))
ssurf = sdl3.SDL_RenderReadPixels(self.renderer, box) #, sdl3.SDL_PIXELFORMAT_XRGB8888, ctypes.pointer(data), (w * 4))
data = ssurf.contents.pixels

if alpha_bg:
surf = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32, w, h)
Expand All @@ -616,9 +623,10 @@ def __draw_text_cairo(

context = cairo.Context(surf)

if self.force_gray:
if force_gray:
options = context.get_font_options()
options.set_antialias(cairo.ANTIALIAS_GRAY)
#options.set_hint_style(cairo.HINT_STYLE_NONE)
context.set_font_options(options)
elif self.force_subpixel_text:
options = context.get_font_options()
Expand Down
16 changes: 14 additions & 2 deletions src/tauon/t_modules/t_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4923,7 +4923,7 @@ def get_track_in_playlist(self, track_index: int, playlist_index: int) -> TrackC
if playlist_index == -1:
playlist_index = self.active_playlist_viewing
try:
playlist = self.multi_playlist[playlist_index].playlist
playlist = self.multi_playlist[playlist_index].playlist_ids
return self.get_track(playlist[track_index])
except IndexError:
logging.exception("Failed getting track object by playlist_index and track_index!")
Expand Down Expand Up @@ -36698,6 +36698,9 @@ def draw(self, x, y, w, h):

# Background is insivible by default (for hightlighting if selected)
bg = [0, 0, 0, 0]
if prefs.transparent_mode:
bg = rgb_add_hls(colours.playlist_box_background, 0, 0.09, 0)
bg[3] = 255

# Highlight if playlist selected (viewing)
if i == pctl.active_playlist_viewing or (tab_menu.active and tab_menu.reference == i):
Expand All @@ -36707,6 +36710,9 @@ def draw(self, x, y, w, h):
bg = rgb_add_hls(colours.playlist_box_background, 0, 0.06, 0)
if light_mode:
bg = [0, 0, 0, 25]
if prefs.transparent_mode:
bg = rgb_add_hls(colours.playlist_box_background, 0, 0.03, 0)
bg[3] = 255

# Highlight target playlist when tragging tracks over
if coll(
Expand Down Expand Up @@ -37537,6 +37543,10 @@ def draw_card(self, artist, x, y, w):
True): # or pctl.get_track(default_playlist[pctl.playlist_view_position]).artist == artist:
ddt.rect(area, [50, 50, 50, 50])
bg = alpha_blend([50, 50, 50, 50], colours.side_panel_background)
if prefs.transparent_mode:
bg = rgb_add_hls(colours.playlist_box_background, 0, 0.2, 0)
ddt.rect(area, bg)

else:

fade = 0
Expand All @@ -37552,6 +37562,8 @@ def draw_card(self, artist, x, y, w):
ddt.rect(area, [50, 50, 50, fade])

bg = alpha_blend([50, 50, 50, fade], colours.side_panel_background)
if prefs.transparent_mode:
bg = colours.side_panel_background

if prefs.artist_list_style == 1:
self.draw_card_with_thumbnail(artist, x, y, w, area, thin_mode, line1_colour, line2_colour, light_mode, bg)
Expand Down Expand Up @@ -44153,7 +44165,7 @@ def drop_file(target):
colours.art_box[3] = 100
colours.window_frame[3] = 100
colours.bottom_panel_colour[3] = 190
#colours.playlist_panel_background = aa
#colours.playlist_panel_background[3] = 220
#colours.playlist_box_background = [0, 0, 0, 100]

prefs.theme_name = gui.theme_name
Expand Down

0 comments on commit 424f249

Please sign in to comment.