-
Notifications
You must be signed in to change notification settings - Fork 666
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
Use with React / React-native? #338
Comments
+1! Would be very nice. Was about to look into this myself. |
Doesn't React also use a canvas? I've been using VexFlow with Pux, which is an interface to React for the language Purescript and I'm drawing my notation on a Canvas through that. Unless I'm not fully comprehending the workings behind Pux, I assume it should be possible. |
@marcoalkema Using the canvas is not the issue - it's more including the library and rendering things.. Do you have an example of how you're doing it? |
If you use react-dom, there's no problem at all to use vexflow. If there's no other volunteers, I will may handle in the future. I'm currently considering to use this (https://github.com/nodebox/opentype.js & https://github.com/icons8/svg-path-bounding-box) |
I am trying to use vexflow with react-native. It's a struggle, as I'm having to do it within a WebView component. I can get a 'hello-world' type example to render, but I don't know how I can do things more dynamically. Very interested in this discussion. |
Can we figure out what we'd need to change in Vexflow to get it working |
Oh wow, quite a few responses! It would be great if we could look into it. I think it would be a great feature! |
It looks many of you want this kind of standalone feature, so I changed my mind to do earlier. I spent today and... I'm happy to share this, now vexflow can successfully generate svg files without DOM! I added new context named SVGStringContext which extends SVGContext.
I'll clean up the codes and push to my fork and share with you tomorrow with details. |
That's great Taehoon. Thanks! How about naming it TextSVGContext? On Wed, May 4, 2016 at 2:24 PM, Taehoon Moon notifications@github.com
Mohit Muthanna [mohit (at) muthanna (uhuh) com] |
Wicked!! That was fast. Any chance you can provide a basic codesample as well?? |
I push to my fork with "standalone" branch.
But one more thing to fix.
Because of that, I found that a single test case broken The first one is blessed image and second thing is rendered by current fork. For rendering musical chord symbols properly, we need special font for chord which should have sharp, flat, other symbols and latin characters. Anyone knows any of license-free font for rendering music chord notations? |
@0xfe I like TextSVGContext, thanks! I renamed :) |
@taehoon, that first image is considered correct? Even though that first |
@mturley You're right, that first image is not correct, but it is blessed. It's probably an uncaught regression that originated before we had the visual regression tests. Given that the second image has the "+5" properly positioned, it seems like the bug related to measureText (as usual.) |
ah this is awesome! :) |
Yes this seems great, thanks for such fast response! A bit of example will really help to get started. |
@panarch re open licensed font, how about Bravura? It implements SMuFL which includes chord symbols. |
@infojunkie Yes it includes chord symbols but the issue is it does not have latin characters. @davidfloegel Yeah current state may not be kind enough to refer if you are not familiar with vexflow test scripts because I just applied it to inside current test scripts. I will add code examples after fixing current chord notation font issue. After that you can easily figure out how to use. |
@panarch re: fonts, it's my understanding that engraving systems typically use two fonts: one for music symbols and another for text, so it would make sense for VexFlow to follow suit. The advantage is that the engraver has the flexibility to choose any regular text font, without being limited to those that also contain music symbols. That's the idea of Bravura, Norfolk, etc. |
I have no problem with using multiple fonts, so long as they're public domain and license unencumbered. Feel free to add new glyphs into |
@0xfe yes, supporting multiple fonts and maybe even allowing app developers to specify their own - that don't need to be shipped with VF. |
Regarding the creation of a React component for VexFlow, I think @mlennon3 and others are wondering, as I do, about how to design such a component to be reusable: the VF tests are of course trivial to wrap in a React component (the DOM/SVG issue above notwithstanding), but how would a reusable component look like? In other words, what kind of API would a generic VF React component expose to allow the app developer to dynamically specify the music to display? To give examples of dynamic VexFlow generation:
A reusable React component would ideally expose all core VF functionality (e.g., via props) and conform to the React rendering workflow. |
@infojunkie @0xfe I got it. My description was not enough for this. The issue is... for running vexflow without web browser, we cannot get web browser's pleasant font system support. So the alternative is opentype.js, it's really nice but currently it does not support using multiple fonts feature. So developers should manually handle fonts. So I think this new TextSVGContext may not fit for many of light users because it requires users to do additional configurations. Users should manage fonts themselves, not convenient as CanvasContext or SVGContext which can use directly without any settings. TextSVGContext would be good choice for developers who wants to use vexflow in node.js or something like react-native, or better rendering performance (Because no more synchronous getBBox calling is required) |
Possible hotfix is that I can bring chord symbols like sharp, flat, etc from BravuraText and merge into current existing fonts(NotoSans, NotoSerif). So, if there looks hard to get proper chord notation font for now, I will modify existing fonts to fit into currently broken test case; "TextNote.TextNote_Superscript_and_Subscript" |
👍 |
@infojunkie And about React component, I'm not sure that I understand correctly. Although new TextSVGContext uses React library but it is not for providing users to make React component easily or somewhat related to React. It just need to use some kind of virtual-dom system to generate svg string and I thought ReactDOM was the best so I just used. In case of making ideal React component which have all core VF functionality, I think it's hard for now. |
@panarch re: React component, yes I agree VF itself lacks a clear programming model. Your idea of Builder API sounds good. I will be looking into the examples I mentioned above to emulate or expand on their approaches. Re: fonts, I guess it's an ongoing area of discussion for VF... Thanks for TextSVGContext, I'm looking forward to using it in my upcoming app project! |
@davidfloegel I've actually just yesterday starting playing around with getting VexFlow to dynamically update using React. My approach so far is to just destroy all the VexFlow created SVGs in https://github.com/dannyid/music-tutor/blob/master/js/components/Tutor.js |
Any progress on the use with react native? :) |
As per this post in Vexflow google group, @panarch has thankfully introduced an SVG rendering context (TextSVGContext) that works with react-native. The context could be found in Taehoon's fork of Vexflow repo https://github.com/panarch/vexflow/commits/standalone I tried to run the included tools/demo.js on android emulator, after making few unrelated changes. Unfortunately, I hit an error at this line:
Error message: Could someone give that demo a try? Hope it works. |
Sounds like maybe react-native-svg isn't processing absolute vs relative move commands in paths correctly. (Absolute is capital M, relative is lower case m.) |
Hi everyone, I have a good news. I wanted to participate since @matt-gardner reactivated but huh, I was having quite tough schedule on my 6 weeks trip so... now it's the last week of my long vacation and I made some work. At first, I thought making VexFlow run with React Native might be similar with Node.js, but it was very different issue. What I did first was replacing my previous Then, other big issue was font. It was easy to use file system in Node.js, but in React Native... it looked little bit messy to use file system directly for loading font files.
|
That is amazing!! Thank you so much :) |
@panarch, thank you very much, why will you add Node.js context? |
@SalahAdDin I just want to run VexFlow in my server without browser emulation. With Node.js context, we can render VexFlow without browser so it can make sense in may purposes. |
@panarch @davidfloegel @0xfe I've done a lot of work to improve the svg spec conformance and rendering accuracy of react-native-svg on android. You might want to try testing my fork, until it gets ported to ios and merged into master. software-mansion/react-native-svg#406 https://github.com/msand/react-native-svg/tree/5.3.0-conformance |
@matt-gardner you should probably get a mention about the fork/pull request as well |
I've forked the seed project, updated react, react-native, and, react-native-svg (using both master and my fork), ported the code to android, and updated the android build setup. If anyone is interested you can check it out here: https://github.com/msand/react-native-vexflow-seed |
Wow, looks great Mike! Thanks for doing this. Would you mind adding some instructions to the Wiki? |
Happy to find this thread! You guys have done some awesome work I get the following error after I |
@njwest Haven't touched this for quite some time, I guess there's newer/more changes in react-native-svg that I need to adapt the code to, or then I had monkey-patched it to work around that problem. Might look at it in the weekend. |
@msand Many thanks for the response -- could you post the package versions your fork works with? |
@ulisinn, hi man, it's your project a open source project? |
Sweet project! I am also a trumpet player :P |
You can simply create a Vexflow component for React. Maybe this will still help someone. |
Thank you so much for this! |
standalone-vexflow-context is fantastic, however, it cannot work with the latest version of Vexflow, as its peer dependencies require a Vexflow version prior to version 2 (which has gotta be extremely old), and the latest version of Vexflow requires calls to the DOM. I may fork standalone-vexflow-context and try to modify it so it can work with Vexflow 4.x.y, though I don't imagine it will be easy if it's even possible. |
这是来自QQ邮箱的假期自动回复邮件。已收到,-_-
|
what? |
Update: turns out altering standard-vexflow-context won't do anything. What allowed for standard-vexflow-context to work with Vexflow all the way back then will not work now as Vexflow is written is TypeScript, and the element property for the renderer has to be an HTML element. Honestly, it's easier to use a WebView at this point, but having to write the HTML as a string is...not ideal. |
Hi there,
Is it possible to use vexflow with react (react-native) at all?
I've used this library before for a phonegap based app but switching to react and would love to keep using this one!
Cheers
david
The text was updated successfully, but these errors were encountered: