mcraiha / Unity-UI-emoji

Show emoji images in Unity UI text
174 stars 35 forks source link

non monospace fonts #2

Open eporral1 opened 7 years ago

eporral1 commented 7 years ago

Hi, thank you for this package, it saved me a lot of work :)

Is it possible to make it work with non mono-space fonts ? Using a non mono-space font (with a ui text inside a layout) makes the emojis position incorrect

I had to change the following line

TextGenerator textGen = textToEdit.cachedTextGenerator;

to

TextGenerator textGen = textToEdit.cachedTextGeneratorForLayout;

Here is an example

image

Thanks!

mcraiha commented 7 years ago

I did not test this with layouts. So if the layouts alter the positioning of characters then the Vector3 imagePos... part will be calculated incorrectly and emoji positions will be wrong.

eporral1 commented 7 years ago

Hi, thank you for your reply!!! I have the same issue without layouts, but using a non monospace font

image

It seems there are missing spaces, how can I fix this ?

Thank you!

mcraiha commented 7 years ago

Check that your font has em quad character (U+2001). And if it is there then check that it is actually occupies square area.

eporral1 commented 7 years ago

Hi @mcraiha , I've just realized that I had a wrong pivot x:

Pivot X 0.8 Pivot Y 1.6

I changed Pivot X to 1.6 and got it to work, even with layouts !!

Thank you so much for your help!

Esteban