diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-19 19:03:33 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-19 19:03:33 +0000 |
commit | e69e8b1d09fb579316595b4e6a850e717358a8b1 (patch) | |
tree | a24fc20865f65772f530d16177520190594ffdd2 /kdvi/TeXFont_PK.cpp | |
parent | eecec9afb81fdebb0f22e9da22635874c403f854 (diff) | |
download | tdegraphics-e69e8b1d09fb579316595b4e6a850e717358a8b1.tar.gz tdegraphics-e69e8b1d09fb579316595b4e6a850e717358a8b1.zip |
TQt4 port kdegraphics
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1237557 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdvi/TeXFont_PK.cpp')
-rw-r--r-- | kdvi/TeXFont_PK.cpp | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/kdvi/TeXFont_PK.cpp b/kdvi/TeXFont_PK.cpp index 7e1ce60d..562c40f9 100644 --- a/kdvi/TeXFont_PK.cpp +++ b/kdvi/TeXFont_PK.cpp @@ -80,18 +80,18 @@ extern void oops(TQString message); -TeXFont_PK::TeXFont_PK(TeXFontDefinition *parent) - : TeXFont(parent) +TeXFont_PK::TeXFont_PK(TeXFontDefinition *tqparent) + : TeXFont(tqparent) { #ifdef DEBUG_PK - kdDebug(4300) << "TeXFont_PK::TeXFont_PK( parent=" << parent << ")" << endl; + kdDebug(4300) << "TeXFont_PK::TeXFont_PK( tqparent=" << tqparent << ")" << endl; #endif for(unsigned int i=0; i<TeXFontDefinition::max_num_of_chars_in_font; i++) characterBitmaps[i] = 0; - file = fopen(TQFile::encodeName(parent->filename), "r"); + file = fopen(TQFile::encodeName(tqparent->filename), "r"); if (file == 0) - kdError(4300) << i18n("Cannot open font file %1.").arg(parent->filename) << endl; + kdError(4300) << i18n("Cannot open font file %1.").tqarg(tqparent->filename) << endl; #ifdef DEBUG_PK else kdDebug(4300) << "TeXFont_PK::TeXFont_PK(): file opened successfully" << endl; @@ -116,7 +116,7 @@ TeXFont_PK::~TeXFont_PK() } -glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQColor& color) +glyph* TeXFont_PK::getGlyph(TQ_UINT16 ch, bool generateCharacterPixmap, const TQColor& color) { #ifdef DEBUG_PK kdDebug(4300) << "TeXFont_PK::getGlyph( ch=" << ch << ", generateCharacterPixmap=" << generateCharacterPixmap << " )" << endl; @@ -136,7 +136,7 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC // If the character is not defined in the PK file, mark the // character as missing, and print an error message if (g->addr == 0) { - kdError(4300) << i18n("TexFont_PK::operator[]: Character %1 not defined in font %2").arg(ch).arg(parent->filename) << endl; + kdError(4300) << i18n("TexFont_PK::operator[]: Character %1 not defined in font %2").tqarg(ch).tqarg(tqparent->filename) << endl; g->addr = -1; return g; } @@ -163,7 +163,7 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC ((g->shrunkenCharacter.isNull()) || (color != g->color)) && (characterBitmaps[ch]->w != 0)) { g->color = color; - double shrinkFactor = 1200 / parent->displayResolution_in_dpi; + double shrinkFactor = 1200 / tqparent->displayResolution_in_dpi; // All is fine? Then we rescale the bitmap in order to produce the // required pixmap. Rescaling a character, however, is an art @@ -209,10 +209,10 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC // Turn the image into 8 bit TQByteArray translated(characterBitmaps[ch]->w * characterBitmaps[ch]->h); - Q_UINT8 *data = (Q_UINT8 *)translated.data(); + TQ_UINT8 *data = (TQ_UINT8 *)translated.data(); for(int x=0; x<characterBitmaps[ch]->w; x++) for(int y=0; y<characterBitmaps[ch]->h; y++) { - Q_UINT8 bit = *(characterBitmaps[ch]->bits + characterBitmaps[ch]->bytes_wide*y + (x >> 3)); + TQ_UINT8 bit = *(characterBitmaps[ch]->bits + characterBitmaps[ch]->bytes_wide*y + (x >> 3)); bit = bit >> (x & 7); bit = bit & 1; data[characterBitmaps[ch]->w*y + x] = bit; @@ -220,7 +220,7 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC // Now shrink the image. We shrink the X-direction first TQByteArray xshrunk(shrunk_width*characterBitmaps[ch]->h); - Q_UINT8 *xdata = (Q_UINT8 *)xshrunk.data(); + TQ_UINT8 *xdata = (TQ_UINT8 *)xshrunk.data(); // Do the shrinking. The pixel (x,y) that we want to calculate // corresponds to the line segment from @@ -231,7 +231,7 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC for(int y=0; y<characterBitmaps[ch]->h; y++) for(int x=0; x<shrunk_width; x++) { - Q_UINT32 value = 0; + TQ_UINT32 value = 0; double destStartX = shrinkFactor*x+srcXTrans; double destEndX = shrinkFactor*(x+1)+srcXTrans; for(int srcX=(int)ceil(destStartX); srcX<floor(destEndX); srcX++) @@ -239,19 +239,19 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC value += data[characterBitmaps[ch]->w*y + srcX] * 255; if (destStartX >= 0.0) - value += (Q_UINT32) (255.0*(ceil(destStartX)-destStartX) * data[characterBitmaps[ch]->w*y + (int)floor(destStartX)]); + value += (TQ_UINT32) (255.0*(ceil(destStartX)-destStartX) * data[characterBitmaps[ch]->w*y + (int)floor(destStartX)]); if (floor(destEndX) < characterBitmaps[ch]->w) - value += (Q_UINT32) (255.0*(destEndX-floor(destEndX)) * data[characterBitmaps[ch]->w*y + (int)floor(destEndX)]); + value += (TQ_UINT32) (255.0*(destEndX-floor(destEndX)) * data[characterBitmaps[ch]->w*y + (int)floor(destEndX)]); xdata[shrunk_width*y + x] = (int)(value/shrinkFactor + 0.5); } // Now shrink the Y-direction TQByteArray xyshrunk(shrunk_width*shrunk_height); - Q_UINT8 *xydata = (Q_UINT8 *)xyshrunk.data(); + TQ_UINT8 *xydata = (TQ_UINT8 *)xyshrunk.data(); for(int x=0; x<shrunk_width; x++) for(int y=0; y<shrunk_height; y++) { - Q_UINT32 value = 0; + TQ_UINT32 value = 0; double destStartY = shrinkFactor*y+srcYTrans; double destEndY = shrinkFactor*(y+1)+srcYTrans; for(int srcY=(int)ceil(destStartY); srcY<floor(destEndY); srcY++) @@ -259,31 +259,31 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC value += xdata[shrunk_width*srcY + x]; if (destStartY >= 0.0) - value += (Q_UINT32) ((ceil(destStartY)-destStartY) * xdata[shrunk_width*(int)floor(destStartY) + x]); + value += (TQ_UINT32) ((ceil(destStartY)-destStartY) * xdata[shrunk_width*(int)floor(destStartY) + x]); if (floor(destEndY) < characterBitmaps[ch]->h) - value += (Q_UINT32) ((destEndY-floor(destEndY)) * xdata[shrunk_width*(int)floor(destEndY) + x]); + value += (TQ_UINT32) ((destEndY-floor(destEndY)) * xdata[shrunk_width*(int)floor(destEndY) + x]); xydata[shrunk_width*y + x] = (int)(value/shrinkFactor); } TQImage im32(shrunk_width, shrunk_height, 32); im32.setAlphaBuffer(true); - // Do QPixmaps fully support the alpha channel? If yes, we use + // Do TQPixmaps fully support the alpha channel? If yes, we use // that. Otherwise, use other routines as a fallback - if (parent->font_pool->QPixmapSupportsAlpha) { + if (tqparent->font_pool->TQPixmapSupportsAlpha) { // If the alpha channel is properly supported, we set the // character glyph to a colored rectangle, and define the // character outline only using the alpha channel. That ensures // good quality rendering for overlapping characters. - im32.fill(qRgb(color.red(), color.green(), color.blue())); - for(Q_UINT16 y=0; y<shrunk_height; y++) { - Q_UINT8 *destScanLine = (Q_UINT8 *)im32.scanLine(y); - for(Q_UINT16 col=0; col<shrunk_width; col++) + im32.fill(tqRgb(color.red(), color.green(), color.blue())); + for(TQ_UINT16 y=0; y<shrunk_height; y++) { + TQ_UINT8 *destScanLine = (TQ_UINT8 *)im32.scanLine(y); + for(TQ_UINT16 col=0; col<shrunk_width; col++) destScanLine[4*col+3] = xydata[shrunk_width*y + col]; } } else { // If the alpha channel is not supported... QT seems to turn the - // alpha channel into a crude bitmap which is used to mask the + // alpha channel into a crude bitmap which is used to tqmask the // resulting TQPixmap. In this case, we define the character // outline using the image data, and use the alpha channel only // to store "maximally opaque" or "completely transparent" @@ -291,18 +291,18 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC // are no longer correctly drawn, but quality is still // sufficient for most purposes. One notable exception is output // from the gftodvi program, which will be partially unreadable. - Q_UINT16 rInv = 0xFF - color.red(); - Q_UINT16 gInv = 0xFF - color.green(); - Q_UINT16 bInv = 0xFF - color.blue(); + TQ_UINT16 rInv = 0xFF - color.red(); + TQ_UINT16 gInv = 0xFF - color.green(); + TQ_UINT16 bInv = 0xFF - color.blue(); - Q_UINT8 *srcScanLine = xydata; - for(Q_UINT16 y=0; y<shrunk_height; y++) { + TQ_UINT8 *srcScanLine = xydata; + for(TQ_UINT16 y=0; y<shrunk_height; y++) { unsigned int *destScanLine = (unsigned int *)im32.scanLine(y); - for(Q_UINT16 col=0; col<shrunk_width; col++) { - Q_UINT16 data = *srcScanLine; + for(TQ_UINT16 col=0; col<shrunk_width; col++) { + TQ_UINT16 data = *srcScanLine; // The value stored in "data" now has the following meaning: // data = 0 -> white; data = 0xff -> use "color" - *destScanLine = qRgba(0xFF - (rInv*data + 0x7F) / 0xFF, + *destScanLine = tqRgba(0xFF - (rInv*data + 0x7F) / 0xFF, 0xFF - (gInv*data + 0x7F) / 0xFF, 0xFF - (bInv*data + 0x7F) / 0xFF, (data > 0x03) ? 0xff : 0x00); @@ -320,8 +320,8 @@ glyph* TeXFont_PK::getGlyph(Q_UINT16 ch, bool generateCharacterPixmap, const TQC -#define ADD(a, b) ((Q_UINT32 *) (((char *) a) + b)) -#define SUB(a, b) ((Q_UINT32 *) (((char *) a) - b)) +#define ADD(a, b) ((TQ_UINT32 *) (((char *) a) + b)) +#define SUB(a, b) ((TQ_UINT32 *) (((char *) a) - b)) @@ -347,7 +347,7 @@ static const uchar bitflip[256] = { 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 }; -static Q_UINT32 bit_masks[33] = { +static TQ_UINT32 bit_tqmasks[33] = { 0x0, 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff, 0x7ff, @@ -454,7 +454,7 @@ void TeXFont_PK::PK_skip_specials() case PK_NOOP : break; default : - oops(i18n("Unexpected %1 in PK file %2").arg(PK_flag_byte).arg(parent->filename) ); + oops(i18n("Unexpected %1 in PK file %2").tqarg(PK_flag_byte).tqarg(tqparent->filename) ); break; } } @@ -477,11 +477,11 @@ void TeXFont_PK::read_PK_char(unsigned int ch) int n; int row_bit_pos; bool paint_switch; - Q_UINT32 *cp; + TQ_UINT32 *cp; register struct glyph *g; register FILE *fp = file; long fpwidth; - Q_UINT32 word = 0; + TQ_UINT32 word = 0; int word_weight, bytes_wide; int rows_left, h_bit, count; @@ -521,7 +521,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch) w = num(fp, n); h = num(fp, n); if (w > 0x7fff || h > 0x7fff) - oops(i18n("The character %1 is too large in file %2").arg(ch).arg(parent->filename)); + oops(i18n("The character %1 is too large in file %2").tqarg(ch).tqarg(tqparent->filename)); characterBitmaps[ch]->w = w; characterBitmaps[ch]->h = h; } @@ -537,7 +537,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch) characterBitmaps[ch]->bits = new char[size != 0 ? size : 1]; } - cp = (Q_UINT32 *) characterBitmaps[ch]->bits; + cp = (TQ_UINT32 *) characterBitmaps[ch]->bits; /* * read character data into *cp @@ -595,12 +595,12 @@ void TeXFont_PK::read_PK_char(unsigned int ch) h_bit -= count; word_weight -= count; if (paint_switch) - word |= bit_masks[count] << word_weight; + word |= bit_tqmasks[count] << word_weight; count = 0; } else if (count >= h_bit && h_bit <= word_weight) { if (paint_switch) - word |= bit_masks[h_bit] << (word_weight - h_bit); + word |= bit_tqmasks[h_bit] << (word_weight - h_bit); *cp++ = word; /* "output" row(s) */ for (i = PK_repeat_count * bytes_wide / 4; i > 0; --i) { @@ -615,7 +615,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch) h_bit = characterBitmaps[ch]->w; } else { if (paint_switch) - word |= bit_masks[word_weight]; + word |= bit_tqmasks[word_weight]; *cp++ = word; word = 0; count -= word_weight; @@ -625,10 +625,10 @@ void TeXFont_PK::read_PK_char(unsigned int ch) } paint_switch = 1 - paint_switch; } - if (cp != ((Q_UINT32 *) (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h))) - oops(i18n("Wrong number of bits stored: char. %1, font %2").arg(ch).arg(parent->filename)); + if (cp != ((TQ_UINT32 *) (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h))) + oops(i18n("Wrong number of bits stored: char. %1, font %2").tqarg(ch).tqarg(tqparent->filename)); if (rows_left != 0 || h_bit != characterBitmaps[ch]->w) - oops(i18n("Bad pk file (%1), too many bits").arg(parent->filename)); + oops(i18n("Bad pk file (%1), too many bits").tqarg(tqparent->filename)); } // The data in the bitmap is now in the processor's bit order, @@ -679,14 +679,14 @@ void TeXFont_PK::read_PK_char(unsigned int ch) while (count > 0) { if (count < word_weight && count < h_bit) { if (paint_switch) - word |= bit_masks[count] << (32 - word_weight); + word |= bit_tqmasks[count] << (32 - word_weight); h_bit -= count; word_weight -= count; count = 0; } else if (count >= h_bit && h_bit <= word_weight) { if (paint_switch) - word |= bit_masks[h_bit] << (32 - word_weight); + word |= bit_tqmasks[h_bit] << (32 - word_weight); *cp++ = word; /* "output" row(s) */ for (i = PK_repeat_count * bytes_wide / 4; i > 0; --i) { @@ -701,7 +701,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch) h_bit = characterBitmaps[ch]->w; } else { if (paint_switch) - word |= bit_masks[word_weight] << (32 - word_weight); + word |= bit_tqmasks[word_weight] << (32 - word_weight); *cp++ = word; word = 0; count -= word_weight; @@ -711,10 +711,10 @@ void TeXFont_PK::read_PK_char(unsigned int ch) } paint_switch = 1 - paint_switch; } - if (cp != ((Q_UINT32 *) (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h))) - oops(i18n("Wrong number of bits stored: char. %1, font %2").arg(ch).arg(parent->filename)); + if (cp != ((TQ_UINT32 *) (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h))) + oops(i18n("Wrong number of bits stored: char. %1, font %2").tqarg(ch).tqarg(tqparent->filename)); if (rows_left != 0 || h_bit != characterBitmaps[ch]->w) - oops(i18n("Bad pk file (%1), too many bits").arg(parent->filename)); + oops(i18n("Bad pk file (%1), too many bits").tqarg(tqparent->filename)); } } // endif: big or small Endian? } |