Skip to content

fix: android font bug fix v1.1.x #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@


## [1.1.13](https://github.com/JimmyDaddy/react-native-image-marker/compare/v1.1.12...v1.1.13) (2024-01-22)


### Bug Fixes

* fix [#158](https://github.com/JimmyDaddy/react-native-image-marker/issues/158) android release bug style not working ([#160](https://github.com/JimmyDaddy/react-native-image-marker/issues/160)) ([a942e30](https://github.com/JimmyDaddy/react-native-image-marker/commit/a942e30732c61094abc1e95ca5003c883d1e4410))
* fontName bug (android) ([#196](https://github.com/JimmyDaddy/react-native-image-marker/issues/196)) ([390a418](https://github.com/JimmyDaddy/react-native-image-marker/commit/390a418fe6034f737485c7609c0276f58d08b2a4))


## [1.1.12](https://github.com/JimmyDaddy/react-native-image-marker/compare/v1.1.11...v1.1.12) (2024-01-01)


Expand Down Expand Up @@ -118,4 +127,4 @@

### Features

* support multiple text and more style options ([#104](https://github.com/JimmyDaddy/react-native-image-marker/issues/104)) ([0b91cd4](https://github.com/JimmyDaddy/react-native-image-marker/commit/0b91cd4baaf2f664f908483b225509e443f9bae7))
* support multiple text and more style options ([#104](https://github.com/JimmyDaddy/react-native-image-marker/issues/104)) ([0b91cd4](https://github.com/JimmyDaddy/react-native-image-marker/commit/0b91cd4baaf2f664f908483b225509e443f9bae7))
3 changes: 2 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[![CI](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/ci.yml/badge.svg)](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/ci.yml)
![platform-iOS](https://img.shields.io/badge/iOS-black?logo=Apple&style=for-the-badge) ![platform-Android](https://img.shields.io/badge/Android-black?logo=Android&style=for-the-badge)
<br/>

</div>

---
Expand Down Expand Up @@ -711,6 +711,7 @@ This library use [Fresco](https://github.com/facebook/fresco) to decode image on
[@gaoxiaosong](https://github.com/gaoxiaosong)
[@onka13](https://github.com/onka13)
[@OrangeFlavoredColdCoffee](https://github.com/OrangeFlavoredColdCoffee)
[@Dendi](https://github.com/vioku)

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ data class TextOptions(val options: ReadableMap) {
style.shadowLayerStyle!!.color
)
}
try {
//设置字体失败时使用默认字体
textPaint.typeface = ReactFontManager.getInstance()
.getTypeface(style.fontName!!, Typeface.NORMAL, context.assets)
} catch (e: Exception) {
textPaint.typeface = Typeface.DEFAULT

var typefaceFamily = Typeface.DEFAULT
if (style.fontName != null) {
typefaceFamily = try {
//设置字体失败时使用默认字体
ReactFontManager.getInstance()
.getTypeface(style.fontName!!, Typeface.NORMAL, context.assets)
} catch (e: Exception) {
Log.e(Constants.IMAGE_MARKER_TAG, "Could not get typeface: " + e.message)
Typeface.DEFAULT
}
}
val textSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
Expand All @@ -75,13 +80,13 @@ data class TextOptions(val options: ReadableMap) {
textPaint.color = Color.parseColor(Utils.transRGBColor(style.color))
textPaint.isUnderlineText = style.underline
textPaint.textSkewX = style.skewX!!
var typeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)
var typeface = Typeface.create(typefaceFamily, Typeface.NORMAL)
if (style.italic && style.bold) {
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD_ITALIC)
typeface = Typeface.create(typefaceFamily, Typeface.BOLD_ITALIC)
} else if (style.italic) {
typeface = Typeface.create(Typeface.DEFAULT, Typeface.ITALIC)
typeface = Typeface.create(typefaceFamily, Typeface.ITALIC)
} else if (style.bold) {
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)
typeface = Typeface.create(typefaceFamily, Typeface.BOLD)
}
textPaint.isStrikeThruText = style.strikeThrough
textPaint.typeface = typeface
Expand Down
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions example/android/link-assets-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"migIndex": 1,
"data": [
{
"path": "assets/fonts/MaShanZheng-Regular.ttf",
"sha1": "1376fdd48ab29afd9599101e8991b773f12177e5"
},
{
"path": "assets/fonts/RubikBurned-Regular.ttf",
"sha1": "546eccbc5a368bd10e6a4fe9570208428c16a036"
}
]
}
Binary file added example/assets/fonts/MaShanZheng-Regular.ttf
Binary file not shown.
Binary file added example/assets/fonts/RubikBurned-Regular.ttf
Binary file not shown.
17 changes: 17 additions & 0 deletions example/ios/ImageMarkerExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
552FE0025890E32E99AF119A /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 744A2F230C283E0D140F997B /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
93F7B1DDABE441E6B6212F21 /* MaShanZheng-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 50CB977CE5BF44179F12CFF5 /* MaShanZheng-Regular.ttf */; };
A119E9E12B162437000C0527 /* ImageMarkerExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A119E9E02B162437000C0527 /* ImageMarkerExampleUITests.swift */; };
A119E9E32B162437000C0527 /* ImageMarkerExampleUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A119E9E22B162437000C0527 /* ImageMarkerExampleUITestsLaunchTests.swift */; };
F95A8E69C66343EEB9A8D9DC /* RubikBurned-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E3DA1B9696844B35AAE670BD /* RubikBurned-Regular.ttf */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -36,6 +38,7 @@
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ImageMarkerExample/main.m; sourceTree = "<group>"; };
26EC0163490429FD1EA48765 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig"; path = "Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests.release.xcconfig"; sourceTree = "<group>"; };
3B4392A12AC88292D35C810B /* Pods-ImageMarkerExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageMarkerExample.debug.xcconfig"; path = "Target Support Files/Pods-ImageMarkerExample/Pods-ImageMarkerExample.debug.xcconfig"; sourceTree = "<group>"; };
50CB977CE5BF44179F12CFF5 /* MaShanZheng-Regular.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = "MaShanZheng-Regular.ttf"; path = "../assets/fonts/MaShanZheng-Regular.ttf"; sourceTree = "<group>"; };
5709B34CF0A7D63546082F79 /* Pods-ImageMarkerExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageMarkerExample.release.xcconfig"; path = "Target Support Files/Pods-ImageMarkerExample/Pods-ImageMarkerExample.release.xcconfig"; sourceTree = "<group>"; };
5AF9B3B6D62946E1E270EDB8 /* Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig"; path = "Target Support Files/Pods-ImageMarkerExample-ImageMarkerExampleUITests/Pods-ImageMarkerExample-ImageMarkerExampleUITests.debug.xcconfig"; sourceTree = "<group>"; };
5DCACB8F33CDC322A6C60F78 /* libPods-ImageMarkerExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ImageMarkerExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -44,6 +47,7 @@
A119E9DE2B162437000C0527 /* ImageMarkerExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ImageMarkerExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
A119E9E02B162437000C0527 /* ImageMarkerExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageMarkerExampleUITests.swift; sourceTree = "<group>"; };
A119E9E22B162437000C0527 /* ImageMarkerExampleUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageMarkerExampleUITestsLaunchTests.swift; sourceTree = "<group>"; };
E3DA1B9696844B35AAE670BD /* RubikBurned-Regular.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = "RubikBurned-Regular.ttf"; path = "../assets/fonts/RubikBurned-Regular.ttf"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -106,6 +110,7 @@
83CBBA001A601CBA00E9B192 /* Products */,
2D16E6871FA4F8E400B85C8A /* Frameworks */,
BBD78D7AC51CEA395F1C20DB /* Pods */,
A12431AF27494A9D92C20CF1 /* Resources */,
);
indentWidth = 2;
sourceTree = "<group>";
Expand All @@ -130,6 +135,16 @@
path = ImageMarkerExampleUITests;
sourceTree = "<group>";
};
A12431AF27494A9D92C20CF1 /* Resources */ = {
isa = PBXGroup;
children = (
E3DA1B9696844B35AAE670BD /* RubikBurned-Regular.ttf */,
50CB977CE5BF44179F12CFF5 /* MaShanZheng-Regular.ttf */,
);
name = Resources;
path = "";
sourceTree = "<group>";
};
BBD78D7AC51CEA395F1C20DB /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -231,6 +246,8 @@
files = (
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
F95A8E69C66343EEB9A8D9DC /* RubikBurned-Regular.ttf in Resources */,
93F7B1DDABE441E6B6212F21 /* MaShanZheng-Regular.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
9 changes: 8 additions & 1 deletion example/ios/ImageMarkerExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string/>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string>want to use</string>
<key>UIAppFonts</key>
<array>
<string>RubikBurned-Regular.ttf</string>
<string>MaShanZheng-Regular.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
13 changes: 13 additions & 0 deletions example/ios/link-assets-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"migIndex": 1,
"data": [
{
"path": "assets/fonts/MaShanZheng-Regular.ttf",
"sha1": "1376fdd48ab29afd9599101e8991b773f12177e5"
},
{
"path": "assets/fonts/RubikBurned-Regular.ttf",
"sha1": "546eccbc5a368bd10e6a4fe9570208428c16a036"
}
]
}
1 change: 1 addition & 0 deletions example/react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ module.exports = {
root: path.join(__dirname, '..'),
},
},
assets: ['./assets/fonts'],
};
6 changes: 3 additions & 3 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ function useViewModel() {
},
style: {
color: '#FF0000AA',
fontName: 'Arial',
fontName: 'MaShanZheng-Regular',
fontSize,
underline,
bold,
Expand Down Expand Up @@ -520,7 +520,7 @@ function useViewModel() {
},
style: {
color: '#FF00AA9F',
fontName: 'NotoSansSC-Regular',
fontName: 'RubikBurned-Regular',
fontSize,
underline,
bold,
Expand Down Expand Up @@ -1146,7 +1146,7 @@ function App() {
/>
</RowSplit>
{/* <RowSplit>

</RowSplit> */}
<TouchableOpacity
style={[s.btn, { height: 40 }]}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-image-marker",
"version": "1.1.12",
"version": "1.1.13",
"description": "Add text or icon watermark to your images",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down