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

GNU+Linux support #40

Closed
felipesanches opened this issue Sep 18, 2017 · 63 comments
Closed

GNU+Linux support #40

felipesanches opened this issue Sep 18, 2017 · 63 comments
Projects

Comments

@felipesanches
Copy link
Collaborator

screenshot at 2017-09-18 18 24 46

https://en.wikipedia.org/wiki/Core_Text

I think @davelab6 mentioned something about someone working on an implementation of a free software substitute for that already?

I'd love to contribute to PageBot once this issue is sorted out.

cheers,
Felipe Sanches

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Sep 18, 2017

Nobody that I know of works on PageBot implementation running outside DrawBot.

It would be interesting to have one running on Google Apps Python server. We did experiments in the past there, but stopped because the SQL version was not 100% standard at the time (missing the "or" in queries).

What needs to be implemented is the imports of DrawBot functions (rect, oval, text, and such) and then make the imports in TextBox conditional. CoreText is used by TextBox FormattedString, to know where lines and runs are located. And to calculate overflows of text.

If we make an alternative for FormattedString (e.g. use the element.html storage instead), then all could work with tagged strings and etree representations of it.

@felipesanches
Copy link
Collaborator Author

felipesanches commented Sep 18, 2017

thanks, @petrvanblokland !

@davelab6
Copy link
Collaborator

davelab6 commented Sep 19, 2017

http://xxyxyz.org/flat is the library and http://xxyxyz.org/even is the ui app

https://github.com/xxyxyz/flat

https://github.com/xxyxyz/even

These use Qt, whereas pagebot/drawbot uses Cocoa.

I don't have any sense when Qt will support variable fonts, but everything else should be possible to do with Flat.

Cc @sukop

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Sep 19, 2017 via email

@davelab6
Copy link
Collaborator

davelab6 commented Sep 19, 2017

The goal I have in mind (and I think Felipe shares, given his "naieve" attempt to run TypographicPoster.py) is that running PageBot on GNU or macOS shouldn't matter and everything "works the same" - which requires option 2, I think :)

(Of course "works the same" is not in the TeX sense that it will be dot for dot, pixel for pixel the same, but that it should not raise any exceptions, and give approximately the same results.)

However, it may be that option 1 is a way point to option 2, since the abstract Drawer wrapper needs to wrap around both Flat and Drawbot classes/methods.

@petrvanblokland
Copy link
Collaborator

That would work for 1) and 2). Currently the a view already decides whether to call page.draw(...) or page.build(...). A view can figure out if DrawBot is available or Flat.
Leaving "Flat-knowledge" available for elements, means that they can optimize for the output device, which is harder with an intermediate layer.

@davelab6
Copy link
Collaborator

Oh! Very good!! :) Yes, elements accessing this directly could open interesting possibilities - I think there are some thing Flat/Drawbot can do that the other can not, due to differences in the underlying platforms which they wrap, and there will surely be other drawing platforms in the future... :)

@petrvanblokland
Copy link
Collaborator

It's the trade-off between redundancy in code and flexibility.
In the past we've tried a lot in hiding in layers, but practice is always that you can the least average of all environments, not the sum of all.
I think for now I'd got with adding a e.flat(...) method to the Element class and inheriting classes, so there is distributed knowledge how to call the API in an optimized way. Also it has the advantage that all output channels work parallel, instead of selecting only one at import.

@petrvanblokland
Copy link
Collaborator

Variable fonts will already work, because PageBot+fonttools save instances as TTF/CFF that are then installed as regular fonts. Same way as it now works in DrawBot.

@petrvanblokland
Copy link
Collaborator

Currently making drawBotBuilder as abstract builder, so we can add flatBuilder.
Big adjustment, needs some testing.

@petrvanblokland
Copy link
Collaborator

I'm probably working for the rest of the coming days weaving together flat and drawbot as separate views and builders.
It's a major operation, but it's also good to separate all the hidden calls that are typically drawbot. Result seems to be very promising, but there's some huge moving of methods and renaming necessary. So we'll need some time to get all examples to run again.
Examples made outside the pagebot git probably need some adjustments as well.

@felipesanches
Copy link
Collaborator Author

Awesome! Thanks a lot for this work, Petr !

@davelab6
Copy link
Collaborator

