46 #include "private/qnumeric_p.h" 47 #include "private/qnativeimage_p.h" 48 #include "private/qfontengine_ft_p.h" 74 for (
int i=0; i<12; ++i) {
89 for (
int j=0; j<images.
size(); ++j) {
90 if (images.
at(j) == img) {
100 return images.
size();
110 subPixelPosition = x - x.
floor();
117 return subPixelPosition;
124 printf(
"Populating with %d glyphs\n", numGlyphs);
134 if (!supportsSubPixelPositions) {
137 #if !defined(Q_WS_X11) 158 for (
int i=0; i < numGlyphs; ++i) {
159 const glyph_t glyph = glyphs[i];
162 if (supportsSubPixelPositions) {
174 printf(
"(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n",
186 if (glyph_height == 0 || glyph_width == 0) {
188 Coord c = { 0, 0, 0, 0, 0, 0 };
192 glyph_width += margin * 2 + 4;
193 glyph_height += margin * 2 + 4;
196 glyph_width = (glyph_width+7)&~7;
204 listItemCoordinates.
insert(key, c);
205 rowHeight =
qMax(rowHeight, glyph_height);
207 if (listItemCoordinates.
isEmpty())
210 rowHeight += margin * 2 + paddingDoubled;
221 int requiredWidth =
m_w;
222 while (iter != listItemCoordinates.
end()) {
227 if (
m_cx + c.
w > requiredWidth) {
228 int new_width = requiredWidth*2;
229 while (new_width <
m_cx + c.
w)
232 requiredWidth = new_width;
252 m_cx += c.
w + paddingDoubled;
264 int requiredHeight =
m_h;
265 int requiredWidth =
m_w;
270 requiredHeight =
qMax(requiredHeight, c.
y + c.
h);
271 requiredWidth =
qMax(requiredWidth, c.
x + c.
w);
276 if (
isNull() || requiredHeight >
m_h || requiredWidth >
m_w) {
298 #if defined(Q_WS_X11) 320 positions[0].
x = subPixelPosition;
322 if (gset && ft->
loadGlyphs(gset, &g, 1, positions, format)) {
325 : (glyph->
width + 3) & ~3);
344 m_image = m_image.copy(0, 0, width, height);
358 for (
int i=0; i<256; ++i, ++
it)
359 *it = 0xff000000 | i | (i<<8) | (i<<16);
360 m_image.setColorTable(colors);
370 #if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) || defined(Q_WS_X11) 382 printf(
"fillTexture of %dx%d at %d,%d in the cache of %dx%d\n", c.
w, c.
h, c.
x, c.
y, m_image.width(), m_image.height());
384 printf(
" ERROR; mask is bigger than reserved space! %dx%d instead of %dx%d\n", mask.
width(), mask.
height(), c.
w,c.
h);
390 QImage ref(m_image.bits() + (c.
x * 4 + c.
y * m_image.bytesPerLine()),
395 p.fillRect(0, 0, c.
w, c.
h,
QColor(0,0,0,0));
396 p.drawImage(0, 0, mask);
399 if (mask.
depth() > 1) {
408 uchar *
d = m_image.bits();
409 int dbpl = m_image.bytesPerLine();
411 for (
int y = 0;
y < c.
h; ++
y) {
412 uchar *dest = d + (c.
y +
y) *dbpl + c.
x/8;
416 for (
int x = 0; x < c.
w/8; ++x) {
423 for (
int x = 0; x < c.
w/8; ++x)
430 uchar *
d = m_image.bits();
431 int dbpl = m_image.bytesPerLine();
433 if (mask.
depth() == 1) {
434 for (
int y = 0;
y < c.
h; ++
y) {
435 uchar *dest = d + (c.
y +
y) *dbpl + c.
x;
438 for (
int x = 0; x < c.
w; ++x) {
440 dest[x] = (src[x >> 3] & (1 << (7 - (x & 7)))) > 0 ? 255 : 0;
444 }
else if (mask.
depth() == 8) {
445 for (
int y = 0;
y < c.
h; ++
y) {
446 uchar *dest = d + (c.
y +
y) *dbpl + c.
x;
449 for (
int x = 0; x < c.
w; ++x) {
462 if (m_image.rect().contains(base))
463 m_image.setPixel(base, 255);
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
virtual int maxTextureWidth() const
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Format
The following image formats are available in Qt.
virtual QImage alphaMapForGlyph(glyph_t)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
QHash< GlyphAndSubPixelPosition, Coord > coords
#define it(className, varName)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
QFixed subPixelPositionForX(QFixed x) const
#define QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH
virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition)
virtual void createTextureData(int width, int height)
T & value() const
Returns a modifiable reference to the current item's value.
The QHash class is a template class that provides a hash-table-based dictionary.
static QFixed fromReal(qreal r)
QImage textureMapForGlyph(glyph_t g, QFixed subPixelPosition) const
virtual int maxTextureHeight() const
virtual Type type() const =0
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
QFontEngineGlyphCache::Type m_type
void fillInPendingGlyphs()
virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t)
Glyph * getGlyph(glyph_t index, QFixed subPixelPosition=0) const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
virtual qreal maxCharWidth() const =0
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual void resizeTextureData(int width, int height)
virtual int glyphPadding() const
static const QCssKnownValue positions[NumKnownPositionModes - 1]
const T & at(int i) const
Returns the item at index position i in the list.
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
The QImage class provides a hardware-independent image representation that allows direct access to th...
int depth() const
Returns the depth of the image.
const Key & key() const
Returns the current item's key as a const reference.
bool loadGlyphs(QGlyphSet *gs, const glyph_t *glyphs, int num_glyphs, const QFixedPoint *positions, GlyphFormat format=Format_Render)
QImage alphaChannel() const
Returns the alpha channel of the image as a new grayscale QImage in which each pixel's red...
int m_subPixelPositionCount
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
void resizeCache(int width, int height)
int width() const
Returns the width of the image.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
virtual int glyphMargin() const
virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat)
QFontEngine * m_current_fontengine
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
int calculateSubPixelPositionCount(glyph_t) const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
bool populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions)
The QPoint class defines a point in the plane using integer precision.
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
int size() const
Returns the number of items in the list.
virtual void fillTexture(const Coord &coord, glyph_t glyph, QFixed subPixelPosition)=0
void createCache(int width, int height)
if(void) toggleToolbarShown
virtual int glyphMargin() const
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
int height() const
Returns the height of the image.
QGlyphSet * loadTransformedGlyphSet(const QTransform &matrix)
T * data()
Returns a pointer to the data stored in the vector.
void invertPixels(InvertMode=InvertRgb)
Inverts all pixel values in the image.
static int qt_next_power_of_two(int v)
QHash< GlyphAndSubPixelPosition, Coord > m_pendingGlyphs
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
virtual bool supportsSubPixelPositions() const