Merge "Revert "Introduce set/getFontVariationSettings.""
This commit is contained in:
committed by
Android (Google) Code Review
commit
24fac986ec
@ -21,7 +21,6 @@ import android.util.Xml;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -105,12 +104,9 @@ public class FontListParser {
|
||||
// Note that a well-formed variation contains a four-character tag and a float as styleValue,
|
||||
// with spacers in between. The tag is enclosd either by double quotes or single quotes.
|
||||
@VisibleForTesting
|
||||
public static ArrayList<Axis> parseFontVariationSettings(@Nullable String settings) {
|
||||
ArrayList<Axis> axisList = new ArrayList<>();
|
||||
if (settings == null) {
|
||||
return axisList;
|
||||
}
|
||||
public static Axis[] parseFontVariationSettings(String settings) {
|
||||
String[] settingList = settings.split(",");
|
||||
ArrayList<Axis> axisList = new ArrayList<>();
|
||||
settingLoop:
|
||||
for (String setting : settingList) {
|
||||
int pos = 0;
|
||||
@ -154,7 +150,7 @@ public class FontListParser {
|
||||
tagString.charAt(3));
|
||||
axisList.add(new Axis(tag, styleValue));
|
||||
}
|
||||
return axisList;
|
||||
return axisList.toArray(new Axis[axisList.size()]);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -71,7 +71,6 @@ public class Paint {
|
||||
|
||||
private LocaleList mLocales;
|
||||
private String mFontFeatureSettings;
|
||||
private String mFontVariationSettings;
|
||||
|
||||
private static final Object sCacheLock = new Object();
|
||||
|
||||
@ -1494,37 +1493,6 @@ public class Paint {
|
||||
nSetFontFeatureSettings(mNativePaint, settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font variation settings.
|
||||
*
|
||||
* @return the paint's currently set font variation settings. Default is null.
|
||||
*
|
||||
* @see #setFontVariationSettings(String)
|
||||
*/
|
||||
public String getFontVariationSettings() {
|
||||
return mFontVariationSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font variation settings.
|
||||
*
|
||||
* @param settings font variation settings, e.g. "'wdth' 300, 'wght' 1.8"
|
||||
*
|
||||
* @see #getFontVariationSettings()
|
||||
*
|
||||
* @param settings the font variation settings. You can pass null or empty string as no
|
||||
* variation settings.
|
||||
*/
|
||||
public void setFontVariationSettings(String settings) {
|
||||
settings = TextUtils.nullIfEmpty(settings);
|
||||
if (settings == mFontVariationSettings
|
||||
|| (settings != null && settings.equals(mFontVariationSettings))) {
|
||||
return;
|
||||
}
|
||||
mFontVariationSettings = settings;
|
||||
setTypeface(Typeface.createFromTypefaceWithVariation(mTypeface, settings));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of hyphen edit.
|
||||
*
|
||||
|
@ -21,7 +21,6 @@ import android.util.Log;
|
||||
import android.util.LongSparseArray;
|
||||
import android.util.LruCache;
|
||||
import android.util.SparseArray;
|
||||
import android.graphics.FontListParser;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
@ -172,15 +171,6 @@ public class Typeface {
|
||||
return typeface;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static Typeface createFromTypefaceWithVariation(Typeface family,
|
||||
String fontVariationSettings) {
|
||||
final long ni = family == null ? 0 : family.native_instance;
|
||||
ArrayList<FontListParser.Axis> axes =
|
||||
FontListParser.parseFontVariationSettings(fontVariationSettings);
|
||||
return new Typeface(nativeCreateFromTypefaceWithVariation(ni, axes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns one of the default typeface objects, based on the specified style
|
||||
*
|
||||
@ -453,8 +443,6 @@ public class Typeface {
|
||||
}
|
||||
|
||||
private static native long nativeCreateFromTypeface(long native_instance, int style);
|
||||
private static native long nativeCreateFromTypefaceWithVariation(
|
||||
long native_instance, List<FontListParser.Axis> axes);
|
||||
private static native long nativeCreateWeightAlias(long native_instance, int weight);
|
||||
private static native void nativeUnref(long native_instance);
|
||||
private static native int nativeGetStyle(long native_instance);
|
||||
|
Reference in New Issue
Block a user