LASi Complex Text Layout Example
================================

This directory contains an example C++ program, "ComplexTextLayout.cpp", that demonstrates
a few additional features of libLASi and also demonstrates the layout of
complex text layout (CTL) scripts such as Arabic and Indic scripts via Pango.
See http://eyegene.ophthy.med.umich.edu/unicode/fontguide/ to obtain the Open Source
fonts specified in the program if you need them.

The key thing to notice in this example is that libLASi divides a Postscript document into
three parts: a header, a body, and a footer.  These three parts correspond directly to the
document structure that you will usually find in a well-structured Postscript document.

As shown in the example, the header can contain Postscript procedures that have been
defined by the user.  In this example, only a few convenience functions -- inch, cm,
and mm-- have been defined to simplify layout using common units of measure. 
In the final Postscript generated by libLASi, the header will also contain
all of the glyph outline procedures needed to draw the text of the document.
Be sure to examine the Postscript output created by the program to see what these
glyph procedures look like.

The body contains the text that we want to print.  Here the "gsave" and "grestore"
operators are used so that we can change the graphics state -- color, rotation,
translation, and so on -- and get back to the original state after we are done.

Also notice the use of libLASi's setFont(), setFontSize(), and show() methods.
These methods should remind you of the Postscript "setfont", "show" and related commands.
But of course here we use libLASi's methods so we can manage Unicode text printed
using TrueType and OpenType fonts.  Notice that all of the strings are
simply UTF-8 strings. 

Another thing to notice is that we also use LASi's get_dimensions() method to
obtain a "lineSpacing".  We then define a Postscript "newLine" routine that uses the
"lineSpacing" value we got from LASi.

Finally the footer can contain any additional Postscript Document Structuring Conventions,
such as the "%%Pages:" directive shown in the example.

The Makefile uses "pkg-config" to determine the proper location of the Pango 
libraries.  Pkg-config is available on all recent Linux distributions.
If you have problems, make sure the environment variable PKG_CONFIG_PATH
includes the path to the "pango.pc" file.  Usually this will be in 
/usr/lib/pkgconfig, /usr/local/lib/pkgconfig, or $PREFIX/lib/pkgconfig where $PREFIX
is an installation prefix that you set up when configuring Pango.

This example prints strings in English, Hebrew, Arabic, Thai, Japanese, Bengali, and Cyrillic:
Be sure to obtain the fonts listed in the source code, or substitute others present on
your machine.  See http://www.unifont.org/fontguide/ if you need fonts.
"Example_2_Result.png" will show you what the resulting Postscript should look like.

To compile the example executable, type:

   make example

If that is successful, then type:

   make display 

... to run the executable to produce a PostScript file and then view the
Postscript output using the "gv" viewer.  "gv" is present on most
Linux distributions.

We hope you enjoy using LASi!

-2004.12.03.ET



