- Paragraph::size_type const last = rowLastPrintable(row);
-
- if (font.language()->lang() == "hebrew") {
- if (Encodings::IsComposeChar_hebrew(c)) {
- int const width = lyxfont::width(c, font2);
- int dx = 0;
- for (Paragraph::size_type i = pos-1; i >= 0; --i) {
- c = row->par()->getChar(i);
- if (!Encodings::IsComposeChar_hebrew(c)) {
- if (IsPrintableNonspace(c)) {
- int const width2 =
- singleWidth(bview,
- row->par(),
- i, c);
- dx = (c == 'ø' || c == 'ã') // dalet / resh
- ? width2 - width : (width2 - width) / 2;
- }
- break;
- }
- }
- // Draw nikud
- pain.text(int(x) + dx, offset + row->baseline(),
- textstring, font);
- } else {
- while (vpos <= last &&
- (pos = vis2log(vpos)) >= 0
- && IsPrintableNonspace(c = row->par()->getChar(pos))
- && !Encodings::IsComposeChar_hebrew(c)
- && font2 == getFont(bview->buffer(), row->par(), pos)) {
- textstring += c;
- ++vpos;
- }
- // Draw text and set the new x position
- pain.text(int(x), offset + row->baseline(),
- textstring, font);
- x += lyxfont::width(textstring, font);
- }
- } else if (font.language()->lang() == "arabic" &&
- (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
- lyxrc.font_norm_type == LyXRC::ISO_10646_1)) {
- if (Encodings::IsComposeChar_arabic(c)) {
- c = transformChar(c, row->par(), pos);
- textstring = c;
- int const width = lyxfont::width(c, font2);
- int dx = 0;
- for (Paragraph::size_type i = pos-1; i >= 0; --i) {
- c = row->par()->getChar(i);
- if (!Encodings::IsComposeChar_arabic(c)) {
- if (IsPrintableNonspace(c)) {
- int const width2 =
- singleWidth(bview,
- row->par(),
- i, c);
- dx = (width2 - width) / 2;
- }
- break;
- }
- }
- // Draw nikud
- pain.text(int(x) + dx, offset + row->baseline(),
- textstring, font);
- } else {
- textstring = transformChar(c, row->par(), pos);
- while (vpos <= last &&
- (pos = vis2log(vpos)) >= 0
- && IsPrintableNonspace(c = row->par()->getChar(pos))
- && !Encodings::IsComposeChar_arabic(c)
- && font2 == getFont(bview->buffer(), row->par(), pos)) {
- c = transformChar(c, row->par(), pos);
- textstring += c;
- ++vpos;
- }
- // Draw text and set the new x position
- pain.text(int(x), offset + row->baseline(),
- textstring, font);
- x += lyxfont::width(textstring, font);
- }
- } else {
- while (vpos <= last &&
- (pos = vis2log(vpos)) >= 0
- && IsPrintableNonspace(c = row->par()->getChar(pos))
- && font2 == getFont(bview->buffer(), row->par(), pos)) {
- textstring += c;
- ++vpos;
- }
- // Draw text and set the new x position
- pain.text(int(x), offset + row->baseline(), textstring, font);
- x += lyxfont::width(textstring, font);
+ // usual characters, no insets
+
+ // special case languages
+ bool const hebrew = (orig_font.language()->lang() == "hebrew");
+ bool const arabic =
+ orig_font.language()->lang() == "arabic" &&
+ (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
+ lyxrc.font_norm_type == LyXRC::ISO_10646_1);
+
+ // draw as many chars as we can
+ if ((!hebrew && !arabic)
+ || (hebrew && !Encodings::IsComposeChar_hebrew(c))
+ || (arabic && !Encodings::IsComposeChar_arabic(c))) {
+ drawChars(p, vpos, true, false);
+ } else if (hebrew) {
+ drawHebrewComposeChar(p, vpos);
+ } else if (arabic) {
+ drawArabicComposeChar(p, vpos);