question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Android's getImageSource returning cropped images

See original GitHub issue

Environment

RN: 0.59.10 react-native-vector-icons: 6.6.0 Target platform: Android

Description

For our app that uses react-native-navigation, we are required to pass images to be used as icons for our bottomTabs. A very common approach is to use this library’s getImageSource function to generate the images. It seems that certain icons are not being generated correctly. Initially I thought it was related to FontAwesome 5 icons which we recently upgraded to but we are not the only ones running into it. (https://github.com/wix/react-native-navigation/issues/4931) and additionally it works perfectly on iOS.

I dove into the code myself, messing around with the getImageForFont Android function (https://github.com/oblador/react-native-vector-icons/blob/master/android/src/main/java/com/oblador/vectoricons/VectorIconsModule.java#L43)

But my knowledge is very limited when it comes to Fonts and how Android’s paint and canvas work. It seems that SVG’s that have a width bigger than height are being cropped incorrectly.

Reproducible Demo

I have confirmed this by doing the following:

loadedIconSource['fa-inbox'] = await FontAwesome.getImageSource('inbox', 24, undefined, FA5Style.solid);

And then using RN’s Image component to render it, (using resizeMode contain to make sure we don’t crop it):

<Image source={loadedIconSource['fa-inbox']} resizeMode="contain" style={{ height: 84, width: 84 }} />

Result is: Selection_018

How it should look like: https://fontawesome.com/icons/inbox?style=regular

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:14
  • Comments:22

github_iconTop GitHub Comments

10reactions
edferreiracommented, Oct 24, 2019

I’m also having this issue

2reactions
ItsNoHaxcommented, Aug 6, 2020

@vrgimael That’s not the fix… That’s the commit that broke this in the first place…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to save cropped image - Android - Stack Overflow
By using this code I'm able to crop the image but It's not saving and returns a Toast message stats Unable to Save...
Read more >
react-native-vector-icons - npm
Customizable Icons for React Native with support for NavBar/TabBar, image source and full styling.. Latest version: 9.2.0, last published: 6 ...
Read more >
image_crop_plus | Flutter Package - Pub.dev
A flutter plugin to crop image on iOS and Android. It processes image files off main thread natively. The plugin provides a Crop...
Read more >
Original Photos Disappear After Saving an Edited Version
Indeed, I could edit a photo or crop it etc... a hundred times and save ... gallery edit each one as you wish...
Read more >
How to pick images from Camera & Gallery in React Native app
To use react-native-image-picker library we have to link some dependencies in Android and iOS project files. So, we need to run the following...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found