ueberdosis / glyphfinder

Unicode character search for macOS & Windows.
https://www.glyphfinder.com
Other
134 stars 22 forks source link

Letter 'A' variants not found by search #84

Open bstrand opened 2 years ago

bstrand commented 2 years ago

Description

Characters that are variations on the letter 'A' are not found by search, whereas equivalent variations on other letters are.

Exception: Variants of alpha 'α' are not affected by this issue.

Examples

Working:
  1. Search: 'i grave'
    • Expected: ì igrave, Ì Igrave
    • Results: 6 glyphs, including igrave, Igrave
      Not working:
  2. Search: 'a grave'
    • Expected: à agrave, À Agrave
    • Results: None
  3. Search: 'a ring'
    • Expected: å aring, Å Aring
    • Results: None
bstrand commented 2 years ago

The problem is caused by code cleaning up the Glyph names when creating the index, wherein instances of the string ' a ' are removed.

          item.name
            .replace(/-[0-9]/g, '')
            .replace(' a ', '')
            .replace(' an ', ''),

This turns, e.g., "latin small letter a with ring above" into "latin small letterwith ring above". The resulting index thus does not yield results for "A …" searches on glyphs with "…letter a…" in the name. (Which, as observed, is inconsistent with other letters.)

Another problem here is that the leading and trailing spaces are both being removed, removing the boundary between the words before & after 'a', e.g. 'letterwith' above.

Will submit PR with a fix shortly.

bstrand commented 2 years ago

Just to expand on the second thing with both spaces being stripped a bit (sorry, not filing a new issue), an example of what it breaks: There is a glyph named x in a rectangle box. It is indexed as x inrectangle box, and thus is not found by searching for "rectangle" (but is found by searching for "inrectangle".)