JimmyDaddy / react-native-image-marker

๐Ÿ™ˆAdding text or icon watermark to your image using React Native๐Ÿ‘€๐Ÿ‘€
https://jimmydaddy.github.io/react-native-image-marker/
MIT License
316 stars 93 forks source link

fontName not work (ANDROID) #195

Closed vioku closed 7 months ago

vioku commented 7 months ago

` const options = { backgroundImage: { src: response.assets[0].uri, scale: 1, }, watermarkTexts: [ { text: 'hello-' + Date.now(), positionOptions: { position: Position.center, }, style: { color: '#ff00ff', fontSize: 30, fontName: 'OoohBaby-Regular',

          textBackgroundStyle: {
            type: TextBackgroundType.none,
          },
        },
      },
    ],
    scale: 1,
    quality: 100,

    saveFormat: ImageFormat.png,
  };
  Marker.markText(options)
    .then(res => {
      setimage('file://' + res);
    })
    .catch(err => {
      console.log(err);
    }); `

Whats wrong ? custom font not work

i have tested on my font show correctly <Text className="text-white font-[OoohBaby-Regular] text-3xl text-center"> Testing Font </Text>

Screenshot 2024-01-22 110545

vioku commented 7 months ago

Solved

how? open YOURPROJECT\node_modules\react-native-image-marker\android\src\main\java\com\jimmydaddy\imagemarker\base\TextOptions.kt

and go to line 78

change this var typeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)

to this var typeface = Typeface.create(ReactFontManager.getInstance() .getTypeface(style.fontName!!, Typeface.NORMAL, context.assets), Typeface.NORMAL)

JimmyDaddy commented 7 months ago

@vioku Can you submit a PR for this fix? ๐Ÿ˜Š

vioku commented 7 months ago

@vioku Can you submit a PR for this fix? ๐Ÿ˜Š

Done Sir @JimmyDaddy ๐Ÿ˜Š๐Ÿ’ฅ