Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

2 color font

Discussion in 'iOS and tvOS' started by deadbug, Jul 15, 2010.

  1. deadbug

    deadbug

    Joined:
    Sep 9, 2009
    Posts:
    165
    Hey there,
    I am trying to find a way to use a font that *has a stroke around it*. Essentially it is 2 colors, black and white. and i believe that a .ttf that unity can import can only be a single color.

    To write two separate fonts , one black and one white on top in a smaller point size will not line up together.


    Has anyone tried to work with this?

    here is an example of what i am going for.



    Thanks much.
    Chris
     

    Attached Files:

  2. arzi

    arzi

    Joined:
    Apr 6, 2009
    Posts:
    154
    We've done this. Though this works only with GUITexts, not with OnGUI.

    You need to export your font to an image (there's a script for that in the wiki), then add the outline in Photoshop or simliar.

    Then create a new material use this shader for the text:

    Code (csharp):
    1. Shader "GUI/Text Shader 2" {
    2. Properties {
    3.     _MainTex ("Font Texture", 2D) = "white" {}
    4.     _BumpMap ("Base (RGB)", 2D) = "white" {}
    5.  
    6.     _Color ("Text Color", Color) = (1,1,1,1)
    7. }
    8.  
    9. SubShader {
    10.     Tags {"Queue" = "Transparent"}
    11.     Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }
    12.     Blend SrcAlpha OneMinusSrcAlpha
    13.     Pass {
    14.         Color [_Color]
    15.         SetTexture [_MainTex] {
    16.             combine primary, texture * primary
    17.         }
    18.         SetTexture [_BumpMap] {
    19.             combine texture * previous, previous * texture
    20.         }
    21.     }
    22. }
    23. }
    Just put the outlined font image to both texture slots. Then just replace the GUIText's material with the material you just created.
     
  3. deadbug

    deadbug

    Joined:
    Sep 9, 2009
    Posts:
    165
    Hey,
    thanks much for that.
    I cant seem to track down the font to image script though...
    Thanks,
    Chris
     
  4. arzi

    arzi

    Joined:
    Apr 6, 2009
    Posts:
    154
  5. megabrobro

    megabrobro

    Joined:
    Jul 8, 2017
    Posts:
    109
    Clicking this link gave my computer a popup virus and I did not get any Unity script. I found online same link but https and it works ok. Not sure if problem was my end: SaveFontTexture - Unify Community Wiki (unity3d.com) .

    Ah, anyway it seems this script is no longer needed (since quite a while ago :D):
    Note: this script isn't necessary in Unity 4, since in that case you can click on the font and choose "Create Editable Copy" in the gear menu in the inspector.

    Sorry for post reviving :D
     
    Last edited: May 23, 2021