Folks,

I'd like to mention a change I will implement on IFPainter#drawText method
in order to accommodate complex scripts (as well as non-complex script usage
in a variety of written languages). I'm bringing this up now so there can be
discussion ahead of time if needed.

Basically, the change is to generalize the int[] dx parameter to be a two
dimensional array of glyph placement/advancement adjustments.

The current interface is:

void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx,
String text) throws IFException;

The modified method interface would read as follows:

void drawText(int x, int y, int letterSpacing, int wordSpacing, int[][]
adjustments, String text) throws IFException;

The adjustments array is optional (in which case it is null). If non-null,
it is effectively typed as int[][4], i.e., an array of int[4] arrays, where
the four elements of each row are:

a[0] = x placement adjustment
a[1] = y placement adjustment
a[2] = x advance adjustment
a[3] = y advance adjustment

The [x,y] placement adjustments are added to the current point to determine
the effective glyph (char) origin, and the [x,y] advance adjustments are
applied to the current point after rendering the glyph (char) and performing
the default (implicit) advance.

To be more explicit, the algorithm using these adjustments is effectively as
follows (ignoring word and letter spacing for the moment):

int curPointX = x;
int curPointY = y;
for ( int i = 0, n = glyphs.length; i < n; i++ ) {
  int g = glyphs [ i ];
  int gx = curPointX;
  int gy = curPointY;
  int[] a = ( adjustments != null ) ? adjustments[i] : null;
  if ( a != null ) {
    gx += a[0];
    gy += a[1];
  }
  drawGlyph ( g, gx, gy );
  curPointX += font.getGlyphAdvanceX ( g );
  curPointY += font.getGlyphAdvanceY ( g );
  if ( a != null ) {
    curPointX += a[2];
    curPointY += a[3];
  }
}

It is mandatory to provide this generality in order to support not only
complex scripts, but also non-complex scripts (e.g, Latin, Greek, Cyrillic,
CJK, etc) when used with non-spacing marks (in many written languages) and
also for other advanced typographic effects.

Attached is a simple example of the use of this feature in order to adjust
the placement (and advance) of U+064E ARABIC FATHA and U+0650 ARABIC KASRA,
respectively, the upper and lower non-spacing marks shown in this example.

Regards,
Glenn

Attachment: test.pdf
Description: Adobe PDF document

Reply via email to