2 color font

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

346752--12082--$fontexample_204.png

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:

Shader "GUI/Text Shader 2" {
Properties {
	_MainTex ("Font Texture", 2D) = "white" {}
	_BumpMap ("Base (RGB)", 2D) = "white" {}

	_Color ("Text Color", Color) = (1,1,1,1)
}

SubShader {
	Tags {"Queue" = "Transparent"}
	Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }
	Blend SrcAlpha OneMinusSrcAlpha
	Pass {
		Color [_Color]
		SetTexture [_MainTex] {
			combine primary, texture * primary
		}
		SetTexture [_BumpMap] {
			combine texture * previous, previous * texture
		}
	}
}
}

Just put the outlined font image to both texture slots. Then just replace the GUIText’s material with the material you just created.

Hey,
thanks much for that.
I cant seem to track down the font to image script though…
Thanks,
Chris

It’s http://www.unifycommunity.com/wiki/index.php?title=SaveFontTexture

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 :smile:):
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 :smile: