[android] add fallback support to local ideograph font families, allow setting a collection of fonts

This commit is contained in:
tobrun
2019-07-30 17:14:26 +03:00
committed by Łukasz Paczos
parent bc09cdbf76
commit 58d7734722
8 changed files with 167 additions and 12 deletions

View File

@@ -0,0 +1,43 @@
package com.mapbox.mapboxsdk.utils;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@RunWith(AndroidJUnit4.class)
public class FontUtilsTest {
@Test
public void testExtractedFontShouldMatchDefault() {
String[] fonts = new String[] {"foo", "bar"};
String actual = FontUtils.extractValidFont(fonts);
assertEquals("Selected font should match", MapboxConstants.DEFAULT_FONT, actual);
}
@Test
public void testExtractedFontShouldMatchMonospace() {
String expected = "monospace";
String[] fonts = new String[] {"foo", expected};
String actual = FontUtils.extractValidFont(fonts);
assertEquals("Selected font should match", expected, actual);
}
@Test
public void testExtractedFontArrayShouldBeNull() {
String[] fonts = null;
String actual = FontUtils.extractValidFont(fonts);
assertNull(actual);
}
@Test
public void testExtractedFontShouldBeNull() {
String actual = FontUtils.extractValidFont(null);
assertNull(actual);
}
}

View File

@@ -7,6 +7,7 @@ import android.widget.GridLayout;
import android.widget.ImageView;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
@@ -68,7 +69,7 @@ public class MapSnapshotterActivity extends AppCompatActivity {
// Optionally the style
.withStyle((column + row) % 2 == 0 ? Style.MAPBOX_STREETS : Style.DARK)
.withLocalIdeographFontFamily("sans-serif");
.withLocalIdeographFontFamily(MapboxConstants.DEFAULT_FONT);
// Optionally the visible region
if (row % 2 == 0) {