chrisjenx / calligraphy Goto Github PK
View Code? Open in Web Editor NEWCustom fonts in Android the easy way...
License: Apache License 2.0
Custom fonts in Android the easy way...
License: Apache License 2.0
To stop the AssetManger
trying to load invalid fonts multiple times, cache the font path as null and always return null thereafter.
Hi!
When I set the attribute "android:textAllCaps" to true on my xml it actually does nothing.
Great library!
setTypeface()
does not work on the CustomTextView (subclass of TextView).
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.inject(this, view);
Typeface robotoBold = Typeface.createFromAsset(getResources().getAssets(), "fonts/Roboto-Bold.ttf");
TextView customTextView = ButterKnife.findById(view, R.id.typeface_roboto_bold_custom);
customTextView.setTypeface(robotoBold);
TextView textView = ButterKnife.findById(view, R.id.typeface_roboto_bold);
textView.setTypeface(robotoBold);
}
<uk.co.chrisjenx.calligraphy.sample.CustomTextView
android:id="@+id/typeface_roboto_bold_custom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This has a typeface set to Roboto Bold, on the custom TextView.\n"/>
<TextView
android:id="@+id/typeface_roboto_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This has a typeface set to Roboto Bold, on the View.\n"/>
I have set custom font from assets via Application class and overridden the Activity base context callback. Now I want to customize a little one TextView. I have set different fontFamily and textStyle (bold). The TextView is not displayed correctly (textStyle and fontFamily is not applied). I'm using 0.7.2. I've done everything exactly what described in the README. What can be wrong?
Hi, great library!
There's this issue where the calligraphy won't work. I have a nav drawer with a main activity(which includes the calligraphy) and 3 fragments attached to it for navigation.
The simple fragment will display my custom font correctly but the other two, which have listviews, won't display the font.
Any ideas?
I don't know if this feature has been implemented or not. I just recently applying OpenSans-Regular.ttf
as global default, then all bold TextView turned to normal (non-bold style). I wish there is a built-in and clean way to provide default bold font file (e.g. OpenSans-Bold.ttf
) when used by TextView
, perhaps by checking it in TextView#getTypeface().isBold()
.
I think this feature will come in handy because it will eliminate the need to apply custom style one by one to all bold/italic texts.
Thanks
Calligraphy doesn't seem to set the font for the TextViews in CheckBoxes. Not sure if this is related but setting the android:fontFamily also doesn't seem to work either. Only way I've gotten it to work was in code with .setTypeFace(Typeface)
I setup default font to "fonts/somefont.ttf"
However In some TextViews I would like to use roboto fonts so I define text view :
<TextView android:id="@+id/test" android:fontFamily="sans-serif-light" ...
http://stackoverflow.com/questions/19691530/valid-values-for-androidfontfamily-and-what-they-map-to
this results in debug warnings :
"Can't create asset from sans-serif-light. Make sure you have passed in the correct path and file name."
is this a bug? or maybe there is some other way to add roboto.
P.S - it seems like this guy had a similar issue .. "sans-serif-light" was within library he references #32
Hi
Thanks for the library!
Is there a way to make Calligaph apply to custom views too?
I don't know if it is something about where TextPaint gets it's typeface from, but it would be great if it could be extended to automatically adjust.
Best Regards
Andreas
First, I download jar and import this.
Second, onCreate in Application class write code about CalligraphyConfig init.
Last, attachBaseContext in Activity write code about CalligraphyContextWrapper.
But I get some error.... I don't know why.
Please help me.
I'm still using the 0.7.x version of your library, but maybe the problem (if it is a real problem) still holds for the current version.
Currently, I'm investigating memory footprint and usage of my app. Via Android Studio, I can record the memory usage of my app with a pretty easy overview. This overview, among other stuff, also displays the allocation of assets. I load two custom fonts for my app using Calligraphy. When I start my app, these two fonts have two references each - so it allocates each font twice. After surfing around, I can see that one of the fonts is allocated 6 times in memory (while the other font keeps with 2).
Asset Allocations
zip:/data/app/***.apk:/assets/fonts/GothamRnd-Medium.otf: 123K
zip:/data/app/***.apk:/assets/fonts/GothamRnd-Medium.otf: 123K
zip:/data/app/***.apk:/assets/fonts/GothamRnd-Book.otf: 133K
zip:/data/app/***.apk:/assets/fonts/GothamRnd-Medium.otf: 123K
zip:/data/app/***.apk:/assets/fonts/GothamRnd-Medium.otf: 123K
zip:/data/app/***.apk:/assets/fonts/GothamRnd-Medium.otf: 123K
zip:/data/app/***:/assets/fonts/GothamRnd-Medium.otf: 123K
zip:/data/app/***:/assets/fonts/GothamRnd-Book.otf: 133K
What's going on there? I'm setting the font via styles in XML. But I'm not sure whether the memory leak is my fault (which I assume), or whether it's maybe a calligraphy bug.
Hey guys, Nice library! It's really useful and helpful.
I have one issue I am unable to resolve using this. I have a Class which extends TextView. I want to set a font for all instances of this class from the constructor. I have tried to do this, but the Apps default font always overwrites this. Is this a bug in the Library? or am I missing how to do this?
I have tried to set the TextView's Typeface, I have tried using the utilities supplied by Calligraphy. I have tried use a default custom style.
Any help would be much appreciated.
Hi, thanks for this wonderful library.
I use this library in one of my application, everything is right till I try to run a suitability test online, and I got the crash message for particular model, including Note 1, S II, both android 4.0.4 ( I could provide full list if needed).
there is the logcat info
05-26 11:01:24.940E16485AndroidRuntimejava.lang.RuntimeException: Unable to start activity ComponentInfo{com.ailk.insight.dev/com.ailk.insight.activity.Main}: android.view.InflateException: Binary XML file line #38: Error inflating class
05-26 11:01:24.940E16485AndroidRuntimeat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.ActivityThread.access$600(ActivityThread.java:127)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
05-26 11:01:24.940E16485AndroidRuntimeat android.os.Handler.dispatchMessage(Handler.java:99)
05-26 11:01:24.940E16485AndroidRuntimeat android.os.Looper.loop(Looper.java:137)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.ActivityThread.main(ActivityThread.java:4511)
05-26 11:01:24.940E16485AndroidRuntimeat java.lang.reflect.Method.invokeNative(Native Method)
05-26 11:01:24.940E16485AndroidRuntimeat java.lang.reflect.Method.invoke(Method.java:511)
05-26 11:01:24.940E16485AndroidRuntimeat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:986)
05-26 11:01:24.940E16485AndroidRuntimeat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:753)
05-26 11:01:24.940E16485AndroidRuntimeat dalvik.system.NativeStart.main(Native Method)
05-26 11:01:24.940E16485AndroidRuntimeCaused by: android.view.InflateException: Binary XML file line #38: Error inflating class
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.createView(LayoutInflater.java:606)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-26 11:01:24.940E16485AndroidRuntimeat com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2885)
05-26 11:01:24.940E16485AndroidRuntimeat com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2945)
05-26 11:01:24.940E16485AndroidRuntimeat com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1686)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.Activity.initActionBar(Activity.java:1816)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.Activity.getActionBar(Activity.java:1803)
05-26 11:01:24.940E16485AndroidRuntimeat com.actionbarsherlock.internal.ActionBarSherlockNative.initActionBar(ActionBarSherlockNative.java:40)
05-26 11:01:24.940E16485AndroidRuntimeat com.actionbarsherlock.internal.ActionBarSherlockNative.getActionBar(ActionBarSherlockNative.java:35)
05-26 11:01:24.940E16485AndroidRuntimeat com.actionbarsherlock.app.SherlockFragmentActivity.getSupportActionBar(SherlockFragmentActivity.java:42)
05-26 11:01:24.940E16485AndroidRuntimeat com.ailk.insight.activity.Main.onCreate(Main.java:82)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.Activity.performCreate(Activity.java:4470)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
05-26 11:01:24.940E16485AndroidRuntimeat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
05-26 11:01:24.940E16485AndroidRuntime... 11 more
05-26 11:01:24.940E16485AndroidRuntimeCaused by: java.lang.reflect.InvocationTargetException
05-26 11:01:24.940E16485AndroidRuntimeat java.lang.reflect.Constructor.constructNative(Native Method)
05-26 11:01:24.940E16485AndroidRuntimeat java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.createView(LayoutInflater.java:586)
05-26 11:01:24.940E16485AndroidRuntime... 30 more
05-26 11:01:24.940E16485AndroidRuntimeCaused by: android.view.InflateException: Binary XML file line #36: Error inflating class TextView
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-26 11:01:24.940E16485AndroidRuntimeat android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-26 11:01:24.940E16485AndroidRuntimeat com.android.internal.widget.ActionBarView.initTitle(ActionBarView.java:826)
05-26 11:01:24.940E16485AndroidRuntimeat com.android.internal.widget.ActionBarView.setDisplayOptions(ActionBarView.java:623)
05-26 11:01:24.940E16485AndroidRuntimeat com.android.internal.widget.ActionBarView.(ActionBarView.java:254)
05-26 11:01:24.940E16485AndroidRuntime... 33 more
05-26 11:01:24.940E16485AndroidRuntimeCaused by: java.lang.IndexOutOfBoundsException
05-26 11:01:24.940E16485AndroidRuntimeat android.content.res.StringBlock.nativeGetString(Native Method)
05-26 11:01:24.940E16485AndroidRuntimeat android.content.res.StringBlock.get(StringBlock.java:81)
05-26 11:01:24.940E16485AndroidRuntimeat android.content.res.AssetManager.getPooledString(AssetManager.java:274)
05-26 11:01:24.940E16485AndroidRuntimeat android.content.res.TypedArray.loadStringValueAt(TypedArray.java:726)
05-26 11:01:24.940E16485AndroidRuntimeat android.content.res.TypedArray.getString(TypedArray.java:124)
05-26 11:01:24.940E16485AndroidRuntimeat uk.co.chrisjenx.calligraphy.CalligraphyUtils.pullFontPathFromStyle(CalligraphyUtil
And If I remove Calligraphy from my app, everything goes right.
Title says it all, are .OTF fonts supported?
like google web font
android:fontfamily is ignored in Spinner widget and spinner is using default font set by CalligraphyConfig.initDefault() in the activity. Any idea what seems to be the problem?
Thanks
Here is something strange that happens on my device.
I have set a global theme in TextView e.g. Roboto-Medium (overriding the theme's "android:textViewStyle"
) and the rest inside the Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CalligraphyConfig.initDefault("fonts/Roboto-Medium.ttf", R.attr.fontPath);
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(new CalligraphyContextWrapper(newBase));
}
For a particular TextView i want another font so I set a custom textAppearance
:
<TextView
android:textAppearance="@style/AppTheme.TextAppearance.Reditum"
... />
Strangely when I open the activity the font has not rendered but when I resume (I guess something happens onResume
that did not before), it is correctly shown.
Is that reproducible?
I tried:
<style name="MyActionBarTabText" parent="@style/Widget.AppCompat.ActionBar.TabText"> #FF2C7699 11sp fonts/Fontin-Regular.ttf </style>I think better to move all initialization of library to Application class. You can override
public class CoreApplication extends Application {
@Override
public void onCreate() {
//todo init fonts
}
@Override
public Object getSystemService(String name) {
if (LAYOUT_INFLATER_SERVICE.equals(name)) {
if (mInflater == null) {
mInflater = new CalligraphyLayoutInflater(LayoutInflater.from(getBaseContext()), this);
}
return mInflater;
}
return super.getSystemService(name);
}
}
in this case all initialization will be in one place for all application and we don't need to add some specific logic inside activity.
I have not test this solution but I think it will be work.
Regards,
Vova.
Error:Failed to find: uk.co.chrisjenx:calligraphy:1.0.+
Open File
Open in Project Structure dialog
I tried android:fontFamily and fontFamilyPath but it doesn't seem to work in widgets.
Hi, I'm playing around with the Android L Preview, and I've noticed that when I use the toolbar.setTitleTextAppearance() method to apply a style that has a Calligraphy fontPath supplied, everything in that style except the custom font is applied. Is this a known bug?
Primarily bug fixes.
Or missed features for 1.0.0.
I have defined the default font which loads fine:
CalligraphyConfig.initDefault("fonts/Roboto-Regular.ttf", R.attr.fontPath);
and also:
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(new CalligraphyContextWrapper(newBase));
}
This works fine. The Roboto-Regular font is then applied.
I am then trying to set a custom font to a TextView, however it doesn't get loaded:
<TextView
android:id="@+id/titleDrawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
fontPath="fonts/Roboto-LightItalic.ttf"
android:textColor="@color/white"
android:textSize="18sp"
/>
No build issues or comments in the log.
What's strange is, I looked at my app before and the custom font was loaded. I didn't change any code, went to rebuild my app and now the custom fonts have gone.
Not really sure what's happening here!
I updated to 1.0.0 today, and certain textviews that I set with spannables (custom fontface) are no longer appearing correctly (font-awesome). The characters display as boxes.
This is the custom spannable:
/**
* Style a {@link Spannable} with a custom {@link Typeface}.
*
* @author Tristan Waddington
*/
public class TypefaceSpan extends MetricAffectingSpan {
private Typeface mTypeface;
/**
* Load the {@link Typeface} and apply to a {@link Spannable}.
*/
public WWTypefaceSpan(AssetManager assets, String typefaceName) {
mTypeface = TypefaceUtils.load(assets, typefaceName);
}
@Override
public void updateMeasureState(TextPaint p) {
p.setTypeface(mTypeface);
// Note: This flag is required for proper typeface rendering
p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
@Override
public void updateDrawState(TextPaint tp) {
tp.setTypeface(mTypeface);
// Note: This flag is required for proper typeface rendering
tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
}
I think it would make sense to add a link to this issue:
https://code.google.com/p/android/issues/detail?id=1087
in the README file so people know why this library is needed in the first place, and also entice them to "star" it so maybe one day it will be resolved :)
Don't get me wrong, this lib is really cool and I thank you for creating it, but it would be a lot preferable to have the feature directly in the platform.
Typeface is not set on the EditText hint/label.
calligraphy-1.0.0-sources.jar is 261 bytes long, and contains only the jar's META-INF/MANIFEST.MF file.
For comparison, calligraphy-0.7.2-sources.jar is 5.7K.
As I understand it supports api level 11 and above. If one wants to use it for previous api levels can it be tweaked?
This used to work with 0.7.2:
<!-- Theme -->
<item name="android:actionBarStyle">@style/my_action_bar</item>
<!-- my_action_bar -->
<item name="android:titleTextStyle">@style/my_title_style</item>
<!-- my_title_style -->
<item name="fontPath">fonts/Lato-Black.ttf</item>
A TextView defining both maxLine (whatever the value) and ellipsize results in the TextView applying the custom font but not displaying the ellipsis (...) for strings longer than maxLines.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fontPath="@string/media_item_title_font"
android:maxLines="2"
android:ellipsize="end"
tools:ignore="MissingPrefix" />
With the following text:
this is line1
this is line2
this is line3
the TextView above will display:
this is line1
this is line2
instead of:
this is line1
this is line2...
Removing the fontPath element produces the expected result
Hi,
This library works great but I have one problem, the navigation drawer items don't get the custom font I apply to them in xml.
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:textColor="@android:color/white"
android:textSize="18sp"
fontPath="fonts/AvenirNextCondensed_Italic.ttf"
tools:text="Nieuw" />
This is for example a navigation item xml layout.
In my activity with the navigation drawer I add
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(new CalligraphyContextWrapper(newBase));
}
It does work in every other part of my app. Is this a known bug or am I doing something wrong ?
Hi,
I'm trying to set the font of my actionbar title in the theme.
This is my xml style:
<style name="HomeActivityTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/HomeActivityTheme.ActionBarStyle</item>
<item name="android:actionBarWidgetTheme">@style/HomeActivityTheme.ActionBarWidgetTheme</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:actionBarItemBackground">@drawable/home_theme_actionbar_item_bg</item>
<item name="android:windowBackground">@drawable/cotton_bg</item>
</style>
<style name="HomeActivityTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:icon">@android:color/transparent</item>
<item name="android:titleTextStyle">@style/ActionBar.WhiteTextStyle</item>
<item name="android:background">@color/immozo_blue</item>
</style>
<style name="ActionBar.WhiteTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/white</item>
<item name="fontPath">fonts/AvenirNextCondensed_Regular.ttf</item>
<item name="android:textSize">@dimen/medium_fontsize</item>
<item name="android:textAllCaps">true</item>
</style>
I apply this theme in the androidManifest.
All the attributes work, but textAllCaps has no effect. I've read that in version 1.1.0 there were some fixes to a textAllCaps bug but I have 1.1.0.
IDE: Android Studio 0.8.2
Whenever I use the app:fontPath in a layout in Android Studio, I get a warning "unexpected namespace prefix "app" found for tag TextView." I'm adding xmlns:app="http://schemas.android.com/apk/res-auto"
in my root layout. I have to add tools:ignore="MissingPrefix" to the view to remove the warning.
I have the following in my values/attr.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="fontPath" />
</resources>
Edit: To be clear, this does not break anything. It's just a slight irritant 😀
As Hugo Visser pointed out, using fontFamily
might make lint whine a bit, and also stops people using fontFamily in a valid fashion.
Add a custom attribute for an 'aar' build.
Using Calligraphy without the custom font attribute results in a Resources.NotFoundException
when inflating a layout. When a custom font attribute is passed to the CalligraphyContext, the issue is solved.
Full stack trace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.calligraphytest.app/com.example.calligraphytest.app.MainActivity}: android.view.InflateException: Binary XML file line #29: Error inflating class TextView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
(...)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2206)
(...)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x10103ac
at android.content.res.Resources.getResourceEntryName(Resources.java:1499)
at uk.co.chrisjenx.calligraphy.CalligraphyUtils.pullFontPath(CalligraphyUtils.java:49)
at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreated(CalligraphyFactory.java:101)
at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onCreateView(CalligraphyFactory.java:65)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2206)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2261)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:203)
at android.app.Activity.setContentView(Activity.java:1657)
at com.example.calligraphytest.app.MainActivity.onCreate(MainActivity.java:17)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
I am using a blank "Hello, World" project:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
}
dependencies {
compile "uk.co.chrisjenx:calligraphy:0.7.+"
}
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CalligraphyConfig.initDefault("UbuntuMono-R.ttf");
setContentView(R.layout.activity_main);
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(new CalligraphyContextWrapper(newBase));
}
}
I'm getting the following warning on a project, just wondering if anyone knows why and how to get rid of it, my project works fine :)
The warning fires every time i open a dialog created with betterpickers https://github.com/derekbrameyer/android-betterpickers
04-21 16:10:27.356: W/Calligraphy(1496): Can't create asset from sans-serif-light. Make sure you have passed in the correct path and file name.
04-21 16:10:27.356: W/Calligraphy(1496): java.lang.RuntimeException: native typeface cannot be made
04-21 16:10:27.356: W/Calligraphy(1496): at android.graphics.Typeface.(Typeface.java:147)
04-21 16:10:27.356: W/Calligraphy(1496): at android.graphics.Typeface.createFromAsset(Typeface.java:121)
04-21 16:10:27.356: W/Calligraphy(1496): at uk.co.chrisjenx.calligraphy.TypefaceUtils.load(TypefaceUtils.java:33)
04-21 16:10:27.356: W/Calligraphy(1496): at uk.co.chrisjenx.calligraphy.CalligraphyUtils.applyFontToTextView(CalligraphyUtils.java:30)
04-21 16:10:27.356: W/Calligraphy(1496): at uk.co.chrisjenx.calligraphy.CalligraphyUtils.applyFontToTextView(CalligraphyUtils.java:42)
04-21 16:10:27.356: W/Calligraphy(1496): at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreated(CalligraphyFactory.java:116)
04-21 16:10:27.356: W/Calligraphy(1496): at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onCreateView(CalligraphyFactory.java:65)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-21 16:10:27.356: W/Calligraphy(1496): at com.doomonafireball.betterpickers.numberpicker.NumberPicker.(NumberPicker.java:75)
04-21 16:10:27.356: W/Calligraphy(1496): at java.lang.reflect.Constructor.constructNative(Native Method)
04-21 16:10:27.356: W/Calligraphy(1496): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
04-21 16:10:27.356: W/Calligraphy(1496): at uk.co.chrisjenx.calligraphy.CalligraphyFactory.createViewOrFailQuietly(CalligraphyFactory.java:89)
04-21 16:10:27.356: W/Calligraphy(1496): at uk.co.chrisjenx.calligraphy.CalligraphyFactory.createViewOrFailQuietly(CalligraphyFactory.java:73)
04-21 16:10:27.356: W/Calligraphy(1496): at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onCreateView(CalligraphyFactory.java:61)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-21 16:10:27.356: W/Calligraphy(1496): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-21 16:10:27.356: W/Calligraphy(1496): at com.doomonafireball.betterpickers.numberpicker.NumberPickerDialogFragment.onCreateView(NumberPickerDialogFragment.java:143)
Hello,
I'm using Calligraphy in an app I'm developing and its a great solution to the fonts issues in android. The only thing I can't seem to figure out is how to prevent Calligraphy from modifying toasts - it seems that the line CalligraphyConfig.initDefault("fonts/Roboto-Thin.ttf"); changes the Toasts' fonts as well, is there any way around this? not calling initDefault causes a crash.
I'm currently developing an app and I'm using Calligraphy almost anywhere in it to display Roboto-Light. The only thing that I can't seem to find is using Calligraphy to modify the action bar's title font: Even if I declare fontPath = "..." inside the action bar's style, it seems to be ignored.
This is more of a suggestion to add this as a feature rather than an issue.
The "android:fontFamily" attribute works perfectly if specified directly on the TextView style, but is ignored if set via the "android:textAppearance":
<style name="TextViewStyle" parent="android:Widget.TextView">
<item name="android:textAppearance">@style/TextAppearanceStyle</item>
</style>
<style name="TextAppearanceStyle" parent="android:TextAppearance" >
<item name="android:fontFamily">fonts/SOME-FONT-HERE</item>
</style>
It would be great to support all TextView styling capabilities including via the "android:textAppearance".
It'd be useful to distribute this as an AAR as well as a jar, for those of us who have switched to gradle.
Change groupid to uk.co.chrisjenx instead of uk.co.chrisjenx.calligraphfy.
It would be best to remove the need to require a default font.
As this breaks fontFamily attribute in some setups.
This bug is very bizarre and reproduced only on LG devices on android 4.1.2 when text of ActionBar or ActionBar menu items contains spans. As I know Calligraphy adds CalligraphyTypefaceSpan
to set custom font after update to 1.1.0. Stacktarce is:
java.lang.IllegalArgumentException: Invalid payload item type
at android.util.EventLog.writeEvent(EventLog.java)
at android.app.Activity.onMenuItemSelected(Activity.java:2757)
at com.android.internal.widget.ActionBarView$3.onClick(ActionBarView.java:172)
at android.view.View.performClick(View.java:4114)
at android.view.View$PerformClick.run(View.java:17095)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(NativeStart.java)
When android:textAllCaps
is set Calligraphy 1.0 doesn't work for that view (the font isn't applied). Does 1.0 use Spans to apply the fonts? There seems to be an issue with Spans and android:textAllCaps
https://code.google.com/p/android/issues/detail?id=67509
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.