Oriental TeX: optimizing paragraphs

27
128 EUROT E X 2012 & 6CM PROCEEDINGS Hans Hagen & Idris Samawi Hamid Oriental T E X: optimizing paragraphs Introduction One of the objectives of the Oriental T E X project has always been to play with para- graph optimization. e original assumption was that we needed an advanced non- standard paragraph builder to Arabic done right but in the end we found out that a more straightforward approach is to use a sophisticated OpenType font in com- bination with a paragraph postprocessor that uses the advanced font capabilities. is solution is somewhat easier to realise than a complex paragraph builder but still involves quite some juggling. At the June 2012 meeting of the ntg there was a talk about typeseing Devanagari and as fonts are always a nice topic (if only because there is something to show) it made sense to tell a bit more about optimizing Arabic at the same time. In fact, that presentation was already a few years too late because a couple of years back, when the oriental T E X project was presented at tug and Dante meetings, the optimizer was already part of the ConT E Xt core code. e main reason for not advocating it was the simple fact that no font other than the (not yet finished) Husayni font provided the relevant feature set. e lack of advanced fonts does not prevent us from showing what we’re dealing with. is is because the ConT E Xt mechanisms are generic in the sense that they can also be used with regular Latin fonts, although it does not make that much sense. Anyhow, in the next section we wrap up the current state of typeseing Arabic in ConT E Xt. We focus on the rendering, and leave general aspects of bidirectional typeseing and layouts for another time. is article is wrien by Idris Samawi Hamid and Hans Hagen and is typeset by ConT E Xt MkIV which uses LuaT E X. is program is an extension of T E X that uses Lua to open op the core machinery. e LuaT E X core team consists of Taco Hoekwater, Hartmut Henkel and Hans Hagen. Manipulating glyphs When discussing optical optimization of a paragraph, a few alternatives come to mind: One can get rid of extensive spaces by adding additional kerns between glyphs. is is oſten used by poor man’s typeseing programs (or routines) and can be ap- plied to non-connecting scripts. It just looks bad. Of course, for connected scripts like Arabic, inter-glyph kerning is not an option, not even in principle. Glyphs can be widened a few percent and this is an option that LuaT E X inherits from its predecessor pdfT E X. Normally this goes unnoticed although excessive scaling makes things worse, and yes, one can run into such examples. is strategy goes under the name hz-optimization (the hz refers to Hermann Zapf, who first came up with this solution). 1 A real nice solution is to replace glyphs by narrower or wider variants. is is in fact the ideal hz solution —including for Arabic-script as well— but for it to happen

Transcript of Oriental TeX: optimizing paragraphs

128 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs

IntroductionOne of the objectives of the Oriental TEX project has always been to play with para-graph optimization The original assumption was that we needed an advanced non-standard paragraph builder to Arabic done right but in the end we found out thata more straightforward approach is to use a sophisticated OpenType font in com-bination with a paragraph postprocessor that uses the advanced font capabilitiesThis solution is somewhat easier to realise than a complex paragraph builder butstill involves quite some juggling

At the June 2012 meeting of the ntg there was a talk about typesetting Devanagariand as fonts are always a nice topic (if only because there is something to show) itmade sense to tell a bit more about optimizing Arabic at the same time In fact thatpresentation was already a few years too late because a couple of years back whenthe oriental TEX project was presented at tug and Dante meetings the optimizer wasalready part of the ConTEXt core code The main reason for not advocating it wasthe simple fact that no font other than the (not yet finished) Husayni font providedthe relevant feature set

The lack of advanced fonts does not prevent us from showing what wersquore dealingwith This is because the ConTEXt mechanisms are generic in the sense that they canalso be used with regular Latin fonts although it does not make that much senseAnyhow in the next section we wrap up the current state of typesetting Arabicin ConTEXt We focus on the rendering and leave general aspects of bidirectionaltypesetting and layouts for another time

This article is written by Idris Samawi Hamid and Hans Hagen and is typeset byConTEXtMkIVwhich uses LuaTEXThis program is an extension of TEX that uses Luato open op the core machinery The LuaTEX core team consists of Taco HoekwaterHartmut Henkel and Hans Hagen

Manipulating glyphsWhen discussing optical optimization of a paragraph a few alternatives come tomind

983085 One can get rid of extensive spaces by adding additional kerns between glyphsThis is often used by poor manrsquos typesetting programs (or routines) and can be ap-plied to non-connecting scripts It just looks bad Of course for connected scriptslike Arabic inter-glyph kerning is not an option not even in principle

983085 Glyphs can be widened a few percent and this is an option that LuaTEX inheritsfrom its predecessor pdfTEX Normally this goes unnoticed although excessivescalingmakes things worse and yes one can run into such examplesThis strategygoes under the name hz-optimization (the hz refers to Hermann Zapf who firstcame up with this solution)1

983085 A real nice solution is to replace glyphs by narrower or wider variants This is infact the ideal hz solutionmdashincluding for Arabic-script as wellmdash but for it to happen

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 129

one not only needs needs fonts with alternative shapes but also a machinery thatcan deal with them

983085 An already old variant is the one first used by Gutenberg who used alternativecuts for certain combinations of characters This is comparable with ligaturesHowever to make the look and feel optimal one needs to analyze the text andmake decisions on what to replace without losing consistency

The solution described here does a bit of everything As it is mostly meant for a con-nective script the starting point is how a scribe works when filling up a line nicelyDepending on how well one can see it coming the writing can be adapted to widenor narrow followingwords And it happens that in Arabic-script there are quite someways to squeeze more characters in a small area andor expand some to the extremeto fill up the available space Shapes can be wider or narrower they can be stackedand they can get replaced by ligatures Of course there is some interference with theoptional marks on top and below but even there we have some freedom The onlycondition is that the characters in a word stay connected2

So given enough alternative glyphs one can imagine that excessive interwordspacing can be avoided However it is non-trivial to check all possible combinationsActually it is not needed either as carefully chosen aesthetic rules put some boundson what can be done One should more think in terms of alternative strategies orsolutions and this is the terminology that we will therefore use

Scaling glyphs horizontally is no problem if we keep the scale factor very smallsay percentages This also means that we should not overestimate the impact Forthe Arabic script we can stretch more mdashusing non-scaling methodsmdash but again thereare some constraints which we will discuss later on

In the next example we demonstrate some excessive stretching

In practice fonts can provide intercharacter kerning which is demonstrated next

W-0984

e are texies W -0984

e are texiesSome poor manrsquos justification routines mess with additional inter-character kern-

ing Although this is within reasonable bounds ok for special purposes like titles itlooks bad in text The first line expands glyphs and spaces the second line expandsspaces and adds additional kerns between characters and the third line expands andadds extra kerns

We are texiesW e a r e t e x i e s W e a r e t e x i e s

Unfortunately we see quite often examples of the last method in novels and evenscientific texts There is definitely a down side to advanced manipulation

Applying features to Latin-scriptIt is easiest to start out with Latin if only because itrsquos more intuitive for most of us tosee what happens This is not the place to discuss all the gory details so you have totake some of the configuration options on face value Once this mechanism is stableand used the options can be described For now we stick to presenting the idea

Letrsquos assume that you know what font features are The idea is to work with com-binations of such features and figure out what combination suits best In order notto clutter a document style these sets are defined in so called goodie files Here is anexcerpt of demolfg

return name = demoversion = 101

130 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

comment = An example of goodiesauthor = Hans Hagenfeaturesets = simple =

mode = nodescript = latn

default =

mode = nodescript = latnkern = yes

ligatures =

mode = nodescript = latnkern = yesliga = yes

smallcaps =

mode = nodescript = latnkern = yessmcp = yes

solutions = experimental =

less = ligatures simple

more = smallcaps

We see four sets of features here You can use these sets in a ConTEXt feature defin-ition like

definefontfeature

[solution-demo]

[goodies=demo

featureset=default]

You can use a set as follows

definefont

[SomeTestFont]

[texgyrepagellaregularsolution-demo at 10pt]

So far there is nothing special or new but we can go a step further

definefontsolution

[solution-a]

[goodies=demo

solution=experimental

method=normalpreroll

criterium=1]

definefontsolution

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 131

[solution-b]

[goodies=demo

solution=experimental

method=normalprerollsplit

criterium=1]

Here we have defined two solutions They refer to the experimental solution inthe goodie file demolfg A solution has a less and a more entry The featuresetsmentioned there reflect ways to make a word narrower or wider There can be morethan one way to do that although it comes at a performance price Before we seehow this works out we turn on a tracing option

enabletrackers

[buildersparagraphssolutionssplitterscolors]

This will color the words in the result according to what has happened Whena featureset out of the more category has been applied the words turn green whenless is applied theword becomes yellowThe preroll option in the method list makessure that we do a more extensive test beforehand

SomeTestFont startfontsolution[solution-a]

input zapf par

stopfontsolution

In Figure 1 we see what happens In each already split line words get wider ornarrower until wersquore satisfied A criterium of 1 is pretty strict3 Keep in mind that weuse some arbitrary features here We try removing kerns to get narrower althoughthere is nothing that guarantees that kerns are positive On the other hand usingligatures might help In order to get wider we use smallcaps Okay the result willlook somewhat strange but so does much typesetting nowadays

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-0650

-0450

-f

-0100

aces -0250

-0200

man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

computer magazines t0150

he in-

-0150

-0350

which t0150

he-0150

y g-0200

et

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as

-0550

-0600

-0250

-0300

-0200

dif-f

-0150

erences betw-0400

een -0350

ty-pog

0150

r-0150

aphic design M people

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 1 Solution a

There is one pitfall here This mechanism is made for a connective script where hy-phenation is not used As a result a word here is actually split up when it has dis-cretionaries and of course this text fragment has It goes unnoticed in the renderingbut is of course far from optimal

132 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

SomeTestFont startfontsolution[solution-b]

input zapf par

stopfontsolution

In this example (Figure 2) we keep words as a whole but as a side effect we skipwords that are broken across a line This is mostly because it makes not much senseto implement it as Latin is not our target Future versions of ConTEXt might get moresophisticated font machinery so then things might look better

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-

-0650

-0450

tronic publishing man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

com magzines or t0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po

-0300

M peo

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 2 Solution b

We show two more methods

definefontsolution

[solution-c]

[goodies=demo

solution=experimental

method=reversepreroll

criterium=1]

definefontsolution

[solution-d]

[goodies=demo

solution=experimental

method=randomprerollsplit

criterium=1]

In Figure 3 we start at the other end of a line As we sort of mimick a scribe we canbe one who plays safe at the start of corrects at the end

In Figure 4 we add some randomness but to what extent this works well dependson how many words we need to retypeset before we get the badness of the linewithin the constraints

Salient features of Arabic-scriptBefore applying the above to Arabic-script letrsquos discuss some salient aspects of theproblem As a cursive script Arabic is extremely versatile and the scribal calligraphytradition reflects that Digital Arabic typography is only beginning to catch up with

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 133

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

C-0350

-0200

-0350

-0450

-0050

-0150

-0650

-0450

-f

-0100

aces -0250

publishing man-0350

yof the ne

