Skip to content

Commit 6e4bd2e

Browse files
JimmyDaddyvioku
andauthored
fix: android font bug fix v1.1.x (#198)
* fix: fontName bug (android) (#196) * fix: add custom fonts to example * docs: add collaborator * chore: release 1.1.13 --------- Co-authored-by: Dendi <[email protected]>
1 parent 2eec9b6 commit 6e4bd2e

File tree

14 files changed

+83
-17
lines changed

14 files changed

+83
-17
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11

22

3+
## [1.1.13](https://github.com/JimmyDaddy/react-native-image-marker/compare/v1.1.12...v1.1.13) (2024-01-22)
4+
5+
6+
### Bug Fixes
7+
8+
* 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))
9+
* 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))
10+
11+
312
## [1.1.12](https://github.com/JimmyDaddy/react-native-image-marker/compare/v1.1.11...v1.1.12) (2024-01-01)
413

514

@@ -118,4 +127,4 @@
118127

119128
### Features
120129

121-
* 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))
130+
* 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))

README.MD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[![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)
1616
![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)
1717
<br/>
18-
18+
1919
</div>
2020

2121
---
@@ -711,6 +711,7 @@ This library use [Fresco](https://github.com/facebook/fresco) to decode image on
711711
[@gaoxiaosong](https://github.com/gaoxiaosong)
712712
[@onka13](https://github.com/onka13)
713713
[@OrangeFlavoredColdCoffee](https://github.com/OrangeFlavoredColdCoffee)
714+
[@Dendi](https://github.com/vioku)
714715

715716
## Examples
716717

android/src/main/java/com/jimmydaddy/imagemarker/base/TextOptions.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,17 @@ data class TextOptions(val options: ReadableMap) {
5757
style.shadowLayerStyle!!.color
5858
)
5959
}
60-
try {
61-
//设置字体失败时使用默认字体
62-
textPaint.typeface = ReactFontManager.getInstance()
63-
.getTypeface(style.fontName!!, Typeface.NORMAL, context.assets)
64-
} catch (e: Exception) {
65-
textPaint.typeface = Typeface.DEFAULT
60+
61+
var typefaceFamily = Typeface.DEFAULT
62+
if (style.fontName != null) {
63+
typefaceFamily = try {
64+
//设置字体失败时使用默认字体
65+
ReactFontManager.getInstance()
66+
.getTypeface(style.fontName!!, Typeface.NORMAL, context.assets)
67+
} catch (e: Exception) {
68+
Log.e(Constants.IMAGE_MARKER_TAG, "Could not get typeface: " + e.message)
69+
Typeface.DEFAULT
70+
}
6671
}
6772
val textSize = TypedValue.applyDimension(
6873
TypedValue.COMPLEX_UNIT_SP,
@@ -75,13 +80,13 @@ data class TextOptions(val options: ReadableMap) {
7580
textPaint.color = Color.parseColor(Utils.transRGBColor(style.color))
7681
textPaint.isUnderlineText = style.underline
7782
textPaint.textSkewX = style.skewX!!
78-
var typeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)
83+
var typeface = Typeface.create(typefaceFamily, Typeface.NORMAL)
7984
if (style.italic && style.bold) {
80-
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD_ITALIC)
85+
typeface = Typeface.create(typefaceFamily, Typeface.BOLD_ITALIC)
8186
} else if (style.italic) {
82-
typeface = Typeface.create(Typeface.DEFAULT, Typeface.ITALIC)
87+
typeface = Typeface.create(typefaceFamily, Typeface.ITALIC)
8388
} else if (style.bold) {
84-
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)
89+
typeface = Typeface.create(typefaceFamily, Typeface.BOLD)
8590
}
8691
textPaint.isStrikeThruText = style.strikeThrough
8792
textPaint.typeface = typeface
Binary file not shown.
Binary file not shown.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"migIndex": 1,
3+
"data": [
4+
{
5+
"path": "assets/fonts/MaShanZheng-Regular.ttf",
6+
"sha1": "1376fdd48ab29afd9599101e8991b773f12177e5"
7+
},
8+
{
9+
"path": "assets/fonts/RubikBurned-Regular.ttf",
10+
"sha1": "546eccbc5a368bd10e6a4fe9570208428c16a036"
11+
}
12+
]
13+
}
5.58 MB
Binary file not shown.
591 KB
Binary file not shown.

example/ios/ImageMarkerExample.xcodeproj/project.pbxproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
1414
552FE0025890E32E99AF119A /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 744A2F230C283E0D140F997B /* libPods-ImageMarkerExample-ImageMarkerExampleUITests.a */; };
1515
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
16+
93F7B1DDABE441E6B6212F21 /* MaShanZheng-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 50CB977CE5BF44179F12CFF5 /* MaShanZheng-Regular.ttf */; };
1617
A119E9E12B162437000C0527 /* ImageMarkerExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A119E9E02B162437000C0527 /* ImageMarkerExampleUITests.swift */; };
1718
A119E9E32B162437000C0527 /* ImageMarkerExampleUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A119E9E22B162437000C0527 /* ImageMarkerExampleUITestsLaunchTests.swift */; };
19+
F95A8E69C66343EEB9A8D9DC /* RubikBurned-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E3DA1B9696844B35AAE670BD /* RubikBurned-Regular.ttf */; };
1820
/* End PBXBuildFile section */
1921

2022
/* Begin PBXContainerItemProxy section */
@@ -36,6 +38,7 @@
3638
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ImageMarkerExample/main.m; sourceTree = "<group>"; };
3739
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>"; };
3840
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>"; };
41+
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>"; };
3942
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>"; };
4043
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>"; };
4144
5DCACB8F33CDC322A6C60F78 /* libPods-ImageMarkerExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ImageMarkerExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -44,6 +47,7 @@
4447
A119E9DE2B162437000C0527 /* ImageMarkerExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ImageMarkerExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4548
A119E9E02B162437000C0527 /* ImageMarkerExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageMarkerExampleUITests.swift; sourceTree = "<group>"; };
4649
A119E9E22B162437000C0527 /* ImageMarkerExampleUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageMarkerExampleUITestsLaunchTests.swift; sourceTree = "<group>"; };
50+
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>"; };
4751
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
4852
/* End PBXFileReference section */
4953

@@ -106,6 +110,7 @@
106110
83CBBA001A601CBA00E9B192 /* Products */,
107111
2D16E6871FA4F8E400B85C8A /* Frameworks */,
108112
BBD78D7AC51CEA395F1C20DB /* Pods */,
113+
A12431AF27494A9D92C20CF1 /* Resources */,
109114
);
110115
indentWidth = 2;
111116
sourceTree = "<group>";
@@ -130,6 +135,16 @@
130135
path = ImageMarkerExampleUITests;
131136
sourceTree = "<group>";
132137
};
138+
A12431AF27494A9D92C20CF1 /* Resources */ = {
139+
isa = PBXGroup;
140+
children = (
141+
E3DA1B9696844B35AAE670BD /* RubikBurned-Regular.ttf */,
142+
50CB977CE5BF44179F12CFF5 /* MaShanZheng-Regular.ttf */,
143+
);
144+
name = Resources;
145+
path = "";
146+
sourceTree = "<group>";
147+
};
133148
BBD78D7AC51CEA395F1C20DB /* Pods */ = {
134149
isa = PBXGroup;
135150
children = (
@@ -231,6 +246,8 @@
231246
files = (
232247
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
233248
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
249+
F95A8E69C66343EEB9A8D9DC /* RubikBurned-Regular.ttf in Resources */,
250+
93F7B1DDABE441E6B6212F21 /* MaShanZheng-Regular.ttf in Resources */,
234251
);
235252
runOnlyForDeploymentPostprocessing = 0;
236253
};

example/ios/ImageMarkerExample/Info.plist

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@
4040
</dict>
4141
</dict>
4242
<key>NSLocationWhenInUseUsageDescription</key>
43-
<string/>
43+
<string></string>
44+
<key>NSPhotoLibraryUsageDescription</key>
45+
<string>want to use</string>
46+
<key>UIAppFonts</key>
47+
<array>
48+
<string>RubikBurned-Regular.ttf</string>
49+
<string>MaShanZheng-Regular.ttf</string>
50+
</array>
4451
<key>UILaunchStoryboardName</key>
4552
<string>LaunchScreen</string>
4653
<key>UIRequiredDeviceCapabilities</key>

example/ios/link-assets-manifest.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"migIndex": 1,
3+
"data": [
4+
{
5+
"path": "assets/fonts/MaShanZheng-Regular.ttf",
6+
"sha1": "1376fdd48ab29afd9599101e8991b773f12177e5"
7+
},
8+
{
9+
"path": "assets/fonts/RubikBurned-Regular.ttf",
10+
"sha1": "546eccbc5a368bd10e6a4fe9570208428c16a036"
11+
}
12+
]
13+
}

example/react-native.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ module.exports = {
77
root: path.join(__dirname, '..'),
88
},
99
},
10+
assets: ['./assets/fonts'],
1011
};

example/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ function useViewModel() {
485485
},
486486
style: {
487487
color: '#FF0000AA',
488-
fontName: 'Arial',
488+
fontName: 'MaShanZheng-Regular',
489489
fontSize,
490490
underline,
491491
bold,
@@ -520,7 +520,7 @@ function useViewModel() {
520520
},
521521
style: {
522522
color: '#FF00AA9F',
523-
fontName: 'NotoSansSC-Regular',
523+
fontName: 'RubikBurned-Regular',
524524
fontSize,
525525
underline,
526526
bold,
@@ -1146,7 +1146,7 @@ function App() {
11461146
/>
11471147
</RowSplit>
11481148
{/* <RowSplit>
1149-
1149+
11501150
</RowSplit> */}
11511151
<TouchableOpacity
11521152
style={[s.btn, { height: 40 }]}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-image-marker",
3-
"version": "1.1.12",
3+
"version": "1.1.13",
44
"description": "Add text or icon watermark to your images",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

0 commit comments

Comments
 (0)