AlexanderOcias / UnityPixelArtCamera

Easy pixel art camera rendering in Unity
120 stars 12 forks source link

Can't render fonts correctly. #2

Closed Saishy closed 6 years ago

Saishy commented 6 years ago

First, thanks a lot for the asset!

My problem is, I've tried using canvas text, textmesh and textmesh pro, with a variety of fonts and all, but they seem to never align correctly, even tried all your shaders and some of mine but the problem persist:

https://i.imgur.com/bcqju6B.gifv

AlexanderOcias commented 6 years ago

Hey Saishy, the font asset just needs to be set up correctly.

Let me know if this fixes it up for you.

Saishy commented 6 years ago

Nope, I was doing exactly that. From over 30 fonts I tried, only 1 worked.

On Sun, Apr 22, 2018, 20:22 AlexanderOcias notifications@github.com wrote:

Hey Saishy, the font asset just needs to be set up correctly.

  • Regular Unity text: set the font asset's Font Size to the same value as you plan to use on the text object, "Rendering Mode" to "Hinted Raster", and "Character" to "Unicode" (a custom set of what you need). Then use the included Pixel Art Font material on your text objects, and set their Font Size to be the same as the font asset's. Check the example scene and its included font if you're unsure.
  • Textmesh Pro: when using the font asset creator, set the "Font Size" to "Custom Size" and set it to the size you plan to use, and set the "Font Render Mode" to "Raster" or "Hinted Raster". Then set your Textmesh Pro UGUI Text object's font size to be the same as the font asset's.

Let me know if this fixes it up for you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AlexanderOcias/UnityPixelArtCamera/issues/2#issuecomment-383420347, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6zzDUnXOwDBd6m0CHUAmbvzpyAL3l0ks5trRC5gaJpZM4Te5ll .

AlexanderOcias commented 6 years ago

Alright, can you please upload and send me a repro project?

Saishy commented 6 years ago

FontTest.zip

Saishy commented 6 years ago

Sorry I forgot to add a textmesh too.

AlexanderOcias commented 6 years ago

Ah right I see, the issue is with world space canvases specifically. The thing to do is set the scale of your world space canvas to (1/PixelsPerUnit) to make sure the font size matches up. Does this render correctly for you?: FontTest - Fixed.zip

Saishy commented 6 years ago

Thank you!!! ... Is there actually an explanation to this?

Also about textmesh, is there a way to render them correctly? Their pixel also don't match.

AlexanderOcias commented 6 years ago

Yeah, canvases don't know about the pixels-per-unit setting when it comes to their transforms, so they treat 1 unit = 1 font size. The Pixel Art Camera configures the main canvas's scaler to correct this automatically, but world space canvases need to be adjusted manually.

As for the textmesh pro issue, I did commit a small fix to repair some minor canvas rendering issues yesterday, so grab that first to see if it helps. But on my end it seems correct: screen shot

If you're getting something else, please send through another screenshot/video.

Saishy commented 6 years ago

This is a textmeshpro not attached to any canvas: https://i.imgur.com/8zwyMkO.gifv Also even a textmeshpro in a canvas will glitch at some positions: https://i.imgur.com/38NJFAo.png Here is 0.1 to the side: https://i.imgur.com/dpdJmfx.png

But the worse is that I really need to be able to use a TextMesh (or even textmeshpro, dunno) that is not attached to a canvas, as canvas does not support materialpropertyblock and I need dynamic outline with colors: https://i.imgur.com/UGleWfX.gifv (This is a normal TextMesh)

AlexanderOcias commented 6 years ago

Right, got it.

Well the solution for non-canvas textmeshpro objects is to set the scale of the object to (1/PixelsPerUnit*10), so 0.625 if your ppu is 16. I'm not exactly sure why this is yet, but that's how I'm able to get to something workable for now.

Saishy commented 6 years ago

Oh, normal textmeshes also seem to be fixed by that!

https://i.imgur.com/4cZ011y.gifv