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

Remove invisible glyphs #92

Closed
brawer opened this issue Oct 8, 2018 · 5 comments
Closed

Remove invisible glyphs #92

brawer opened this issue Oct 8, 2018 · 5 comments

Comments

@brawer
Copy link
Contributor

brawer commented Oct 8, 2018

Could libraqm delete invisible glyphs from the returned glyph array when compiled against a recent HarfBuzz version (which has hb_buffer_set_invisible_glyph, introduced in harfbuzz/harfbuzz@e42cd58 / harfbuzz/harfbuzz#1216)?

In Unicode’s test suite for rendering engine I’m using libraqm. Currently, test case CMAP-1 is failing on the free stack because HarfBuzz inserts an invisible space (by default, HarfBuzz uses space as invisible glyph).

I can’t just filter out all spaces in my test harness, because the test suite contains checks that look at the shaping of spaces.

@khaledhosny
Copy link
Collaborator

hb_buffer_set_invisible_glyph() wouldn’t help here since there would still be a glyph even if it is not space glyph (OK, we can use a special glyph id here and filter that, but that is a bit hacky). However, there is HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES which is what you want. We probably need an API that sets this flag, since by default we want to keep them as it allows for simpler output glyph to input text mapping.

@brawer
Copy link
Contributor Author

brawer commented Oct 8, 2018

Indeed, setting HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES would fix my problem. In raqm, what API would you like to see for this? Perhaps the following, which would be similar to raqm’s raqm_set_freetype_load_flags() function?

bool
raqm_set_harfbuzz_buffer_flags (raqm_t *rq,
                                int flags);

@khaledhosny
Copy link
Collaborator

I’d rather not expose buffer flags directly, for example we set HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT unconditionally since we always process full paragraphs. I’d add the following, with negative gid meaning drop invisible glyphs:

bool
raqm_set_invisible_glyph (raqm_t *rq,
                          int gid);

@brawer
Copy link
Contributor Author

brawer commented Oct 9, 2018

Like this? Maybe a little complex?

For solving my problem in the test suite, it would be sufficient if I could call a libraqm function that makes the invisible glyphs disappear by setting HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES. So I wouldn’t care about specific glyph IDs, but maybe there is a use case?

/**                                                                             
 * raqm_set_invisible_glyph:                                                    
 * @rq: a #raqm_t.                                                              
 * @gid: glyph id to use for invisible glyphs.                                  
 *                                                                              
 * If @gid is negative, invisible glyphs will be suppressed from the output.    
 * This works on all versions of HarfBuzz.                                      
 *                                                                              
 * If @gid is zero, invisible glyphs will be rendered as space.                 
 * This works on all versions of HarfBuzz.                                      
 *                                                                              
 * If @gid is a positive number, it will be used for invisible glyphs.
 * This requires a version of HarfBuzz that has hb_buffer_set_invisible_glyph().
 * For older versions, the return value will be %false and the shaping behavior
 * does not change.                                                                     
 *                                                                              
 * Return value:                                                                
 * %true if no errors happened, %false otherwise.                               
 *                                                                              
 * Since: 0.6                                                                   
 */
bool
raqm_set_invisible_glyph (raqm_t *rq,
                          int gid)

@khaledhosny
Copy link
Collaborator

Sounds good. Yes, the complexity is expected but I think it is OK.

khaledhosny pushed a commit that referenced this issue Oct 10, 2018
Change test harness to check for system requirements, and skip test
cases that cannot be run on the current platform. Specifically, if
we're running on an old HarfBuzz without `hb_buffer_set_invisible_glyph()`,
the test case `invisible_glyph_explicit` is skipped.

Fixes #92.
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

2 participants