Automatic text wrapping/text box filling

Offen
#6,201 27 Kommentare 9 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

  • #9639 von @RichardHopperProGrammar — ohne Merge geschlossen

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
30/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Ruhig
Tech-Stack
python

Rechercherichtung

Start with the existing draw_multiline_text and getsize APIs and compare the linked script for current wrapping behavior. Clarify which width, height, clipping, and font-size behaviors are in scope before coding; done should be a defined text-box API with the selected behaviors covered by tests.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Enhancement

many people have written scripts to do this and it's relatively easy with the library's getsize func but I feel like it really should be a built-in feature.

i think there should be a draw_text_box or similar function which has these properties on top of the existing draw_multiline_text:

  • you can specify a max width in pixels and Pillow will automatically insert line breaks to keep the text's width under the max width
    • I think there should be an option to only break at word boundaries unless the word exceeds the max width, like the CSS word-break property
  • you can specify a max height in pixels with one of two behaviors:
    • when reaching the max height, the text box is clipped and doesn't draw any more.
    • when reaching the max height, the font size is gradually reduced until the text fits inside
      • I think a min font size property would be useful here
    • also an option to find the biggest font size that fits within the text box
      • a max font size property would be useful here

I'm not very experienced with the library internals or C in general so for now I won't make a pull, I just want to throw the idea out there to the devs

Vorherrschende Sprache
Python
Sterne
14k
Forks
2.6k
Ø Merge
1 T. 1 Std.
Gemergte PRs (30 T.)
205

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python-pillow/Pillow

Alle Issues in python-pillow/Pillow

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.