-0100

w typographers receiv-0400

e their

-0150

-0300

-0150

t

0150

he r0100

ules -0250

book0100

sfrom computer magazines or in-

-0150

-0350

-0050

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as da

-0400

ys -0300

-0200

dif-f

-0150

erences bad ty-pog

0150

r-0150

aphic design M

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 3 Solution c

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Com-0200

-0350

-0450

-0050

-0150

-f

-0100

aces elec-0250

publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heir

-0150

-0300

-0150

t

0150

he r0100

ules typogr-0150

aph-0350

y from book0100

sfrom com magazines t

0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T is -0150

-0100

much -0350

-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po sign M peo

-0150

-0650

-0250

-0450

-0250

PCs -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-

-0100

up -0450

mak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

normal solution

Figure 4 Solution d

the possibilities afforded by the scribal tradition Indeed early lead-punch typogra-phy and typesetting of Arabic-script was more advanced than most digital typogra-phy even up to this day In any case let us begin to organize some of that versatilityinto a taxonomy for typography purposes

Whatrsquos availableWe have to work within the following parameters

983085 No hyphenation ever (well almost never)It is commonly pointed out that there is no hyphenation in Arabic This is some-thing of a half-truth In the manuscript tradition one actually does find somethingakin to hyphenation In the ancient Kufic script breaking a word across lines is

134 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

actually quite common But even in the more modern Naskh script the one mostnormal Arabic text fonts are based on it does occur albeit rarely and presumablywhen the scribe is out of options for the line he is working on Indeed one couldregard it as a failure on the part of the scribe once he reaches the end of the line4

But there is still an important rule regardless of whether we use Naskh Kuficor any other Arabic script Consider the word below

983046983491984442﮲983114ا

It is a single word composed of two cursive strings One could actually hyphen-ate it with our rule being to break it at the end of the first cursive string and beforethe beginning of the second cursive string

983125﮲اا983434983354ا983114﮲983046

983491984442

Again itrsquos a rare phenomenon and hardly ever occurs in modern typesettinglead-punch or digital if at all On the other hand it could have some creative usesin future Arabic-script typography

983085 Macrotypography (aesthetic features)In Arabic there are often numerous aesthetic ways of writing out the exact samesemantic string5

983727984030983381983923ا983784983781983783983072ا983114983067983118983072اNormally we combine OpenType features into feature sets that are each in-

ternally and aesthetically coherent So in the above example we have used threedifferent sets reading from right to leftWersquoll call them simple default and dipped

Just as Latin typography uses separate fonts to mark off different uses of text(bold italic etc) an advanced Arabic font can use aesthetic feature sets to sim-ilar effect This works best on distinguishing long streams of text from one an-other since the differences between feature sets are not always noticeable on shortstringsThat is two different aesthetic sets may type a given short string such as asingle word exactly the same way Consider the above three sets (simple defaultand dipped) once more

983095983115﮵983491984534﮵983491984534﮵

For the above string the default and dipped aesthetic sets (middle and left) givethe exact same result while the basic one (right) remains well quite basic

Letrsquos go back to our earlier example

983727984030983381983923ا983784983781983783983072ا983114983067983118983072ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 135

Note that the simple version is wider than the default and the dipped versionis (slightly) thinner than the default This relates to another point An aestheticfeature set can serve two functions1 It can serve as the base aesthetic style2 It can serve as a resource for glyph substitution for a given string in another

base aesthetic styleThis brings us back to our main topic

983085 Microtypography (paragraph optimization features)Here our job is to optimize the paragraph for even spacing and aesthetic viewingIt turns out that there are a number of ways to look at this issue and we will beginexploring these in the next subsection

Two approachesLet us start off with a couple of samples Qurʾānic transcription has always been thegold standard of Arabic-script In Figure 5 we see a nice example of scribal optimiza-tion The scribe here is operating under the constraint that each page ends with the

Figure 5 Scribal Optimization Scribe ʿUthmān Ṭāhā Qurʾān circa 1997

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 129

one not only needs needs fonts with alternative shapes but also a machinery thatcan deal with them

983085 An already old variant is the one first used by Gutenberg who used alternativecuts for certain combinations of characters This is comparable with ligaturesHowever to make the look and feel optimal one needs to analyze the text andmake decisions on what to replace without losing consistency

The solution described here does a bit of everything As it is mostly meant for a con-nective script the starting point is how a scribe works when filling up a line nicelyDepending on how well one can see it coming the writing can be adapted to widenor narrow followingwords And it happens that in Arabic-script there are quite someways to squeeze more characters in a small area andor expand some to the extremeto fill up the available space Shapes can be wider or narrower they can be stackedand they can get replaced by ligatures Of course there is some interference with theoptional marks on top and below but even there we have some freedom The onlycondition is that the characters in a word stay connected2

So given enough alternative glyphs one can imagine that excessive interwordspacing can be avoided However it is non-trivial to check all possible combinationsActually it is not needed either as carefully chosen aesthetic rules put some boundson what can be done One should more think in terms of alternative strategies orsolutions and this is the terminology that we will therefore use

Scaling glyphs horizontally is no problem if we keep the scale factor very smallsay percentages This also means that we should not overestimate the impact Forthe Arabic script we can stretch more mdashusing non-scaling methodsmdash but again thereare some constraints which we will discuss later on

In the next example we demonstrate some excessive stretching

In practice fonts can provide intercharacter kerning which is demonstrated next

W-0984

e are texies W -0984

e are texiesSome poor manrsquos justification routines mess with additional inter-character kern-

ing Although this is within reasonable bounds ok for special purposes like titles itlooks bad in text The first line expands glyphs and spaces the second line expandsspaces and adds additional kerns between characters and the third line expands andadds extra kerns

We are texiesW e a r e t e x i e s W e a r e t e x i e s

Unfortunately we see quite often examples of the last method in novels and evenscientific texts There is definitely a down side to advanced manipulation

Applying features to Latin-scriptIt is easiest to start out with Latin if only because itrsquos more intuitive for most of us tosee what happens This is not the place to discuss all the gory details so you have totake some of the configuration options on face value Once this mechanism is stableand used the options can be described For now we stick to presenting the idea

Letrsquos assume that you know what font features are The idea is to work with com-binations of such features and figure out what combination suits best In order notto clutter a document style these sets are defined in so called goodie files Here is anexcerpt of demolfg

return name = demoversion = 101

130 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

comment = An example of goodiesauthor = Hans Hagenfeaturesets = simple =

mode = nodescript = latn

default =

mode = nodescript = latnkern = yes

ligatures =

mode = nodescript = latnkern = yesliga = yes

smallcaps =

mode = nodescript = latnkern = yessmcp = yes

solutions = experimental =

less = ligatures simple

more = smallcaps

We see four sets of features here You can use these sets in a ConTEXt feature defin-ition like

definefontfeature

[solution-demo]

[goodies=demo

featureset=default]

You can use a set as follows

definefont

[SomeTestFont]

[texgyrepagellaregularsolution-demo at 10pt]

So far there is nothing special or new but we can go a step further

definefontsolution

[solution-a]

[goodies=demo

solution=experimental

method=normalpreroll

criterium=1]

definefontsolution

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 131

[solution-b]

[goodies=demo

solution=experimental

method=normalprerollsplit

criterium=1]

Here we have defined two solutions They refer to the experimental solution inthe goodie file demolfg A solution has a less and a more entry The featuresetsmentioned there reflect ways to make a word narrower or wider There can be morethan one way to do that although it comes at a performance price Before we seehow this works out we turn on a tracing option

enabletrackers

[buildersparagraphssolutionssplitterscolors]

This will color the words in the result according to what has happened Whena featureset out of the more category has been applied the words turn green whenless is applied theword becomes yellowThe preroll option in the method list makessure that we do a more extensive test beforehand

SomeTestFont startfontsolution[solution-a]

input zapf par

stopfontsolution

In Figure 1 we see what happens In each already split line words get wider ornarrower until wersquore satisfied A criterium of 1 is pretty strict3 Keep in mind that weuse some arbitrary features here We try removing kerns to get narrower althoughthere is nothing that guarantees that kerns are positive On the other hand usingligatures might help In order to get wider we use smallcaps Okay the result willlook somewhat strange but so does much typesetting nowadays

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-0650

-0450

-f

-0100

aces -0250

-0200

man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

computer magazines t0150

he in-

-0150

-0350

which t0150

he-0150

y g-0200

et

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as

-0550

-0600

-0250

-0300

-0200

dif-f

-0150

erences betw-0400

een -0350

ty-pog

0150

r-0150

aphic design M people

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 1 Solution a

There is one pitfall here This mechanism is made for a connective script where hy-phenation is not used As a result a word here is actually split up when it has dis-cretionaries and of course this text fragment has It goes unnoticed in the renderingbut is of course far from optimal

132 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

SomeTestFont startfontsolution[solution-b]

input zapf par

stopfontsolution

In this example (Figure 2) we keep words as a whole but as a side effect we skipwords that are broken across a line This is mostly because it makes not much senseto implement it as Latin is not our target Future versions of ConTEXt might get moresophisticated font machinery so then things might look better

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-

-0650

-0450

tronic publishing man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

com magzines or t0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po

-0300

M peo

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 2 Solution b

We show two more methods

definefontsolution

[solution-c]

[goodies=demo

solution=experimental

method=reversepreroll

criterium=1]

definefontsolution

[solution-d]

[goodies=demo

solution=experimental

method=randomprerollsplit

criterium=1]

In Figure 3 we start at the other end of a line As we sort of mimick a scribe we canbe one who plays safe at the start of corrects at the end

In Figure 4 we add some randomness but to what extent this works well dependson how many words we need to retypeset before we get the badness of the linewithin the constraints

Salient features of Arabic-scriptBefore applying the above to Arabic-script letrsquos discuss some salient aspects of theproblem As a cursive script Arabic is extremely versatile and the scribal calligraphytradition reflects that Digital Arabic typography is only beginning to catch up with

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 133

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

C-0350

-0200

-0350

-0450

-0050

-0150

-0650

-0450

-f

-0100

aces -0250

publishing man-0350

yof the ne

-0100

w typographers receiv-0400

e their

-0150

-0300

-0150

t

0150

he r0100

ules -0250

book0100

sfrom computer magazines or in-

-0150

-0350

-0050

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as da

-0400

ys -0300

-0200

dif-f

-0150

erences bad ty-pog

0150

r-0150

aphic design M

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 3 Solution c

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Com-0200

-0350

-0450

-0050

-0150

-f

-0100

aces elec-0250

publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heir

-0150

-0300

-0150

t

0150

he r0100

ules typogr-0150

aph-0350

y from book0100

sfrom com magazines t

0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T is -0150

-0100

much -0350

-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po sign M peo

-0150

-0650

-0250

-0450

-0250

PCs -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-

-0100

up -0450

mak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

normal solution

Figure 4 Solution d

the possibilities afforded by the scribal tradition Indeed early lead-punch typogra-phy and typesetting of Arabic-script was more advanced than most digital typogra-phy even up to this day In any case let us begin to organize some of that versatilityinto a taxonomy for typography purposes

