//---------------------------------------------------------------- // Text::TPrivate::uploadTexture // bool Text::TPrivate::uploadTexture(const Text & item) { QRectF maxRect; getMaxRect(item, maxRect); double supersample = item.supersample_.get(); maxRect.setWidth(maxRect.width() * supersample); maxRect.setHeight(maxRect.height() * supersample); BBox bboxContent; item.Item::get(kPropertyBBoxContent, bboxContent); iw_ = (int)ceil(bboxContent.w_ * supersample); ih_ = (int)ceil(bboxContent.h_ * supersample); if (!(iw_ && ih_)) { return true; } GLsizei widthPowerOfTwo = powerOfTwoGEQ<GLsizei>(iw_); GLsizei heightPowerOfTwo = powerOfTwoGEQ<GLsizei>(ih_); QImage img(widthPowerOfTwo, heightPowerOfTwo, QImage::Format_ARGB32); { const Color & color = item.color_.get(); #ifndef _WIN32 Color bg = color.transparent(); #else const Color & bg = item.background_.get(); #endif img.fill(QColor(bg).rgba()); QPainter painter(&img); QFont font = item.font_; double fontSize = item.fontSize_.get(); font.setPointSizeF(fontSize * supersample); painter.setFont(font); QFontMetricsF fm(font); int flags = item.textFlags(); QString text = getElidedText(maxRect.width(), item, fm, flags); painter.setPen(QColor(color)); painter.drawText(maxRect, flags, text); } // do not upload supersampled texture at full size, scale down first: downsample_ = downsampleImage(img, supersample); bool ok = yae::uploadTexture2D(img, texId_, supersample == 1.0 ? GL_NEAREST : GL_LINEAR_MIPMAP_LINEAR); return ok; }
// virtual: void evaluate(BBox & result) const { QRectF maxRect; getMaxRect(item_, maxRect); calcTextBBox(item_, result, maxRect.width(), maxRect.height()); }
DkPolyRect DkPageSegmentation::getDocumentRect() const { return getMaxRect(); }