Skip to content
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

fix: custom fontFamily in <SvgChart /> #110

Merged
merged 4 commits into from
Sep 21, 2023

Conversation

RohrerF
Copy link
Contributor

@RohrerF RohrerF commented Sep 12, 2023

While trying to use the <SvgChart /> I noticed that i can't set custom fonts for any of the elements. I noticed that the fontFamily prop is not properly set on the react-native-svg <Text/> element.

The following changes fix this issue:

  • Since the global flag is set on fontStyleReg the test function is stateful(documentation). This makes the second style not match the regex. Switching to matchAll resolves this issue. Alternatively the global flag could be removed from the regex, but matchAll is better showing the intent of the code.
  • the key of font-family is no longer ignored on purpose. Based on the code and history I could not figure out why this condition was there in the first place.

Signed-off-by: Florian Rohrer <dev@florianrohrer.ch>
@RohrerF RohrerF closed this Sep 12, 2023
@RohrerF RohrerF reopened this Sep 12, 2023
@zhiqingchen
Copy link
Member

matchAll doesn't work in lower versions of the js engine, so i replace it.
2b6ab35#diff-c71a0ed3ed3f13c38a88bd5580035be58180949a59ae19a62c9b01916b59fa7e

Signed-off-by: Florian Rohrer <dev@florianrohrer.ch>
@RohrerF
Copy link
Contributor Author

RohrerF commented Sep 13, 2023

i have now removed the use of matchAll and removed the global flag from the regex instead

@zhiqingchen
Copy link
Member

Thanks, we'll check the history and confirm if we can just remove the code.

@yechunxi
Copy link
Contributor

Now, We may can't remove this code
When SVG assets contain unavailable fonts, it result in a Unrecognized font family ... error, as shown below

1695031237678

react-native-svg has a similar issue, like this issue

@RohrerF
Copy link
Contributor Author

RohrerF commented Sep 18, 2023

How can I change the font on individual chart components if this attribute is filtered out? Additionally if I use an unavailable/invalid font in a chart I would expect an error to occur, so I don't see why this change shouldn't be possible.

@zhiqingchen
Copy link
Member

We need to change the default font settings and allow for custom fonts

@yechunxi
Copy link
Contributor

@RohrerF We solved the problem of echart's default font unrecognized error, and submitted a PR to your branch. Please merge it, so that custom fonts can be allowed.

fix: handle echart defalut font unrecognized error in ios
@zhiqingchen zhiqingchen merged commit e40f28f into wuba:main Sep 21, 2023
1 check failed
@RohrerF
Copy link
Contributor Author

RohrerF commented Sep 25, 2023

Thanks for merging 👍 please release a new version of the package if possible, thanks

@RohrerF RohrerF deleted the rohrerf/fix-svgChart-fonts branch September 25, 2023 05:32
@zhiqingchen
Copy link
Member

1.2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants