diff options
Diffstat (limited to 'lib/kotext/KoComplexText.cpp')
-rw-r--r-- | lib/kotext/KoComplexText.cpp | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/lib/kotext/KoComplexText.cpp b/lib/kotext/KoComplexText.cpp index 54599d07..475f439d 100644 --- a/lib/kotext/KoComplexText.cpp +++ b/lib/kotext/KoComplexText.cpp @@ -65,14 +65,14 @@ KoBidiContext::~KoBidiContext() delete parent; } -static TQChar *tqshapeBuffer = 0; -static int tqshapeBufSize = 0; +static TQChar *shapeBuffer = 0; +static int shapeBufSize = 0; /* Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on arabic). - Each tqunicode char has a joining class (right, dual (left&right), center (joincausing) or transparent). + Each unicode char has a joining class (right, dual (left&right), center (joincausing) or transparent). transparent joining is not encoded in TQChar::joining(), but applies to all combining marks and format marks. Right join-causing: dual + center @@ -103,7 +103,7 @@ static int tqshapeBufSize = 0; */ /* - Two small helper functions for arabic shaping. They get the next tqshape causing character on either + Two small helper functions for arabic shaping. They get the next shape causing character on either side of the char in question. Implements rule R1. leftChar() returns true if the char to the left is a left join-causing char @@ -113,7 +113,7 @@ static inline const TQChar *prevChar( const TQString &str, int pos ) { //kdDebug() << "leftChar: pos=" << pos << endl; pos--; - const TQChar *ch = str.tqunicode() + pos; + const TQChar *ch = str.unicode() + pos; while( pos > -1 ) { if( !ch->isMark() ) return ch; @@ -127,7 +127,7 @@ static inline const TQChar *nextChar( const TQString &str, int pos) { pos++; int len = str.length(); - const TQChar *ch = str.tqunicode() + pos; + const TQChar *ch = str.unicode() + pos; while( pos < len ) { //kdDebug() << "rightChar: " << pos << " isLetter=" << ch.isLetter() << ", joining=" << ch.joining() << endl; if( !ch->isMark() ) @@ -155,11 +155,11 @@ KoComplexText::Shape KoComplexText::glyphVariant( const TQString &str, int pos) { // ignores L1 - L3, done in the codec TQChar::Joining joining = str[pos].joining(); - //kdDebug() << "checking " << str[pos].tqunicode() << ", joining=" << joining << endl; + //kdDebug() << "checking " << str[pos].unicode() << ", joining=" << joining << endl; switch ( joining ) { case TQChar::OtherJoining: case TQChar::Center: - // these don't change tqshape + // these don't change shape return XIsolated; case TQChar::Right: // only rule R2 applies @@ -200,11 +200,11 @@ KoComplexText::Shape KoComplexText::glyphVariantLogical( const TQString &str, in { // ignores L1 - L3, ligatures are job of the codec TQChar::Joining joining = str[pos].joining(); - //kdDebug() << "checking " << str[pos].tqunicode() << ", joining=" << joining << endl; + //kdDebug() << "checking " << str[pos].unicode() << ", joining=" << joining << endl; switch ( joining ) { case TQChar::OtherJoining: case TQChar::Center: - // these don't change tqshape + // these don't change shape return XIsolated; case TQChar::Right: // only rule R2 applies @@ -229,11 +229,11 @@ KoComplexText::Shape KoComplexText::glyphVariantLogical( const TQString &str, in // ------------------------------------------------------------- -// The tqunicode to tqunicode shaping codec. +// The unicode to unicode shaping codec. // does only presentation forms B at the moment, but that should be enough for // simple display static const ushort arabicUnicodeMapping[256][2] = { - // base of tqshaped forms, and number-1 of them ( 0 for non shaping, + // base of shaped forms, and number-1 of them ( 0 for non shaping, // 1 for right binding and 3 for dual binding { 0x0600, 0 }, // 0x600 { 0x0601, 0 }, // 0x601 @@ -355,7 +355,7 @@ static const ushort arabicUnicodeMapping[256][2] = { { 0x066e, 0 }, // 0x66e { 0x066f, 0 }, // 0x66f - // ### some glyphs do not have tqshaped mappings in the presentation forms A. + // ### some glyphs do not have shaped mappings in the presentation forms A. // these have the shaping set to 0 for the moment. Will have to find out better mappings for them. { 0x0670, 0 }, // 0x670 { 0xfb50, 1 }, // 0x671 R Alef Wasla @@ -512,7 +512,7 @@ static const ushort arabicUnicodeMapping[256][2] = { }; -// this is a bit tricky. Alef always binds to the right, so the second parameter descibing the tqshape +// this is a bit tricky. Alef always binds to the right, so the second parameter descibing the shape // of the lam can be either initial of medial. So initial maps to the isolated form of the ligature, // medial to the final form static const ushort arabicUnicodeLamAlefMapping[6][4] = { @@ -524,14 +524,14 @@ static const ushort arabicUnicodeLamAlefMapping[6][4] = { { 0xfffd, 0xfffd, 0xfefb, 0xfefc } // 0x627 R Alef }; -static inline int getShape( const TQChar * /* base */, uchar cell, int tqshape, +static inline int getShape( const TQChar * /* base */, uchar cell, int shape, const TQFontMetrics * /* fm */ ) { - uint ch = arabicUnicodeMapping[cell][0] + tqshape; + uint ch = arabicUnicodeMapping[cell][0] + shape; /* - // we revert to the untqshaped glyph in case the tqshaped version doesn't exist + // we revert to the unshaped glyph in case the shaped version doesn't exist if ( fm && !fm->inFont( ch ) ) { - switch( tqshape ) { + switch( shape ) { case KoComplexText::XIsolated: break; // try base form case KoComplexText::XFinal: @@ -551,7 +551,7 @@ static inline int getShape( const TQChar * /* base */, uchar cell, int tqshape, return ch; } -TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQPainter::TextDirection dir, const TQFontMetrics *fm ) +TQString KoComplexText::shapedString(const TQString& uc, int from, int len, TQPainter::TextDirection dir, const TQFontMetrics *fm ) { if( len < 0 ) len = uc.length() - from; @@ -561,13 +561,13 @@ TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQ // we have to ignore NSMs at the beginning and add at the end. int num = uc.length() - from - len; - const TQChar *ch = uc.tqunicode() + from + len; + const TQChar *ch = uc.unicode() + from + len; while ( num > 0 && ch->combiningClass() != 0 ) { ch++; num--; len++; } - ch = uc.tqunicode() + from; + ch = uc.unicode() + from; while ( len > 0 && ch->combiningClass() != 0 ) { ch++; len--; @@ -575,16 +575,16 @@ TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQ } if ( len == 0 ) return TQString(); - if( !tqshapeBuffer || len > tqshapeBufSize ) { - if( tqshapeBuffer ) free( (void *) tqshapeBuffer ); - tqshapeBuffer = (TQChar *) malloc( len*sizeof( TQChar ) ); -// delete [] tqshapeBuffer; -// tqshapeBuffer = new TQChar[ len + 1]; - tqshapeBufSize = len; + if( !shapeBuffer || len > shapeBufSize ) { + if( shapeBuffer ) free( (void *) shapeBuffer ); + shapeBuffer = (TQChar *) malloc( len*sizeof( TQChar ) ); +// delete [] shapeBuffer; +// shapeBuffer = new TQChar[ len + 1]; + shapeBufSize = len; } int lenOut = 0; - TQChar *data = tqshapeBuffer; + TQChar *data = shapeBuffer; if ( dir == TQPainter::RTL ) ch += len - 1; for ( int i = 0; i < len; i++ ) { @@ -601,8 +601,8 @@ TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQ int pos = i + from; if ( dir == TQPainter::RTL ) pos = from + len - 1 - i; - int tqshape = glyphVariantLogical( uc, pos ); - //kdDebug() << "mapping U+" << ch->tqunicode() << " to tqshape " << tqshape << " glyph=0x" << arabicUnicodeMapping[ch->cell()][tqshape] << endl; + int shape = glyphVariantLogical( uc, pos ); + //kdDebug() << "mapping U+" << ch->unicode() << " to shape " << shape << " glyph=0x" << arabicUnicodeMapping[ch->cell()][shape] << endl; // take care of lam-alef ligatures (lam right of alef) ushort map; switch ( c ) { @@ -615,7 +615,7 @@ TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQ case 0x25: case 0x27: //kdDebug() << " lam of lam-alef ligature" << endl; - map = arabicUnicodeLamAlefMapping[pch->cell() - 0x22][tqshape]; + map = arabicUnicodeLamAlefMapping[pch->cell() - 0x22][shape]; goto next; default: break; @@ -627,7 +627,7 @@ TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQ case 0x23: // alef with hamza above case 0x25: // alef with hamza below case 0x27: // alef - if ( prevChar( uc, pos )->tqunicode() == 0x0644 ) { + if ( prevChar( uc, pos )->unicode() == 0x0644 ) { // have a lam alef ligature //kdDebug() << " alef of lam-alef ligature" << endl; goto skip; @@ -635,7 +635,7 @@ TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQ default: break; } - map = getShape( ch, c, tqshape, fm ); + map = getShape( ch, c, shape, fm ); next: *data = map; data++; @@ -649,11 +649,11 @@ TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQ } if ( dir == TQPainter::Auto && !uc.simpleText() ) { - return bidiReorderString( TQConstString( tqshapeBuffer, lenOut ).string() ); + return bidiReorderString( TQConstString( shapeBuffer, lenOut ).string() ); } if ( dir == TQPainter::RTL ) { // reverses the non spacing marks to be again after the base char - TQChar *s = tqshapeBuffer; + TQChar *s = shapeBuffer; int i = 0; while ( i < lenOut ) { if ( s->combiningClass() != 0 ) { @@ -684,17 +684,17 @@ TQString KoComplexText::tqshapedString(const TQString& uc, int from, int len, TQ } } - return TQConstString( tqshapeBuffer, lenOut ).string(); + return TQConstString( shapeBuffer, lenOut ).string(); } -TQChar KoComplexText::tqshapedCharacter( const TQString &str, int pos, const TQFontMetrics *fm ) +TQChar KoComplexText::shapedCharacter( const TQString &str, int pos, const TQFontMetrics *fm ) { - const TQChar *ch = str.tqunicode() + pos; + const TQChar *ch = str.unicode() + pos; if ( ch->row() != 0x06 ) return *ch; else { - int tqshape = glyphVariantLogical( str, pos ); - //kdDebug() << "mapping U+" << ch->tqunicode() << " to tqshape " << tqshape << " glyph=0x" << arabicUnicodeMapping[ch->cell()][tqshape] << endl; + int shape = glyphVariantLogical( str, pos ); + //kdDebug() << "mapping U+" << ch->unicode() << " to shape " << shape << " glyph=0x" << arabicUnicodeMapping[ch->cell()][shape] << endl; // lam aleph ligatures switch ( ch->cell() ) { case 0x44: { // lam @@ -705,7 +705,7 @@ TQChar KoComplexText::tqshapedCharacter( const TQString &str, int pos, const TQF case 0x23: case 0x25: case 0x27: - return TQChar(arabicUnicodeLamAlefMapping[nch->cell() - 0x22][tqshape]); + return TQChar(arabicUnicodeLamAlefMapping[nch->cell() - 0x22][shape]); default: break; } @@ -716,13 +716,13 @@ TQChar KoComplexText::tqshapedCharacter( const TQString &str, int pos, const TQF case 0x23: // alef with hamza above case 0x25: // alef with hamza below case 0x27: // alef - if ( prevChar( str, pos )->tqunicode() == 0x0644 ) + if ( prevChar( str, pos )->unicode() == 0x0644 ) // have a lam alef ligature return TQChar(0); default: break; } - return TQChar( getShape( ch, ch->cell(), tqshape, fm ) ); + return TQChar( getShape( ch, ch->cell(), shape, fm ) ); } } @@ -739,7 +739,7 @@ TQPointArray KoComplexText::positionMarks( TQFontPrivate *f, const TQString &str if ( !nmarks ) return TQPointArray(); - TQChar baseChar = KoComplexText::tqshapedCharacter( str, pos ); + TQChar baseChar = KoComplexText::shapedCharacter( str, pos ); TQRect baseRect = f->boundingRect( baseChar ); int baseOffset = f->textWidth( str, pos, 1 ); @@ -842,7 +842,7 @@ TQPointArray KoComplexText::positionMarks( TQFontPrivate *f, const TQString &str default: break; } - //kdDebug() << "char=" << mark.tqunicode() << " combiningClass = " << cmb << " offset=" << p.x() << "/" << p.y() << endl; + //kdDebug() << "char=" << mark.unicode() << " combiningClass = " << cmb << " offset=" << p.x() << "/" << p.y() << endl; markRect.moveBy( p.x(), p.y() ); p += TQPoint( -baseOffset, 0 ); attachmentRect |= markRect; @@ -864,7 +864,7 @@ static TQChar::Direction basicDirection(const TQString &str, int start = 0) { int len = str.length(); int pos = start > len ? len -1 : start; - const TQChar *uc = str.tqunicode() + pos; + const TQChar *uc = str.unicode() + pos; while( pos < len ) { switch( uc->direction() ) { @@ -913,7 +913,7 @@ TQPtrList<KoTextRun> *KoComplexText::bidiReorderLine( KoBidiControl *control, co } } - KoBiditqStatus status = control->status; + KoBidiStatus status = control->status; TQChar::Direction dir = TQChar::DirON; int sor = start; @@ -1406,8 +1406,8 @@ TQString KoComplexText::bidiReorderString( const TQString &str, TQChar::Directio int len = str.length(); TQString visual; visual.setUnicode( 0, len ); - TQChar *vch = (TQChar *)visual.tqunicode(); - const TQChar *ch = str.tqunicode(); + TQChar *vch = (TQChar *)visual.unicode(); + const TQChar *ch = str.unicode(); while( lineStart < len ) { lineEnd = lineStart; while( *ch != '\n' && lineEnd < len ) { |