How to include custom Fonts in build (pink squares problem)
(I hope I'm not double posting as the page asked me to log in after my previous question but it was gone after that.) I tried to search google like crazy to fix this in a similar fashion as I did with the Shaders turning pink, that is, by going to Graphics Inspector and adding them there, but I've found no such setting with custom Fonts. I've imported the font into the Assets folder, tried all the different settings in the Font Inspector (Include Font Data On/Off, Dynamic, Ascii, Unicode etc. etc.) but none of them have been included in the game when I have built it. Is there some sort of way of forcing Unity to include the custom Fonts in the build? If they're not included then they'll turn up as pink squares in the build. Anyone?
Answer by 5c4r3cr0w · May 09, 2016 at 11:37 AM
Add this Shader to your fonts.
Shader "GUI/3D Text Shader" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting Off Cull Back ZWrite Off Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Color [_Color]
SetTexture [_MainTex] {
combine primary, texture * primary
}
}
}
}
You'll be able to add your fonts.
Hey thanks, I made the Shader now, but realized I've never added a Shader script to text before. What's the best way to go about it?
You are supposed to add this shader to the material of the text you're using . i.e. your font material.
Ok so now I figured out that the text component needs a material as well :) Thanks for that, problem solved. Was confused because Unity was still drawing the text correctly in editor even without a material.
Answer by vtran · Jan 12, 2017 at 07:00 PM
I ran into a similar problem where the fonts were not included in the build at all when viewing the editor.log after a build. I fixed it by moving the fonts into a Resource folder.
Your answer
![](https://koobas.hobune.stream/wayback/20220612080437im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
magenta screen on game start on iOS port of a game 0 Answers
Build Font Changes on different computer. 1 Answer
Pink / Purple artifacts after building Baked lights 0 Answers
Why does my font stop rendering after some builds? 0 Answers
Unity (default) Fonts going pink in build (pink squares!!!!) 0 Answers