opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.38k stars 468 forks source link

Multiline #164

Open eric-schleicher opened 8 years ago

eric-schleicher commented 8 years ago

This is more of a questions than an issue.

Is there a reason (techical/philospical) not to support the generation of multiline text?

i can see how this might be considered to be too high level function for open type as it (perhap not so) subtly implies the handling of handling justifications and line heights

Generally, i would expect that in most fonts there is information (either explicitly or derivable) on how to set the a base line spacing. I'm unfamiliar on how to determine this... any pointers would be appreciated...

I just wasn't sure if it was a possibility, or whether i need to implement this in my own code that uses opentype, or whether it might be something we could contribute, or create as a wrapper library.

Fabric has sort of nailed this down, but we're no longer using it because it doesn't work for our purposes, but alas multiline text is important for our application.

-Thanks for creating this awesome library!

fthues commented 8 years ago

+1, that would be great to have.

fdb commented 8 years ago

Multi-line text is certainly a good idea! This would probably only be supported for western languages, though (I have no experience with the layout of complex scripts, where we get into Harfbuzz territory).

eric-schleicher commented 8 years ago

I have some code that I could share here. Its essentially a (very basic) multiline object and provides control over basic justification.

Im not particularly proud of it, but a better developer might find it useful.

Let me know On Dec 16, 2015 5:11 AM, "Frederik De Bleser" notifications@github.com wrote:

Multi-line text is certainly a good idea! This would probably only be supported for western languages, though (I have no experience with the layout of complex scripts, where we get into Harfbuzz territory).

— Reply to this email directly or view it on GitHub https://github.com/nodebox/opentype.js/issues/164#issuecomment-165099861 .

fdb commented 8 years ago

Not claiming I'm a better developer, but I would love to take a look :-)

mattdesl commented 8 years ago

I just released opentype-layout which should handle basic word wrapping and new line characters. If nothing else, the source can be used as a reference for future work. :smile:

fdb commented 8 years ago

Thanks @mattdesl, looks good!

I'm still pondering if this is something that falls in the scope of OpenType.js, or is something that can be handled through libraries.

mattdesl commented 8 years ago

I personally don't think it should be in scope of Opentype.js, as it has the potential to bloat the library, become tied to application-specific rendering (i.e. making lineHeight act like CSS spec rather than typical print handling) and also is very hard to properly implement (i.e. Harfbuzz).

I think it's better to push things into user-land modules since npm has become pretty widely adopted by JS devs.

:smile:

fdb commented 8 years ago

Well now I have a module to refer to 😄

Harbs commented 8 years ago

I agree that multi-line is important, and I also agree that it should probably not be part of the core. (a complete solution is a very complex problem)

@fdb I do have experience with complex scripts and I'm currently the one maintaining Apache Flex TLF.

I'm first dipping my toes into opentype.js, and I'm impressed with what you've done. I'm hoping to build a wrapper around it to emulate the FTE and hopefully allow TLF to use opentype.js to render the text at the core. I'd love to discuss my thoughts if you want to have a discussion off-line.

kuzvac commented 7 years ago

Any news about this feature? :)

fdb commented 7 years ago

Hi @kuzvac, we're not going to make this part of opentype.js: look at opentype-layout for a module that does this.

kuzvac commented 7 years ago

@fdb ok, thank you.