-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add support for hyphenation to wrapped text #668
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8ea3dc0
hyphenate text
pepijndevos daa2734
add --hyphenate parameter
pepijndevos 8b617b7
forgot docstring
pepijndevos 8cbfa15
update text docs
pepijndevos ac07354
add pyphen to project
pepijndevos 5a3c360
reformat
pepijndevos 72cdc66
ruff checks
pepijndevos 14dd56a
changelog
pepijndevos 620f16c
add example language codes
pepijndevos e90071b
fix ruff check again
pepijndevos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,12 @@ | |
) | ||
@click.option("-s", "--size", type=LengthType(), default=18, help="Text size (default: 18).") | ||
@click.option("-w", "--wrap", type=LengthType(), help="Wrap to provided width.") | ||
@click.option( | ||
"-h", | ||
"--hyphenate", | ||
type=TextType(), | ||
help="Hyphenate wrapped words using the provided language.", | ||
) | ||
@click.option("-j", "--justify", is_flag=True, help="Justify text block (wrap-mode only).") | ||
@click.option( | ||
"-p", | ||
|
@@ -38,6 +44,7 @@ def text( | |
font: str, | ||
size: float, | ||
wrap: float | None, | ||
hyphenate: str | None, | ||
justify: float, | ||
position: tuple[float, float], | ||
align: str, | ||
|
@@ -53,7 +60,8 @@ def text( | |
|
||
In wrap mode, the text start at (0, 0) and expends left until it reach the specified width. | ||
The `--align` option controls how the text is laid out within the column and behaves as | ||
typically expected. | ||
typically expected. The `--hyphenate` options enables hyphenation using the provided | ||
language code. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
|
||
To start the text at the different location than (0, 0), use the `--position` option. | ||
""" | ||
|
@@ -64,7 +72,13 @@ def text( | |
|
||
if wrap: | ||
lc = vp.text_block( | ||
string, font_name=font, width=wrap, size=size, align=align, justify=justify | ||
string, | ||
font_name=font, | ||
width=wrap, | ||
size=size, | ||
align=align, | ||
justify=justify, | ||
hyphenate=hyphenate, | ||
) | ||
else: | ||
lc = vp.text_line(string, font_name=font, size=size, align=align) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to indicate what format(s) are acceptable for the language, and provide a couple of examples.