Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

phantomjs not rendering emoji characters correctly #12461

Closed
sth519 opened this issue Aug 16, 2014 · 6 comments
Closed

phantomjs not rendering emoji characters correctly #12461

sth519 opened this issue Aug 16, 2014 · 6 comments
Labels

Comments

@sth519
Copy link

sth519 commented Aug 16, 2014

I'm trying to render a page that includes emoji characters into a PNG file.
However, the emoji characters (multibyte utf-8) are not displayed correctly.

no-emoji

I'm using phantomjs 1.9.7 (from homebrew) on OS X 10.9.
The page renders correctly in normal browsers.

@monkeycraps
Copy link

it display at web brow correctly, at mac os, with AppleColorEmoji
©😊(^__^) 嘻嘻……🐦🌰বাংলা bn হিলিয়ামΩ

but when render pdf, it dose't contain the emoji, i've install the ttf font , at my computer, set it by font-face

@font-face {
    font-family: 'AppleColorEmoji';
    font-style: normal;
    font-weight: normal;
    src: url('font/emojione-apple.ttf');
}
body {
    font-family: 'FZCHYJW', 'fzltxh', 'AppleColorEmoji', 'Georgia', 'arial', 'sans-serif';
}
<span>©😊(*^__^*) 嘻嘻……🐦🌰বাংলা bn হিলিয়ামΩ</span>

@CoryDanielson
Copy link

Did either of you find a solution to this? A specific set of fonts that solved it?

@monkeycraps
Copy link

no 囧

@ashwinrathod78
Copy link

ashwinrathod78 commented Oct 27, 2017

Hello,

I am trying to add emoji in html file in div and span tag. phantomjs is not rendering emoji characters .

I am using below mentioned html code:

<html>
	<head>
		<meta content="text/html;charset=UTF-8" http-equiv="Content-Type" />
		<title></title>
	</head>
	<body>
                   I am 🐧 one
		  <br/>
		 <div>
			<span>I am second🐺🐗and again 🐧Third</span>
		 </div>
	</body>
</html>

I am getting [] (square symbol) at the place of emoji as shown below.
image

Your help is really appriciate.

thanks

@CoryDanielson
Copy link

CoryDanielson commented Oct 27, 2017

I used twemoji to fix it for me. Twemoji replaces emoji characters with images of the emojis.

https://github.com/twitter/twemoji

My code looks like this (it uses jQuery and Lodash which are optional)

// Looks through all text nodes of elements passed in, and replaces the emoji characters with an <span><img class='emoji'.../></span>
// See https://github.com/twitter/twemoji
// If you'd like to size the emoji according to the surrounding text, you can add the following CSS to your stylesheet:
// img.emoji {
//    height: 1em;
//    width: 1em;
//    margin: 0 .05em 0 .1em;
//    vertical-align: -0.1em;
// }
export const replaceEmojisWithImagesInElements = (elements: HTMLElement[]) => {
        // Don't call elements.forEach, phantomjs doesn't like that for some reason
        // if not using _.forEach, maybe do for loop (i = 0; i < elements.length; i++)
	_.forEach(elements, element => twemoji.parse(element));
};

I call that function like this

replaceEmojisWithImagesInElements($('.TextWithEmojis'));

@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants