Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Ayuda con custom font

Iniciado por ElectroMan, Noviembre 25, 2016, 06:50:04 PM

Tema anterior - Siguiente tema
Noviembre 25, 2016, 06:50:04 PM Ultima modificación: Noviembre 25, 2016, 06:52:24 PM por ElectroMan
Estoy intentando crear una fuente a partir de una imagen PNG. Los carácteres son pixel art de 5x12 y parece que los parámetros los pongo bien porque en el texto de prueba sale el carácter correcto. El problema es que a veces me muestra píxeles de otros carácteres, no sé si me explico.
 
Por ejemplo, si le digo que imprima una A (de 5x12píxeles) hay frames en los que parece que muestra un píxel más de alto y se ve la primera linea de píxeles del carácter que tiene abajo en el PNG original... 
 
Otro problema es que no sé como poder darle diferentes tamaños a la fuente, al ser pixel art no necesitaría filtros y supongo que será más sencillo, pero cuando en el objeto de texto le cambio el tamaño de la fuente, no hace caso.

Hola, la verdad nunca trabaje con fuentes propias, pero lo poco que te puedo decir es con respecto al tamaño:
 
Generalmente uso estilos para determinar un tipo de fuente (GUI):
 

GUIStyle titleStyle = new GUIStyle();
titleStyle.alignment = TextAnchor.MiddleCenter;
titleStyle.fontSize = 60; // <-- tamaño de la fuente
titleStyle.normal.textColor = new Vector4 (, 1, , 1);
titleStyle.font = customFont; // <-- Aca pones tu fuente
//Dibujar Label
GUI.Label (Title_rect, "Title" , titleStyle);

 
Como es el proceso completo que haces para importar tu propia fuente a Unity?
 
viste las referencias con respecto a Fonts? sobretodo a lo ultimo (Custom Fonts)
 
https://docs.unity3d.com/Manual/class-Font.html
 
Dice esto:
 
************************************************************************************************************************
 
The Size field is for defining how many characters are in your font.
 
Within each Element there is an index field for the ascii index of the character. This will be an integer that represents the character in this element.
 
To work out the UV values you need to figure out how your characters are positioned on a scale of 0 to 1. You divide 1 by the number of characters on a dimension. For example if you have a font and the image dimensions on it are 256x128, 4 characters across, 2 down (so 64x64), then UV width will be 0.25 and UV height will be 0.5.
 
For UV X and Y, it's just a matter of deciding which character you want and multiplying the width or height value times the column/row of the letter.
 
Vert size is based on the pixel size of the characters e.g. your characters are each 128x128, putting 128 and –128 into the Vert Width and Height will give properly proportioned letters. Vert Y must be negative.
 
Width will be the width of your character in pixels.
 
************************************************************************************************************************
 
Puede ser que esten los UV's mal calculados?de CuantoxCuanto es tu grilla?

 

Cita de: lightbug date=1480102682Hola, la verdad nunca trabaje con fuentes propias, pero lo poco que te puedo decir es con respecto al tamaño:
   
   
      Generalmente uso estilos para determinar un tipo de fuente (GUI):
   
   

GUIStyle titleStyle = new GUIStyle();
titleStyle.alignment = TextAnchor.MiddleCenter;
titleStyle.fontSize = 60; // <-- tamaño de la fuente
titleStyle.normal.textColor = new Vector4 (, 1, , 1);
titleStyle.font = customFont; // <-- Aca pones tu fuente
//Dibujar Label
GUI.Label (Title_rect, "Title" , titleStyle);

   
      Como es el proceso completo que haces para importar tu propia fuente a Unity?
   
   
      viste las referencias con respecto a Fonts? sobretodo a lo ultimo (Custom Fonts)
   
   
      https://docs.unity3d.com/Manual/class-Font.html
   
   
      Dice esto:
   
   
      ************************************************************************************************************************
   
   
      The Size field is for defining how many characters are in your font.
   
   
      Within each Element there is an index field for the ascii index of the character. This will be an integer that represents the character in this element.
   
   
      To work out the UV values you need to figure out how your characters are positioned on a scale of 0 to 1. You divide 1 by the number of characters on a dimension. For example if you have a font and the image dimensions on it are 256x128, 4 characters across, 2 down (so 64x64), then UV width will be 0.25 and UV height will be 0.5.
   
   
      For UV X and Y, it's just a matter of deciding which character you want and multiplying the width or height value times the column/row of the letter.
   
   
      Vert size is based on the pixel size of the characters e.g. your characters are each 128x128, putting 128 and –128 into the Vert Width and Height will give properly proportioned letters. Vert Y must be negative.
   
   
      Width will be the width of your character in pixels.
   
   
      ************************************************************************************************************************
   
   
      Puede ser que esten los UV's mal calculados?de CuantoxCuanto es tu grilla?

       
   


 
 
Precisamente he seguido esa documentación. Al final lo de poder darle tamaño lo he arreglado haciendo la fuente a partir de una copia editable de una fuente TrueType. A esa fuente le he puesto un material con la imagen de los caracteres y luego he rellenado los campos. Ahora el problema es el de que parece que muestra pixeles de otros carácteres unas veces sí y otras no. A veces se muestran píxeles que no deberían como se ve debajo de la primera linea y del carácter 'd'. Pero otras veces lo muestra bien...
 

Osea, supongo que si son X de ancho e Y de alto (a 5x12) entonces tendrias:
 
- dimension de imagen (X*5) x (Y*12)
 
- UVs
 
     x = 1/X ,
 
     y = 1/Y
 
 

Etiquetas: