how can i import musica fonts into eclipse to support musical unicode? Any workaround?
This is the simple one.
create a folder in the root of your project called assets/fonts/ then paste the TTF font file (in this case Verdana.ttf). Then, if you want to apply that font to, say a TextView, do the following:
public class FontSampler extends Activity {
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
TextView tv=(TextView)findViewById(R.id.custom);
Typeface face=Typeface.createFromAsset(getAssets(),
"fonts/Verdana.ttf");
tv.setTypeface(face);
}
}
This example was taken from the ComonsWare book (written by Mark Murphy). You can download the full example from GitHub .
Related
So, I am making a Game called Fall Down 4 and currently I am just using the built in font (the font that it usually comes with). Now, I want the Title to look more attractive and Good and to do that, i actually downloaded different fonts from Google. I Then created a assests folder and in that folder i copied the font that i installed in my computer (I looked at the different forums on stack overflow). Now my question is how Do i Change the default font to this new downloaded font. Like I just Don't know where to go to change the font of the Text.
I have seen many people ask this question on this fourm but what i want is different FONTS, a FONT that is not BUILT IN, i wannt to USE the FONT I DOWNLOADED and That is what I need help With.
So Please tell me step by step on how to change the font of the text to the font That I have installed in my computer.
The Code:
public class FallDown4TitleScreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fall_down_title_screen);
Typeface myTypeFace = Typeface.createFromAsset(getAssets(), "Spac3 tech free promo.ttf");
final Button playbutton = (Button) findViewById(R.id.Playbutton);
final Button custButton = (Button) findViewById(R.id.custButton);
final Button settingButton = (Button) findViewById(R.id.settingButton);
final TextView textView = (TextView) findViewById(R.id.textView);
textView.setTypeface(myTypeFace);
playbutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
custButton.setVisibility(View.INVISIBLE);
settingButton.setVisibility(View.INVISIBLE);
textView.setVisibility(View.VISIBLE);
playbutton.setVisibility(View.INVISIBLE);
}
});
}
}
If you are looking to set a custom TrueType font from your asset folder to some textviews or similar views, you could simply do like:
textview.setTypeface(Typeface.createFromFile(getAssets(),"fonts/yourfont.ttf"));
take a look at this discussion if you are looking to change the default font in your app:
Is it possible to set a custom font for entire of application?
However, mobile games generally use bitmap fonts, and draw that on canvas.
Hope that helped!!
I,m trying to show Sinhala Unicode characters in android app.
when i am using Samsung tabs or phones Unicode is running it on without problem.but it does not work on other phones or tab.cause there is no Sinhala Unicode.How to do this for an example i run this code on Samsung tab successfully.
Toast.makeText(this, "අන්තර්ජාල සම්බන්දතාවය තිබේ ", Toast.LENGTH_SHORT).show();
but other phones or tab does n't work.
You might need to have a Sinhalese font file (say, Sinhalese.ttf) in the directory assets/fonts in the root of your project. You create a dummy text view because it has a method called setTypeface, which sets the font for next code:
import android.graphics.Typeface;
public class FontSampler extends Activity {
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
TextView tv=(TextView)findViewById(R.id.custom); // a dummy text view
Typeface face=Typeface.createFromAsset(getAssets(),
"fonts/Sinhalese.ttf");
tv.setTypeface(face);
Toast.setView(tv).makeText(this, "අන්තර්ජාල සම්බන්දතාවය තිබේ ", Toast.LENGTH_SHORT).show();
}
}
This way, even if an android phone doesn't have a font installed, then the font embedded in your app will serve. Hope this helps.
If you want to render the Both sinhala and English in same text box then use Iskolapota font file.And do the same as #Nonymous answer says. It works for me.
Below is my code where I am using typeface correctly to change the font for the punjabi but it is still showing incorrect text on Galaxy S2 and punctuations on phones other than Samsung. Not sure how can I fix this
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Typeface tf = Typeface.createFromAsset(getAssets(),
"fonts/ANMOL_L.TTF");
TextView txt = (TextView) findViewById(R.id.text);
txt.setTextSize(40);
txt.setTypeface(tf);
txt.setText("ੴ ਸਤਿ ਨਾਮੁ ਕਰਤਾ ਪੁਰਖੁ ਨਿਰਭਉ ਨਿਰਵੈਰੁ ਅਕਾਲ ਮੂਰਤਿ ਅਜੂਨੀ ਸੈਭੰ ਗੁਰ ਪ੍ਰਸਾਦਿ ॥");
}
}
Try txt.setText("Testing"); And you will notice you will see Punjabi text. This is because the font you have chosen is not a Unicode compatible font. It overrides ASCII codes. Choose another font file.
I have tested AnmolUni.ttf and AmbarSlim.ttf files from http://www.gurbanifiles.org/unicode/ and they work.
I'm already working on an Android application that displays RSS feed.
My problem is that this feed has some lines in Tamil(which Android still doesn't support)
I found a font online that displays the text right(without converting to Bamini) but the problem is that textStyle doesn't have any effect on it.
so you know any font that can do the job or any thing i have to do to make textStyling?
thanks in advance
What you need to do is import custom fonts on to the phone before using them.
A good way to do that is to include them in the package - in the APK file
Hence you should be having the font in your project when you build the APK file.
Let me give you an example. Assuming your tamil font's name is Harabara.ttf and you have copied it to /assets/fonts
Use this method (anywhere in your activity)
private void initializeFonts() {
font_harabara = Typeface.createFromAsset(getAssets(), "fonts/Harabara.ttf");
}
and call this API from your onCreate like this
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initializeFonts();
setContentView(getViewResourceId());
}
Make sure you have declared this class level variable
Typeface font_harabara = null;
Finally, simply use
myTextField.setTypeface(font_harabara);
tada ! tamil font should now start displaying.
nandri vanakkam,
vaidyanathan
There are hundreds of fonts available online. Did you check some TSCII fonts?
I've written some solutions for Tamil and Android issues. Check it out too.
I have created an android application where I want to display unicoded bengali sentences.
For this I have done the following steps.
Step1: I store my bengali font named Siyamrupali.ttf in the Assets folder.
Step2: In main.xml file I took a text view where I display characters.
Step3: In my MainActivity. Java I wrote this...
public class mainAc extends Activity
{
AssetManager arabi_font;
TextView tx;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tx=(TextView)findViewById(R.id.tv);
try
{
String str="\u0986";
tx.setTypeface(Typeface.createFromAsset(getAssets(),"Siyamrupali.ttf"));
tx.setText(str);
}
catch(Exception ex)
{
tx.setText("font cannot load: "+ ex.toString() );
}
}
Then output show আ Which one is correct But When i wrote String str="\u0986\u09AE\u09Bf";
In MainActivity. Java
Then output shows আমই But i should be আমি
What can I do now to solve this problem. Any body give me some advice or link or sample code.
\u0986\u09A\u09BF is not a valid unicode character. I am afraid why you didnot get error. please have a look on the following like
Unicode character of Bengali scripts
Thanks
Android doesn't have full complex text layout support for all of Unicode yet, and Bengali matras are one feature that isn't rendered right. See issue 5925. Sorry!