pop-os / cosmic-text

Pure Rust multi-line text handling
https://pop-os.github.io/cosmic-text/cosmic_text/
Apache License 2.0
1.53k stars 89 forks source link

Space not included in layout #194

Open MinusGix opened 9 months ago

MinusGix commented 9 months ago

Layout glyphs don't seem to always include the space character.

For example, with wrapping (I think I ran into another case, but I'm failing to remember how):
image (editor-libcosmic example)

Glyph: LayoutGlyph { start: 146, end: 147, font_size: 14.0, font_id: ID(InnerId(1038v1)), glyph_id: 75, x: 968.5338, y: 0.0, w: 8.651999, level: Level(0), x_offset: 0.0, y_offset: 0.0, color_opt: Some(Color(4292071624)), metadata: 0 }
        portion of text: "h"

So 'h' is the last glyph, which is what end of line and clicking past the end of that line stop at - rather than the expected space (like other editors).
At first I thought the space was skipped over because it would provide no positioning, but it seems like multiple spaces will get correctly handled?

(Of course, right after that space is the same index as the i in ipsum on the next line but affinity can handle that)

Is there some good way to get past that? I presume no since the examples don't implement it, so it may be a bug.

grovesNL commented 9 months ago

Related to #155