Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Improve: Add dynamic font sizing for large task displays in GIFs
Anshdeep Singhc05980ac79e8
diff --git a/browser_use/agent/gif.py b/browser_use/agent/gif.pyindex 1cb7cbc9c..a2bd6705c 100644--- a/browser_use/agent/gif.py+++ b/browser_use/agent/gif.py@@ -155,10 +155,28 @@ def _create_task_frame(# Calculate vertical center of imagecenter_y = image.height // 2- # Draw task text with increased font size+ # Draw task text with dynamic font size based on task lengthmargin = 140 # Increased marginmax_width = image.width - (2 * margin)- larger_font = ImageFont.truetype(regular_font.path, regular_font.size + 16) # Increase font size more++ # Dynamic font size calculation based on task length+ # Start with base font size (regular + 16)+ base_font_size = regular_font.size + 16+ min_font_size = max(regular_font.size - 10, 16) # Don't go below 16pt+ max_font_size = base_font_size # Cap at the base font size++ # Calculate dynamic font size based on text length and complexity+ # Longer texts get progressively smaller fonts+ text_length = len(task)+ if text_length > 200:+ # For very long text, reduce font size logarithmically+ font_size = max(base_font_size - int(10 * (text_length / 200)), min_font_size)+ else:+ font_size = base_font_size++ larger_font = ImageFont.truetype(regular_font.path, font_size)++ # Generate wrapped text with the calculated font sizewrapped_text = _wrap_text(task, larger_font, max_width)# Calculate line height with spacing