Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serbian Cyrillic letters not supported #1182

Open
hristinanikpi opened this issue Nov 28, 2023 · 2 comments
Open

Serbian Cyrillic letters not supported #1182

hristinanikpi opened this issue Nov 28, 2023 · 2 comments

Comments

@hristinanikpi
Copy link

We work on a project where we want to automate creation of a poetry book from a bunch of poems in rst format. We have to folders eng (with poems in English) and rs (with poems in Serbian). Our goal is to have all the poems in one document in rst format and convert it to pdf. Everything is done on Ubuntu Linux.

The problem that appears is that Serbian characters are not recognized. The command that we used is:
rst2pdf book.rst -o book.pdf

We tried setting up the font:
rst2pdf book.rst -o book.pf --font-path=path-to-a-specific-ttf-file
This produced a pdf but all the unrecognized characters were marked black.

Afterwards, we tried setting up both font and language:
rst2pdf book.rst -o book.pdf --font-path=/usr/share/fonts/X11/Cyrillic --language='sr'
We tried with a few different fonts and tried using 'sr-Rs' and 'rs' for language, but unsuccessfully. Here we got the following error:
languages.py:39 Language 'sr' not supported by Docutils

🖥 Versions
python3 -V
Python 3.10.12

pip freeze | grep rst2pdf
rst2pdf==0.101

pip freeze | grep reportlab
reportlab==3.6.8

@lornajane
Copy link
Contributor

I'll be honest: the maintainers here are English speakers so our character set knowledge is limited. Does this past issue help at all with your use case? #1125

@RadeKornjaca
Copy link

RadeKornjaca commented Feb 25, 2024

Hi @hristinanikpi, my answer comes a little bit late, but maybe the experience I had with Serbian Latin characters would help. I had the same problem with the unrecognized characters (they were replaced with black squares). It can be solved through by using a separate styling file which contains the font instructions for different elements, for example:

styles:
  base: {fontName: DejaVuSans, fontSize: 12}
  footer: {alignment: TA_CENTER, parent: base}
  heading1: {fontName: DejaVuSans, parent: heading}
  title: {fontName: DejaVuSans, fontSize: 32}
  table-heading: {fontName: DejaVuSans-Bold, parent: heading}

And then run the rst2pdf command like this:

rst2pdf -S book-style.yaml book.rst -o book.pdf

Where book-style.yaml contains the styles configuration.

The fontName DejaVuSans displays the characters well, so it did the trick for the Serbian Latin, maybe it would help with the Cyrillic as well. If not, try experimenting with some other fonts. Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants