Пример #1
0
 public TTFTextTexturePortion ComputeGlyphBitmap(object parameters, object font, char c)
 {
     TTFTextTexturePortion p=new TTFTextTexturePortion(
     _texture,
     0,0,1,1,
     _textWidthPixels,_textHeightPixels,
     0,0,
     true
     );
     return p;
 }
        public TTFTextTexturePortion ComputeGlyphBitmap(object parameters, object font, char c)
        {
            SysFontTexture tex=new SysFontTexture();
            FontSelector fs=(FontSelector)GetFontSelectorFromFontName((string) font);
            tex.AndroidFontName=fs.AndroidFontName;
            tex.AppleFontName=fs.AppleFontName;
            tex.Update();

              Texture2D _texture = new Texture2D(1, 1, TextureFormat.Alpha8, false);
              //Texture2D _texture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
              _texture.hideFlags = HideFlags.HideInInspector | HideFlags.DontSave;
              _texture.filterMode = FilterMode.Point;
              _texture.wrapMode = TextureWrapMode.Clamp;
               	 int textureID = _texture.GetNativeTextureID();

            SysFont.QueueTexture(""+c,
            #if UNITY_ANDROID
            fs.AndroidFontName
            #else
            #if UNITY_IPHONE
            fs.AppleFontName
            #else
            ((string)font)
            #endif
            #endif
            ,
            12,
            false,//_isBold,
            false,//_isItalic,
            SysFont.Alignment.Left,//_alignment,
            false,
            2048,
              		2048,
            textureID
            );

            int _textWidthPixels  = SysFont.GetTextWidth(textureID);
            int _textHeightPixels = SysFont.GetTextHeight(textureID);

            SysFont.UpdateQueuedTexture(textureID);
            Debug.Log(".");

            Parameters cp =parameters as Parameters;
            Material m=null;
            if (cp!=null) {
              Shader shader=Shader.Find(cp.shaderName);
              if (shader==null) {shader=Shader.Find("Mobile/Diffuse");}
             	  if (shader==null) {shader=Shader.Find("Diffuse");}
              m=new Material(shader);
              m.color=new Color(cp.red,cp.green,cp.blue,cp.alpha);
              m.mainTexture=_texture;
            }
            else {
              Shader shader=Shader.Find("SysFont/Unlit Transparent");
              if (shader==null) {shader=Shader.Find("Mobile/Diffuse");}
             	  if (shader==null) {shader=Shader.Find("Diffuse");}
              m=new Material(shader);
              m.color=Color.black;
              m.mainTexture=_texture;
            }

            TTFTextTexturePortion p=new TTFTextTexturePortion(
            m,
            0,0,1,1,
            _textWidthPixels * cp.scale,_textHeightPixels *cp.scale,
            0,0,
            true
            );

            return p;
        }
        public TTFTextTexturePortion GetChar(char c)
        {
            //int idx=requested_characters.IndexOf(c);
            Rect q=quads[c];
            Rect r=rects[c];
            TTFTextTexturePortion portion=null;
            if (!packed_material) {
              portion=new TTFTextTexturePortion(packed_textures,
                r.x,
                r.y,

                r.width,
                r.height,

                q.width,
                q.height,
                q.x,
                q.y,
                false
                );
            }
            else {
              portion=new TTFTextTexturePortion(packed_material,
                r.x,
                r.y,
                r.width,
                r.height,
                q.width,
                q.height,
                q.x,
                q.y,
                false
                );

            }
            return portion;
        }