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

Subsetting emojis from an emoji font results in a non-working font #26

Closed
Calinou opened this issue Oct 29, 2024 · 2 comments
Closed

Subsetting emojis from an emoji font results in a non-working font #26

Calinou opened this issue Oct 29, 2024 · 2 comments

Comments

@Calinou
Copy link

Calinou commented Oct 29, 2024

Using Node.js 23.1.0 on Windows 11 23H2, I've tried to subset a small number of emoji from Noto Color Emoji which I've downloaded from Google Fonts. For context, I'm looking to address godotengine/godot-demo-projects#1119 without committing a 24 MB file to that repository.

Using the following script:

#!/usr/bin/env node
const fs = require('fs');
const subsetFont = require('subset-font');

const inputFile = 'NotoColorEmoji-Regular.ttf';
const outputFile = 'NotoColorEmoji-Regular-subset.woff2';
const subsetText = '🥳🧁🍰🎁🎂🎈🎺🎉🎊📧〽️🧿🌶️🔋😂❤️😍🤣😊🥺🙏💕😭😘👍😅👏';

const mySfntFontBuffer = Buffer.from(fs.readFileSync(inputFile));
(async () => {
  const subsetBuffer = await subsetFont(mySfntFontBuffer, subsetText, {
    targetFormat: 'woff2',
  });

  fs.writeFile(outputFile, subsetBuffer, 'binary', (err) => {
    if (!err) {
      console.log(`Subset written to: ${outputFile}`);
    } else {
      console.error(err);
    }
  });
})();

package.json:

{
  "type": "commonjs",
  "dependencies": {
    "subset-font": "^2.4.0"
  }
}

The font generation process works, but the resulting font doesn't have working emoji, even though they are included in the font. You don't see emoji when trying to enter them using an emoji keyboard (or copy-pasting from a website listing emoji).

I've tried both WOFF2 and SFNT (.ttf) output to no avail.

Wakamai Fondue has this to say about the generated subset:

image

image

The original TTF in comparison:

image

Loading the original font in Godot 4.3:

image

Loading either of the subset fonts:

image

@Calinou Calinou changed the title Subsetting emojis from an emoji font results in Unicode codepoints being shifted around Subsetting emojis from an emoji font results in a non-working font Oct 29, 2024
@papandreou
Copy link
Owner

Can you confirm that the same subsetting works with hb-subset?

@Calinou
Copy link
Author

Calinou commented Nov 3, 2024

Can you confirm that the same subsetting works with hb-subset?

I've tried and it didn't work in Godot either.

NotoColorEmoji-subset.zip

Command line:

hb-subset NotoColorEmoji-Regular.ttf \
  --text="🥳🧁🍰🎁🎂🎈🎺🎉🎊📧〽️🧿🌶️🔋😂❤️😍🤣😊🥺🙏💕😭😘👍😅👏" \
  --output-file="NotoColorEmoji-Regular-subset.ttf"

However, this is actually most likely a Godot bug, so I'll close this for now.

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants