New Emoji Component
In Symfony 6.2 we introduced a feature to transliterate and slugify emojis. This works by adding to the Symfony Intl component all the emoji data from the ICU library. This data includes the descriptions of all emojis and all its variants in all languages.
As a result, when you create a fresh new Symfony application, symfony/intl
takes more than 70% of the total installation size (43MB unzipped). This is going
to get worse as more emojis are added in the future.
That's why in Symfony 7.1 we've decided to remove the emoji data from Symfony Intl and move it to a new Emoji component. The only difference in practice is that when transliterating/slugifying emojis, you need to run this first in your project to install the new component:
1
$ compose require symfony/emoji
Emojify Twig Filter
For those applications that handle emojis, Symfony 7.1 adds a new emojify filter
that transforms the textual representation of an emoji (e.g. :wave:
) into the
actual emoji (👋):
1 2 3
{{ 'This is :+1: from me'|emojify }} {# renders: This is 👍 from me #}
{{ 'This is :+1: from me'|emojify('github') }} {# renders: This is 👍 from me #}
{{ 'This is :thumbsup: from me'|emojify('gitlab') }} {# renders: This is 👍 from me #}
The optional argument of the filter defines the emoji catalog that was used to
transliterate the emojis. The gitlab
catalog was also introduced in Symfony 7.1
by Antoine Lamirault`_ in `PR #54441.
A Common Emoji Text Code Catalog
Emojis are the same everywhere, but the text codes used to represent them vary
from one service to another. For example, 🥝 is :kiwi-fruit:
in GitHub,
:kiwi:
in GitLab, and :kiwifruit:
in Slack.
That's why in Symfony 7.1 we're adding a common emoji text code catalog
that merges the text codes of all the other catalogs into a single one called text
:
1 2 3
{{ 'I like :kiwi-fruit:'|emojify('text') }} {# renders: I like 🥝 #}
{{ 'I like :kiwi:'|emojify('text') }} {# renders: I like 🥝 #}
{{ 'I like :kiwifruit:'|emojify('text') }} {# renders: I like 🥝 #}
So good!
Is there unified font for these emojis as well? Because it's really ugly on Windows without custom font.
@Michal for Windows you have the Segoe UI Emoji font (https://learn.microsoft.com/en-us/typography/font-list/segoe-ui-emoji)
Other non-official fonts that you could use are Google's Noto Color Emoji (https://fonts.google.com/noto/specimen/Noto+Color+Emoji) and Noto B&W emoji (https://fonts.google.com/noto/specimen/Noto+Emoji)