All Projects → Drivemode → Typefacehelper

Drivemode / Typefacehelper

Licence: apache-2.0
Helper object for injecting typeface into various text views of android.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Typefacehelper

Space Grotesk
Space Grotesk: a proportional variant of the original fixed-width Space Mono family
Stars: ✭ 1,045 (+876.64%)
Mutual labels:  font, typeface
Css Mono
Monospaced Typeface Created for CSS Coding
Stars: ✭ 85 (-20.56%)
Mutual labels:  font, typeface
Some Time Later
Font inspired by the title and time cards in the Nickelodeon cartoon SpongeBob SquarePants
Stars: ✭ 62 (-42.06%)
Mutual labels:  font, typeface
Ufodiff
UFO source file diff application
Stars: ✭ 23 (-78.5%)
Mutual labels:  font, typeface
Lab Mono
Grotesque-esque monospaced typeface
Stars: ✭ 99 (-7.48%)
Mutual labels:  font, typeface
Kepler
Futuristic / minimal monospace typeface.
Stars: ✭ 9 (-91.59%)
Mutual labels:  font, typeface
Helmet
Neo-grotesque typeface
Stars: ✭ 84 (-21.5%)
Mutual labels:  font, typeface
Qiji Font
齊伋體 - typeface from Ming Dynasty woodblock printed books
Stars: ✭ 536 (+400.93%)
Mutual labels:  font, typeface
Victor Mono
A free programming font with cursive italics and ligatures. Donations welcome ❤️
Stars: ✭ 1,854 (+1632.71%)
Mutual labels:  font, typeface
Work Sans
A grotesque sans.
Stars: ✭ 1,319 (+1132.71%)
Mutual labels:  font, typeface
Android Robototextview
Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab fonts.
Stars: ✭ 791 (+639.25%)
Mutual labels:  font, typeface
Sporting Grotesque
A grotesque typeface by @LucasLeBihan
Stars: ✭ 101 (-5.61%)
Mutual labels:  font, typeface
Sarasa Gothic
Sarasa Gothic / 更纱黑体 / 更紗黑體 / 更紗ゴシック / 사라사 고딕
Stars: ✭ 6,771 (+6228.04%)
Mutual labels:  font, typeface
Google Type
Collaborative typography project using select passages from Aesop's Fables set to Google Fonts
Stars: ✭ 971 (+807.48%)
Mutual labels:  font, typeface
Codeface
Typefaces for source code beautification
Stars: ✭ 5,612 (+5144.86%)
Mutual labels:  font, typeface
Mikhak
simple monoline Arabic-Latin semi handwriting typeface
Stars: ✭ 64 (-40.19%)
Mutual labels:  font, typeface
Crimson
The Crimson Text typeface
Stars: ✭ 439 (+310.28%)
Mutual labels:  font, typeface
Undefined Medium
undefined medium — a free and open-source monospace typeface with 400+ characters
Stars: ✭ 449 (+319.63%)
Mutual labels:  font, typeface
Cdnjs
🤖 CDN assets - The #1 free and open source CDN built to make life easier for developers.
Stars: ✭ 9,270 (+8563.55%)
Mutual labels:  library, font
Ahk Rare
My collection of rare and maybe very useful functions
Stars: ✭ 101 (-5.61%)
Mutual labels:  library, font

TypefaceHelper

Gitter Android Arsenal License Circle CI

Helper object for injecting typeface into various text views of android.

Overview

We can use various custom typefaces asset for any text views(like TextView, Button, RadioButton, EditText, etc.), but there's no way to set the typeface as a styled theme to apply the typeface for overall screens in the app.

This library helps to do it in easy way :)

And there's also a serious bug that creating typeface from asset resource will cause memory leak (See this link for more details), this library will take care about this problem as well.

How to use

First, put your typeface into asset directory.

In your application class, take care about the helper object lifecycle.

public class MyApp extends Application {
  @Override
  public void onCreate() {
    super.onCreate();

    TypefaceHelper.initialize(this);
  }

  @Override
  public void onTerminate() {
    TypefaceHelper.destroy();
    super.onTerminate();
  }
}

And in your activity, if you would like to set your typeface to a text view,

public class MyActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TextView hello = (TextView) findViewById(R.id.hello_world);
    TypefaceHelper.getInstance().setTypeface(hello, "font/font_file.ttf");
  }
}

You can also set your typeface for all text views that belong to a specific view group just like this.

public class MyActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    LinearLayout container = (LinearLayout) findViewById(R.id.text_container);
    TypefaceHelper.getInstance().setTypeface(container, "font/font_file.ttf");
  }
}

If you want to apply the typeface for all text views under the activity layout,

public class MyActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(TypefaceHelper.getInstance().setTypeface(this, R.layout.activity_main, "font/font_file.ttf"));
  }
}

Nice and easy!

You can apply the typeface to your whole window like this.

public class MyActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_activity_main);
    TypefaceHelper.getInstance().setTypeface(this, "font/font_file.ttf");
  }
}

And... you can also pass the font name as a string resource id:

public class MyActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_activity_main);
    TypefaceHelper.getInstance().setTypeface(this, R.string.font_primary);
  }
}

Download

Gradle:

compile 'com.drivemode:TypefaceHelper:[email protected]'

License

Copyright (C) 2014 Drivemode, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

And the sample app uses the following font under OFL.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].