Whatrsquos availableWe have to work within the following parameters

983085 No hyphenation ever (well almost never)It is commonly pointed out that there is no hyphenation in Arabic This is some-thing of a half-truth In the manuscript tradition one actually does find somethingakin to hyphenation In the ancient Kufic script breaking a word across lines is

134 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

actually quite common But even in the more modern Naskh script the one mostnormal Arabic text fonts are based on it does occur albeit rarely and presumablywhen the scribe is out of options for the line he is working on Indeed one couldregard it as a failure on the part of the scribe once he reaches the end of the line4

But there is still an important rule regardless of whether we use Naskh Kuficor any other Arabic script Consider the word below

983046983491984442﮲983114ا

It is a single word composed of two cursive strings One could actually hyphen-ate it with our rule being to break it at the end of the first cursive string and beforethe beginning of the second cursive string

983125﮲اا983434983354ا983114﮲983046

983491984442

Again itrsquos a rare phenomenon and hardly ever occurs in modern typesettinglead-punch or digital if at all On the other hand it could have some creative usesin future Arabic-script typography

983085 Macrotypography (aesthetic features)In Arabic there are often numerous aesthetic ways of writing out the exact samesemantic string5

983727984030983381983923ا983784983781983783983072ا983114983067983118983072اNormally we combine OpenType features into feature sets that are each in-

ternally and aesthetically coherent So in the above example we have used threedifferent sets reading from right to leftWersquoll call them simple default and dipped

Just as Latin typography uses separate fonts to mark off different uses of text(bold italic etc) an advanced Arabic font can use aesthetic feature sets to sim-ilar effect This works best on distinguishing long streams of text from one an-other since the differences between feature sets are not always noticeable on shortstringsThat is two different aesthetic sets may type a given short string such as asingle word exactly the same way Consider the above three sets (simple defaultand dipped) once more

983095983115﮵983491984534﮵983491984534﮵

For the above string the default and dipped aesthetic sets (middle and left) givethe exact same result while the basic one (right) remains well quite basic

Letrsquos go back to our earlier example

983727984030983381983923ا983784983781983783983072ا983114983067983118983072ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 135

Note that the simple version is wider than the default and the dipped versionis (slightly) thinner than the default This relates to another point An aestheticfeature set can serve two functions1 It can serve as the base aesthetic style2 It can serve as a resource for glyph substitution for a given string in another

base aesthetic styleThis brings us back to our main topic

983085 Microtypography (paragraph optimization features)Here our job is to optimize the paragraph for even spacing and aesthetic viewingIt turns out that there are a number of ways to look at this issue and we will beginexploring these in the next subsection

Two approachesLet us start off with a couple of samples Qurʾānic transcription has always been thegold standard of Arabic-script In Figure 5 we see a nice example of scribal optimiza-tion The scribe here is operating under the constraint that each page ends with the

Figure 5 Scribal Optimization Scribe ʿUthmān Ṭāhā Qurʾān circa 1997

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

130 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

comment = An example of goodiesauthor = Hans Hagenfeaturesets = simple =

mode = nodescript = latn

default =

mode = nodescript = latnkern = yes

ligatures =

mode = nodescript = latnkern = yesliga = yes

smallcaps =

mode = nodescript = latnkern = yessmcp = yes

solutions = experimental =

less = ligatures simple

more = smallcaps

We see four sets of features here You can use these sets in a ConTEXt feature defin-ition like

definefontfeature

[solution-demo]

[goodies=demo

featureset=default]

You can use a set as follows

definefont

[SomeTestFont]

[texgyrepagellaregularsolution-demo at 10pt]

So far there is nothing special or new but we can go a step further

definefontsolution

[solution-a]

[goodies=demo

solution=experimental

method=normalpreroll

criterium=1]

definefontsolution

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 131

[solution-b]

[goodies=demo

solution=experimental

method=normalprerollsplit

criterium=1]

Here we have defined two solutions They refer to the experimental solution inthe goodie file demolfg A solution has a less and a more entry The featuresetsmentioned there reflect ways to make a word narrower or wider There can be morethan one way to do that although it comes at a performance price Before we seehow this works out we turn on a tracing option

enabletrackers

[buildersparagraphssolutionssplitterscolors]

This will color the words in the result according to what has happened Whena featureset out of the more category has been applied the words turn green whenless is applied theword becomes yellowThe preroll option in the method list makessure that we do a more extensive test beforehand

SomeTestFont startfontsolution[solution-a]

input zapf par

stopfontsolution

In Figure 1 we see what happens In each already split line words get wider ornarrower until wersquore satisfied A criterium of 1 is pretty strict3 Keep in mind that weuse some arbitrary features here We try removing kerns to get narrower althoughthere is nothing that guarantees that kerns are positive On the other hand usingligatures might help In order to get wider we use smallcaps Okay the result willlook somewhat strange but so does much typesetting nowadays

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-0650

-0450

-f

-0100

aces -0250

-0200

man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

computer magazines t0150

he in-

-0150

-0350

which t0150

he-0150

y g-0200

et

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as

-0550

-0600

-0250

-0300

-0200

dif-f

-0150

erences betw-0400

een -0350

ty-pog

0150

r-0150

aphic design M people

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 1 Solution a

There is one pitfall here This mechanism is made for a connective script where hy-phenation is not used As a result a word here is actually split up when it has dis-cretionaries and of course this text fragment has It goes unnoticed in the renderingbut is of course far from optimal

132 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

SomeTestFont startfontsolution[solution-b]

input zapf par

stopfontsolution

In this example (Figure 2) we keep words as a whole but as a side effect we skipwords that are broken across a line This is mostly because it makes not much senseto implement it as Latin is not our target Future versions of ConTEXt might get moresophisticated font machinery so then things might look better

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-

-0650

-0450

tronic publishing man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

com magzines or t0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po

-0300

M peo

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 2 Solution b

We show two more methods

definefontsolution

[solution-c]

[goodies=demo

solution=experimental

method=reversepreroll

criterium=1]

definefontsolution

[solution-d]

[goodies=demo

solution=experimental

method=randomprerollsplit

criterium=1]

In Figure 3 we start at the other end of a line As we sort of mimick a scribe we canbe one who plays safe at the start of corrects at the end

In Figure 4 we add some randomness but to what extent this works well dependson how many words we need to retypeset before we get the badness of the linewithin the constraints

Salient features of Arabic-scriptBefore applying the above to Arabic-script letrsquos discuss some salient aspects of theproblem As a cursive script Arabic is extremely versatile and the scribal calligraphytradition reflects that Digital Arabic typography is only beginning to catch up with

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 133

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

C-0350

-0200

-0350

-0450

-0050

-0150

-0650

-0450

-f

-0100

aces -0250

publishing man-0350

yof the ne

-0100

w typographers receiv-0400

e their

-0150

-0300

-0150

t

0150

he r0100

ules -0250

book0100

sfrom computer magazines or in-

-0150

-0350

-0050

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as da

-0400

ys -0300

-0200

dif-f

-0150

erences bad ty-pog

0150

r-0150

aphic design M

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 3 Solution c

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Com-0200

-0350

-0450

-0050

-0150

-f

-0100

aces elec-0250

publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heir

-0150

-0300

-0150

t

0150

he r0100

ules typogr-0150

aph-0350

y from book0100

sfrom com magazines t

0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T is -0150

-0100

much -0350

-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po sign M peo

-0150

-0650

-0250

-0450

-0250

PCs -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-

-0100

up -0450

mak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

normal solution

Figure 4 Solution d

the possibilities afforded by the scribal tradition Indeed early lead-punch typogra-phy and typesetting of Arabic-script was more advanced than most digital typogra-phy even up to this day In any case let us begin to organize some of that versatilityinto a taxonomy for typography purposes

Whatrsquos availableWe have to work within the following parameters

983085 No hyphenation ever (well almost never)It is commonly pointed out that there is no hyphenation in Arabic This is some-thing of a half-truth In the manuscript tradition one actually does find somethingakin to hyphenation In the ancient Kufic script breaking a word across lines is

134 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

actually quite common But even in the more modern Naskh script the one mostnormal Arabic text fonts are based on it does occur albeit rarely and presumablywhen the scribe is out of options for the line he is working on Indeed one couldregard it as a failure on the part of the scribe once he reaches the end of the line4

But there is still an important rule regardless of whether we use Naskh Kuficor any other Arabic script Consider the word below

983046983491984442﮲983114ا

It is a single word composed of two cursive strings One could actually hyphen-ate it with our rule being to break it at the end of the first cursive string and beforethe beginning of the second cursive string

983125﮲اا983434983354ا983114﮲983046

983491984442

Again itrsquos a rare phenomenon and hardly ever occurs in modern typesettinglead-punch or digital if at all On the other hand it could have some creative usesin future Arabic-script typography

983085 Macrotypography (aesthetic features)In Arabic there are often numerous aesthetic ways of writing out the exact samesemantic string5

983727984030983381983923ا983784983781983783983072ا983114983067983118983072اNormally we combine OpenType features into feature sets that are each in-

ternally and aesthetically coherent So in the above example we have used threedifferent sets reading from right to leftWersquoll call them simple default and dipped

Just as Latin typography uses separate fonts to mark off different uses of text(bold italic etc) an advanced Arabic font can use aesthetic feature sets to sim-ilar effect This works best on distinguishing long streams of text from one an-other since the differences between feature sets are not always noticeable on shortstringsThat is two different aesthetic sets may type a given short string such as asingle word exactly the same way Consider the above three sets (simple defaultand dipped) once more

983095983115﮵983491984534﮵983491984534﮵

For the above string the default and dipped aesthetic sets (middle and left) givethe exact same result while the basic one (right) remains well quite basic

Letrsquos go back to our earlier example

983727984030983381983923ا983784983781983783983072ا983114983067983118983072ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 135

Note that the simple version is wider than the default and the dipped versionis (slightly) thinner than the default This relates to another point An aestheticfeature set can serve two functions1 It can serve as the base aesthetic style2 It can serve as a resource for glyph substitution for a given string in another

base aesthetic styleThis brings us back to our main topic

983085 Microtypography (paragraph optimization features)Here our job is to optimize the paragraph for even spacing and aesthetic viewingIt turns out that there are a number of ways to look at this issue and we will beginexploring these in the next subsection

Two approachesLet us start off with a couple of samples Qurʾānic transcription has always been thegold standard of Arabic-script In Figure 5 we see a nice example of scribal optimiza-tion The scribe here is operating under the constraint that each page ends with the

Figure 5 Scribal Optimization Scribe ʿUthmān Ṭāhā Qurʾān circa 1997

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 131

[solution-b]

[goodies=demo

solution=experimental

method=normalprerollsplit

criterium=1]

Here we have defined two solutions They refer to the experimental solution inthe goodie file demolfg A solution has a less and a more entry The featuresetsmentioned there reflect ways to make a word narrower or wider There can be morethan one way to do that although it comes at a performance price Before we seehow this works out we turn on a tracing option

enabletrackers

[buildersparagraphssolutionssplitterscolors]

