Remplacer le mode « les deux » par « comparer » et servir le texte « Comment lire » à la carte et au PDF
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@ -487,15 +487,27 @@ def _draw_legend(c, box, mm):
|
||||
c.setFont("Helvetica", 6)
|
||||
c.drawString((rcx + r_out + 5) * mm, (rcy + 2) * mm, _pdf_text("Teinte = orientation"))
|
||||
c.drawString((rcx + r_out + 5) * mm, (rcy - 1) * mm, _pdf_text("de la pente"))
|
||||
# Texte de légende
|
||||
# Texte de légende ("Comment lire" : phrases habillées à la largeur de la boîte)
|
||||
from reportlab.pdfbase.pdfmetrics import stringWidth
|
||||
ty = rcy - r_out - 6
|
||||
c.setFont("Helvetica", 5.8)
|
||||
for line in VIZ_LEGENDS[LAYER]["legend"].split("\n"):
|
||||
for part in line.split(" | "):
|
||||
for sentence in VIZ_LEGENDS[LAYER].get("reading") or VIZ_LEGENDS[LAYER]["legend"].split("\n"):
|
||||
line = ""
|
||||
for word in _pdf_text(sentence).split(" "):
|
||||
test = (line + " " + word).strip()
|
||||
if stringWidth(test, "Helvetica", 5.8) * 0.3528 > w and line: # pt → mm
|
||||
if ty < y + 1:
|
||||
return
|
||||
c.drawString(x * mm, ty * mm, line)
|
||||
ty -= 2.9
|
||||
line = word
|
||||
else:
|
||||
line = test
|
||||
if line:
|
||||
if ty < y + 1:
|
||||
return
|
||||
c.drawString(x * mm, ty * mm, _pdf_text(part))
|
||||
ty -= 2.9
|
||||
c.drawString(x * mm, ty * mm, line)
|
||||
ty -= 3.6 # interligne un peu plus grand entre deux phrases
|
||||
|
||||
|
||||
def _draw_quality(c, box, bbox, zq, mm):
|
||||
|
||||
Reference in New Issue
Block a user