Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-18911

Wince Cleartype Patch

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.7.2
    • GUI: Text handling
    • None
    • Wince6.0/iMx515

    Description

      according to last mailing list, anti-aliasing on wince/qt is unavailable.

      but i found anti-aliasing enable method.

      QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform) designed to RGB32

      when wince use 16bpp problems occured

      qGray function is for RGB32/24 not RGB565

      this patch is make font 256 gray anti-aliasing

      i don't know how make RGB mask for text

      if U can make RGB mask, it will be able to subpixel font rendering too.

      ==============================================================================================================

      wince_Antialiasing.diff
      --- D:/Qt/qt-4.7.1-wince6L/src/gui/text/qfontengine_win.cpp.org	화 4 26 10:55:54 2011
      +++ D:/Qt/qt-4.7.1-wince6L/src/gui/text/qfontengine_win.cpp	화 4 26 10:56:15 2011
      @@ -1190,7 +1190,6 @@
           return ni;
       }
       
      -
       extern uint qt_pow_gamma[256];
       
       QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
      @@ -1221,26 +1220,24 @@
       
           // Copy data... Cannot use QPainter here as GDI has messed up the
           // Alpha channel of the ni.image pixels...
      -    for (int y=0; y<mask->height(); ++y) {
      -        uchar *dest = indexed.scanLine(y);
      -        if (mask->image.format() == QImage::Format_RGB16) {
      -            const qint16 *src = (qint16 *) ((const QImage &) mask->image).scanLine(y);
      -            for (int x=0; x<mask->width(); ++x)
      -                dest[x] = 255 - qGray(src[x]);
      -        } else {
      -            const uint *src = (uint *) ((const QImage &) mask->image).scanLine(y);
      -            for (int x=0; x<mask->width(); ++x) {
      +	const QImage source = mask->image.depth() == 32
      +		? mask->image
      +		: mask->image.convertToFormat(QImage::Format_RGB32);
      +
      +	for (int y=0; y<source.height(); ++y) {
      +		uchar *dest = indexed.scanLine(y);
      +		const uint *src = (uint *) source.scanLine(y);
      +		for (int x=0; x<source.width(); ++x) {
       #ifdef Q_OS_WINCE
      -                dest[x] = 255 - qGray(src[x]);
      +			dest[x] = 255 - qGray(src[x]);
       #else
      -                if (QNativeImage::systemFormat() == QImage::Format_RGB16)
      -                    dest[x] = 255 - qGray(src[x]);
      -                else
      -                    dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
      +			if (QNativeImage::systemFormat() == QImage::Format_RGB16)
      +				dest[x] = 255 - qGray(src[x]);
      +			else
      +				dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
       #endif
      -            }
      -        }
      -    }
      +		}
      +	}
       
           // Cleanup...
           delete mask;
      @@ -1257,12 +1254,16 @@
       QImage QFontEngineWin::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &t)
       {
           HFONT font = hfont;
      +	if (qt_cleartype_enabled) {
      +		LOGFONT lf = logfont;		
      +		lf.lfQuality = ANTIALIASED_QUALITY;
      +		font = CreateFontIndirect(&lf);
      +	}
       
           int contrast;
           SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0);
           SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0);
      -
      -    QNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32);
      +	QNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QNativeImage::systemFormat());
           SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) contrast, 0);
       
           if (mask == 0)
      @@ -1278,11 +1279,14 @@
               uint *dest = (uint *) rgbMask.scanLine(y);
               const uint *src = (uint *) source.scanLine(y);
               for (int x=0; x<mask->width(); ++x) {
                  dest[x] = 0xffffffff - (0x00ffffff & src[x]);
               }
           }
       
           delete mask;
      +	if (qt_cleartype_enabled) {
      +		DeleteObject(font);
      +	}
       
           return rgbMask;
       }
      

      Attachments

        1. CEZoom4.png
          CEZoom4.png
          5 kB
        2. cleartype.png
          cleartype.png
          8 kB
        3. qtCleartype.png
          qtCleartype.png
          5 kB
        4. qtCleartype.diff
          3 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            darius Darius Kim
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes