1

I have an android app using

io.github.inflationx:calligraphy3:3.0.0

With the following build settings

compileSdkVersion 28

buildToolsVersion "27.0.3"

Testing on Google Pixel XL OS android 9

What is interesting is, if I have a small text view that needs to show the 5 character, the text is elongated / squished in a weird way. This is for font_avenir_medium It only happens on the P devices, and it happens when the font SP is set below 25. But only for this font. If I change in to say avenir_book it will work fine.

This happened all over the app when I was on Calligraphy 2 and P came out, but other letters excluding the character '5' were resolved in 3. In that case more than the 5 was effected.

<TextView
               android:id="@+id/clockin_hour_count"
               android:text="5"
               android:textColor="@color/favor_blue"
               android:textSize="15sp"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_centerInParent="true"
               style="@style/AppTheme.MediumFontText"
               tools:ignore="MissingPrefix"
               />



   <style name="AppTheme.MediumFontText">
        <item name="fontPath">@string/font_avenir_medium</item>
    </style>

My base activity has the following and all other fonts are set correctly.

  @Override
  protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
  }

This is the CUSTOM VIEW in question, though theres really nothing interesting in it. Other than its a custom view.

public class ClockView extends LinearLayout {


....
  @BindView(R.id.clockin_hour_count)
  TextView mHoursCountTextview;

  public ClockView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;
  }

  public void setData(@NonNull BootStrap bootStrap, EventBus eventBus, int selectedIndex) {
    init(selectedIndex);
   ...
  }

  private void init(int selectedIndex) {
    ...
  }

  public void updateHours(int numHours) {
    mNumHours = numHours;

        mHoursCountTextview.setText(
            mContext.getResources().getQuantityString(R.plurals.hours, numHours, numHours)
        );

    String text = String.format(getResources().getText(R.string.run_until).toString(), getHour(numHours));
    mRunTillButton.setText(text);
  }

  @OnClick(R.id.minus_clockin_button)
  public void onMinusClicked() {
    if (mNumHours > MIN_HOURS) {
      mNumHours--;
    }
    updateHours(mNumHours);
    updateHourButtonStates();
  }

  private void updateHourButtonStates() {
    minusIv.setEnabled(mNumHours > MIN_HOURS);
    plusIv.setEnabled(mNumHours < MAX_HOURS);

  }

  @OnClick(R.id.plus_clockin_button)
  public void onPlusClicked() {
    if (mNumHours < MAX_HOURS) {
      mNumHours++;
    }
    updateHours(mNumHours);
    updateHourButtonStates();
  }

  private String getHour(int numHours) {
    Calendar cal = Calendar.getInstance(); // creates calendar
    cal.setTime(new Date()); // sets calendar time/date
    cal.add(Calendar.HOUR_OF_DAY, numHours); // adds one hour
    cal.getTime(); // returns new date object, one hour in the future
    return sdf.format(cal.getTime());
  }

}

We can see here from left to right the effect. 15sp, 20sp, 25sp enter image description here

StarWind0
  • 1,554
  • 2
  • 17
  • 46
  • Did you try using font resources? Does the issue happen with font resources as well? I believe you don't need Calligraphy these days anymore. – Zielony Nov 26 '18 at 23:58
  • That is the solution I am trying, but the gravity of that change is immense, as it will touch almost every XML file. – StarWind0 Nov 27 '18 at 03:52
  • Update, I've updated gradle and my build tools, and removed cal2, and replaced it with the new native fonts. We still have this issue.. – StarWind0 Jan 07 '19 at 20:54
  • The end issue was the file itself. Replacing it with a new version of the same file worked. Even though the two files were supposed to be the same. – StarWind0 Feb 25 '19 at 16:34

0 Answers0