gvx / richtext

A text and image layout library for LÖVE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Canvas is rendered in "alpha" blendmode...

Germanunkol opened this issue · comments

... and I think it should be "premultiplied" instead.
Here's an example of what it looks like when rendering a short text:
2013-12-01-195438_800x600_scrot
And this is what it should look like instead:
2013-12-01-195355_800x600_scrot

This happens because the text is rendered onto the canvas in "alpha" blendmode and then rendered again onto the screen in the "alpha" mode as well.
Instead, something like this solves the problem:

function rich:draw(x, y)
    local firstR, firstG, firstB, firstA = love.graphics.getColor()
    love.graphics.setColor(255, 255, 255, 255)
    local prevMode = love.graphics.getBlendMode()
    if self.framebuffer then
        love.graphics.setBlendMode("premultiplied")
        love.graphics.draw(self.framebuffer, x, y)
        love.graphics.setBlendMode(prevMode)
    else