Coder Social home page Coder Social logo

Comments (5)

tomolt avatar tomolt commented on June 7, 2024

Hi maxstepin.
This is a problem I have known of pretty much from the start. It's not really a bug, and more a limitation of the underlying algorithm. These rows of not-quite-black pixels are the result of a combination of quantization errors and general numerical instability.
It is very likely that you can find the same behaviour with other font renderers that use a similiar algorithm such as stb_truetype.
Is this only an annoyance to you, or does this actually pose a potential problem?

from libschrift.

maxstepin avatar maxstepin commented on June 7, 2024

Yeah, it's not really a problem.
Thanks!

from libschrift.

maxstepin avatar maxstepin commented on June 7, 2024

I tried switching to floating point here:
struct cell { double area, cover; };
and invoke quantize() at the last possible moment in post_process()
and artifacts seems to disappear completely.

Just thought you might consider it.

I looked into stb_truetype and they also seems to be doing float->int conversion at the last possible moment.

from libschrift.

tomolt avatar tomolt commented on June 7, 2024

Hi maxstepin,

So I just tested this for myself. And you're right, the background is now completely black!

I would've thought the error caused by numerical instability would be much greater.
Actually, last time I measured it it was in fact bigger than the quantization error!
But since then, the algorithm has been changed dramatically, so I really should have updated my measurements.

I was a bit worried about the performance implications, but apparently this is pretty much exactly as fast as before. This is pretty shocking, considering we're now reading and writing 4x the amount of data to the buffer! Just in the last major version release, I got a 15% speedup overall by reducing the data size of the outline struct - I would have expected a comparable slowdown here. I guess draw_lines and post_process just aren't that memory-bound in the first place. Oh well, at least this turns out to be an easy fix now!

I'll probably put this in the next minor version (v7.1).
Thanks!

SideNote: I also tested this with float instead of double, but the slowdown from double-to-float conversion makes this much slower, so it's currently not worth it.

from libschrift.

maxstepin avatar maxstepin commented on June 7, 2024

You might simplify quantize() now, considering it's only used in one place, and in that place (x >= 0.0) condition is always true.

from libschrift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.