font size
This commit is contained in:
@@ -22,6 +22,8 @@ Options:
|
||||
--silent
|
||||
--include-answers
|
||||
--output-filepath TEXT
|
||||
--num-columns INTEGER
|
||||
--font-size INTEGER
|
||||
--help Show this message and exit.
|
||||
|
||||
```
|
||||
|
||||
1
TODO.md
1
TODO.md
@@ -4,7 +4,6 @@
|
||||
- pdf options
|
||||
- problem numbers [true]
|
||||
- number of columns [auto]
|
||||
- font
|
||||
- include column labels
|
||||
- print
|
||||
- addition
|
||||
|
||||
@@ -14,6 +14,7 @@ from app.pdf import make_pdf
|
||||
@click.option("--include-answers", default=True, is_flag=True)
|
||||
@click.option("--output-filepath")
|
||||
@click.option("--num-columns", default=4)
|
||||
@click.option("--font-size", default=12)
|
||||
def main(
|
||||
bits: int,
|
||||
num_problems: int,
|
||||
@@ -22,6 +23,7 @@ def main(
|
||||
include_answers: bool = True,
|
||||
output_filepath: str = None,
|
||||
num_columns: int = 4,
|
||||
font_size: int = 12,
|
||||
) -> None:
|
||||
|
||||
validate_args(pdf, silent, output_filepath)
|
||||
@@ -39,6 +41,7 @@ def main(
|
||||
output_path=output_filepath or "problems.pdf",
|
||||
include_answers=include_answers,
|
||||
num_columns=num_columns,
|
||||
font_size=font_size,
|
||||
)
|
||||
|
||||
if not silent:
|
||||
|
||||
12
app/pdf.py
12
app/pdf.py
@@ -11,6 +11,7 @@ def make_pdf(
|
||||
output_path: str,
|
||||
include_answers: bool,
|
||||
num_columns: int,
|
||||
font_size: int,
|
||||
) -> None:
|
||||
if include_answers:
|
||||
pdf_jobs = (("problems", problems), ("answers", answers))
|
||||
@@ -22,7 +23,9 @@ def make_pdf(
|
||||
output_path = make_answers_path(output_path)
|
||||
with tempfile.NamedTemporaryFile(mode="w") as txt_file:
|
||||
write_to_txtfile(txt_file, text)
|
||||
make_postscript_file(txt_file, num_columns)
|
||||
make_postscript_file(
|
||||
txt_file=txt_file, num_columns=num_columns, font_size=font_size
|
||||
)
|
||||
make_pdf_file(output_path)
|
||||
os.unlink(POSTSCRIPT_FILEPATH)
|
||||
|
||||
@@ -43,6 +46,9 @@ def make_pdf_file(output_path):
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
|
||||
def make_postscript_file(txt_file, num_columns):
|
||||
command = f"enscript --columns={num_columns} --no-header --output={POSTSCRIPT_FILEPATH} {txt_file.name}"
|
||||
def make_postscript_file(txt_file: str, num_columns: int, font_size: int):
|
||||
command = (
|
||||
f"enscript --columns={num_columns} --no-header --output={POSTSCRIPT_FILEPATH} "
|
||||
f"-FCourier{font_size} {txt_file.name}"
|
||||
)
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
Reference in New Issue
Block a user