[reportlab-users] JustifyRight in ParagraphStyle
Moshe Uminer
mosheduminer at gmail.com
Wed Mar 17 17:25:31 EDT 2021
Hi Robin,
Thanks for taking a look!
Package versions:
reportlab==3.5.65
pyfribidi==0.12.0
The font used in the repro is Libre David (though the behavior is the same
with other fonts as well). Downloadable from google fonts here
https://fonts.google.com/specimen/David+Libre
Reproduction code:
```
from reportlab.platypus import Paragraph
from reportlab.lib.enums import TA_JUSTIFY
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.pagesizes import LETTER
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.platypus.doctemplate import SimpleDocTemplate
pdfmetrics.registerFont(TTFont("David", "DavidLibre-Regular.ttf"))
text = "שלום! זו תהיה פסקה שהשורה האחרונה שלה לא תוצדק כהלכה. "
text = text * 2
doc = SimpleDocTemplate(
"repro.pdf",
pagesize=LETTER,
rightMargin=72,
leftMargin=72,
topMargin=72,
bottomMargin=72,
)
styles = getSampleStyleSheet()
normal_hebrew = ParagraphStyle(
parent=styles["Normal"],
name="NormalHebrew",
wordWrap="RTL",
alignment=TA_JUSTIFY,
fontName="David",
fontSize=14,
)
flowables = [Paragraph(text, normal_hebrew)]
doc.build(flowables)
```
Thank you for looking into this!
(Sorry, I accidentally sent my reply only to you, hence I am resending).
On Wed, Mar 17, 2021 at 4:33 PM Robin Becker <robin at reportlab.com> wrote:
> Hi Moshe,
>
> I'll take a look at this; can you provide a simple example of the code
> that you useto demonstrate the problem. If
> possible I need to use the same text, style, width and font. Also if
> possible what reportlab version and I guess fribidi
> etc etc if you are using that.
>
>
> On 17/03/2021 12:48, Moshe Uminer wrote:
> > Hi, I'm enjoying reportlab, but I've run into an issue.
> > Currently, when using TA_JUSTIFY in ParagraphStyle, the last line is
> > aligned to the left. This is problematic when using an RTL language
> > together with justify, as the last line of the paragraph should be
> aligned
> > right.
> > I don't know how complex it would be to add this option, but I would
> > definitely appreciate it :).
> .......
>
> --
> Robin Becker
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20210317/f2f50998/attachment.html>
More information about the reportlab-users
mailing list