Skip to content

Commit

Permalink
Add default fonts control
Browse files Browse the repository at this point in the history
In #181 and #188 we added Liberation fonts as the default ones for reports. However this made it a little bit harder to choose a different default font (default fonts are the ones that the system interprets for `monospace`, `sans-serif` and `serif`).

From now on, if you want to override the default fonts, you have to add the package in `dependencies/apt.txt` or a `build.d` script, and add one or more of these new build arguments: `FONT_{MONO,SANS,SERIF}`. This way you make sure to override the default fonts. Before this, if you only added the package, it only made those fonts available, *not default*.
  • Loading branch information
yajo committed Sep 16, 2019
1 parent 4fe371d commit 3c01a69
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 11.0.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ ONBUILD ARG DEPTH_DEFAULT=1
ONBUILD ARG DEPTH_MERGE=100
ONBUILD ARG CLEAN=true
ONBUILD ARG COMPILE=true
ONBUILD ARG FONT_MONO="Liberation Mono"
ONBUILD ARG FONT_SANS="Liberation Sans"
ONBUILD ARG FONT_SERIF="Liberation Serif"
ONBUILD ARG PIP_INSTALL_ODOO=true
ONBUILD ARG ADMIN_PASSWORD=admin
ONBUILD ARG SMTP_SERVER=smtp
Expand Down
3 changes: 3 additions & 0 deletions 12.0.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ ONBUILD ARG DEPTH_DEFAULT=1
ONBUILD ARG DEPTH_MERGE=100
ONBUILD ARG CLEAN=true
ONBUILD ARG COMPILE=true
ONBUILD ARG FONT_MONO="Liberation Mono"
ONBUILD ARG FONT_SANS="Liberation Sans"
ONBUILD ARG FONT_SERIF="Liberation Serif"
ONBUILD ARG PIP_INSTALL_ODOO=true
ONBUILD ARG ADMIN_PASSWORD=admin
ONBUILD ARG SMTP_SERVER=smtp
Expand Down
3 changes: 3 additions & 0 deletions 8.0.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ ONBUILD ARG DEPTH_DEFAULT=1
ONBUILD ARG DEPTH_MERGE=100
ONBUILD ARG CLEAN=true
ONBUILD ARG COMPILE=true
ONBUILD ARG FONT_MONO="Liberation Mono"
ONBUILD ARG FONT_SANS="Liberation Sans"
ONBUILD ARG FONT_SERIF="Liberation Serif"
ONBUILD ARG PIP_INSTALL_ODOO=true
ONBUILD ARG ADMIN_PASSWORD=admin
ONBUILD ARG SMTP_SERVER=smtp
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,23 @@ FROM tecnativa/doodba@sha256:fba69478f9b0616561aa3aba4d18e4bcc2f728c9568057946c9
Make sure there's a `ir.config_parameter` called `report.url` with the value
`http://localhost:8069`.

### How to change report fonts?

Doodba ships [Liberation fonts](https://wikipedia.org/wiki/Liberation_fonts)
as defaults.

If you want to make another font package _available_, just add it to
[`apt.txt`][dependencies] (if it's a normal Debian package) or install it in
a [custom build script][build.d] called i.e. `build.d/200-custom-fonts`
(if you need to install it in a more complex way).

If, in addition to that, you want those fonts to be the _defaults_, then add
one (or more) of these build arguments:

- `FONT_MONO`
- `FONT_SANS`
- `FONT_SERIF`

### How can I whitelist a service and allow external access to it?

This can become useful when you have isolated environments
Expand Down Expand Up @@ -1313,7 +1330,9 @@ scaffolding versions is preserved.
[`repos.yaml`]: #optodoocustomsrcreposyaml
[`click-odoo`]: https://github.com/acsone/click-odoo
[`click-odoo-contrib`]: https://github.com/acsone/click-odoo-contrib
[build.d]: #optodoocustombuildd
[builds]: https://hub.docker.com/r/tecnativa/doodba/builds/
[dependencies]: #optodoocustomdependenciestxt
[development]: #development
[docker-socket-proxy]: https://hub.docker.com/r/tecnativa/docker-socket-proxy/
[doodba-qa]: https://github.com/Tecnativa/doodba-qa
Expand Down
30 changes: 30 additions & 0 deletions build.d/300-fontconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -e

cat <<END > ~odoo/.fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- Odoo default fonts, generated by Doodba -->
<fontconfig>
<alias>
<family>monospace</family>
<prefer>
<family>$FONT_MONO</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>$FONT_SANS</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>$FONT_SERIF</family>
</prefer>
</alias>
</fontconfig>
END

chown odoo:odoo ~odoo/.fonts.conf
4 changes: 4 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ def test_smallest(self):
("test", "-x", "/usr/local/bin/unittest"),
("addons", "list", "-cpix"),
("pg_activity", "--version"),
# Default fonts must be liberation
("bash", "-c", """test "$(fc-match monospace)" == 'LiberationMono-Regular.ttf: "Liberation Mono" "Regular"'"""),
("bash", "-c", """test "$(fc-match sans-serif)" == 'LiberationSans-Regular.ttf: "Liberation Sans" "Regular"'"""),
("bash", "-c", """test "$(fc-match serif)" == 'LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"'"""),
# Must be able to install base addon
ODOO_PREFIX + ("--init", "base"),
# Auto updater must work
Expand Down

0 comments on commit 3c01a69

Please sign in to comment.