auto flake and corrections

This commit is contained in:
2025-11-08 23:46:15 +01:00
parent 1ea870eef5
commit 781a9b6c08
81 changed files with 4646 additions and 3718 deletions
+17 -15
View File
@@ -5,40 +5,41 @@ Debug script to test text positioning in the line breaking system
import sys
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
# Add pyWebLayout to path
sys.path.insert(0, str(Path(__file__).parent))
from PIL import Image, ImageDraw
from pyWebLayout.style import Font
from pyWebLayout.concrete.text import Text, Line
from pyWebLayout.style.layout import Alignment
# Add pyWebLayout to path
sys.path.insert(0, str(Path(__file__).parent))
def test_simple_text_rendering():
"""Test basic text rendering to debug positioning issues"""
# Create a simple image
width, height = 300, 200
image = Image.new('RGB', (width, height), 'white')
draw = ImageDraw.Draw(image)
# Draw a border for reference
draw.rectangle([0, 0, width-1, height-1], outline=(200, 200, 200), width=2)
# Create a font
font = Font(font_size=12)
# Test 1: Direct PIL text rendering
print("Test 1: Direct PIL text rendering")
draw.text((10, 30), "Direct PIL text", font=font.font, fill=(0, 0, 0))
# Test 2: Using our Text class
print("Test 2: Using Text class")
text_obj = Text("Text class rendering", font, draw)
text_obj.set_origin([10, 60]) # Set position
print(f"Text origin: {text_obj.origin}")
text_obj.render()
# Test 3: Using Line class
print("Test 3: Using Line class")
line = Line(
@@ -49,26 +50,27 @@ def test_simple_text_rendering():
font=font,
halign=Alignment.LEFT
)
# Create a simple word to add to the line
from pyWebLayout.abstract.inline import Word
word = Word("Line class rendering", font)
success, overflow = line.add_word(word)
print(f"Word added successfully: {success}")
print(f"Line origin: {line.origin}")
print(f"Line baseline: {line._baseline}")
print(f"Text objects in line: {len(line.text_objects)}")
if line.text_objects:
for i, text in enumerate(line.text_objects):
print(f" Text {i}: '{text.text}' at origin {text.origin}")
line.render()
# Save the debug image
image.save("debug_text_positioning.png")
print("Debug image saved as debug_text_positioning.png")
if __name__ == "__main__":
test_simple_text_rendering()