chrisjenx / Calligraphy

Custom fonts in Android the easy way...
Apache License 2.0
8.59k stars 1.1k forks source link

"android:textAllCaps" does not work #42

Closed saguinav closed 10 years ago

saguinav commented 10 years ago

Hi!

When I set the attribute "android:textAllCaps" to true on my xml it actually does nothing.

Great library!

chrisjenx commented 10 years ago

@saguinav Which version of Android / Calligraphy

saguinav commented 10 years ago

@chrisjenx I'm using 0.7.1. Is there any new update?

chrisjenx commented 10 years ago

There is a 1.0.0 snapshot.

I'll see if I can reproduce in the morning. As I use Calligraphy with text all caps.

Any more information you can give? On 28 May 2014 18:31, "Samuel Guirado Navarro" notifications@github.com wrote:

@chrisjenx https://github.com/chrisjenx I'm using 0.7.1. Is there any new update?

— Reply to this email directly or view it on GitHubhttps://github.com/chrisjenx/Calligraphy/issues/42#issuecomment-44439180 .

chrisjenx commented 10 years ago

@saguinav I can't reproduce this annoyingly. Must either be the Font your using. Or Device/Android bug :unamused:

I'll closing this for now, open again if you have more details on how to reproduce it. (also provide as much examples of your setup as possible).

bubbleguuum commented 10 years ago

I also have noticed this issue on all my devices running Android 4.4.2. For example:

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        fontPath="fonts/RobotoCondensed-Regular.ttf"
        android:textAllCaps="true"
        tools:ignore="MissingPrefix" />

In that case, the text is in caps but with the default font. fontPath is registered normally and works without problem if textAllCaps is omiited:

In the Application's onCreate()

CalligraphyConfig.initDefault(R.attr.fontPath);

chrisjenx commented 10 years ago

textAllCaps works but it ignores the fontPath? I tried a few combinations and I can't replicate this.

Device? Version of Android? Any clues guys.....

On 29 May 2014 18:24, bubbleguuum notifications@github.com wrote:

I also have noticed this issue. For example:

<TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    fontPath="fonts/RobotoCondensed-Regular.ttf"
    android:textAllCaps="true"
    tools:ignore="MissingPrefix" />

In that case, the text is in caps but with the default font. fontPath is registered normally and works without problem if textAllCaps is omiited:

In the Application's onCreate()

CalligraphyConfig.initDefault(R.attr.fontPath);

— Reply to this email directly or view it on GitHubhttps://github.com/chrisjenx/Calligraphy/issues/42#issuecomment-44558738 .

bubbleguuum commented 10 years ago

Android 4.4.2 on Nexus 5, Nexus 7 (2012). Maybe looking at the TextView source code to check what it does when allCaps is enabled would give a hint ?

chrisjenx commented 10 years ago

Yeah will do. It may of been fixed inadvertently post 0.7.2. But I can check again. On 29 May 2014 18:47, "bubbleguuum" notifications@github.com wrote:

Android 4.4.2 on Nexus 5, Nexus 7 (2012). Maybe looking at the TextView source code to check what it does whan allCaps is enabled would give a hint ?

— Reply to this email directly or view it on GitHubhttps://github.com/chrisjenx/Calligraphy/issues/42#issuecomment-44561618 .

bubbleguuum commented 10 years ago

Looking briefly at the code (KitKat), it seems to set a TransformationMethod and at some point call this, which might interfere with the Calligraphy custom span ?:

if (mTransformation != null) {
                sp.setSpan(mTransformation, 0, textLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            }
saguinav commented 10 years ago

Tested on a Nexus 5 v4.4.2 and Emulator Galaxy Nexus v4.4.2

My setup is the following:

Application:

@Override
public void onCreate() {
    super.onCreate();

    CalligraphyConfig.initDefault("fonts/OpenSans-Regular.ttf");
}

Activity:

@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(new CalligraphyContextWrapper(newBase));
}

Layout

    <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="@style/TextHeader"
            android:gravity="center"
            android:text="@string/title"
            android:textAllCaps="true" />

Style

     <style name="TextHeader">
         <item name="android:textSize">@dimen/text_size_xlarge</item>
         <item name="android:textColor">@color/text_body_1</item>
         <item name="android:maxLines">?textHeaderMaxLines</item>
         <item name="android:ellipsize">end</item>
         <item name="android:textIsSelectable">true</item>
         <item name="android:textAlignment">viewStart</item>
         <item name="android:fontFamily">fonts/OpenSans-Bold.ttf</item>
     </style>
Vince0H commented 9 years ago
   <android.support.v7.internal.widget.CompatTextView
    style="@style/MyTextViewStyle"
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:textAllCaps="true"/>
twinkleSiya commented 6 years ago

Hii, Good Afternoon.

I have implemented Tablayout with viewpager, when tab title text in .ttf font not working.

I have done Style code, but I'm facing the same problem.

see my xml code -> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/CustomTabLayout" android:background="#eceff1" app:tabMode="fixed" app:tabGravity="fill"/>

style code ->

Thank u in advance...