Fuente de Tamil Android entre la palabra inglesa
Estoy teniendo un TextView que tiene un texto enorme entre tengo una palabra de tamil y sé cómo incrustar la fuente de tamil en textview separado. Pero necesito la palabra de tamil entre la palabra inglesa por favor ayuda gracias de antemano
Mi parte del texto en textview:
- Cómo iniciar la barra de acción contextual para ver el texto de forma programática con opions por defecto copiar y seleccionar todo?
- Cómo configurar un efecto ripple en textview o imageview en Android?
- Mantener texto en TextView con drawableLeft centrado
- Cómo hacer que el TextView arrastre en LinearLayout suave, en android?
- El interfuncionamiento de TextView
Los mensajes estacionales como welcome (நல்வரவு) se usan en Kolam. Voluntariado para dibujar kolam en el templo a veces se hace cuando un devoto
- Abrir vínculos de TextView en otra actividad, no en el navegador predeterminado
- Cómo procesar textview para HTML y Linkify
- ¿Cómo puedo cambiar el color del textView android.R.layout.simple_spinner_dropdown_item?
- Establecer el estilo TextView (en negrita o en cursiva)
- ¿Con qué frecuencia puede actualizar una vista de texto sin desorden
- Cómo eliminar ellipsized propiedad de TextView de código?
- Estilo TextView como un Spinner con appcompat v21
- Cómo cambiar fontFamily de TextView en Android
Intente establecer esta fuente Akshar.ttf a su TextView a través de setTypeface, suuports Inglés y tamil.
Aquí está el resultado:
O bien, busque una fuente similar que soporte ambos idiomas.
Su segunda solución es usar la imagen para esta porción pequeña del texto de Tamil usando SpannableStringBuilder .
Código para configurar la fuente personalizada en TextView:
Suponiendo que tiene la fuente Akshar.ttf en la carpeta de fuentes en la carpeta de activos :
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Akshar.ttf"); TextView tv = (TextView) findViewById(R.id.CustomFontText); tv.setTypeface(tf); tv.setText("Seasonal messages like welcome (நல்வரவு) is used in Kolam. Volunteering to draw kolam at temple is sometimes done when a devotee's");
Hay otra solución si desea admitir varias fuentes dentro de un TextView, pero no se admiten en un solo ttf:
Utilice el siguiente código: (Estoy usando fuente Bangla y Tamil)
TextView txt = (TextView) findViewById(R.id.custom_fonts); txt.setTextSize(30); Typeface font = Typeface.createFromAsset(getAssets(), "Akshar.ttf"); Typeface font2 = Typeface.createFromAsset(getAssets(), "bangla.ttf"); SpannableStringBuilder SS = new SpannableStringBuilder("আমারநல்வரவு"); SS.setSpan (new CustomTypefaceSpan("", font2), 0, 4,Spanned.SPAN_EXCLUSIVE_INCLUSIVE); SS.setSpan (new CustomTypefaceSpan("", font), 4, 11,Spanned.SPAN_EXCLUSIVE_INCLUSIVE); txt.setText(SS);
El resultado es:
Clase CustomTypefaceSpan:
package my.app; import android.graphics.Paint; import android.graphics.Typeface; import android.text.TextPaint; import android.text.style.TypefaceSpan; public class CustomTypefaceSpan extends TypefaceSpan { private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Override public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Override public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); } private static void applyCustomTypeFace(Paint paint, Typeface tf) { int oldStyle; Typeface old = paint.getTypeface(); if (old == null) { oldStyle = 0; } else { oldStyle = old.getStyle(); } int fake = oldStyle & ~tf.getStyle(); if ((fake & Typeface.BOLD) != 0) { paint.setFakeBoldText(true); } if ((fake & Typeface.ITALIC) != 0) { paint.setTextSkewX(-0.25f); } paint.setTypeface(tf); } }
Referencia
Tuve este problema en Android 4.0. He encontrado que esto se debe a csc (Country Code). Si es una India entonces Tamil funcionando correctamente no funciona. Puedo confirmar esto.
Till ICS (4.0) no había ninguna fuente Tamil disponible en Android Systems. Incluso entonces tenía bugs y Google lo arregló todo con Jelly Bean (4.2).
Ahora, si quieres mostrar Tamil en tu aplicación, necesitas usar codificaciones TAB, TAM, BAMINI o TSCII.
Escribí una biblioteca simple que hace la conversión para usted dinámicamente . Todo lo que usted tiene que escribir es código simple como abajo.
// Initialise the Typeface (assumes TSCII, Bamini, Anjal, TAB or TAM font located inside assets/fonts folder) Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/mylai.ttf"); // Initialises the TextView TextView tv = (TextView)findViewById(R.id.textView1); //Setting the Typeface tv.setTypeface(tf); //Magic happens here ;) encoding conversion String TSCIIString = TamilUtil.convertToTamil(TamilUtil.TSCII, "வணக்கம் அன்ரொயிட்"); //Setting the new string to TextView tv.setText(TSCIIString);
He escrito más sobre este tema en esta respuesta. Por favor, compruébelo también.
- Envío de la carga útil de los pares clave-valor a Google Analytics
- Inconsistencia de SensorEvent.timestamp