In the past we've tried a lot in hiding in layers, but practice is always that you can the least average of all environments, not the sum of all.

I think that is a very interesting point, to add to the introductory documentation about the code architecture :)

Variable fonts will already work, because PageBot+fonttools save instances as TTF/CFF that are then installed as regular fonts. Same way as it now works in DrawBot.

Oh!! I didn't appreciate this; I (mis)remembered from the Typographics workshop that the CoreText FormattedString was what powered variable fonts support, I didn't understand it was 'pogo' style :)

we'll need some time to get all examples to run again. Examples made outside the pagebot git probably need some adjustments as well.

Perhaps @felipesanches can help with that

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Sep 19, 2017

@felipesanches What is the closest equivalent of OSX FormattedString that we could get in Flat? Plain unicode string? Or HTML tagged? Or something else?
In PageBot the FormattedString is also used to query (width,height), e.g. for placement and overflow. That kind of query is done before any builder rendering during page composition. It would be good if Flat could give something back as textSize(formattedString)

@felipesanches
Copy link
Collaborator Author

I'll have to dive into it for a while before being able to answer that question. But I'd be delighted to do so.

@felipesanches
Copy link
Collaborator Author

felipesanches commented Sep 19, 2017

I'm new to flat (just heard of it from @davelab6 this morning here in this thread). The kind of work done by FormattedString in DrawBot seems to be similar to things that pango and harfbuzz do such as describing a layout, applying styles to chunks of text and then performing itemization/shaping.

If I got it right, then it seems that this code in flat does some portion of that:
https://github.com/xxyxyz/flat/blob/master/flat/text.py

@davelab6
Copy link
Collaborator

Yes, the closest equivalent of macOS FormattedString is flat.text.strike() http://xxyxyz.org/flat#reference

@sukop
Copy link

sukop commented Sep 19, 2017

Hello!

I'm not quite up to speed with your effort but here are few notes that might be useful:

[Flat] is covering a large part of DrawBot, except for API differences and naming

For the purpose of interop, I think the greatest difference is that DrawBot follows PostScript way of drawing, i.e. there is a global graphic state of which properties such as line width and color can be altered and which is then used for painting. Whereas in Flat one creates instances of style (drawing of shapes) and strike (drawing of text) and then using these "factories" one creates and places concrete graphic objects on the page.

What is the closest equivalent of OSX FormattedString that we could get in Flat?

In Flat, one first loads a font to pass it into "strike" constructor. a "strike" is then set up with particular typographic properties, which is the used to create a "span". Spans build up "paragraph", paragraphs build up "text", which can then be broken into various text "blocks" placed on pages.

