Php function imagettftext () for writing text using emoticons

I use the imagettftext function to write text on the image, but my text contains emoticons and it replaces the emoticons with a square square.

Here is my code:

$black = imagecolorallocate ( $main_img, 0x00, 0x00, 0x00 );
$font_path = "Arial.ttf";
imagettftext ( $main_img, 14, 0, 73, 685, $black, $font_path, $text );

Text:

test testt😘 Hello 👋💐 Those 👏  Mega x 👊❤️  Graphic 💋

I tried to change the font, which is "Arial Unicode", but its problem is not resolved.

How can I solve this problem?

Thanks in advance.

+4
source share
5 answers

First, we need to understand how emojis is implemented:

Apple PNG images (SBIX table)

Apple , TrueType/OpenType, PNG . PNG . Google , Apple.

Mozilla Adobes SVG ( SVG).

- : SVG OpenType. Unicode char SVG-. SVG, , . Firefox 26!

Microsoft COLR/CPAL

Segoe UI Emoji TrueType/OpenType. Unicode-, " ". : COLR . CPAL ( " " ) . ( .) , , .

GoogleGogles PNG ( CBDT/CBLC).

Google , PNG . . , , , . , . , , CSS. , , GLYF - , "" , - , , . FreeType, Android Linux, OpenType Windows Apple.


: 1 2

- , . , imagefttext - , PHP GD. GD FreeType .

Emojis FreeType 2.5. php -i, , FreeType. :

FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.5.2

, , , PHP :

Warning: imagefttext(): Could not set character size

, GD- FT_LOAD_COLOR. . . FreeType:

2013-05-23  Behdad Esfahbod  

    Add support for color embedded bitmaps (eg. color emoji).

    A new load flag, FT_LOAD_COLOR, makes FreeType load color
    embedded-bitmaps, following this draft specification

      https://color-emoji.googlecode.com/git/specification/v1.html

: , imagefttext. .

:

- GD. , GD 1-3 UTF-8. Emojis 4 UTF-8.

: https://github.com/libgd/libgd/blob/master/src/gdft.c#L341

Emojis UTF-8: http://apps.timwhitlock.info/emoji/tables/unicode

+3

unicode emoji. Symbola

+1

, ? , , charmap . Arial : ☺☻☼♀♂ ♠ ♣ ♥ ♦ ♪ ♫ ♯ - . php.net

+1

PHP ImageMagick. emoji, , , Unicode, DG.

, IM - , , - .

,

+1

:

0
source

Source: https://habr.com/ru/post/1605883/


All Articles