Android-PTTextView


Source link: https://github.com/olegosipenko/PTTextView

Android-PTTextView

Deprecated - use new TextView android:font attribute instead

An implementation of a TextView with support of Paratype & Google PT font family

A project was inspired by RobotoTextView

####List of supported fonts:

###List of supported widgets:

  • PTTextView
  • PTEditText
  • PTButton
  • PTCheckBox
  • PTAutocompleteTextView
  • PTCheckedTextView
  • PTCompoundButton
  • PTExtractEditText
  • PTMultiAutoCompleteTextView
  • PTRadioButton
  • PTSwitch
  • PTToggleButton
  • PTChronometer
  • PTDigitalClock
  • PTTextClock

Download

Download the latest JAR or grab via Maven:

<dependency>
<groupId>com.github.olegosipenko</groupId>
<artifactId>PTTextView</artifactId>
<version>1.0.0</version> </dependency>

or Gradle:

repositories {

  jcenter() 
}
  dependencies {

  compile 'com.github.olegosipenko:pttextview:1.0.0' 
}

Usage

In XML

To setup a typeface you must specify the parameter typeface:

<pttextview.widget.PTTextView

 xmlns:android="http://schemas.android.com/apk/res/android"

 xmlns:app="http://schemas.android.com/apk/res-auto"

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

 app:typeface="pt_serif_bold_italic"/>

or specify a set of parameters fontFamily, textWeight and textStyle:

<pttextview.widget.PTTextView

 xmlns:android="http://schemas.android.com/apk/res/android"

 xmlns:app="http://schemas.android.com/apk/res-auto"

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

 app:fontFamily="pt_mono"

 app:textWeight="bold"

 app:textStyle="regular"/>

Setup typeface in code:

In Code

Using parameter typeface:

PTTextView textView = new PTTextView(context);
 Typeface typeface = PTTypefaceManager.getTypeface(

context, PTTypefaceManager.Typefaces.PT_SERIF_CAPTION_ITALIC);
 PTTextViewUtils.setTypeface(textView, typeface);

Using parameters fontFamily, textWeight and textStyle:

PTTextViewUtils textView = new PTTextViewUtils(context);
 Typeface typeface = PTTypefaceManager.getTypeface(

context,

PTTypefaceManager.FontFamilies.PT_SANS_NARROW,

PTTypefaceManager.TextWeights.BOLD,

PTTypefaceManager.TextStyles.REGULAR);
 PTTextViewUtils.setTypeface(textView, typeface);

With Span

Using parameter typeface:

PTTypefaceSpan span = new PTTypefaceSpan(

context,

PTTypefaceManager.Typefaces.PT_SERIF_CAPTION_ITALIC);
 Spannable spannable = new SpannableString("text");
 spannable.setSpan(span, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

Using parameters fontFamily, textWeight and textStyle:

PTTypefaceSpan span = new PTTypefaceSpan(

context,

PTTypefaceManager.FontFamilies.PT_SERIF,

PTTypefaceManager.TextWeights.BOLD,

PTTypefaceManager.TextStyles.ITALIC);
 Spannable spannable = new SpannableString("text");
 spannable.setSpan(span, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

Gradle

If you intend to use is not all fonts, the extra fonts can be removed.

android.applicationVariants.all{
 variant ->
  variant.mergeAssets.doFirst {

File fonts = file("${
projectDir
}
/build/intermediates/exploded-aar/pttextview/pttextview/1.0.0/assets/fonts")

if (fonts.exists()) {

 for (File file : fonts.listFiles()) {

  if (file.getName().contains("PT Sans")) {

println("delete " + file.getName() + " font")

file.delete()

  
}
;

 
}

}

  
}
 
}

Compatibility

The widget supports API down to Android 2.1 (API >= 7)

Credits

The idea of this library was inspired by [Android-RobotoTextView] ( https://github.com/johnkil/Android-RobotoTextView) by Evgeny Shishkin

License

Copyright (C) 2015 Oleg Osipenko  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. 

Resources

Facade modules for dealing with complicated MediaStore in a simple way.

Intercom for Android, for integrating Intercom into your Android application.

An android app that can be used by any conference to display information like sessions, speakers, etc.

Electra for android is simple persistence framework with compile time processing.

Primary design goals:

  • Easy to use and configure
  • Easy integrate with existing code
  • Compile time processing, no reflection
  • Simple beans
  • Expression builder
  • RxJava support
  • No Dependencies

WhatsappFormatter repo helps to perform formatting just like whatsapp does it on its EditText and TextView.

An adapter library to prevent a lot of duplication code.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes