Skip to content

Support multi-character emoji #511

@forresto

Description

@forresto

This issue with monochrome Noto Emoji is distinct from the color emoji issue (#193).

#338 added support for non-Basic-Multilingual-Plane (BMP) characters, but uses Array.from, which doesn't account for combined emoji.

It seems that Opentype.js has the glyph information needed, but the initial text-to-glyph translation is the issue:

image
https://opentype.js.org/glyph-inspector.html

Expected Behavior

Calling notoEmojiFont.draw(context, "👨‍👩‍👧‍👦") should render
image

Current Behavior

Calling notoEmojiFont.draw(context, "👨‍👩‍👧‍👦") renders
image

Possible Solution

  1. If "ccmp" is not supported yet and would cover this, this issue can be closed as a duplicate of Consider adding support to more GSUB tags? #443.

  2. Intl.Segmenter is a native solution, but isn't supported by Firefox yet.

const splitSegmentArray = (string) => Array.from(new Intl.Segmenter().segment(string)).map(x => x.segment);
console.log(splitSegmentArray("😅👨‍👩‍👧‍👦💖👩‍💻💔👩‍🌾🧡👨🏽‍🌾💜🖖🏾🌈"))
  1. graphemer is a library-based solution. (It is a fairly big library.)

  2. twemoji-parser is focused on parsing emoji sequences, so it's smaller than graphemer.

Steps to Reproduce (for bugs)

Live demo: https://gm69qn.csb.app

  1. Call notoEmojiFont.stringToGlyphs("👨‍👩‍👧‍👦") and get glyphs for "👨👩👧👦" interspersed with the combiner ("uni200D") instead of the one glyph for the combined family.

image

  1. Same for other combined emoji, like 👩‍💻, 👩‍🌾, 👨🏽‍🌾, 🖖🏾

Context

We're adding support for emoji to Cuttle CAD, which can render various fonts as vectors for laser cutting, etc.

Your Environment

  • Version used: 1.3.4
  • Font used: Noto Emoji (ttf)
  • Browser Name and version: Various tested
  • Operating System and version (desktop or mobile): Mac OS desktop
  • Link to your project: https://gm69qn.csb.app

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions