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

Load settings from a configuration file, allow customizing the output PDF font #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lenormf
Copy link

@lenormf lenormf commented May 14, 2020

Fixes #35.

@vilcans
Copy link
Owner

vilcans commented May 15, 2020

Thanks for this! I haven't tested it manually yet, but the test script bin/test gives style errors. There's also some strange indentation in config.py.

@lenormf
Copy link
Author

lenormf commented May 15, 2020

I'll fix the linting errors (I didn't get any with flake8), but I'm getting a lot of UTF8 decoding errors with the unit tests, despite using a UTF8 locale.

lenormf added 2 commits May 15, 2020 11:27
This commit allows settings to be loaded from a configuration
file. If one exists at `$XDG_CONFIG_HOME/screenplain/screenplain.cfg`
(by default), it will be loaded.

A new `-c`/`--config` command line flag allows loading a configuration
file explicitly. Command line options take precedence over the settings
loaded from the configuration file.

The format of the file is INI, with no interpolations, options without
values are allowed, and double-bracketed "sub-sections" (aesthetics
only, the hierarchy of such sections in relation with "root-level"
sections is not enforced).

An example of a configuration file would be:

```ini
    [export]
        format: pdf

        [[pdf]]
            strong: no

        [[html]]
            base: no
            css
```
This commit allows the configuration file to declare custom fonts to
be used, when exporting a PDF file.

The functionality could probably be extended to HTML exports.

Example that sets "Courier Prime" as default font:

```ini
[export]
    format: pdf

    [[pdf]]
        strong: no
        font: courier_prime

[font]

    [[courier_prime]]
        name: Courier Prime
        regular: ["Courier Prime", "courier-prime.ttf"]
        bold: ["Courier Prime Bold", "courier-prime-bold.ttf"]
        italic: ["Courier Prime Italic", "courier-prime-italic.ttf"]
        bold_italic: ["Courier Prime Bold Italic", "courier-prime-bold-italic.ttf"]
```
@lenormf
Copy link
Author

lenormf commented May 15, 2020

Linting warning fixed.

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

Successfully merging this pull request may close these issues.

Diacritic characters in generated PDFs?
2 participants