Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tools/rst2pdf/generate-pdfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ABI_ROOT="${CURR_DIR}/../.."
OUTPUT_DIR=$1

# Use matplotlib's bundled font dir as we can't trust the standard host paths
# to contain the font we want.
FONT_DIR="$(python3 -c 'from pathlib import Path; import matplotlib; print(Path(matplotlib.get_data_path()) / "fonts" / "ttf")')"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I wouldn't expect the /fonts/ttf dir to change. It could be worth a test that the directory in ${FONT_DIR} exists and exit with an error message if it doesn't. May save us some time debugging if anything goes wrong.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough. done!

if [ ! -d "${FONT_DIR}" ]; then
echo "error: PDF font directory does not exist: ${FONT_DIR}"
exit 1
fi

for font in DejaVuSans.ttf DejaVuSans-Bold.ttf DejaVuSans-Oblique.ttf DejaVuSans-BoldOblique.ttf; do
if [ ! -r "${FONT_DIR}/${font}" ]; then
echo "error: required PDF font is missing: ${FONT_DIR}/${font}"
exit 1
fi
done

mkdir -p "${OUTPUT_DIR}"
declare -a docs=(
# 32-bit
Expand Down Expand Up @@ -60,6 +76,7 @@ for doc in "${docs[@]}"; do

( set -x; rst2pdf "${ABI_ROOT}/${doc}/${doc}.rst" \
-s "${CURR_DIR}/rst2pdf-abi.style" \
--font-path "${FONT_DIR}" \
--repeat-table-rows \
--default-dpi=110 \
-c \
Expand Down
13 changes: 13 additions & 0 deletions tools/rst2pdf/rst2pdf-abi.style
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

embeddedFonts: []
[DejaVuSans.ttf, DejaVuSans-Bold.ttf, DejaVuSans-Oblique.ttf, DejaVuSans-BoldOblique.ttf]

fontsAlias:
stdFont: DejaVuSans
stdBold: DejaVuSans-Bold
stdItalic: DejaVuSans-Oblique
stdBoldItalic: DejaVuSans-BoldOblique
fontSans: DejaVuSans
fontSansBold: DejaVuSans-Bold
fontSansItalic: DejaVuSans-Oblique
fontSansBoldItalic: DejaVuSans-BoldOblique

pageTemplates:
oneColumn:
defaultFooter : ".. class:: center\n\n###Page###\n\n.. class:: center\n\n|footer|"
Expand Down
Loading