This will color the words in the result according to what has happened Whena featureset out of the more category has been applied the words turn green whenless is applied theword becomes yellowThe preroll option in the method list makessure that we do a more extensive test beforehand

SomeTestFont startfontsolution[solution-a]

input zapf par

stopfontsolution

In Figure 1 we see what happens In each already split line words get wider ornarrower until wersquore satisfied A criterium of 1 is pretty strict3 Keep in mind that weuse some arbitrary features here We try removing kerns to get narrower althoughthere is nothing that guarantees that kerns are positive On the other hand usingligatures might help In order to get wider we use smallcaps Okay the result willlook somewhat strange but so does much typesetting nowadays

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-0650

-0450

-f

-0100

aces -0250

-0200

man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

computer magazines t0150

he in-

-0150

-0350

which t0150

he-0150

y g-0200

et

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as

-0550

-0600

-0250

-0300

-0200

dif-f

-0150

erences betw-0400

een -0350

ty-pog

0150

r-0150

aphic design M people

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 1 Solution a

There is one pitfall here This mechanism is made for a connective script where hy-phenation is not used As a result a word here is actually split up when it has dis-cretionaries and of course this text fragment has It goes unnoticed in the renderingbut is of course far from optimal

132 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

SomeTestFont startfontsolution[solution-b]

input zapf par

stopfontsolution

In this example (Figure 2) we keep words as a whole but as a side effect we skipwords that are broken across a line This is mostly because it makes not much senseto implement it as Latin is not our target Future versions of ConTEXt might get moresophisticated font machinery so then things might look better

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-

-0650

-0450

tronic publishing man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

com magzines or t0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po

-0300

M peo

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 2 Solution b

We show two more methods

definefontsolution

[solution-c]

[goodies=demo

solution=experimental

method=reversepreroll

criterium=1]

definefontsolution

[solution-d]

[goodies=demo

solution=experimental

method=randomprerollsplit

criterium=1]

In Figure 3 we start at the other end of a line As we sort of mimick a scribe we canbe one who plays safe at the start of corrects at the end

In Figure 4 we add some randomness but to what extent this works well dependson how many words we need to retypeset before we get the badness of the linewithin the constraints

Salient features of Arabic-scriptBefore applying the above to Arabic-script letrsquos discuss some salient aspects of theproblem As a cursive script Arabic is extremely versatile and the scribal calligraphytradition reflects that Digital Arabic typography is only beginning to catch up with

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 133

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

C-0350

-0200

-0350

-0450

-0050

-0150

-0650

-0450

-f

-0100

aces -0250

publishing man-0350

yof the ne

-0100

w typographers receiv-0400

e their

-0150

-0300

-0150

t

0150

he r0100

ules -0250

book0100

sfrom computer magazines or in-

-0150

-0350

-0050

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as da

-0400

ys -0300

-0200

dif-f

-0150

erences bad ty-pog

0150

r-0150

aphic design M

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 3 Solution c

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Com-0200

-0350

-0450

-0050

-0150

-f

-0100

aces elec-0250

publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heir

-0150

-0300

-0150

t

0150

he r0100

ules typogr-0150

aph-0350

y from book0100

sfrom com magazines t

0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T is -0150

-0100

much -0350

-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po sign M peo

-0150

-0650

-0250

-0450

-0250

PCs -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-

-0100

up -0450

mak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

normal solution

Figure 4 Solution d

the possibilities afforded by the scribal tradition Indeed early lead-punch typogra-phy and typesetting of Arabic-script was more advanced than most digital typogra-phy even up to this day In any case let us begin to organize some of that versatilityinto a taxonomy for typography purposes

Whatrsquos availableWe have to work within the following parameters

983085 No hyphenation ever (well almost never)It is commonly pointed out that there is no hyphenation in Arabic This is some-thing of a half-truth In the manuscript tradition one actually does find somethingakin to hyphenation In the ancient Kufic script breaking a word across lines is

134 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

actually quite common But even in the more modern Naskh script the one mostnormal Arabic text fonts are based on it does occur albeit rarely and presumablywhen the scribe is out of options for the line he is working on Indeed one couldregard it as a failure on the part of the scribe once he reaches the end of the line4

But there is still an important rule regardless of whether we use Naskh Kuficor any other Arabic script Consider the word below

983046983491984442﮲983114ا

It is a single word composed of two cursive strings One could actually hyphen-ate it with our rule being to break it at the end of the first cursive string and beforethe beginning of the second cursive string

983125﮲اا983434983354ا983114﮲983046

983491984442

Again itrsquos a rare phenomenon and hardly ever occurs in modern typesettinglead-punch or digital if at all On the other hand it could have some creative usesin future Arabic-script typography

983085 Macrotypography (aesthetic features)In Arabic there are often numerous aesthetic ways of writing out the exact samesemantic string5

983727984030983381983923ا983784983781983783983072ا983114983067983118983072اNormally we combine OpenType features into feature sets that are each in-

ternally and aesthetically coherent So in the above example we have used threedifferent sets reading from right to leftWersquoll call them simple default and dipped

Just as Latin typography uses separate fonts to mark off different uses of text(bold italic etc) an advanced Arabic font can use aesthetic feature sets to sim-ilar effect This works best on distinguishing long streams of text from one an-other since the differences between feature sets are not always noticeable on shortstringsThat is two different aesthetic sets may type a given short string such as asingle word exactly the same way Consider the above three sets (simple defaultand dipped) once more

983095983115﮵983491984534﮵983491984534﮵

For the above string the default and dipped aesthetic sets (middle and left) givethe exact same result while the basic one (right) remains well quite basic

Letrsquos go back to our earlier example

983727984030983381983923ا983784983781983783983072ا983114983067983118983072ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 135

Note that the simple version is wider than the default and the dipped versionis (slightly) thinner than the default This relates to another point An aestheticfeature set can serve two functions1 It can serve as the base aesthetic style2 It can serve as a resource for glyph substitution for a given string in another

base aesthetic styleThis brings us back to our main topic

983085 Microtypography (paragraph optimization features)Here our job is to optimize the paragraph for even spacing and aesthetic viewingIt turns out that there are a number of ways to look at this issue and we will beginexploring these in the next subsection

Two approachesLet us start off with a couple of samples Qurʾānic transcription has always been thegold standard of Arabic-script In Figure 5 we see a nice example of scribal optimiza-tion The scribe here is operating under the constraint that each page ends with the

Figure 5 Scribal Optimization Scribe ʿUthmān Ṭāhā Qurʾān circa 1997

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

132 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

SomeTestFont startfontsolution[solution-b]

input zapf par

stopfontsolution

In this example (Figure 2) we keep words as a whole but as a side effect we skipwords that are broken across a line This is mostly because it makes not much senseto implement it as Latin is not our target Future versions of ConTEXt might get moresophisticated font machinery so then things might look better

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Coming back -0150

-

-0650

-0450

tronic publishing man-0350

yof the new typogr

-0150

aphers receiv-0400

e their

-0150

-0300

-0150

r

0100

ules of typogr-0150

aph-0350

y from book0100

s

-0250

com magzines or t0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T -0150

-0100

so much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po

-0300

M peo

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 2 Solution b

We show two more methods

definefontsolution

[solution-c]

[goodies=demo

solution=experimental

method=reversepreroll

criterium=1]

definefontsolution

[solution-d]

[goodies=demo

solution=experimental

method=randomprerollsplit

criterium=1]

In Figure 3 we start at the other end of a line As we sort of mimick a scribe we canbe one who plays safe at the start of corrects at the end

In Figure 4 we add some randomness but to what extent this works well dependson how many words we need to retypeset before we get the badness of the linewithin the constraints

Salient features of Arabic-scriptBefore applying the above to Arabic-script letrsquos discuss some salient aspects of theproblem As a cursive script Arabic is extremely versatile and the scribal calligraphytradition reflects that Digital Arabic typography is only beginning to catch up with

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 133

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

C-0350

-0200

-0350

-0450

-0050

-0150

-0650

-0450

-f

-0100

aces -0250

publishing man-0350

yof the ne

-0100

w typographers receiv-0400

e their

-0150

-0300

-0150

t

0150

he r0100

ules -0250

book0100

sfrom computer magazines or in-

-0150

-0350

-0050

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as da

-0400

ys -0300

-0200

dif-f

-0150

erences bad ty-pog

0150

r-0150

aphic design M

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 3 Solution c

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Com-0200

-0350

-0450

-0050

-0150

-f

-0100

aces elec-0250

publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heir

-0150

-0300

-0150

t

0150

he r0100

ules typogr-0150

aph-0350

y from book0100

sfrom com magazines t

0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T is -0150

-0100

much -0350

-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po sign M peo

-0150

-0650

-0250

-0450

-0250

PCs -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-

-0100

up -0450

mak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

normal solution

Figure 4 Solution d

the possibilities afforded by the scribal tradition Indeed early lead-punch typogra-phy and typesetting of Arabic-script was more advanced than most digital typogra-phy even up to this day In any case let us begin to organize some of that versatilityinto a taxonomy for typography purposes

Whatrsquos availableWe have to work within the following parameters

983085 No hyphenation ever (well almost never)It is commonly pointed out that there is no hyphenation in Arabic This is some-thing of a half-truth In the manuscript tradition one actually does find somethingakin to hyphenation In the ancient Kufic script breaking a word across lines is

134 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

actually quite common But even in the more modern Naskh script the one mostnormal Arabic text fonts are based on it does occur albeit rarely and presumablywhen the scribe is out of options for the line he is working on Indeed one couldregard it as a failure on the part of the scribe once he reaches the end of the line4

But there is still an important rule regardless of whether we use Naskh Kuficor any other Arabic script Consider the word below

983046983491984442﮲983114ا

It is a single word composed of two cursive strings One could actually hyphen-ate it with our rule being to break it at the end of the first cursive string and beforethe beginning of the second cursive string

983125﮲اا983434983354ا983114﮲983046

983491984442

Again itrsquos a rare phenomenon and hardly ever occurs in modern typesettinglead-punch or digital if at all On the other hand it could have some creative usesin future Arabic-script typography

983085 Macrotypography (aesthetic features)In Arabic there are often numerous aesthetic ways of writing out the exact samesemantic string5

983727984030983381983923ا983784983781983783983072ا983114983067983118983072اNormally we combine OpenType features into feature sets that are each in-

ternally and aesthetically coherent So in the above example we have used threedifferent sets reading from right to leftWersquoll call them simple default and dipped

Just as Latin typography uses separate fonts to mark off different uses of text(bold italic etc) an advanced Arabic font can use aesthetic feature sets to sim-ilar effect This works best on distinguishing long streams of text from one an-other since the differences between feature sets are not always noticeable on shortstringsThat is two different aesthetic sets may type a given short string such as asingle word exactly the same way Consider the above three sets (simple defaultand dipped) once more

983095983115﮵983491984534﮵983491984534﮵

For the above string the default and dipped aesthetic sets (middle and left) givethe exact same result while the basic one (right) remains well quite basic

Letrsquos go back to our earlier example

983727984030983381983923ا983784983781983783983072ا983114983067983118983072ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 135

Note that the simple version is wider than the default and the dipped versionis (slightly) thinner than the default This relates to another point An aestheticfeature set can serve two functions1 It can serve as the base aesthetic style2 It can serve as a resource for glyph substitution for a given string in another

base aesthetic styleThis brings us back to our main topic

983085 Microtypography (paragraph optimization features)Here our job is to optimize the paragraph for even spacing and aesthetic viewingIt turns out that there are a number of ways to look at this issue and we will beginexploring these in the next subsection

Two approachesLet us start off with a couple of samples Qurʾānic transcription has always been thegold standard of Arabic-script In Figure 5 we see a nice example of scribal optimiza-tion The scribe here is operating under the constraint that each page ends with the

Figure 5 Scribal Optimization Scribe ʿUthmān Ṭāhā Qurʾān circa 1997

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 133

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

C-0350

-0200

-0350

-0450

-0050

-0150

-0650

-0450

-f

-0100

aces -0250

publishing man-0350

yof the ne

-0100

w typographers receiv-0400

e their

-0150

-0300

-0150

t

0150

he r0100

ules -0250

book0100

sfrom computer magazines or in-

-0150

-0350

-0050

-0050

PC sof0100

t-w

-0300

are T -0150

-0100

much basic in-

-0150

-0350

-0450

-0150

-0300

-1050

w-0300

as da

-0400

ys -0300

-0200

dif-f

-0150

erences bad ty-pog

0150

r-0150

aphic design M

-0150

-0650

-0250

-0450

-0250

PC -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am -0100

-0450

make everything automatic from nowon

normal solution

Figure 3 Solution c

Coming back t-0100

o t0150

he use of type-f

-0100

aces in electronic publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heirkno

-0250

w-0350

ledg-0200

e and inf-0150

ormation aboutt

0150

he r0100

ules of typogr-0150

aph-0350

y from book0100

sfrom computer magazines or t

0150

he in-s

-0150

tr0100

uction manuals which t0150

he-0150

y g-0200

etwit

0150

h t0150

he purchase of a PC or sof0100

t-w

-0300

are There is no-0150

t so much basic in-s

-0150

tr0100

uction as of no-0250

w-1050

as t0150

here w-0300

asin t

0150

he old da-0400

ys sho-0250

wing t0150

he dif-f

-0150

erences betw-0400

een good and bad ty-pog

0150

r-0150

aphic design Man-0350

y people arejus

-0150

t f-0100

ascinated b-0300

y t0150

heir PCs trick0100

sand t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-g

0150

r-0150

am called up on t0150

he screen willmak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

Com-0200

-0350

-0450

-0050

-0150

-f

-0100

aces elec-0250

publishing man-0350

yof t

0150

he ne-0100

w typogr-0150

aphers receiv-0400

e t0150

heir

-0150

-0300

-0150

t

0150

he r0100

ules typogr-0150

aph-0350

y from book0100

sfrom com magazines t

0150

he in-

-0150

-0350

-0050

-0050

PC -

-0750

T is -0150

-0100

much -0350

-

-0150

-0350

-0450

-0150

-0300

-1050

-0750

-0550

-0600

-0250

-0300

-0200

-

-0200

-0350

-po sign M peo

-0150

-0650

-0250

-0450

-0250

PCs -0050

and t

0150

hink t0150

hat a widel-0250

y--pr-0150

aised pro-

-0100

up -0450

mak

-0100

e e-0100

v-0400

er0150

yt0150

hing aut-0100

omatic from no-0250

won

normal solution

Figure 4 Solution d

the possibilities afforded by the scribal tradition Indeed early lead-punch typogra-phy and typesetting of Arabic-script was more advanced than most digital typogra-phy even up to this day In any case let us begin to organize some of that versatilityinto a taxonomy for typography purposes

Whatrsquos availableWe have to work within the following parameters

983085 No hyphenation ever (well almost never)It is commonly pointed out that there is no hyphenation in Arabic This is some-thing of a half-truth In the manuscript tradition one actually does find somethingakin to hyphenation In the ancient Kufic script breaking a word across lines is

134 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

actually quite common But even in the more modern Naskh script the one mostnormal Arabic text fonts are based on it does occur albeit rarely and presumablywhen the scribe is out of options for the line he is working on Indeed one couldregard it as a failure on the part of the scribe once he reaches the end of the line4

But there is still an important rule regardless of whether we use Naskh Kuficor any other Arabic script Consider the word below

983046983491984442﮲983114ا

It is a single word composed of two cursive strings One could actually hyphen-ate it with our rule being to break it at the end of the first cursive string and beforethe beginning of the second cursive string

983125﮲اا983434983354ا983114﮲983046

983491984442

Again itrsquos a rare phenomenon and hardly ever occurs in modern typesettinglead-punch or digital if at all On the other hand it could have some creative usesin future Arabic-script typography

983085 Macrotypography (aesthetic features)In Arabic there are often numerous aesthetic ways of writing out the exact samesemantic string5

983727984030983381983923ا983784983781983783983072ا983114983067983118983072اNormally we combine OpenType features into feature sets that are each in-

ternally and aesthetically coherent So in the above example we have used threedifferent sets reading from right to leftWersquoll call them simple default and dipped

Just as Latin typography uses separate fonts to mark off different uses of text(bold italic etc) an advanced Arabic font can use aesthetic feature sets to sim-ilar effect This works best on distinguishing long streams of text from one an-other since the differences between feature sets are not always noticeable on shortstringsThat is two different aesthetic sets may type a given short string such as asingle word exactly the same way Consider the above three sets (simple defaultand dipped) once more

983095983115﮵983491984534﮵983491984534﮵

For the above string the default and dipped aesthetic sets (middle and left) givethe exact same result while the basic one (right) remains well quite basic

Letrsquos go back to our earlier example

983727984030983381983923ا983784983781983783983072ا983114983067983118983072ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 135

Note that the simple version is wider than the default and the dipped versionis (slightly) thinner than the default This relates to another point An aestheticfeature set can serve two functions1 It can serve as the base aesthetic style2 It can serve as a resource for glyph substitution for a given string in another

base aesthetic styleThis brings us back to our main topic

983085 Microtypography (paragraph optimization features)Here our job is to optimize the paragraph for even spacing and aesthetic viewingIt turns out that there are a number of ways to look at this issue and we will beginexploring these in the next subsection

Two approachesLet us start off with a couple of samples Qurʾānic transcription has always been thegold standard of Arabic-script In Figure 5 we see a nice example of scribal optimiza-tion The scribe here is operating under the constraint that each page ends with the

Figure 5 Scribal Optimization Scribe ʿUthmān Ṭāhā Qurʾān circa 1997

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

134 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

actually quite common But even in the more modern Naskh script the one mostnormal Arabic text fonts are based on it does occur albeit rarely and presumablywhen the scribe is out of options for the line he is working on Indeed one couldregard it as a failure on the part of the scribe once he reaches the end of the line4

But there is still an important rule regardless of whether we use Naskh Kuficor any other Arabic script Consider the word below

983046983491984442﮲983114ا

It is a single word composed of two cursive strings One could actually hyphen-ate it with our rule being to break it at the end of the first cursive string and beforethe beginning of the second cursive string

983125﮲اا983434983354ا983114﮲983046

983491984442

Again itrsquos a rare phenomenon and hardly ever occurs in modern typesettinglead-punch or digital if at all On the other hand it could have some creative usesin future Arabic-script typography

983085 Macrotypography (aesthetic features)In Arabic there are often numerous aesthetic ways of writing out the exact samesemantic string5

983727984030983381983923ا983784983781983783983072ا983114983067983118983072اNormally we combine OpenType features into feature sets that are each in-

ternally and aesthetically coherent So in the above example we have used threedifferent sets reading from right to leftWersquoll call them simple default and dipped

Just as Latin typography uses separate fonts to mark off different uses of text(bold italic etc) an advanced Arabic font can use aesthetic feature sets to sim-ilar effect This works best on distinguishing long streams of text from one an-other since the differences between feature sets are not always noticeable on shortstringsThat is two different aesthetic sets may type a given short string such as asingle word exactly the same way Consider the above three sets (simple defaultand dipped) once more

983095983115﮵983491984534﮵983491984534﮵

For the above string the default and dipped aesthetic sets (middle and left) givethe exact same result while the basic one (right) remains well quite basic

Letrsquos go back to our earlier example

983727984030983381983923ا983784983781983783983072ا983114983067983118983072ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 135

Note that the simple version is wider than the default and the dipped versionis (slightly) thinner than the default This relates to another point An aestheticfeature set can serve two functions1 It can serve as the base aesthetic style2 It can serve as a resource for glyph substitution for a given string in another

base aesthetic styleThis brings us back to our main topic

983085 Microtypography (paragraph optimization features)Here our job is to optimize the paragraph for even spacing and aesthetic viewingIt turns out that there are a number of ways to look at this issue and we will beginexploring these in the next subsection

Two approachesLet us start off with a couple of samples Qurʾānic transcription has always been thegold standard of Arabic-script In Figure 5 we see a nice example of scribal optimiza-tion The scribe here is operating under the constraint that each page ends with the

Figure 5 Scribal Optimization Scribe ʿUthmān Ṭāhā Qurʾān circa 1997

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 135

Note that the simple version is wider than the default and the dipped versionis (slightly) thinner than the default This relates to another point An aestheticfeature set can serve two functions1 It can serve as the base aesthetic style2 It can serve as a resource for glyph substitution for a given string in another

base aesthetic styleThis brings us back to our main topic

983085 Microtypography (paragraph optimization features)Here our job is to optimize the paragraph for even spacing and aesthetic viewingIt turns out that there are a number of ways to look at this issue and we will beginexploring these in the next subsection

Two approachesLet us start off with a couple of samples Qurʾānic transcription has always been thegold standard of Arabic-script In Figure 5 we see a nice example of scribal optimiza-tion The scribe here is operating under the constraint that each page ends with the

Figure 5 Scribal Optimization Scribe ʿUthmān Ṭāhā Qurʾān circa 1997

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

136 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 6 Alternate Fixed Glyphs From theal-Husayni Muṣḥaf of the Qurʾān 1923

end of a Qurʾānic verse (designated by the symbol U+06DD ) That is no verse isbroken across pages That constraint which is by no means mandatory or universalgives the scribe lots of space for optimization even more than normal

In Figure 6 we have a page of the famous al-Husayni Muṣḥaf of 1919ndash1923 whichremains up to this day the only typeset copy of the Qurʾān to attain general accep-tance in the Muslim world Indeed it remains the standard lsquoeditionrsquo of the Qurʾānand even later scribal copies such as the one featured in Figure 5 are based on itsorthography Unlike the scribal version the typesetters of the al-Husayni Muṣḥaf didnot try to constrain each page to end with the end of a Qurʾānic verse Again that isa nice feature to have as it makes recitation somewhat easier but it is by no means amandatory one

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 137

In any case both samples share verses 172ndash176 in commmon so there is lots tocompare and contrast We will also use these verses as our main textual sample forparagraph optimization

Using Figure 5 and Figure 6 as benchmarks we can begin by analyzing the ap-proaches to paragraph optimization in Arabic-script typography into two kinds

