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

Add font ligature support #1

Open
meh opened this issue Oct 18, 2016 · 1 comment
Open

Add font ligature support #1

meh opened this issue Oct 18, 2016 · 1 comment

Comments

@meh
Copy link
Owner

meh commented Oct 18, 2016

Supporting ligatures is not going to be easy considering how the rendering is currently done.

On the bright side Cairo and Pango easily support rendering text with ligatures, but they require the whole text to do the job (obviously).

As it currently stands the Renderer has a Cache with an LRU for glyph caching, what this does is using the value of the cell to store the font and compute the shape, which is then sent to Cairo for rendering, this means that each cell is rendered as a single grapheme.

To support ligatures instead of using PangoGlyphString it should use PangoGlyphItem, which is just a pair of PangoItem and PangoGlyphString, looking through the Pango documentation I haven't found a way to "slice" a PangoGlyphString, so I presume a PangoGlyphItem must be used for that.

To keep performance good, the cache should be computed based on neighboring cells, where a cell is a neighbor iff:

  • it's on the same row
  • it has the same style
  • is not an empty cell

This does completely break the nice property of the LRU cache just storing the grapheme, which meant it could be reused for other cells containing the same grapheme.

Regardless, I think this could be done with an option without making the code too ugly, so people who do not care about ligatures (me) can opt-out and gain some performance.

@meh
Copy link
Owner Author

meh commented Oct 18, 2016

It's also important to note the rendering of a single cell could affect the rendering of its neighbors, which means neighbors should always get re-rendered unless their cache is up to date, which also means neighbors would end up trickling down if one cell in the middle changes style/content.

Need to investigate if there's a way to see if a glyph has a ligature in it.

@meh meh changed the title Support ligatures. Add font ligature support Nov 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant