[android] Expose "local ideograph font family" in MapSnapshotter::Options
Use local glyph generation in test app's MapSnapshotterActivity.
This commit is contained in:
@@ -95,6 +95,7 @@ public class MapSnapshotter {
|
||||
private LatLngBounds region;
|
||||
private CameraPosition cameraPosition;
|
||||
private boolean showLogo = true;
|
||||
private String localIdeographFontFamily;
|
||||
|
||||
/**
|
||||
* @param width the width of the image
|
||||
@@ -171,6 +172,22 @@ public class MapSnapshotter {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font family for generating glyphs locally for ideographs in the 'CJK Unified Ideographs'
|
||||
* and 'Hangul Syllables' ranges.
|
||||
* <p>
|
||||
* The font family argument is passed to {@link android.graphics.Typeface#create(String, int)}.
|
||||
* Default system fonts are defined in '/system/etc/fonts.xml'
|
||||
*
|
||||
* @param fontFamily font family for local ideograph generation.
|
||||
* @return the mutated {@link Options}
|
||||
*/
|
||||
@NonNull
|
||||
public Options withLocalIdeographFontFamily(String fontFamily) {
|
||||
this.localIdeographFontFamily = fontFamily;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the width of the image
|
||||
*/
|
||||
@@ -214,6 +231,14 @@ public class MapSnapshotter {
|
||||
public CameraPosition getCameraPosition() {
|
||||
return cameraPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the font family used for locally generating ideographs
|
||||
*/
|
||||
public String getLocalIdeographFontFamily() {
|
||||
return localIdeographFontFamily;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,7 +256,7 @@ public class MapSnapshotter {
|
||||
|
||||
nativeInitialize(this, fileSource, options.pixelRatio, options.width,
|
||||
options.height, options.styleUrl, options.styleJson, options.region, options.cameraPosition,
|
||||
options.showLogo, programCacheDir);
|
||||
options.showLogo, programCacheDir, options.localIdeographFontFamily);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -513,7 +538,8 @@ public class MapSnapshotter {
|
||||
FileSource fileSource, float pixelRatio,
|
||||
int width, int height, String styleUrl, String styleJson,
|
||||
LatLngBounds region, CameraPosition position,
|
||||
boolean showLogo, String programCacheDir);
|
||||
boolean showLogo, String programCacheDir,
|
||||
String localIdeographFontFamily);
|
||||
|
||||
@Keep
|
||||
protected native void nativeStart();
|
||||
|
||||
@@ -68,7 +68,8 @@ public class MapSnapshotterActivity extends AppCompatActivity {
|
||||
.withPixelRatio(1)
|
||||
|
||||
// Optionally the style
|
||||
.withStyle((column + row) % 2 == 0 ? Style.MAPBOX_STREETS : Style.DARK);
|
||||
.withStyle((column + row) % 2 == 0 ? Style.MAPBOX_STREETS : Style.DARK)
|
||||
.withLocalIdeographFontFamily("sans-serif");
|
||||
|
||||
// Optionally the visible region
|
||||
if (row % 2 == 0) {
|
||||
|
||||
@@ -24,7 +24,8 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
|
||||
const jni::Object<LatLngBounds>& region,
|
||||
const jni::Object<CameraPosition>& position,
|
||||
jni::jboolean _showLogo,
|
||||
const jni::String& _programCacheDir)
|
||||
const jni::String& _programCacheDir,
|
||||
const jni::String& _localIdeographFontFamily)
|
||||
: javaPeer(_env, _obj)
|
||||
, pixelRatio(_pixelRatio)
|
||||
, threadPool(sharedThreadPool()) {
|
||||
@@ -65,7 +66,10 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
|
||||
pixelRatio,
|
||||
cameraOptions,
|
||||
bounds,
|
||||
jni::Make<std::string>(_env, _programCacheDir));
|
||||
jni::Make<std::string>(_env, _programCacheDir),
|
||||
_localIdeographFontFamily ?
|
||||
jni::Make<std::string>(_env, _localIdeographFontFamily) :
|
||||
optional<std::string>{});
|
||||
|
||||
}
|
||||
|
||||
@@ -156,7 +160,7 @@ void MapSnapshotter::registerNative(jni::JNIEnv& env) {
|
||||
|
||||
// Register the peer
|
||||
jni::RegisterNativePeer<MapSnapshotter>(env, javaClass, "nativePtr",
|
||||
jni::MakePeer<MapSnapshotter, const jni::Object<MapSnapshotter>&, const jni::Object<FileSource>&, jni::jfloat, jni::jint, jni::jint, const jni::String&, const jni::String&, const jni::Object<LatLngBounds>&, const jni::Object<CameraPosition>&, jni::jboolean, const jni::String&>,
|
||||
jni::MakePeer<MapSnapshotter, const jni::Object<MapSnapshotter>&, const jni::Object<FileSource>&, jni::jfloat, jni::jint, jni::jint, const jni::String&, const jni::String&, const jni::Object<LatLngBounds>&, const jni::Object<CameraPosition>&, jni::jboolean, const jni::String&, const jni::String&>,
|
||||
"nativeInitialize",
|
||||
"finalize",
|
||||
METHOD(&MapSnapshotter::setStyleUrl, "setStyleUrl"),
|
||||
|
||||
@@ -35,7 +35,8 @@ public:
|
||||
const jni::Object<LatLngBounds>& region,
|
||||
const jni::Object<CameraPosition>& position,
|
||||
jni::jboolean showLogo,
|
||||
const jni::String& programCacheDir);
|
||||
const jni::String& programCacheDir,
|
||||
const jni::String& localIdeographFontFamily);
|
||||
|
||||
~MapSnapshotter();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user