• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Custom fonts without writing code.

Letter Press

Android Arsenal Build Status Download

Custom typefaces without a single line of code!

With Letter Press, adding custom fonts to your app means not a single line of code is needed; simply add the fonts to your app, replace your views with their Font counterparts, and specify the fonts through attributes, styles and themes.

All fonts are referenced into (subdirectories of) the app's assets folder.

Sample

You can apply your custom fonts in a few ways: by using the theme, by specifying a specific style per view, or on the view explicitly using view attributes pix_font, pix_fontBold,pix_fontItalic or pix_fontBoldItalic.

Check out the sample app to see how easy it is to set up.

Basic sample

The easiest example is to set a typeface through layout attributes. In your layouts, replace Android widgets with the Font counterparts. For instance, use FontTextView instead of TextView and it will use the Action Man font.

<com.pixplicity.fontview.FontTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:pix_font="fonts/Action_Man.ttf"
    android:text="Custom font from attributes"/>

Style sample

Through a style, you can provide the same style to multiple views. By overriding the default parent style, it's easy enough to swap out existing styles (but is not required).

<resources>
    <style name="FontTextViewStyle" parent="@android:style/TextAppearance.Widget.TextView">
        <item name="pix_font">fonts/Action_Man.ttf</item>
        <item name="pix_fontBold">fonts/Action_Man_Bold.ttf</item>
        <item name="pix_fontItalic">fonts/Action_Man_Italic.ttf</item>
        <item name="pix_fontBoldItalic">fonts/Action_Man_Bold_Italic.ttf</item>
    </style>
</resources>

Define the style once, and you can reference it in multiple views, for instance:

<com.pixplicity.fontview.FontTextView
    style="@style/FontEditTextStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Custom font from style"/>

Theme sample

The most scalable way to set a common typeface is through providing a custom theme:

<resources>
    <!-- Base application theme. -->
    <style name="BaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="android:autoCompleteTextViewStyle">@style/FontAutoCompleteTextViewStyle</item>
        <item name="android:buttonStyle">@style/FontButtonStyle</item>
        <item name="android:checkboxStyle">@style/FontCheckBoxStyle</item>
        <item name="android:editTextStyle">@style/FontEditTextStyle</item>
        <item name="android:radioButtonStyle">@style/FontRadioButtonStyle</item>
        <item name="android:textViewStyle">@style/FontTextViewStyle</item>
        <item name="android:buttonStyleToggle">@style/FontToggleButton</item>
        <item name="autoCompleteTextViewStyle">@style/FontAutoCompleteTextViewStyle</item>
        <item name="buttonStyle">@style/FontButtonStyle</item>
        <item name="checkboxStyle">@style/FontCheckBoxStyle</item>
        <item name="editTextStyle">@style/FontEditTextStyle</item>
        <item name="radioButtonStyle">@style/FontRadioButtonStyle</item>
    </style>
    <style name="AppTheme" parent="BaseTheme">
    </style>
</resources>

Now, your FontTextView doesn't need any attributes or styles at all, and inherits the attributes from the default style:

<com.pixplicity.fontview.FontTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Custom font from theme"/>

Download

Download the latest AAR or grab via Maven:

<dependency>
  <groupId>com.pixplicity.letterpress</groupId>
  <artifactId>library</artifactId>
  <version>(insert latest version)</version>
  <type>aar</type>
</dependency>

Provide the dependency in Gradle:

compile 'com.pixplicity.letterpress:library:(insert latest version)'

License

Copyright 2014 Pixplicity (http://pixplicity.com)

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.

More Repositories

1

MultiViewPager

The MultiViewPager is an extension of the support-v4 library's ViewPager that allows the pages to be wider or narrower than the ViewPager itself. It takes care of aligning the pages next to each other, and always keeping the selected page centered.
Java
906
star
2

HtmlCompat

Compatibility library for Android's Html class. [DEPRECATED]
Java
558
star
3

EasyPrefs

A small library containing a wrapper/helper for the Shared Preferences of android.
Java
419
star
4

humpty-dumpty-android

Simple file dump utility for Android
Shell
104
star
5

gene-rate

Generate a better rating for your Android app
Java
67
star
6

android-custom-components

Custom Components for Android
Java
21
star
7

Proguard-rules

Proguard rules for commonly used libraries
19
star
8

sync-demo

Sync Demo
Java
16
star
9

android-bluetooth-demo

This project demonstrates communicating with a bluetooth device in an Android app.
Java
16
star
10

PoorIntentions

Illustrates invalid back stacks on Android and offers a resolution
Kotlin
11
star
11

adb-control

ADB Control for Root app
Java
6
star
12

HaldCLUT

C/C++ generator for Hald Color Lookup Tables
C
4
star
13

castdemo

Google Cast Demo
Java
4
star
14

ChoiceGridView

Variant of Android's GridView that has improved handling for multiselection.
Java
3
star
15

StandardSmashdown

The official Standard Rules for Smashdown Ping-Pong
3
star
16

gimbal-proximity

Fork and improvement of Gimbal Proximity SDK sample app
Java
3
star
17

flutter_animation_motion

Companion app for my "Animation and motion in Flutter" presentation, showcasing what the framework has to offer to developers for creating simple and yet beautiful animations.
Dart
3
star
18

multi-window-demo

Demo of Android N's Multi-Window mode
Java
2
star
19

weardemo

Java
2
star
20

overlay-android-bug

Demo of a bug in Android 7.1.2 (Nougat) on a Nexus 6P
Java
2
star
21

animation-demo

Java
1
star
22

nougat-photo

A very basic no-frills implementation of using the default camera to return a photo, compatible with Android Nougat.
Java
1
star
23

PriorityAlert

Java
1
star
24

HeadphoneData

Java
1
star
25

resource-converter

Java
1
star