jemmybutton / byrne-euclid

MetaPost + TeX rendition of Oliver Byrne's "The first six books of the Elements of Euclid"
GNU General Public License v3.0
1.2k stars 105 forks source link

Right-to-left languages #65

Open Fakeel opened 3 years ago

Fakeel commented 3 years ago

I have started a challenge to translate the whole book in Arabic. I am not an expert in Context but I am learning.

As you know some languages writing system like Arabic, Hebrew, Pashto, Persian, Urdu, and Sindhi are written from right to left. So I solve most of issue for the Arabic language, only one remain issue.

Solving the Lettrine placement for both pages

What should I do?

page_design.zip

jemmybutton commented 3 years ago

@Fakeel Wow! That's super cool!

There was a bug in my initials placement algorithm when an RtL script is used. Now it's fixed (hopefully) and your example seems to work ok. All you need to do now is to update preamble_be.tex file.

byrne_ar

There most likely are still some problems left, so please don't hesitate to ask, if something goes wrong, i'll try to fix it. One thing that definitely doesn't work now is lettrines.mp script for the generated initials with ornaments. It currently only supports one glyph at a time, but you seem to use full words. I'll try and fix that at some point.

As a side note: are there initials in Arabic typography? Maybe you have some references?

Fakeel commented 3 years ago

There aren't initials in Arabic typography and it does not use block letters and separate letters. Most of the Arabic art uses calligraphy design.

In this project the whole Arabic word should be place inside the lettrine or use calligraphy design like the one below

https://www.arabiccalligraphygenerator.com/ image

jemmybutton commented 3 years ago

If initials do not belong in Arabic typography, I can simply add an option to turn them off.

Fakeel commented 3 years ago

I have tried your fixed Nothing is changed

I am missing something?

page_design.zip page_design.pdf

jemmybutton commented 3 years ago

Strange, my output seems ok for the same file. page_design.pdf What version of ConTeXt are you using?

Fakeel commented 3 years ago

ConTeXt version 2018.04.04 00:51

mtx-context | ConTeXt Process Management 1.02 mtx-context | mtx-context | main context file: /usr/share/texmf/tex/context/base/mkiv/context.mkiv mtx-context | current version: 2018.04.04 00:51

jemmybutton commented 3 years ago

I have a newer version and it apparently is different from the older ones (I had to use newer system on TravisCI, because build failed with the older one). Currently the code decides where to place the initial using an internal variable \textdirection which seems to have appeared only in recent versions. So I suspect, this may be the problem. You can try, as a a quick fix, setting it manually somewhere in the preamble (say, right before starttext like so:

\newcount\textdirection
\textdirection=1 %1 stands for RtL

Or update to a newer version.

Fakeel commented 3 years ago

Thank, it works.

It will be helpful if there is a note or comment to indicate which version of ConTeXt should be used.

jemmybutton commented 3 years ago

Great! There's a nasty bug in the version I'm currently using, so I can't recommend it, at the same time, everything seemed to be reasonably backwards-compatible till this case. Once i update, i'll indicate the best version to use in the README.md.

jemmybutton commented 3 years ago

@Fakeel Multi-glyph initials, as you do in Arabic, should work now, but only in theory. In practice, the function which produces text outlines in ConTeXt's MetaPost currently doesn't respect RtL text. Also some longer words may not fit well into the square box and I'm thinking about making this box's width variable.

Fakeel commented 3 years ago

You are right, ConTeXt's MetaPost currently doesn't respect RtL text as shown in
out.pdf

Also, don't worry about box's width because I am trying to choose Arabic word that don't exceed 3 letter.

jemmybutton commented 3 years ago

@Fakeel With this change initials' placeholders should work again for RtL, but you still can't generate ornaments for them. The bug with RtL is fixed in future versions of ConTeXt, so I guess, I'd just wait for the fixed version to be released and then everything should work fine.