10
66
Fork
You've already forked fcft
13

Text shaping #21

Manually merged
dnkl merged 17 commits from text-shaping into master 2022年03月24日 22:16:22 +01:00
Owner
Copy link

This PR adds two new functions, fcft_text_run_rasterize(), and fcft_text_run_destroy().

fcft_text_run_rasterize() is like fcft_glyph_rasterize() and fcft_grapheme_rasterize(), but takes a whole string, instead of a single character, or grapheme cluster.

fcft does not cache the resulting set of glyphs - this can be done by the calling application.

TODO

  • documentation (including example code? Or refer to the example program)
  • changelog
  • bump fcft version to at least 2.3.91, (削除) or maybe go straight to 2.4.0 (削除ここまで)
  • update README

Closes #12

This PR adds two new functions, `fcft_text_run_rasterize()`, and `fcft_text_run_destroy()`. `fcft_text_run_rasterize()` is like `fcft_glyph_rasterize()` and `fcft_grapheme_rasterize()`, but takes a whole string, instead of a single character, or grapheme cluster. fcft does **not** cache the resulting set of glyphs - this can be done by the calling application. **TODO** * [x] documentation (including example code? Or refer to the example program) * [x] changelog * [x] bump fcft version to at least 2.3.91, ~~or maybe go straight to 2.4.0~~ * [x] update README Closes #12
dnkl added this to the 2.4 milestone 2021年04月17日 12:25:42 +02:00
Author
Owner
Copy link

Current state:

Screenshot of text rendering

  • First row is rendered using fcft_glyph_rasterize().
  • Second row is rendered using fcft_grapheme_rasterize().
  • Third row is rendered using fcft_text_run_rasterize().

fcft_grapheme_rasterize() doesn't handle RTL at all, and requires the calling application to do the grapheme clustering (using e.g. utf8proc).

fcft_text_run_rasterize() does everything for you.

TODO: while the arabic text looks right, at least to me (who speaks, or reads, no arabic at all), I'm not sure the spacing in the hebrew text is correct.

note: the first two rows looking wrong is expected.

Current state: [![Screenshot of text rendering](https://codeberg.org/attachments/c1f5e0d0-51dc-4651-b24e-78df8ff9fb14)](https://codeberg.org/attachments/c1f5e0d0-51dc-4651-b24e-78df8ff9fb14) * First row is rendered using `fcft_glyph_rasterize()`. * Second row is rendered using `fcft_grapheme_rasterize()`. * Third row is rendered using `fcft_text_run_rasterize()`. `fcft_grapheme_rasterize()` doesn't handle RTL at all, and requires the calling application to do the grapheme clustering (using e.g. utf8proc). `fcft_text_run_rasterize()` does everything for you. TODO: while the arabic text looks right, at least to me (who speaks, or reads, no arabic at all), I'm not sure the spacing in the hebrew text is correct. **note**: the first two rows looking wrong is **expected**.
Author
Owner
Copy link

I think I've fixed the glyphs' x-offsets now:

Screenshot of text rendering

This was done by adding the HarfBuzz provided glyph x offset to the offset from FreeType, instead of replacing it. Still need to find example code, or documentation, that backs this up.

And I still can't make heads or tails of the glyphs' y offset.

I think I've fixed the glyphs' x-offsets now: [![Screenshot of text rendering](https://codeberg.org/attachments/114da717-21a4-43f6-b309-88e2dc72228b)](https://codeberg.org/attachments/114da717-21a4-43f6-b309-88e2dc72228b) This was done by **adding** the HarfBuzz provided glyph x offset to the offset from FreeType, instead of replacing it. Still need to find example code, or documentation, that backs this up. And I still can't make heads or tails of the glyphs' y offset.
Author
Owner
Copy link

And I still can't make heads or tails of the glyphs' y offset.

Looks like it was a bad font. With other fonts it's very clear that the vertical offset must be applied in the exact same way the horizontal offset is.

> And I still can't make heads or tails of the glyphs' y offset. Looks like it was a bad font. With other fonts it's very clear that the vertical offset **must** be applied in the exact same way the horizontal offset is.
Author
Owner
Copy link
With Noto: [![Screenshot of text rendering](https://codeberg.org/attachments/c013223d-733c-4089-845b-d3b70985394d)](https://codeberg.org/attachments/c013223d-733c-4089-845b-d3b70985394d)
Author
Owner
Copy link

One limitation of the current implementation is that LTR/RTL changes are only detected when/where we fail to lookup a glyph. In other words, if the primary font has all the glyphs, we never detect LTR/RTL changes.

One limitation of the current implementation is that LTR/RTL changes are only detected when/where we fail to lookup a glyph. In other words, if the primary font has all the glyphs, we never detect LTR/RTL changes.
dnkl changed title from (削除) WIP: text shaping (削除ここまで) to Text shaping 2021年04月29日 10:36:40 +02:00
Author
Owner
Copy link

@sterni is this something you'd be interrested in testing before I merge? If not, just say no :)

There's an example program (configure meson with -Dexamples=true to build) you can use to render arbitrary strings using the three currently available methods: individual glyphs, individual grapheme clusters and text runs. It is what you see in the screenshots above.

This will soon be released as fcft-2.4.0, and I plan to use it in yambar, fuzzel and fnott, but not in foot (due to all the previously discussed issues with text shaping in a terminal).

@sterni is this something you'd be interrested in testing before I merge? If not, just say no :) There's an example program (configure meson with `-Dexamples=true` to build) you can use to render arbitrary strings using the three currently available methods: individual glyphs, individual grapheme clusters and text runs. It is what you see in the screenshots above. This will soon be released as fcft-2.4.0, and I plan to use it in yambar, fuzzel and fnott, but _not_ in foot (due to all the previously discussed issues with text shaping in a terminal).
dnkl manually merged commit 12652429ff into master 2021年05月04日 10:06:30 +02:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/fcft!21
Reference in a new issue
dnkl/fcft
No description provided.
Delete branch "text-shaping"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?