Это то, что происходит в режиме предварительного просмотра и на устройстве:
TextView ничего особенного, он просто загружает пользовательский шрифт:
public class TestTextView extends AppCompatTextView {
public TestTextView(Context context) {
super(context);
init(context);
}
public TestTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public TestTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
void init(Context context) {
Typeface t = Typeface.createFromAsset(context.getAssets(), "fonts/daisy.ttf");
setTypeface(t);
}
}
Макет также очень простой, но на всякий случай:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/material_red200"
android:orientation="vertical">
<*custompackage* .TestTextView
android:gravity="left"
android:padding="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="just some text for testing"
android:textColor="@color/material_black"
android:textSize="100dp" />
</LinearLayout>
Как вы можете видеть, левые части, такие как "j" и "f", обрезаны.
Настройка отступов или полей не работает.
Этот шрифт вписывается в кадр при использовании из других программ.
Спасибо заранее.
Изменить: То, о чем упоминается @play_err_, не является решением в моем случае.
- Я использую в окончательной версии текстовое окно, которое автоматически изменяет размер, поэтому добавление пробелов было бы ужасно трудным.
- Мне нужно объяснение, почему другие программы (например, photoshop, after effects...) могут вычислять правильную ограничительную рамку, а андроид не может
-
Я также загружаю разные шрифты динамически, и я не хочу создавать
if(badfont) addSpaces()