Help with fonts in Application!

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Help with fonts in Application!

Postby stover » Wed Mar 25, 2009 3:15 am

Hi All,
I am working on a simple little app which uses some different fonts. I have searched the board and have found a few
other threads on this subject. I decided to implement what I needed in the following code (Not sure if it is correct though):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle savedInstanceState) {
  2.  
  3.                 super.onCreate(savedInstanceState);
  4.  
  5.                 setContentView(R.layout.main);
  6.  
  7.                
  8.  
  9.                 Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/teletype.ttf");
  10.  
  11.                 ScoreText = (TextView) findViewById(R.id.TextView01);
  12.  
  13.                 ScoreText.setTypeface(myTypeface);
  14.  
  15.         }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


The problem I am having is that when I create the "fonts" folder in the Android project (Using Eclipse 3.4/ADT) I get an project error.
If I put the ttf file in another folder (i.e. raw) inside my project it will compile but the font is not found or loaded. Anyone have any similar issues or know how to resolve this.

Thanks in advance for your help.

-Stover
stover
Freshman
Freshman
 
Posts: 4
Joined: Sat Mar 21, 2009 5:11 pm
Location: Morgan Hill,CA

Top

Postby kanzlr » Wed Mar 25, 2009 8:51 am

hm, i put mine in the fonts folder and it works...whats the error you are getting?
kanzlr
Developer
Developer
 
Posts: 25
Joined: Sun Mar 15, 2009 4:44 pm
Location: Vienna/Austria/EU

Postby stover » Wed Mar 25, 2009 5:53 pm

kanzlr wrote:hm, i put mine in the fonts folder and it works...whats the error you are getting?


If I put the *.ttf file in the assets/fonts folder. I don't get a build error but nothing happens when I execute the
application in the emulator. I have a simple XML file which just has a TextView on it.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:orientation="vertical"
  4.    android:layout_width="fill_parent"
  5.    android:layout_height="fill_parent"
  6.    >
  7.  
  8. <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello"></TextView>
  9. </LinearLayout>
  10.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Not sure what I am doing wrong here?
stover
Freshman
Freshman
 
Posts: 4
Joined: Sat Mar 21, 2009 5:11 pm
Location: Morgan Hill,CA

Postby kanzlr » Wed Mar 25, 2009 5:57 pm

uppercase/lowercase?
kanzlr
Developer
Developer
 
Posts: 25
Joined: Sun Mar 15, 2009 4:44 pm
Location: Vienna/Austria/EU

Postby stover » Wed Mar 25, 2009 6:05 pm

kanzlr wrote:uppercase/lowercase?


Whoops! That was the problem. The code says load "fonts/teletype.ttf" but the file in the fonts folder
is "fonts/teletype.TTF" Duh!

Thanks for your help. :)
stover
Freshman
Freshman
 
Posts: 4
Joined: Sat Mar 21, 2009 5:11 pm
Location: Morgan Hill,CA

Postby kanzlr » Wed Mar 25, 2009 6:13 pm

you know, linux is case sensitive :)
kanzlr
Developer
Developer
 
Posts: 25
Joined: Sun Mar 15, 2009 4:44 pm
Location: Vienna/Austria/EU

Top

Postby stover » Wed Mar 25, 2009 8:39 pm

kanzlr wrote:you know, linux is case sensitive :)


Yep. Just had some brain fade :( :D
stover
Freshman
Freshman
 
Posts: 4
Joined: Sat Mar 21, 2009 5:11 pm
Location: Morgan Hill,CA

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests