Skip to content

Instantly share code, notes, and snippets.

@zolex
Created April 30, 2012 08:56
Show Gist options
  • Select an option

  • Save zolex/2556694 to your computer and use it in GitHub Desktop.

Select an option

Save zolex/2556694 to your computer and use it in GitHub Desktop.
OpenGLES TTF Example
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000" >
<android.opengl.GLSurfaceView
android:id="@+id/glview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<TextView
android:id="@+id/something"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text=""
android:textSize="24dp" />
</RelativeLayout>
/*
* Example Activity
*/
class Xy extends Activity {
public static Typeface font;
public static TextView something;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.glview); // glview.xml
GLSurfaceView glView = (GLSurfaceView)findViewById(R.id.glview);
glView.setRenderer(this);
font = Typeface.createFromAsset(getAssets(), "some_font.ttf");
something = (TextView)findViewById(R.id.something);
something.setTypeface(font);
}
public void onDrawFrame(GL10 unused) {
this.unOnUiThread(new Runnable() {
public void run() {
Xy.something.setText("i'm looking good!");
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment