Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving text rendering #45

Closed
tdewolff opened this issue May 20, 2020 · 6 comments
Closed

Improving text rendering #45

tdewolff opened this issue May 20, 2020 · 6 comments

Comments

@tdewolff
Copy link
Owner

tdewolff commented May 20, 2020

Instead of reinventing the wheel, we should be using existing solutions. Especially important to me is using HarfBuzz for text shaping (rendering glyphs correctly in all languages, such as direction, accents, kerning, etc.). See https://github.com/grisha/hbshape for an example of a port.

See https://harfbuzz.github.io/ch01s03.html for what HarfBuzz does, and https://harfbuzz.github.io/what-harfbuzz-doesnt-do.html for what it doesn't do. The latter is what we need to implement here:

  • Line-break, word break, justification: Knuths algorithm. Note that "boxes" can also be a path (not just text) to support inline images, and that the text box boundaries may not be rectangular but a path (hard?)
  • Breaking text in pieces of different font faces, we already do this
  • Solving bidirectionality, no idea, probably use https://github.com/fribidi/fribidi
  • Rendering, we already do this but the rasterizer is slow! Why not use FreeType?

For an example see https://github.com/anoek/ex-sdl-cairo-freetype-harfbuzz/. (NB: they don't use FreeType for rasterization?)

Additionally, but with less priority, I'd like to support the TCC file format (how does that pan out with fc-match?). And finally I'd like to support OpenGL rendering using Blinn and Loop algorithm or something similar (see https://lambdacube3d.wordpress.com/2014/11/12/playing-around-with-font-rendering/ as well). This needs proper tesselation of paths which is not that trivial. Low priority.

@mewmew
Copy link

mewmew commented May 23, 2020

Instead of reinventing the wheel, we should be using existing solutions. Especially important to me is using HarfBuzz for text shaping (rendering glyphs correctly in all languages, such as direction, accents, kerning, etc.). See https://github.com/grisha/hbshape for an example of a port.

@tdewolff you may also be interested in checking out github.com/npillmayer/gotype/engine/text/textshaping for text rendering using HarfBuzz.

In general, I think both you and @npillmayer are working on a similar set of problems (check out https://github.com/npillmayer/gotype) and you may consider getting in touch and discuss how to best collaborate your efforts, where applicable. I feel really happy and grateful to have stumbled on both your work today Taco, and the work of Norbert. You are both a huge source of inspiration as I'm just starting to get into type-setting and reading up on this domain with excitement.

Wish you a great start of the summer!

With kindness,
Robin Eklind

@npillmayer
Copy link

npillmayer commented May 25, 2020 via email

@tdewolff
Copy link
Owner Author

@mewmew Thank you for bringing this up! The textshaping repository is definitely interesting and will help. I think people like you are needed more in the community, to bring together developers and save time!

@npillmayer Nice work on gotype! I was thinking along the same lines with Harfbuzz that it'd be a lot of work for nothing to reimplement. Given that Harfbuzz is pure C is really nice, I think we shouldn't be afraid of using a little C to use a industry-standard approach to text visualization. In the same line of thought I was considering adding fribidi, but I'll see how it goes. I might get started with your port of Harfbuzz and work it out a little further (in whichever repo it might end up). I'd be glad to work together with you on this!

I might seem high-energy on my open source projects, but I'm pretty much balancing between a job and relationship too ;-), though the quarantaine has given me extra time I'd otherwise spend socializing haha. Though I really need more hands on canvas to make it better. Anyways, I can always help you out with any problem you encounter while using canvas, as edge-cases may need to get worked on!

Keep it up!

@mewmew
Copy link

mewmew commented May 27, 2020

@mewmew Thank you for bringing this up! The textshaping repository is definitely interesting and will help. I think people like you are needed more in the community, to bring together developers and save time!

More than happy to :)

In the same line of thought I was considering adding fribidi, but I'll see how it goes.

@tdewolff, for bidi you may also look into golang.org/x/text/unicode/bidi. It seems bidi.ReverseString could be used in place of the visual_str return value of fribidi_log2vis. However, fribidi still seems more powerful as it also handles visual positions of characters, so x/text/unicode/bidi only covers a subset of the functionality.

@tdewolff
Copy link
Owner Author

I've gone ahead and implemented bindings for HarfBuzz and FriBidi, based on the implementation from @npillmayer, thanks a lot! It's currently in the develop branch and will be tracked in the roadmap in #74

@mewmew
Copy link

mewmew commented Feb 15, 2021

Very exciting to follow this development! Glad you both continue to facilitate and build upon each others work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants