dfrg / swash

Font introspection, complex text shaping and glyph rendering.
Apache License 2.0
584 stars 34 forks source link

🤖🪵 Fix emoji placement by calculating full bounds #30

Closed Jasper-Bekkers closed 1 year ago

Jasper-Bekkers commented 1 year ago

Addresses incorrect emoji rendering as reported in #26

Previously the placement of the very first colored outline was used to calculate image dimensions, however this is incorrect. One should use the full bounds of all outlines for calculating this size.

Notice that this also needs a tiny PR on zeno https://github.com/dfrg/zeno/pull/4

Attached are correctly rendered 🤖 and 🪵 emoji's as per the issue file.

stuff stuff

Jasper-Bekkers commented 1 year ago

Examples of this rendered in cosmic-text;

image

dfrg commented 1 year ago

Thanks! This looks good but I did notice that Outline already has a bounds method (https://docs.rs/swash/latest/swash/scale/outline/struct.Outline.html#method.bounds) that computes the full bounding box. I assume this will return the same result as your code without requiring the change to zeno though I’m happy to accept that one as well.

Jasper-Bekkers commented 1 year ago

This is what I'm using, however, Bounds didn't have a way to grow yet; which is what I PR'd to Zeno.

dfrg commented 1 year ago

Right, but Outline::bounds should already return the union of all layer bboxes so there’s no need to calculate it manually.

Jasper-Bekkers commented 1 year ago

Right, but Outline::bounds should already return the union of all layer bboxes so there’s no need to calculate it manually.

Thanks for the heads up! I've update the code to just call this instead and that seems to work fine as well (re-ran my tests for it).

dfrg commented 1 year ago

Thanks for fixing this! I’ll bump the version and publish a new release to crates later today.

Jasper-Bekkers commented 1 year ago

Thanks! A release would be quite welcome 👍

dfrg commented 1 year ago

Released 0.1.5!