superlou / fountain-atom

Grammar and tools for the Fountain screenwriting syntax
MIT License
48 stars 15 forks source link

Feature Request: Setting to Specify Font Used in PDF Preview/Export #53

Open HughxDev opened 6 years ago

HughxDev commented 6 years ago

This setting was the first thing I looked for after installing the package, before I even began writing. I wanted to set the PDF font to Courier Prime, assuming the package would default to Courier or Courier New. Not being able to find such a setting, and being curious, I exported a test PDF and inspected it (Acrobat: File → Properties → Fonts) to learn it uses Courier Prime by default. Cool for my purposes, but that was just a lucky coincidence.

While the Hollywood standard is 12-point Courier or adjacent, some people might like to:

So it would be nice if we could specify at least font and font size, and possibly line height.

jrbostic commented 6 years ago

So, I just checked and this was not listed as something supported by Afterwriting... however, after searching their repo, I found that there actually a configuration attribute which supports it. At this point, I'm not sure why it wasn't documented... and I'm not sure if it is internally regulated by the module, but I will find out.

Current setting is: "font_family": "CourierPrime"

If it's possible, I should be able to hook it in pretty quick. Give me a few days.

jrbostic commented 6 years ago

So, I was able to get this property hooked in with relative ease. It does change the font as expected. Two issues arise, however... And I'm not sure that we can address them in this project.

1) Other fonts do not render parts of title page correctly--the author section 2) General layout can be negatively impacted

Number 2 is sort of a 'meh' for me (because plain Courier looks fine). But number 1 has to be an issue with Afterwriting CLI or the underlying engine, so I think we'd need to take it up there.

It also appears that there is a font_size property being used within afterwriting, but it is not exposed as far as I can tell.

jrbostic commented 6 years ago

And when I say that "Other fonts do not render parts of title page correctly", I mean that the encoding is messed up.... it's just a series of garbled characters.

jrbostic commented 6 years ago

https://github.com/ifrost/afterwriting-labs/issues/93

jrbostic commented 6 years ago

Okay, so I was a little off in my interpretation above. See my comments on afterwriting issue for any developments, if interested.

jrbostic commented 6 years ago

@hguiney or anyone else who comes across this... what are the fonts that you would like to be among the font options? It would need to be something under an open license with a link.

See: https://fontlibrary.org/en

Many things from the font library appear to be usable and have .ttf files for multiple types (normal, bold, italic, and italicbold). Some fonts with excessive character widths may present a problem for afterwriting.

Please shout out, if you've got a specific want or need for a particular font.

HughxDev commented 6 years ago

Is it not possible to just allow the user to select from their system fonts?

jrbostic commented 6 years ago

It is not possible. Rendering the PDF is provided custom by afterwriting. In order to do that, it requires that fonts be provided to support various styles used in rendering. In particular, if you want bold and italic distinctions, then each "font profile" requires actually providing the whole font file (encoded) in its various styles. See the discussion in my afterwriting ticket for more info.

Anyhow, looking for desired fonts that would actually be used. We want to provide a dependable set of fonts, I think, if we're going to do this. Preferable monospaced (as per the discussion in linked ticket)... But I'm willing to try other fonts.

jrbostic commented 6 years ago

Well, I should say, there could be a future enhancement to actually provide your own .ttf files... but it would be more time investmen, less dependable, and less user friendly than providing a specific set of supported fonts. So, I would consider that beyond the scope of simply providing additional font options. If we can get my current branch into afterwriting, any future such enhancement could be discussed entirely within the context of the fountain plugin.

jrbostic commented 6 years ago

@superlou You haven't changed in on this one. Are you down with the proposition? If so, what fonts would you want to support? I was thinking an open source Courier, like Typewriter, and CourierPrime at least...

jrbostic commented 6 years ago

*chimed in

superlou commented 6 years ago

I'm generally agreeable, with the only real limitations being that we are really careful about the licenses for the fonts that are used. Is bundling the fonts going to make the effective size of the plugin annoyingly large when people are doing updates?

jrbostic commented 6 years ago

I'll make sure and run all the fonts by you, so we can assure they are licensed properly. I'm trying to only look at open font licenses, but I'll document locations in a PR... Or you can tell me which ones. I don't think it's going to blow up the size too much, but we can also verify the exact growth. I didn't plan on adding more than a few. I'm assuming that would be the equivalent of like 12 more files... 4 for each font... But maybe I'm tripping. I'm not sure about the average size of a base64 encoded ttf file.

jrbostic commented 6 years ago

I just checked. The config file with two full font profiles amounts to a little less than 1MB.

superlou commented 6 years ago

The curmudgeon in me feels like 1 MB is a large size for the amount of actual code, but it doesn't seem like it can be helped. Any idea how other plug-ins deal with this? I'm nervous that no matter how many fonts we bundle, someone will want their own custom font.

jrbostic commented 6 years ago

I'm not sure how others deal with this... We could look at ways to do the base64 encoding on the fly or on load, which might decrease total size on download... But I'm not sure about the render/load time increase that might incur.

Regarding the custom fonts, I'm still trying to think of a way to make that possible. What I'm thinking is maybe supporting discovery of a config file that could be created/maintained by users (if they really must have an alternative). I'm not sure if the standard atom settings support file selection, so that was part of my original skepticism about custom fonts. My only other big concern about it is that there are a lot of fonts that afterwriting just won't layout properly, so it's somewhat impractical/unfriendly for most users... Nonetheless, it's on my list of things to look at.

jrbostic commented 6 years ago

Here are some fonts that I think might work and aren't too whimsical or out of the ordinary:

Planned: https://fontlibrary.org/en/font/courier-code https://fontlibrary.org/en/font/courier-prime

Possible: https://fontlibrary.org/en/font/anka-coder-narrow https://fontlibrary.org/en/font/inconsolata-lgc-markup https://fontlibrary.org/en/font/anonymous-pro

I plugged in CourierCode and it looked cleaner than what we're getting out of CourierPrime, so that was a good test. The others are just some I paged through that had all 4 font styles and were monospaced. I'm willing to try whatever, but I don't want to spend a bunch more time converting fonts for fun, so if there is some specific interest in one of these... or one not mentioned... let me know.

In the meantime, I'm going to move on to looking at user-customized font support and some ways that might work without getting too demanding for the plugin.

jrbostic commented 6 years ago

We've got custom font support merged and released into afterwriting, so I'll be working on getting a few supported fonts setup in my working branch along with a setting that allows users to select. I may not initially attempt the user-provided-font support, but if an idea strikes me along the way... I'll probably take a swing at it.

jrbostic commented 6 years ago

https://github.com/ifrost/afterwriting-labs/tree/v1.10.0

jrbostic commented 6 years ago

https://github.com/superlou/fountain-atom/pull/60