IMO, I would go with externs. The externs SWC defines the API for a replaceable module, and then if we do want to leverage this code in other FlexJS targets, we simply implement that SWC on a different target. You could go the extra mile and make sure everything on the API surface is an Interface and not a Class, but not necessary, I think.
If you do this work in public, you are right that there is going to be more overhead, but the tradeoff is that some other company who needs the same or similar thing will pitch in and essentially provide free labor, and, while I may not help write any of the code, I will be more motivated to try to help answer questions and fix bugs in other code that is affecting you. AIUI, your company can get attribution in our NOTICE file, if that helps. -Alex On 7/15/16, 1:41 AM, "Harbs" <harbs.li...@gmail.com> wrote: >Oh boy. What a title… ;-) > >I’ve been spending a lot of time thinking how to handle text with FlexJS >and I think I have a plan. > >I found a javascript library called OpenType.js[1] The library can load >regular font files and parse GPOS and GSUB tables. It can output to >canvas and/or SVG. The license is MIT, so we should be able to use it as >well. > >It’s totally reasonable to wrap OpenType.js in a set of APIs which map to >FTE APIs. Once there is a set of APIs which have the same interface as >FTE, theoretically all references in TLF to FTE can be swapped out with >that, and all DisplayObject references can be swapped out with >HTML/SVG/Canvas equivalents. > >TLF is a beast, but using it is probably the easiest way to get to my >goal. Ultimately we might be able to swap TLF out for something less >massive. > >However, no matter how you slice this pie, it’s a LOT of work. > >I have two major dilemmas which I want to bring up: > >1. Wrapping OpenType.js can be done by referencing the JS library and >putting together externs, or it can be done by actually porting the >library to ActionScript. The second way seems more straight-forward as >far as implementation goes, but it would be work in terms of syncing up >codebases as improvements are made to the library. (There’s still work to >do there.) One advantage of doing a port to ActionScript is that the >library could actually be used to render text to any platform that FlexJS >can target. That could mean that we could render true font files in Flash >(rather than fonts converted to sfws) as well as any future target. > >2. Whether to do this work in private or public. Right now, my #1 >priority is time. I need to make a decision on how I work based on which >path gets me to my goal the quickest. I think it’s safe to say that >trying to add something like this to the FlexJS framework would have >overhead both in terms of integration and in terms of dealing with legal >issues. On the other hand, if I would not be working in a vacuum, others >might help pick up some of the work. There’s also the commercial value to >owning a complete text rendering library vs. the social value of making >this public. I’m more-or-less sitting on the fence regarding this one. >So, I’m throwing this out there to see how much interest there is in this >(huge) task, and how much help I could reasonably expect. > >Harbs > >[1]http://opentype.js.org/