mapbox / mapbox/mapbox-maps-ios
Local font Chinese does not take effect
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
Environment
- Xcode version: 15.2
- iOS version: 17.2
- Devices affected: iphone1 5 pro max
- Maps SDK Version: 11.1.0
hello,I used the following code to set local fonts for mapbox,but only letters and numbers are valid, Chinese characters are not valid.
code:
let center = CLLocationCoordinate2D(latitude: 40.669957, longitude: -103.5917968)
let cameraOptions = CameraOptions(center: center, zoom: 2)
if let path = Bundle.main.path(forResource: "blueprint_style", ofType: "json"),
let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe),
var json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
let fontPath = "asset:/\(NSHomeDirectory())/Fonts/{fontstack}/{range}.pbf"
json["glyphs"] = fontPath
let styleJson = json.jsonString()
let mapOptions = MapOptions(glyphsRasterizationOptions: GlyphsRasterizationOptions(rasterizationMode: .ideographsRasterizedLocally))
let mapInitOptions = MapInitOptions(mapOptions: mapOptions, cameraOptions: cameraOptions, styleJSON: styleJson)
mapView = MapView(frame: view.bounds, mapInitOptions: mapInitOptions)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
mapView.tintColor = .lightGray
view.addSubview(mapView)
mapView.mapboxMap.onStyleLoaded.observeNext { [weak self] _ in
self?.addPointClusters()
}.store(in: &cancelables)
}
The effect is as shown below
The local fonts are as follows
Font.zip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported behavior from the Swift snippet using the provided local font archive, Mapbox Maps SDK 11.1.0, and the stated iOS environment. Compare Chinese glyph rendering with letters and numbers, then trace the local glyph configuration and rasterization options. Done means Chinese characters render correctly from the local fonts, or the limitation and required configuration are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100