How to make ANY pixel perfect font with Unity's Text Mesh Pro Component!

  Рет қаралды 19,893

Zac Marvin

Zac Marvin

Күн бұрын

Пікірлер: 88
@Manas-co8wl
@Manas-co8wl Жыл бұрын
I got it. I experimented with the same dimensions (7x9, b2) and this is how I got undistorted pixel perfect text, as well as having the same ppu as my game objects (16ppu): If you don't touch the output settings at all in your converter site, the default should be like this: em 1024, ascent 768, descent -256, and pixel size 128. Your target fontsize, that is the [Font Size] variable in your ttf inspector, should always be em / pixel size. In this case 1024 / 128 = 8. This is how you never get distortions in your pixel. By the way, the default output settings would be wrong in this case; the ascent should be 128 * 7, so 896 not 768. If you don't do this, you have to manually adjust the line spacing setting in Unity.. which is a pain you don't have to deal with if you set your ascent right. Actually the ascent should be "minimum" 7, which means that the ems would just touch each other. (The tail of g and head of T, for example.) You can give as many space as you want in between lines via ascent. I gave it one more pixel, so that's 128 * 8 = 1024 ascent. And your em should be 1024 ascent - (-256) descent = 1280. And your target Font Size will be 1280 / 128 = 10. You can decrese your descent rather than increasing your ascent size for line spacing, if you want. It really doesn't matter, I think. /// The following step is for those who want "exact perfect ppu" as your game objects, and with pixel snapping too. /// This means you can't use UI scaling or dynamic "media-queried" sizing... but you can make texts that match the style and grid of your game. /// It can also be kind of awkward if you have non-gameobject UI elements... so you'll probably have to make those just gameobjects too. Next, you don't use tmp font or even legacy font. Instead, you make your text a regular gameobject and make it textmesh. This is because the UI elements are impossible to get the right pixel size by manipulating the fontsize. Instead, go to your font inspector, and select the inner ellipsis menu (three dots). Press 'Editable Copy' and you'll get a texture, material, and a new font copy. You can edit the texture however you want, just as you'd with textmesh pro. Just make sure it's point filter. (I don't think ppu matters here.) Make a gameobject. Give it a TextMesh component and drag the new font copy into its font. I have no idea why, but the font will have a 10 ppu no matter which dimensions you've first drawn with. If your target ppu is x, make your fontsize 10 / x. For example, for 16 ppu, make your fontsize 0.625. Now you have a perfectly sized text. If your game world camera is pixel perfect, it will You can go a step further from here. Your text will have pixel perfection if your camera is pixel perfect. This is because your text is now a gameobject not a ui object. However, you'll find that it doesn't quite pixel snap to the same ppu as your game objects, but to a fraction of it. To create perfect pixel snapping, you have to make a script, attach it to the text gameobject, and place this: transform.position = new Vector3( Mathf.Round(transform.position.x * pixelsPerUnit) / pixelsPerUnit, Mathf.Round(transform.position.y * pixelsPerUnit) / pixelsPerUnit, transform.position.z ); where pixelsPerUnit is your target ppu. Depending on whether your text moves or not, you may have to call this at awake or update. Now if you move your text around, you'll find that it has the exact same ppu, non-distorted, and snapping at your pixel perfectly. It might be a bit harder to manage. You might have to make a separate UI camera for this (if you have that script, you don't need a pixel perfect camera). But you can honestly just make it work with one camera via sorting layers or z sorting, and making your ui follow the camera. It's easy to do that in a 2d game. /// That was long... but this took me more agonizing days than it ever should, and I wanted to make some more good out of it. Hopefully someone else can benefit from this.
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
Wow really insightful! Thank you so much. Gonna pin this to help future viewers
@kappis06
@kappis06 Жыл бұрын
This really helped, thank you so much!
@sofern2681
@sofern2681 Жыл бұрын
why is it this hard to make a font pixel perfect lol
@danielwalley6554
@danielwalley6554 Жыл бұрын
Thank you kindly!
@Kevin-fp9bu
@Kevin-fp9bu Жыл бұрын
I try change the texture but i can see anything change. :S What am i doing wrong? :(
@pengoo1933
@pengoo1933 2 жыл бұрын
Why is this the only good tutorial on fonts, like, does no one use text in their games? Thanks so much my guy!
@pengoo1933
@pengoo1933 2 жыл бұрын
I had a huge head ache even with this tutorial were the font would ALMOST be right but just a bit of and the thing that fixed it was just leaving the font size as 16 if anyone else has a similar issue
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
I’m so glad it helped you!
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
Glad you got it worked out!
@user-gr5bv4op7d
@user-gr5bv4op7d 2 жыл бұрын
Thanks so much, this has helped me immensely. Amazed how complex sorting out fonts is.
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
You're very welcome!
@Tiny_Tree
@Tiny_Tree 11 ай бұрын
Why do the silhouettes of your letters change when you begin to start dragging the correctly coloured versions over? Im having issues with my font and im rewatching the video and im wondering if you missed a part which is why im having issues. Thanks.
@ZacMarvinGameDev
@ZacMarvinGameDev 10 ай бұрын
It can be a little quirky. I’ve noticed that too
@giannimorrone696
@giannimorrone696 5 ай бұрын
You're an animal, bro. Thanks a lot for this. My font came out like garbage, but you give a full walkthrough, and I learned a lot.
@giannimorrone696
@giannimorrone696 5 ай бұрын
I tried again, with a standard pixel art font, like in 8 bit and arcade games (one color), but it comes out weird, I followed you step by step and didn't work out.
@ZacMarvinGameDev
@ZacMarvinGameDev 4 ай бұрын
Glad I could help!
@ZacMarvinGameDev
@ZacMarvinGameDev 4 ай бұрын
Interesting. Did you play with the values at all?
@franchisethebull
@franchisethebull Жыл бұрын
Keep coming back to this, thanks for the good method of tackling this
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
Really glad it’s helping you out!
@crimecommitter
@crimecommitter 2 жыл бұрын
Great tutorial! To save time, I found that if I only use the letter outlines when making the font, I can overlay the atlas on a white background and just cut out the bits I want to keep transparent. Hopefully that helps!
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
Great tip! That probably speeds things up quite a bit!
@NihongoWakannai
@NihongoWakannai Жыл бұрын
thanks for the video! this really helped a lot. I ended up coloring my text red and outline green so I could easily make a shader to replace the colors with anything.
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
That’s awesome
@OhDangTheJam
@OhDangTheJam 2 жыл бұрын
Dude, thanks so much. I've spent almost my whole afternoon trying to figure this out. It's crazy since having this functionality seems pretty basic as far as having a readable font in a pixel game goes, I'm surprised there isn't an easy way to do it. As for the easier way to replace all the characters, after I extracted the atlas, I just used a global magic wand & fill tool to fill everything as white, then a contiguous magic wand to select and delete the background.
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
So glad I could help! That’s a good idea to use the global magic wand!
@d_gonzaga
@d_gonzaga Жыл бұрын
when I "Extract Atlas" from my font asset, my letters in the png is all blurry... why? I followed all steps explained in the video
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
Hmm you may need to play with the settings of the font asset creator
@gabrielguimaraesdealmeida173
@gabrielguimaraesdealmeida173 2 жыл бұрын
Great video man, it really helped me. Keep up the good work
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
Glad to hear it! Thank you!
@11jedenjeden
@11jedenjeden 10 ай бұрын
If you are zooming as far as you can and have grid enabled you may see some disalignemnt. I found that changing Shader type to TextMeshPro/Mobile?Distance Field SSD helps a lot and is perfect.
@ZacMarvinGameDev
@ZacMarvinGameDev 10 ай бұрын
That’s great!
@fyi_cinnamontoast
@fyi_cinnamontoast 10 ай бұрын
To get a proper look without dragging all the characters by hand, increase the "sampling point size" and "Atlas Resolution". This will generate the font with all the forms preserved properly.
@ZacMarvinGameDev
@ZacMarvinGameDev 10 ай бұрын
Sweet!
@reganmusicnz
@reganmusicnz 10 ай бұрын
When using the FontAssetCreator and pressing the "Generate Font Atlas" button for my ttf (exported from the pixel font converter tool), I get an error saying it failed and possibly the font is invalid. I pasted the character set perfectly. If I don't use custom-set and just leave it set to Dynamic, I get no errors. What could I be doing wrong?
@ZacMarvinGameDev
@ZacMarvinGameDev 10 ай бұрын
Hmm, I’ve never experienced those errors before. Does it do the same thing in a fresh unity project? That would narrow it down to something with your file
@reganmusicnz
@reganmusicnz 10 ай бұрын
@@ZacMarvinGameDev Yeah have tried a new Unity prj. No luck. I'm not sure it matters actually though, as it seems to detect my characters perfectly fine when simply set to Dynamic. An additional setting found in the font asset before taking it into the FontAssetCreator is "Include Font Data" which I assume is doing what you'd normally use the custom input interface for, probably automatically includes the character set I'd otherwise be inputting/pasting manually? I'd love someone from Unity to chime in on this because it doesn't make a heck of a lot of sense. Their documentation doesn't seem to assume we have any use for custom fonts like this. An additional step I had to do with my fonts is, in the Output tab of the online converter tool, I had to set Pixel Size to 32 or my fonts would be all squished and overlapping. No idea what this setting does or why it has to be 32 (I just took its suggestion to try Power-of-2 values, my font tiles are actually 24px).
@jameslafritz2867
@jameslafritz2867 2 жыл бұрын
Also in the Online Tool that you are using there are options to change for Output, Pixel Size, Em size, Ascent, and Descent. Set Descent to Pixel size * by the Number of Pixels below the base line, in your case pixel size is set to 64 * 3 = -192 Ascent will be Pixel size * number Pixels above the base line 64 * 7 = 448, then Em Size would be 448 + 192 = 640. Or using 32 for the Pixel Size 224, -96, 320. Again I am not sure if this will help with Duel Color Fonts.
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
Awesome thank you!
@danieles6684
@danieles6684 Жыл бұрын
Hell yeah, this video did me up good. Thanks!
@ZacMarvinGameDev
@ZacMarvinGameDev 10 ай бұрын
So glad!
@kappis06
@kappis06 Жыл бұрын
Each character in my font is 7 pixels wide and 8 pixels tall. Nothing works with Sampling Point Size in the Font Asset Creator, 7 is too little and 8 is too much. Does anyone know how to make it work? Thanks
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
Check out Manas comment section! I’ll pin it to the top of the thread. It may help you!
@kappis06
@kappis06 Жыл бұрын
@@ZacMarvinGameDev It helped, thank you (and Manas) so much!
@homuhomudance
@homuhomudance Жыл бұрын
I had to use a sampling point size of 8 to get it to work, otherwise the letters in the atlas would be all distorted. Which is odd cause my font was the exact same size as yours (7x9).
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
After further research it seems point size isn’t exact. My exact pixel perfect point size is 8.6125 for some reason. Doing more research on this as we speak
@leomonge2626
@leomonge2626 Жыл бұрын
Thanks for the tutorial. Something so obvious yet so booooring and time consuming. Got a question: What happens or how can I add to the atlas a new letter? Say for example I have to translate something to another language and they add leters. Can I manually add them and reference it? Because I believe different file, different atlas...Thanks
@ZacMarvinGameDev
@ZacMarvinGameDev 10 ай бұрын
Unfortunately it’s a different atlas and I haven’t found a better way to do it than recreating the whole thing
@linedoltrainerchannelgammi2247
@linedoltrainerchannelgammi2247 Жыл бұрын
what do you use to make pixel custom text?
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
Usually just aseprite!
@mairinger80
@mairinger80 2 жыл бұрын
Thanks for sharing! I was looking for a way to use an existing font from a classic game‘s spritesheet and this will be helpful. Regarding dual color, would the Outline effect in TMP not be an option?
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
No problem! From my experience the outline effect with text mesh pro works well with regular fonts but with pixel fonts the outline isn’t pixel perfect and can make the font look off
@ZeroStas
@ZeroStas Жыл бұрын
Probably faster would be just make letter without outlines, then draw just outline or use outline filters.
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
Not a bad idea
@crookedstudio4090
@crookedstudio4090 2 жыл бұрын
Thank you for the awesome tutorial! I think it's time I bite the bullet and make several of my own fonts for my game. It took me a while to realize that since you can't really scale a pixel font and keep your target pixel resolution, it becomes a matter of finding several fonts that were created in the various sizes you need for titles, headers, and body. This is almost impossible to do sourcing fonts online. Question: Are you doing any math to land on a 36 pt font size in your TMP Text component, so it meets your target pixel resolution?
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
I wish I could tell you some formula to figure that out but unfortunately it was just trial and error for me to figure out the proper sizing
@crookedstudio4090
@crookedstudio4090 2 жыл бұрын
I think I may have made some sense of it! I was operating on the assumption that font size has a 1:1 relationship with pixels, but this is actually false. My font was 11 pixels tall, and is actually considered a 8 point font (you can look up a conversion chart, unfortunately I can't post it in comments) Once I adjusted my font asset + TMP font asset settings to all match 8 pt, as well as configured Canvas to my desired 640 x 360 scale, everything slid into place.
@pengoo1933
@pengoo1933 2 жыл бұрын
Bro if it wasn't for you and this tutorial I probably would have spent more time than the entire rest of my game just trying to make the stupid UI
@mairinger80
@mairinger80 2 жыл бұрын
Thanks a lot, got it working!
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
Awesome! Glad I could help!
@retronos0
@retronos0 2 жыл бұрын
I can't believe how well this worked. God bless you and everyone you love, fellow tutorial man! thanks from the bottom of my heart
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
So glad to help!
@random_precision_software
@random_precision_software 2 жыл бұрын
Thanks your a life saver.!
@coJetty
@coJetty Жыл бұрын
Thanks!
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
No problem!
@jameslafritz2867
@jameslafritz2867 2 жыл бұрын
Did you try setting the Sampling point size to a larger size? you set it to 7 but that is smaller then the size of your font, You r Height was 9. I do not know if that makes a difference with the dull color font. You can get a better layout by better adjusting the Atlas Resolution, Change the Height to the smallest possible size as well. There is no way to make it pack the atlas by the same way that you drew them, It compresses the images together, in order to use the online tool you have to have it in a grid, Unity and TMP PRO pack them together, by the size of the image.
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
I’m not entirely sure why 7 seemed to work but it does. I’ll look into what you said a little more because I’m going to have to make another pass on the font to add localization characters
@jameslafritz2867
@jameslafritz2867 2 жыл бұрын
@@ZacMarvinGameDev p.s. thanks for the great tutorial. You gave me a new tool to play with, I had a project that I am working on converting from XNA studio that has several sprite fonts, the tools you pointed me to made it much easier to use. Before this I had to use the text atlas of Textmesh and convert all my strings to hex.her. These tools made it much easier
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
@@jameslafritz2867 that’s great news! So glad I could help!
@kristiyanaleksiev8403
@kristiyanaleksiev8403 2 жыл бұрын
yo really helpful thanks
@artcadedev
@artcadedev Жыл бұрын
Thanks for the tutorial however it would be much better if the video goes straight into the tutorial
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
Noted! Will do this in the future
@TheGameLecturer
@TheGameLecturer 2 ай бұрын
Nice !
@ZacMarvinGameDev
@ZacMarvinGameDev 2 ай бұрын
Glad to help!
@vomgame
@vomgame Жыл бұрын
It's working 😄
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
That’s great news!
@alergames147
@alergames147 2 жыл бұрын
W tutorial
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
Thanks!
@amisner2k
@amisner2k 2 жыл бұрын
Good tutorial, but I'd recommend getting rid of the facecam. I don't need to see who's talking to me, I need to see what's being shown on screen.
@ZacMarvinGameDev
@ZacMarvinGameDev 2 жыл бұрын
Good to know! Thanks
@tgijukebox3401
@tgijukebox3401 2 жыл бұрын
@@ZacMarvinGameDev Facecam is good
@carlosdalomba
@carlosdalomba Жыл бұрын
Late here, but I like the facecam! Perhaps during snippets where we need to see what's under it (on your screen), you could hide the facecam temporarily during that short section of the video? (If it's not too much work -- it wasn't a big deal for me!) Awesome tutorial video, thanks for the guidance with fonts/pixel art (which is oddly hard to find info on online!)
How to make Pixel Art Fonts!
9:23
Pixel Overload
Рет қаралды 89 М.
How I learned Unity without following tutorials (Developing 1)
18:11
Game Maker's Toolkit
Рет қаралды 2,1 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 17 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 107 МЛН
路飞做的坏事被拆穿了 #路飞#海贼王
00:41
路飞与唐舞桐
Рет қаралды 26 МЛН
How to make a Save & Load System in Unity
26:56
Shaped by Rain Studios
Рет қаралды 205 М.
Make a Pixel Art Font - Beginner Tutorial
11:45
MortMort
Рет қаралды 73 М.
Making UI That Looks Good In Unity
18:06
Game Dev Guide
Рет қаралды 695 М.
Sprites inside your text boxes! How to use sprites in Unity Text Mesh Pro
5:38
Christina Creates Games
Рет қаралды 20 М.
An Aseprite Crash Course In 30 Minutes
31:47
AdamCYounis
Рет қаралды 1,1 МЛН
Unlocking The Power Of Unity's Scriptable Render Pipeline
21:05
Game Dev Guide
Рет қаралды 225 М.
TextMeshPro - Dynamic Font Asset Creation Process
20:49
Zolran
Рет қаралды 34 М.
Pixel Art Animation. Reinvented - Astortion Devlog
4:41
aarthificial
Рет қаралды 2,1 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 17 МЛН