This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core, ios, macos, android] Support TinySDF for local glyph generation #10522
Merged
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0db5503
[core] C++ port of TinySDF
ChrisLoer 4c4ba86
[core] Enable local glyph generation using TinySDF.
ChrisLoer 477b3b5
[ios,macos] Darwin implementation of a CoreText-based LocalGlyphRaste…
ChrisLoer 35b9de1
[ios, macos] Adds support for specifying an ideographic font family name
d74807e
[android] Android implementation of local CJK glyph rendering
ChrisLoer f559cbf
[darwin, ios, macos] Introduces an MGLRendererConfiguration class
8140b96
[core, macos, ios] Unit tests for LocalGlyphRasterizer
ChrisLoer b38b137
[macos,ios,android] Unit test fixups
ChrisLoer 7d66f04
[android] Add Configuration hook for local ideograph font family and …
1681718
[android] Fixups for LocalGlyphActivity
ChrisLoer 978c4d0
[android] Tweak LocalGlyphActivity description to be a bit more speci…
ChrisLoer 0e1a259
[ios,macos] Remove dead/non-functioning font-weight and glyph metric …
ChrisLoer 9012b22
[darwin, macos] Rename Info.plist key for consistency
0247d2e
[macos, ios] Adds documentation for the MGLIdeographFontFamilyName key
e91272d
[ios,macos] Update docs to use Apple-friendly "PingFang" font example.
ChrisLoer a60d316
[ios,macos] Revert ideographic->ideograph name change.
ChrisLoer 3e7619b
[android] Add basic JavaDoc comment for LocalGlyphActivity.
ChrisLoer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...roid/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.mapbox.mapboxsdk.text; | ||
|
||
import android.graphics.Canvas; | ||
import android.graphics.Paint; | ||
import android.graphics.Bitmap; | ||
import android.graphics.Typeface; | ||
import android.support.annotation.WorkerThread; | ||
|
||
/** | ||
* LocalGlyphRasterizer is the Android-specific platform implementation used | ||
* by the portable local_glyph_rasterizer.hpp | ||
*/ | ||
public class LocalGlyphRasterizer { | ||
|
||
/*** | ||
* Uses Android-native drawing code to rasterize a single glyph | ||
* to a square @{link Bitmap} which can be returned to portable | ||
* code for transformation into a Signed Distance Field glyph. | ||
* | ||
* @param fontFamily Font family string to pass to Typeface.create | ||
* @param bold If true, use Typeface.BOLD option | ||
* @param glyphID 16-bit Unicode BMP codepoint to draw | ||
* | ||
* @return Return a @{link Bitmap} to be displayed in the requested tile. | ||
*/ | ||
@WorkerThread | ||
protected static Bitmap drawGlyphBitmap(String fontFamily, boolean bold, char glyphID) { | ||
/* | ||
35x35px dimensions are hardwired to match local_glyph_rasterizer.cpp | ||
These dimensions are large enough to draw a 24 point character in the middle | ||
of the bitmap (y: 20) with some buffer around the edge | ||
*/ | ||
Bitmap bitmap = Bitmap.createBitmap(35, 35, Bitmap.Config.ARGB_8888); | ||
|
||
Paint paint = new Paint(); | ||
paint.setAntiAlias(true); | ||
paint.setTextSize(24); | ||
paint.setTypeface(Typeface.create(fontFamily, bold ? Typeface.BOLD : Typeface.NORMAL)); | ||
|
||
Canvas canvas = new Canvas(); | ||
canvas.setBitmap(bitmap); | ||
canvas.drawText(String.valueOf(glyphID), 0, 20, paint); | ||
|
||
return bitmap; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be package protected I think? Could you please add short JavaDoc description of the class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a short JavaDoc description. Made the
drawGlyphMap
static method protected -- is that what you meant?