To answer your question, yes, "text.py" is the place to look into. To get the width of some span, use style.width (the raw result for a font is scaled by unitsPerEm and current text size in pt) and for the height search for rmq (range minimum query). So to put a rich text on the page, one basically creates a sequence of spans, such as page.place(text([paragraph([red.span('Hello '), blue.span('world!')])]).

If you have any more question, please ask.

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Sep 19, 2017 via email

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Sep 19, 2017 via email

@felipesanches
Copy link
Collaborator Author

@petrvanblokland Let me know if there's any way I can help here. I may be able to dedicate some time to this effort next Thursday and Friday.

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Oct 3, 2017 via email

@felipesanches
Copy link
Collaborator Author

hey, @petrvanblokland ! I considered looking at this in more detail today and by reading your previous message here I had the impression that some new code was written based on the discussions of this github issue thread. But looking at the master branch I don't see any new commit related to this. Perhaps your working on a separate branch for this?

@felipesanches
Copy link
Collaborator Author

OK. I think I found it. It seems to be the new_views_builder branch, right?
Also, it seems to me that your first commit related to this issue was this: bf071b6

Can you confirm that?

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Oct 19, 2017 via email

@felipesanches
Copy link
Collaborator Author

Thanks!

Please merge the trivial syntax error fix at #43

@felipesanches
Copy link
Collaborator Author

There's a relevant comment at fe192ee

@petrvanblokland said at that commit:

There is much to be reworked, now the layer of contexts is added. Old code using DrawBot functions directly need to be "upgraded". Extending the API of the context, so DrawBot and Flex are identical on that level. Make alternatives for where they differ or lack in functions. Especially the translation of the FormattedString (Now in BabelString as wrapper for both) needs to be translated into Flex.

@felipesanches
Copy link
Collaborator Author

I'm looking for an example of a script that was already "upgraded" to not call drawBot directly. So that I could replicate that kind of refactoring in all the other examples.

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Oct 19, 2017 via email

@felipesanches
Copy link
Collaborator Author

@petrvanblokland I'm back at it today!

Back when I last dealt with it I ended up making several miscellaneous code changes attempting to adapt the code to become truly cross-platform. I was still unable to run even a simple script on GNU+Linux.

I tried to create some simple / minimal example script but the best I was able to get was a blank PDF as output.

I'll continue tweaking the codebase here, but I would appreciate if someone could provide a very minimalistic sample script accompained with an explanation of what it does and what's expected as correct output. A reference output file would be surely good as well, so that I have something to compare against while trying to get it to work.

felipesanches added a commit to felipesanches/PageBot that referenced this issue Dec 4, 2017
felipesanches added a commit to felipesanches/PageBot that referenced this issue Dec 4, 2017
@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Dec 5, 2017 via email

@felipesanches
Copy link
Collaborator Author

Great! Thanks!

@petrvanblokland
Copy link
Collaborator

We have the first small script to work: HelloCircleSquare.py, making 3 png files with random circles and square.
The Flat flavour BabelString needs to implement
text = s # TODO: make font-->strike-->text in flat.

@felipesanches
Copy link
Collaborator Author

thanks, @petrvanblokland !

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Dec 6, 2017

Once we have rudimentary formatted text functions (through FlatString(BabelString) usage), we can start making documents+elements works with Flat.
SierpinskySquare.py now also works.

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Dec 6, 2017 via email

@felipesanches
Copy link
Collaborator Author

HelloCircleSquare.py working nice on GNU+Linux !

screenshot at 2017-12-06 14 54 01

@felipesanches
Copy link
Collaborator Author

I suppose that with that first major step I can slowly start expanding support for all the rest! :-)

@petrvanblokland
Copy link
Collaborator

I'll work from the other side, making more existing examples work through context.

@davelab6
Copy link
Collaborator

davelab6 commented Dec 6, 2017 via email

@felipesanches
Copy link
Collaborator Author

:-D

@felipesanches felipesanches changed the title GNU+Linux support (with a CoreText substitute perhaps ?) GNU+Linux support Jan 30, 2018
@felipesanches
Copy link
Collaborator Author

The Sierpinski.py script is also working :-)

screenshot at 2018-01-30 09 40 27

@felipesanches
Copy link
Collaborator Author

Examples/Howto/DrawSpirals.py works, but the center looks funny. It seems to be some bad math on the example script itself, rather than a PageBot problem.

screenshot at 2018-02-01 18 25 28

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Feb 1, 2018 via email

@felipesanches
Copy link
Collaborator Author

Examples/Howto/FloatTextOnTopOfElement.py:

screenshot at 2018-02-01 20 19 44

@felipesanches
Copy link
Collaborator Author

felipesanches commented Feb 2, 2018

I've hit on a roadblock in the past few hours here: #96

@petrvanblokland
Copy link
Collaborator

petrvanblokland commented Feb 2, 2018 via email

@felipesanches
Copy link
Collaborator Author

thanks!

@felipesanches
Copy link
Collaborator Author

Alright!

MakeABookCover.py:
screenshot at 2018-02-02 00 42 40

@michielkauwatjoe michielkauwatjoe added this to In Progress in Flat Jul 11, 2018
Flat automation moved this from In Progress to Done Nov 5, 2020
@felipesanches
Copy link
Collaborator Author

Closing this issue means that PageBot works nicely on GNU+Linux now? I'm not so sure about that, but I haven't been following this closely lately, so let me know it there's something new that I'm still not aware of.

@michielkauwatjoe
Copy link
Member

michielkauwatjoe commented Nov 5, 2020

Hi, the core PageBot functions should work pretty smoothly on Linux now. Most of the files in the examples repo run both the Flat and the DrawBot context, with pretty much the same output (some pixel offsets on font baselines here and there). There's still some more specific parts of the DrawBot implementation to deal with in Flat but I'm putting those in separate issues.

@felipesanches
Copy link
Collaborator Author

great, thanks! :-D

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

No branches or pull requests

5 participants