rafael2k / fog

Automatically exported from code.google.com/p/fog
1 stars 1 forks source link

Font scaling in drawText - Strange behaviour #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

If you have a transform that in not identity for the canvas and
your ctx.hints.tranformType is >= RASTER_TRANSFORM_SUBPX,
your font is scaled by the outer transform but if you patch the
ctx.hints.tranformType to 0 as shown below the font is drawn at the correct 
scale.

Not sure how to fix this issue as the path returned from font.getOutline(text, 
tmpPath0) should not be scaled a second time.

err_t RasterPaintEngine::drawText(const PointI& pt_, const String& text, const 
Font& font, const RectI* clip_)
{
  RASTER_ENTER_PAINT_FUNC();

  // TODO: Not optimal, no clip used.

 // ctx.hints.transformType = 0 ; // Add to verify path was scaled twice not just once

  if (ctx.hints.transformType >= RASTER_TRANSFORM_SUBPX || ctx.hints.forceOutlineText)
  {
    tmpPath0.clear();
    FOG_RETURN_ON_ERROR(font.getOutline(text, tmpPath0));
    tmpPath0.translate((double)pt_.x, (double)pt_.y + font.getAscent());
    return _serializePaintPath(tmpPath0, false);
  }
  else
  {
    int tx = ctx.finalTranslate.x;
    int ty = ctx.finalTranslate.y;

    PointI pt(pt_.x + tx, pt_.y + ty);
    RectI clip;

    if (clip_)
    {
      clip.set(clip_->x + tx, clip_->y + ty, clip_->w, clip_->h);
      clip_ = &clip;
    }

    tmpGlyphSet.clear();
    FOG_RETURN_ON_ERROR(font.getGlyphSet(text.getData(), text.getLength(), tmpGlyphSet));

    return _serializePaintGlyphSet(pt, tmpGlyphSet, clip_);
  }
}

Original issue reported on code.google.com by marietta...@peernet.com on 1 Nov 2010 at 1:01

GoogleCodeExporter commented 9 years ago
Accepted, but delayed...

I'm working on new painter architecture which should solve all these issues.

Thanks!

Original comment by kobalicek.petr on 1 Nov 2010 at 2:32