983085 Alternate glyphsMuch of pre-digital Arabic typography uses this method Generally a wide variantof a letter is used to take up the space which would normally get absorbed by hy-phenation in Latin Here are examples of three of the most common substitutionsagain reading from right to left

983117983046larr984219983814﮳ب983046﮴983114985263اlarr﮳ب983046﮴983114983108zwjاzwnjzwnjzwnjzwnj﮲983275983878﮲اlarr﮲983275983878﮲ا

Each of the six strings above occurs in Figure 6 Identifying them is an exerciseleft to the reader We call these kinds of alternate glyphs alternate-shaped glyphs

The three substitutions above are the most common alternate-glyph substitu-tions found in pre-digital Arabic-script typography including some contextualvariants (initial medial final and isolated) where appropriate (The scribal tra-dition contains a lot more alternate-shaped glyphs A few lead-punch fonts im-plement some of them and we have implemented many of these in our Husaynifont) The results generally look quite nice and much more professional than mostdigital Arabic typography which generally dispenses with these alternates

But one also finds attempts at extending individual characters without changingthe shape very much One finds this already in Figure 6 We call these kinds ofalternate glyphs naturally curved widened glyphs or just naturally widened glyphsfor short Sometimes this is done for the purpose of making enough space for thevowels (which in Arabic take the form of diacritic characters) For example

983250983878983320983878983987983046larr﮵984996984995984878983320983878 984879983810

As you can see there are two letters that have been widened for vowel accom-modation In Figure 6 there are some good but near-clumsy attempts at this Wesay lsquonear-clumsyrsquo because the typographers and typesetters mix natural curvedwidened variants of letters with flat horizontal extended versions One reason forthis is that a full repertoire of naturally curved glyph alternates would bemuch toounwieldy for even the best lead-punch typesetting machines and their operatorsEven with these limitations one can find brave examples of lead-based typesettingthat do a good job of sophisticated paragraph optimization via glyph alternatesboth widened and alternate-shaped Figure 7 is a representative example (in thecontext of columns)Careful examination of this two-column sample will reveal the tension betweennaturally widened and horizontally extended glyphs in the execution of paragraphoptimization On the other hand there is one apparent lsquorulersquo that one finds in thisand other examples of lead-punch Arabic-script typesetting

Generally there is only one naturally widened character per word or onealternate-shaped character per wordIn Figure 5 one can see that this lsquorulersquo is not always observed by scribes see

eg the middle word in line 9 from the top which uses two of the alternate-shapedcharacters we encountered above (can you identify that word) But we still need

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

138 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Figure 7 Mixed Alternate Glyphs in Two Columns From the classical dictionary Mukhtār al-Ṣiḥāḥ

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 139

some constraints for decent-looking typesetting and the above tentative rule is agood place to start the analysis For widened characters in particular we see thateven the scribe (Figure 5) closely approximates this rule So letrsquos begin improvingon our tentative rule somewhat and expand it into a number of possibilities Letrsquoslook at the naturally-widened-glyph case first

Generally there is only one naturally widened character allowed per wordHowever two extended non-consecutive characters may be allowed (The logicof the experimental font Husayni already has contraints that prevent con-secutive curved widened characters)For example we prefer to get widening like the following

983077﮳﮵983116larr983077﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr983077﮳﮵984442zwjzwj983077﮳﮵983116larr983077﮳﮵984442

983077﮳﮵983116larr984181﮳﮵983116zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵983116zwjzwj983077﮳﮵983116larr984185﮳﮵983116

But as eg a last resort or for stylistic purposes we can also do

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984185﮳﮵984442

Or even better we mix it up a bit That is if there is more than one widenedcharacter one should be longer than the other eg

983077﮳﮵983116larr984181﮳﮵984442zwnjzwnjzwnjzwnj983077﮳﮵983116larr984183﮳﮵984442zwjzwj983077﮳﮵983116larr984183﮳﮵984442

One will notice that the middle substitution (where the first widened characteris longer than the second) does not look as good as the two outer ones (where thesecond is longer than the first) These kinds of aesthetic issues can be formalizedfor future work In the meantime here is a working modified version of the rulefor naturally-widened-glyphs

Generally there is only one naturally widened character allowed per wordHowever two non-consecutive widenedcharacters may be allowed In that casethe second widened character should be longer than the firstOne case where cases of two naturally widened characters will be common is

in poetry which involves wide lines Wersquoll say more about this in the section onflat extending

Now letrsquos look at the alternate-shaped caseGenerally there is only one alternate-shaped character allowed per word

However two non-consecutive alternate-shaped characters may be allowedSo we prefer eg

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

140 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲ن

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵983108﮴983118983123﮲zwnjzwnjzwnj

but we could have eg as a last resort or as a stylistic option

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnj

﮵983108﮴983118983123﮲نlarr﮵985263﮴983118983123﮲zwnjzwnjzwnjzwnjzwnj

Again in poetry this kind of multiple substitution within a single word couldoccur frequently A challenge will be to develop a system of parameters where wecan almost predict which kinds of substitution will happen under a given set ofvalues of those parameters

983085 Flat extendingIn the transition from lead-punch to digital typography alternate-glyph substi-tution largely vanished6 The problem of spacing remained and a simple yet in-elegant solution was adopted flat horizontal extending of characters Now thissolution did have some precedent in pre-digital Arabic typography as you can seein Figure 6 and Figure 7 This solution had the advantage that it required onlya single character a simple horizontal bar called a taṭwīl or more commonly akashidah (U+0640) This character could then be repeated as often as necessary tofill any extra space

Now an examination of pre-digital books shows a (rather wise) reticence tousing this method too slavishly That reticence has now been thrown to the windsThis can be seen by looking at the standard implementation of flat extending asprovided by MicrosoftWord This program provides three levels of extending thatit calls lsquojustificationrsquo See Figure 9 for examples of all three The minimum level isactually very close to the default (ie no-justification) level Note that the sampletext used in Figure 9 is the same as that used in the earlier samples from theQurʾān

Older implementations of Arabic-script within TEX such as ArabTEX andOmegaAleph also provided facilities for flat extending The most common usewas in poetry which requires a fixed width for each stanza

In OmegaAleph a method based on xleaders was used based on a very thintaṭwīl glyph (much thinner than U+0640) that could be used for very fine extendingoptimization based on TEXrsquos badness parameter One nice application is in mar-ginal notes See Figure 10 where the marginal note on the right is zoomed in Onthe other hand we see that the leaders method creates extending that may be con-sidered too perfectly even Do we want to impose the rule that only one charactershould be extended per word (or at most two non-consecutive characters) I haveseen a lot of older digital Arabic typography that does even extending includingthe poetry in the ArabTEX sample in figure 8 Compare this with the MicrosoftWord method (Figure 9) The method used in Microsoft Word with only one ex-tension per word seems to be the current standard for flat-extending justification

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 141

477

aacuteOacuteagraveAiquest agrave13

eth H AmIgrave eth eacute

OacuteAJ regEuml ETH ntildeK

agrave P ntildeEuml agrave A

B13

frac12Euml

X uacuteIcirc laquo oslash Q k A Ograveicirc DOacute 15

Ntildeordm k feacute Ograve

ordm k agraventilde

ordmK eth Q k

B iexcl regm A Oacute P Y B

13eacuteJOacute

J K Otilde

Euml eth Q k

B shy ordf A Ograveeuml Y g

13

oslash ntilderegEuml

eth eacuteJeuml A UumlIuml I

P eth Eacutereg ordfEuml I k

13 IK A

iquest eth reg

JEuml I

K13A Ograve pound13

Xntilde k ntildeEuml oslash ntilde

regEuml agraveA

iquest agraveA13

agrave13

eth A Ograveicirc DJK Eacuteordf regEuml uacute

Q C P A

JEuml uacute

egrave AOgrave jUuml

Iuml egrave

YKYmIgraveAiquest Xntilde k ntilde

Euml [202] I icircE A

Qlaquo A

Euml

EgraveA Y KY

mIgraveAiquest Q ordf

EumlAK AicircE A Oacute agraveA

iquest 20

Q Oacute13B eacute K A

eth C iquest A Q Ograve m

Igrave I

P eth h AgQ Euml

PQ Ocirc

g B eth h Y A Uuml

szlig13Aiquest eth h Y B

eth Q Ocircg A Uuml

szlig13Afrac34

YOgraveJ A Uuml

szlig 13 A Ograveicirc DOacute Y g ethEacuteiquest eth

ordm ordf

Euml uacute

Icirc laquo QOacute

13B agraveA

iquest eacuteJeuml A Uuml

Iuml oslash ntilde

regEuml agraveA

iquest agrave13

ethYOgraveJ C

egraveY aacuteOacute ntilde euml A Oacute ntilde

m aacuteOacute Z uacuteaelig

EumlYOgraveJ B

X 13 eacute k

aacuteOacute XYUumlszlig oslash ntilde

regK ethntilde euml A Uuml

szlig 13 feacute ordf Oacute QkB

EacuteJ Oacute eth frac12Euml

Yraquo ntilde euml IJ k aacuteOacute

ordm ordf

Euml B

eth eacuteOgraveEcirccentEuml aacuteOacute Pntilde

JEuml 25

A Ograveicirc13EA regJ Euml

uml ntildeK

13 aacuteOacute

YOgraveJ

eacuteJeuml A UumlIuml eth eacute laquo ntilde

K aacuteOacute AicircE13B H

QmIgrave uml

ntildeK

13 aacuteOacute

YOgraveJ Xntilde k ntilde

EumlA

AK Aiquest X 13 A ordfOacute eacute J

Q pound aacuteOacuteYOgraveJ B

Yg ntildeEuml I

raquoQUuml

Iuml eth Aecirclaquo ntilde

K aacuteOacute AicircE13B Peth

QaringEuml

16eacuteJOacute ]

eacuteJ laquo T p 212

24aacuteOacute Z uacuteaelig

EumlYOgraveJ ] aacuteOacute

YOgraveJ T p 214

25aacuteOacute ] aacuteOacute eth T p 214

28 eacute J Q pound ] eacute J

Q pound T p 215

15ndash16 A Ograveeuml Y g13 ] The word A Ograveeuml Y g

13 is a correction by the author in the margin Part of the pronoun A Ograveeuml is

cut off in the manuscript but from the context as well from comparison with T there is no doubt that

A Ograveeuml Y g13 is meant

28 eacute J Q pound ] In A we find eacuteJ Q pound but from the context and the commentary it is clear that the author meant

Figure 8 Poetry Justification in ArabTEX

يت ٢٧١ يا أي ها الذين آمنوا كلوا من طيبات ما رزق ناكم واشكروا لله إن كنتم إياه ت عبدون ر لل يكم ال ا إن ولم النزير وما أهل به لغي الل ه ل و ل الل ف م إل للي ه والد رر يي ر ب ا ن ا ورر ر يمر ف إن الل ه ي

ويه ت رون ب ه ن ا قل يم ٢٧١ ون م ا أل زه الل ه م ن الكت ا أولئ م ا ي وكلون بر ولم إ إن ال ذين يكتر أل يمر الن يام و ي زكيهم وا م ل ذا ه م الل ه ي و ال أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ار و يكل

رة غ بال ا أصب رهم للى النار والعذا ل بون الله ل ز ٢٧١ ف بالق ذ وا ه الكتا ت ل وإن ال ذين اي شاقل بعيدل ل ٢٧١ الكتا

ر ٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ا إن ول م النزي ر وم ا أه ل ب ه لغ ي الل ه لل يك يت وال د ل و ل الل ف م إل م ال رر يي ر ب ا ن ا ف ورر ر يمر للي ه ويه ت رون ب ه ن ا ٢٧١ إن الل ه ي ون م ا أل زه الل ه م ن الكت ا إن ال ذين يكتيام و ي زكيهم قل يم ه م الل ه ي و ال ر أولئ م ا ي وكلون بر ولم إ الن ار و يكل وا م ل ذارة ٢٧١ أل يمر غ ب ال ا أص ب رهم لل ى الن ار أولئ ال ذين اش ت روا الة مل باا د والع ذا ٢٧١ ف

بالق ل بون الله ل زه الكتا ي شاقل بعيدل ذ ل وا الكتا ت ل ٢٧١ وإن الذين ا

٢٧١ ي ا أي ه ا ال ذين آمن وا كل وا م ن طيب ات م ا رزق ن اكم واش كروا لل ه إن كن تم إي اه ت عب دون ول م النزي ر وم ا أه ل ب ه لغ ي الل ه يت وال د ر لل يكم ال ا رر إن ن ا ل ف يي ر ب ا

ورر ر يمر و ل الل ف م إل للي ه ون م ا أل زه الل ه م ن ٢٧١ إن الل ه ي إن ال ذين يكت ويه ت رون ب ه ن ا قل يم ه م الل ه أولئ م ا ي وكلون بر ولم إ الن ار و يك الكت ا ل

ر أل يمر يام و ي زكيهم وا م ل ذا أولئ ال ذين اش ت روا الة مل باا د ٢٧١ ي و الرة غ ب ال ا أص ب رهم لل ى الن ار والع ذا ب ٢٧١ ف ل ب ون الل ه ل زه الكت ا الق ذ

ي شاقل بعيدل ل وا الكتا ت ل ٢٧١ وإن الذين ا

Figure 9 Flat justification from Microsoft Word 2010

On the other hand the justification used in Microsoft Word is not particularlyaesthetically pleasing The answer will lie again in parameterization of some sort

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

142 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

thorncedilordmthorn

RpoundW7poundSsectRnotsectnotregasectsectbRpoundepounduacuteV_sectHpoundUumlaaringVKnotVTHORN

FfeYVVFRSzRSnotRPResectSsectbNgtRbrvbarhVKNtildeRbidYacutegtSbrvbarh6bReKe[enotRnotjTHORNgtSOgraveReKeYacutegteReKeYacuteaLregReKeUuml

igraveRpoundWsectKnotVuacutesecteumlpoundabrvbarTHORNfrac14acute

igraveeumlZnotipoundQYnotQpoundUacutepoundYicircregaumlsectbVsectKpoundbrvbarFOpoundgtaumlQsecticircregRpoundbiduacutetimesSdegKagtpoundKYacuteapound]SdegGasectsectbYacuteapoundWKdegKaasectsectbUumlabrvbaraacuteYnotanotQVKVicircregVipoundFuacutesectapoundLregegravetimesccedil=poundSenotuacuteRpoundETHe7uacuteUumlaQsectVipoundFRnotpounddLsectRpoundsect[aRpoundbsectregenotuacutea=poundeSenotuacuteRpoundWsectNnotuacuteRpoundWsect[pound7KuacutegtSepoundszligNKbpoundR[YacutesectbthornsectethnotciUumlaringbrvbarinotsectbGsectfrac14sup1

RpoundCOacutepoundaRnotszligRpoundWacircsectRpoundKsectdegasectRnotjUsectRpoundWsectVsectRpoundWsect_UgravepoundsectRpoundmsectpoundnotsectRpoundWsectO regsectszligbpoundRLsectRpoundcRpoundWsectaringregsecteacuteYacutebrvbarBiexclpoundbrvbaraacute-dKpound3eRpound sectpoundYsectUuml

abrvbar igravesectbeumlRpoundagravepoundsectRpoundeKsectUumlaRWnotGpounddOsectpoundVipoundFsectRpoundsect[poundbYVsectbaumlnotbpoundeYacuteFjsectnotVpoundJVuacuteRpound sectpoundYgtSepoundaumlJQigravegtplusmnegrave=ccedileumlYacuteecircafrac12acute

QsectRnotpounddLgttimesbpoundesect]eacuteaumlaigraveVpoundeumlUacutepounduacuteRNtildenot+deg0RepoundsectpoundZYacuteapounduacute

frac14sup1frac14raquosectbthornsectUumlUumlUumlRcRWsectbregsectTHORNRWsectKETH(sectVRsup1frac12THORNparacedilparapara〈

uacutefrac14cedilR_SenotuacuteTHORNN brvbarRPTUumlR_eSenotuacuteTHORNN brvbarRPTUuml

Figure 10 Marginal-note justification in OmegaAleph

to be determined As TEXies we want to be able to have fine control over this kindof behavior in any case In the meantime we mirror the same rule we arrived atfor naturally-widened-glyphs

Generally there is only one flat extended character allowed per word How-ever two non-consecutive extended characters may be allowed In that casethe second extended character should be longer than the firstFor example

983077﮳﮵983116larr983077﮳﮵ــzwj983116

983077﮳﮵983116larr983077ــzwj﮳﮵ـــzwj983116

In accordance with our working rule the top substitution uses only one flatextended character The bottom uses two but the second is longer than the first

In our own estimation the smaller the type as in eg footnotes and marginal notesthe less aesthetic variants that are needed And the less aesthetic variants neededthe better that flat extending will work as a solution Consider another example ofthe same word processed in three different variants

983784983781983783983072ا983727983767zwj983118983072ا983114983067983118983072اIn this case our default is on the left The variant on the right is about as basic as

one can get the default on the left is a sophisticated aesthetic variant The middleone is well in between Letrsquos try them with flat extending using only one extendedcharacter per word

983072ـــzwj983784983781983783ا983072ـــzwj983727983767zwj983118ا983072ـــzwj983114983067983118ا

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 143

On the left we have an aesthetic combination of letters followed by a flat taṭwīlThis is what MicrosoftWord would give us and the result is aesthetically distastefulIn the word on the right however the flat extension fits well with the basic natureof the feature set As for the middle one it could go either way and we leave it to thereader to decide what one thinks

Now letrsquos repeat with more naturally curved widening

983784983781984418984432ا983727983767zwj984307984432ا983114983067984307984432اHere the variant on the left comes out much nicerThe one on the right looks okay

with curved widening although one could arguably do better with flat extending atleast in some contexts The middle one again could go either way though we thinkit does somewhat better with curved widening compared to the one on the right Thevariant on the left only works well with curved widening

Towards a ConTEXt solutionIn what follows we will focus on a solution to the problem of paragraph optimiza-tion via alternate glyphs (including alternately-shaped and naturally-widened vari-ants) It turns out that the xleadersmethod used by OmegaAleph does not work inLuaTEX so flat extending could not be naively implemented that way At themomentflat extending is yet to be implemented in ConTEXt

Since flat extending is so ubiquitous in current Arabic-script typography andsince it does have important applications (poetry and small font sizes where oneprefers simpler aesthetic variants) one could askwhy this was not implemented firstIn part this is because the immediate priority of the Oriental TEX project has beentop-notch unparalleled aesthetic sophistication of the script As we noted above flatextending does not work so well with sophisticated aesthetic variation So althoughthe flat-extending problem is apparently simpler it is understandable that we havefocused on the more difficult problem first A clear understanding of the issues andchallenges involved with the more general alternate glyph method will help us im-plement a solution to the the flat-extended problem as a special case We will comeback to this issue towards the end

Let us now consider the current experimental ConTEXt setup for paragraph opti-mization for Arabic-script

Applying Features to Arabic-scriptWersquore now ready for the real thing Arabic scriptThe initial setup is not that differentfrom the Latin-script case

definefontfeature

[husayni-whatever]

[goodies=husayni

featureset=default]

definefontsolution

[FancyHusayni]

[goodies=husayni

solution=experimental]

definefont

[FancyHusayni]

[filehusaynihusayni-whatever at 24pt]

But here the definitions in the goodies file look way more complex Here we haveonly one shrink set but multiple expansion sets

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

144 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

local yes = yes

local basics =

analyze = yes

mode = node

language = dflt

script = arab

local analysis =

ccmp = yes

init = yes medi = yes fina = yes

local regular =

rlig = yes calt = yes salt = yes anum = yes

ss01 = yes ss03 = yes ss07 = yes ss10 = yes ss12 = yes

ss15 = yes ss16 = yes ss19 = yes ss24 = yes ss25 = yes

ss26 = yes ss27 = yes ss31 = yes ss34 = yes ss35 = yes

ss36 = yes ss37 = yes ss38 = yes ss41 = yes ss42 = yes

ss43 = yes js16 = yes

local positioning =

kern = yes curs = yes mark = yes mkmk = yes

local minimal_stretching =

js11 = yes js03 = yes

local medium_stretching =

js12=yes js05=yes

local maximal_stretching=

js13 = yes js05 = yes js09 = yes

local wide_all =

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

local shrink =

flts = yes js17 = yes ss05 = yes ss11 = yes ss06 = yes

ss09 = yes

local default =

basics analysis regular positioning

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 145

return

name = husayni

version = 100

comment = Goodies that complement the Husayni font by profHamid

author = Idris Samawi Hamid and Hans Hagen

featuresets =

default =

default

minimal_stretching =

default

js11 = yes js03 = yes

medium_stretching =

default

js12=yes js05=yes

maximal_stretching=

default

js13 = yes js05 = yes js09 = yes

wide_all =

default

js11 = yes js12 = yes js13 = yes js05 = yes js09 = yes

shrink =

default flts = yes

js17 = yes

ss05 = yes ss11 = yes ss06 = yes ss09 = yes

solutions =

experimental =

less =

shrink

more =

minimal_stretching medium_stretching maximal_stretching

wide_all

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

146 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

There are some 55 stylistic and 21 justification features Not all make sense whenoptimizing We predefine some Lua tables to make the sets and solutions easier tounderstand The default rendering looks as follows

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲أ﮳با984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Note that we already have a degree of widened substitution in this exampleThis isall for the accommodation of vowels and is defined entirely in the OpenType tablesof the font We also added some special orthography (the rasm font feature to get theQurʾānic features just right) You can also do this by adding the feature to the lfg file(local regular = ) There is no paragraph optimization as yet although the defaultLuaTEX engine does a good job to start with

Next we show a more optimized result

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 147

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

Now letrsquos see what happenswhen parfillskip= 0pt ie the last line has no extraspace after the end of the paragraph This is important for getting eg the last lineof the page to end with the end of a verse as we discussed earlier

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

148 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

setupfontsolution

[FancyHusayni]

[method=prerollnormal

criterium=1]

startfontsolution[FancyHusayni]

FancyHusayni

righttoleft

definefontfeature[rasm][script=arabss05=yesjs06=noss55=yes]

addffrasm

parfillskip=0pt

getbuffer[sample]

par

stopfontsolution

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د﮲

ل﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ﮵﮶984880إ

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ا ﮲نو﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151983275983878﮲983311983878و

﮲ا﮳أ984878983335983878983882983888983885أ984879و984996984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴﮳983046ى983875او﮲﮳با

﮳983046983606﮲﮲983499

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ﮲﮴ة

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887Just as the effects are more visible in the parfillskip= 0pt case the impact is

much larger when the available width is less In figures 11 12 13 14 and 15 we cansee the optimizer in action when that happens

In our estimation the current experimental solution works best for alternate-shaped glyphs although there is some success with naturally widened charactersClearly some widened substitutions work better than others A lot of fine tuning isneeded both within the OpenType features as well as the optimization algorithm

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 149

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875985196﮲ا﮳﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا985062﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 11 A narrower sample (a)

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

150 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲ن984878ا983157983159983142984881﮲﮲983123ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983046

983250983878984081﮲ن﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮲﮴ة

984878﮲ن984878﮳985033﮲ذ983882983888983886ر984878983046﮲983114ا983619﮳984878أ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ال984878﮲﮲983157983159983142984881ا

983396﮲﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

983157983159983142984881او

984880983250983878إ﮴﮲﮲ن984880إ 984878983046ه﮴﮳﮲نو983882983888983883إ984880﮲984878983810

984878م﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878 ا983157983159983142984881

﮲﮲ا﮲984434984878

﮲984482983878﮳983046و﮲غ984878983151983810د

﮲إ984880﮶﮵إ984880﮲984878ا983157983159983142984881﮲﮲985112ر

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ984878983335983878983882983888983884ر

983279983877﮶﮵و﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ ﮲نو

﮳984998﮶﮲983046﮴﮵983156أ984879و984996984995984880983810

983250983878984081﮲ن﮲983396﮳985062﮲984422إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲ا﮳أ984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983810ىw983875او﮲﮳با﮳983810983606﮲﮲983499

﮴ة

﮲أ984878﮳983872ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا﮲983396

983882983888983887﮵﮳﮴ق983046﮴﮶983396﮲﮳984996﮴ا

normal no parfillskip

Figure 12 A narrower sample with no parfillskip (b)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 151

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮵﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲983283983878 ا983157983159983142984881﮲﮲ا﮲983074984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983396﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا﮲

﮳984996﮴983046﮲زر﮴﮲984996او﮶983074

او

983157983159983142984881إ984880﮲ن﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ﮴﮴او985114984878م

﮲او ﮲﮲983275983878وأ984879984878﮳984998

﮲984482983878ا983157983159983142984881﮲﮲ا﮲984434984878

﮲984482983878

﮳983046و﮲غ984878983151983810د﮲إ984880﮶﮵

984878﮲ن984880إ984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

983157983159983142984881ال﮲﮲984878أ﮲ن983123﮴﮵﮲983275983878﮲984878ا

﮲ا﮴984996﮳و﮵﮶983279983877 ﮲نو﮳984998

﮶﮲983046﮴﮵983156أ984879و984996984995984880983046983250983878984081﮲ن

﮲983867﮳985112﮲إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴و983151

983275983878﮲983311983878و﮲أ﮳با984878983335983878983882983888983885

984996و984879أ984995984880ا984878﮲983275983878﮲ا﮶983279983877 ااو983114﮲984878984996﮴

﮳983046ى983875او﮲﮳با﮳983046983606﮲﮲983499

﮴ة

﮲أ984878﮳983619ا984215﮲984878983810ر983882983888983886

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 13 An even narrower sample (c)

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

152 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا984081ا

﮲﮵﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983810984878م

﮵ا983606﮵

﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983046﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴إو984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲983123ا

﮲983396ا﮴984996﮳﮲983396﮶﮴983046﮴ق

﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲985062ا984081ا

﮲﮵

﮳984996﮴983046﮲زر﮴﮲984996

983074﮶او

984880983250983878إ﮴﮲﮲ن984880إ983157983159983142984881او 984878983046ه

﮴﮳﮲نو983882983888983883إ984880﮲984878983814984878م

﮵ا983606﮵﮴﮴او985114984878وم

﮲ا ﮲﮲983275983878وأ984879984878﮳984998﮲983283983878

983074﮲ا﮲﮲983157983159983142984881ا984878

﮲984482983878﮳983046﮲غ

﮵﮶984880إ﮲د984878983151983810و

984878983335983878983882983888983884رر985062﮲﮲983157983159983142984881ا984878﮲ن984880إ

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983156﮵﮴983046﮲﮶984998﮳﮲نو﮴﮶﮵و

984996و984879أ984995984880983810983250983878984081﮲ن﮲983867

﮳985112﮲إ984880984878983151ا983114﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983875ى983046﮳﮴984878984996﮲984215ااو﮴﮶ا983499﮲﮲983046983606﮳﮳با﮲او

﮲﮴ة

983882983888983886ر984878983810﮲983114ا983619﮳984878أ

﮳984996﮴ال984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

﮳983046﮴985195 984880﮲ن984878ا984878﮲983275983878﮲ا﮲﮴﮲984669985196

﮲983396ا﮴984996﮳﮲983396﮶﮴983810﮴ق

﮳﮵983882983888983887

normal narrow

Figure 14 An even narrower sample (d)

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

Oriental TEX optimizing paragraphs EUROTEX 2012 amp 6CM PROCEEDINGS 153

﮵984996984995984878983320983878 984879983810ا984878﮲983275983878﮲اء﮲983123ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983810984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983283983878﮲984998﮳984879984878أ ا983157983159983142984881

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر983123﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳983123﮲983987 إ984880984878983151ا983114﮲984878983046ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵984996﮴

﮳با﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا ااو983114﮲984878984996﮴﮳983046ى983875983499﮲﮲983046983606﮳﮳با﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

984878﮲ن984880إو﮴983046﮳﮳984996﮴ا

﮳984996﮴ا983396﮲ا983123﮲﮴﮲ا﮲983275983878﮲984878ا

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

﮵984996984995984878983320983878 984879983814ا984878﮲983275983878﮲اء﮲985112ا

984081ا﮲﮵﮳984996﮴983046

983074﮶او984996﮲﮴﮲زر

﮲ن984880إ983157983159983142984881او

﮲﮴إ984880983250983878 984878983046ه﮴﮳﮲نو983882983888983883

﮵983606ا﮵م984878983814984878﮲984880إ

﮴﮴

﮲اوم985114984878او ﮲﮲983275983878و

983157983159983142984881ا984482983878﮲984998﮳984879984878أ

﮲﮲ا﮲983074984878

﮲984482983878﮳983046و﮲غ984878983151

983810د﮲إ984880﮶﮵إ984880﮲ن984878

984878983335983878983882983888983884رر984674﮲﮲983157983159983142984881ا

﮲ن983123﮴﮵﮲983275983878﮲984878ا984878﮲ن984880إ

﮳984996﮴ا﮲983157983159983142984881ال﮲﮲984878أ

983279983877﮶﮵و ﮲نو﮳984998﮶﮲983046﮴﮵983156

984996و984879أ984995984880983046983250983878984081﮲ن﮲983396

﮳985062﮲984422إ984880984878983151ا984215﮲984878983810ور983151

﮵983600 985034 ا983157983159983142984881﮵ام﮴﮵ــ﮴

﮳ا﮲و983311983878﮲983151983275983878و

984996و984879أ984878983335983878983882983888983885أ984995984880ا984878﮲983275983878﮲

983279983877﮶ا 985196 983875ى983046﮳﮴984878984996﮲983114ا983499﮲﮲983046983606﮳﮳ا﮲او

﮴ة

﮲أ984878﮳983619ا983114﮲984878983046ر983882983888983886

ل984878﮲﮲983157983159983142984881ا984878﮲ن984878﮳985033﮲ذ

985195﮴983046﮳﮳984996﮴ا 984880﮲ن984878

984669985196﮲﮴﮲ا﮲983275983878﮲984878ا ﮲983396ا﮴984996﮳

﮲983396﮶﮴983046﮴ق﮳﮵983882983888983887

normal narrow

Figure 15 An even narrower sample (e)

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid

154 EUROTEX 2012 amp 6CM PROCEEDINGS Hans Hagen amp Idris Samawi Hamid

Without going into a detailed analysis at the moment we restrict ourselves to twocritical observations

First in our tests one will notice that the glyph substitutions tend to take place onthe right side of the line They should be more evenly distributed throughout eachline

Second we can say that the current method works better for alternate-shapedglyph substitution than it does for naturally-widened glyph substitution This leadsus to the next step in this research project

Within the Husayni font there is now a mapping between flat extending via taṭwīland curved widening via alternate glyphs Consider the following manually typedutf text using the taṭwīl character (U+0640)

ليعف ARROW لـــيعف

In flat-extended typography that comes out like this

﮲983096﮵983116larr﮲983096﮵ـzwjــzwj983116

Husayni through the optional Stylistic Alternates feature (salt) will map the flattaṭwīl-extended characters to curved widened characters So with salt=yes selectedin ConTEXt we get

﮲983096﮵983116larr﮲983096﮵984442

This opens up a way to connect a forthcoming solution to the flat taṭwīl-extendedcharacter method with the curved widened-glyph method A future version of theoptimizer may be able to optimize the paragraph in terms of the taṭwīl character anda set of rules along the lines we discussed earlier Then we can simply convert theresult to curves using the taṭwīl character At least this is one possibility

In any case the current paragraph optimizer even in its experimental status at themoment represents one of the greatest and most important steps in the evolution ofdigital Arabic-script typography Its potential impact on for Arabic-script typesettingis immense and we excitedly look forward to its completion

Notes1 Sometimes hz-optimization also goes under the rubric of lsquoSemitic justificationrsquo See eg Bringhurst

in pre-3rd editions of his Elements of Typographic Style This technique does not work well for Arabicscript in general because glyphs are connected in two dimensions On the other hand a certain basicyet ubiquitous Semitic justification can be achieved by using the taṭwīl character commonly calledthe kashīdah (U+0640) We will discuss this later in this article

2 Much of this is handled within the GPOS features of the OpenType font itself (eg mark and mkmk)

3 This number reflects the maximum badness and future versions might have a different measure withmore granularity

4 Indeed even Latin hyphenation when it occurs can be considered a lsquofailurersquo of sorts

5 This five character string can be represented in Latin by the five character string lsquoal-ḥmdrsquo (not includ-ing the lsquo-rsquo) It is pronounced lsquoal-ḥamdursquo Note that Arabic script is mainly consonantal pure vowelsare not part of the alphabet and are instead represented by diacritics

6 Indeed as was the case with Latin typography Arabic-script typography took a sharp turn for theworse with the advent of digital typography On the other hand Latin typography recovered muchmore quickly in large part thanks to Knuthrsquos development of TEX

Hans Hagen amp Idris Samawi Hamid