Non-breaking slash?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Non-breaking slash?
Does renpy have markup for *preventing* line breaks at unwanted locations? In particular, I want to make renpy treat phrases like "km/h" and "AC/DC" as single words, not breakable at the slash.
Unicode has official non-breaking space and non-breaking hyphen characters, but apparently no non-breaking slash.
It looks like I can make it work by typing "A\uFEFF/\uFEFFC" instead of "A/C", but man, is that ugly.
Unicode has official non-breaking space and non-breaking hyphen characters, but apparently no non-breaking slash.
It looks like I can make it work by typing "A\uFEFF/\uFEFFC" instead of "A/C", but man, is that ugly.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
- m_from_space
- Veteran
- Posts: 302
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: Non-breaking slash?
You could write your own text tag.
https://www.renpy.org/doc/html/custom_text_tags.html
https://www.renpy.org/doc/html/custom_text_tags.html
Re: Non-breaking slash?
All right then. This works as long as there's no nested markup within the {nb}…{/nb} tags, which is good enough for my current purposes.
Code: Select all
def non_breaking_tag(tag, argument, contents):
"""Insert unicode non-breaking zero-width code point between every content character."""
rv = []
for txi in contents:
if txi[0] == renpy.TEXT_TEXT:
rv.append((txi[0], "\uFEFF".join(txi[1])))
else:
rv.append(txi)
return tuple(rv)
config.custom_text_tags["nb"] = non_breaking_tag
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
- Ocelot
- Eileen-Class Veteran
- Posts: 1882
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Non-breaking slash?
Be aware, that this wrecks autovoicing, and, as a consequence, reduces accessebility. It is fine if you are just using on abbreviations, just don't use it on actual words.
EDIT: I think, you can try WORD JOINER instead of ZERO-WIDTH NON-BREAKING SPACE. It might work better with automated readers.
< < insert Rick Cook quote here > >
Re: Non-breaking slash?
WORD JOINER, ok.
Code: Select all
rv.append((txi[0], "\u2060".join(txi[1])))
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Re: Non-breaking slash?
Why not
Where the '/' is whichever symbol that should be a non-breaking slash?
Code: Select all
renpy.language_tailor('/',"WJ")- Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
- Contact:
Re: Non-breaking slash?
What if you used a backward slash instead of a forward slash?
https://www.renpy.org/doc/html/text.htm ... characters
Code: Select all
"AC\\DC"
https://www.renpy.org/doc/html/text.htm ... characters
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot]
