habulaj commited on
Commit
44f7480
·
verified ·
1 Parent(s): cd3a870

Update routers/news.py

Browse files
Files changed (1) hide show
  1. routers/news.py +5 -3
routers/news.py CHANGED
@@ -218,13 +218,15 @@ def render_responsive_text(draw: ImageDraw.Draw, text: str, x: int, y: int, max_
218
  bbox = draw.textbbox((0, 0), line, font=final_font)
219
  line_height = bbox[3] - bbox[1]
220
  draw.text((x, current_y), line, fill=fill_color, font=final_font)
221
- current_y += line_height
 
222
  else:
223
  # Desenhar texto de baixo para cima (alinhamento à base)
224
  current_y = y
225
  for i, line in enumerate(reversed(lines)):
226
  line_height = line_heights[len(lines) - 1 - i]
227
- current_y -= line_height
 
228
  draw.text((x, current_y), line, fill=fill_color, font=final_font)
229
 
230
  def create_canvas(image_url: Optional[str], text: Optional[str] = None, text_position: str = "bottom", text_color: str = "white") -> BytesIO:
@@ -272,7 +274,7 @@ def create_canvas(image_url: Optional[str], text: Optional[str] = None, text_pos
272
 
273
  # Determinar posição Y baseada no text_position
274
  if text_position.lower() == "top":
275
- text_y = 60 # Posição para texto no topo com espaçamento de 78px
276
  else:
277
  text_y = 1180 # Posição para texto embaixo (padrão)
278
 
 
218
  bbox = draw.textbbox((0, 0), line, font=final_font)
219
  line_height = bbox[3] - bbox[1]
220
  draw.text((x, current_y), line, fill=fill_color, font=final_font)
221
+ # Aplicar line height de 115% (adicionar 15% de espaçamento extra)
222
+ current_y += int(line_height * 1.15)
223
  else:
224
  # Desenhar texto de baixo para cima (alinhamento à base)
225
  current_y = y
226
  for i, line in enumerate(reversed(lines)):
227
  line_height = line_heights[len(lines) - 1 - i]
228
+ # Aplicar line height de 115% (adicionar 15% de espaçamento extra)
229
+ current_y -= int(line_height * 1.15)
230
  draw.text((x, current_y), line, fill=fill_color, font=final_font)
231
 
232
  def create_canvas(image_url: Optional[str], text: Optional[str] = None, text_position: str = "bottom", text_color: str = "white") -> BytesIO:
 
274
 
275
  # Determinar posição Y baseada no text_position
276
  if text_position.lower() == "top":
277
+ text_y = 60 # Posição para texto no topo com espaçamento de 60px
278
  else:
279
  text_y = 1180 # Posição para texto embaixo (padrão)
280