1265 lines
82 KiB
HTML
1265 lines
82 KiB
HTML
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
<title>Text — Ren'Py Documentation</title>
|
||
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap.min.css" />
|
||
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" />
|
||
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css" />
|
||
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||
<script type="text/javascript" src="_static/underscore.js"></script>
|
||
<script type="text/javascript" src="_static/doctools.js"></script>
|
||
<script type="text/javascript" src="_static/language_data.js"></script>
|
||
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
|
||
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
|
||
<script type="text/javascript" src="_static/bootstrap-3.3.6/js/bootstrap.min.js"></script>
|
||
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
|
||
<link rel="index" title="Index" href="genindex.html" />
|
||
<link rel="search" title="Search" href="search.html" />
|
||
<link rel="next" title="Translation" href="translation.html" />
|
||
<link rel="prev" title="Voice" href="voice.html" />
|
||
<meta charset='utf-8'>
|
||
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
|
||
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
|
||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
|
||
</head><body>
|
||
|
||
<div id="navbar" class="navbar navbar-default navbar-fixed-top">
|
||
<div class="container">
|
||
<div class="navbar-header">
|
||
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
|
||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
|
||
<span class="icon-bar"></span>
|
||
<span class="icon-bar"></span>
|
||
<span class="icon-bar"></span>
|
||
</button>
|
||
<a class="navbar-brand" href="index.html">
|
||
Ren'Py Documentation</a>
|
||
<span class="navbar-text navbar-version pull-left"><b>7.5.3</b></span>
|
||
</div>
|
||
|
||
<div class="collapse navbar-collapse nav-collapse">
|
||
<ul class="nav navbar-nav">
|
||
|
||
<li><a href="https://www.renpy.org">Home Page</a></li>
|
||
<li><a href="https://www.renpy.org/doc/html/">Online Documentation</a></li>
|
||
|
||
|
||
<li class="dropdown globaltoc-container">
|
||
<a role="button"
|
||
id="dLabelGlobalToc"
|
||
data-toggle="dropdown"
|
||
data-target="#"
|
||
href="index.html">Site <b class="caret"></b></a>
|
||
<ul class="dropdown-menu globaltoc"
|
||
role="menu"
|
||
aria-labelledby="dLabelGlobalToc"><ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="gui.html">GUI Customization Guide</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="language_basics.html">Language Basics</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="label.html">Labels & Control Flow</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="dialogue.html">Dialogue and Narration</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="displaying_images.html">Displaying Images</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="menus.html">In-Game Menus</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="python.html">Python Statements</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="conditional.html">Conditional Statements</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="audio.html">Audio</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="movie.html">Movie</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="voice.html">Voice</a></li>
|
||
</ul>
|
||
<ul class="current">
|
||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Text</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="translation.html">Translation</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="displayables.html">Displayables</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="transforms.html">Transforms</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="transitions.html">Transitions</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="atl.html">Animation and Transformation Language</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="matrixcolor.html">Matrixcolor</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="layeredimage.html">Layered Images</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="3dstage.html">3D Stage</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="live2d.html">Live2D Cubism</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="style.html">Styles</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="style_properties.html">Style Properties</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="screens.html">Screens and Screen Language</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="screen_actions.html">Screen Actions, Values, and Functions</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="screen_special.html">Special Screen Names</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="screen_optimization.html">Screen Language Optimization</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration Variables</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="preferences.html">Preference Variables</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="store_variables.html">Store Variables</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="mouse.html">Custom Mouse Cursors</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="launcher.html">Launcher</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="developer_tools.html">Developer Tools</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="director.html">Interactive Director</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="nvl_mode.html">NVL-Mode Tutorial</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="input.html">Text Input</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="side_image.html">Side Images</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="rooms.html">Image Gallery, Music Room, and Replay Actions</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="drag_drop.html">Drag and Drop</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="sprites.html">Sprites</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="keymap.html">Customizing the Keymap</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="achievement.html">Achievements</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="history.html">Dialogue History</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="multiple.html">Multiple Character Dialogue</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="splashscreen_presplash.html">Splashscreen and Presplash</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="statement_equivalents.html">Statement Equivalents</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="save_load_rollback.html">Saving, Loading, and Rollback</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="persistent.html">Persistent Data</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="trans_trans_python.html">Transforms and Transitions in Python</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="gui_advanced.html">Advanced GUI</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="screen_python.html">Screens and Python</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="modes.html">Modes</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="cdd.html">Creator-Defined Displayables</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="cds.html">Creator-Defined Statements</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="custom_text_tags.html">Custom Text Tags</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="character_callbacks.html">Character Callbacks</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="file_python.html">File Access</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="color_class.html">Color Class</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="matrix.html">Matrix</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="model.html">Model-Based Rendering</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="other.html">Other Functions and Variables</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="build.html">Building Distributions</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="updater.html">Web Updater</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="android.html">Android</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="chromeos.html">Chrome OS/Chromebook</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="ios.html">iOS</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="iap.html">In-App Purchasing</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="gesture.html">Gestures</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="raspi.html">Raspberry Pi</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="security.html">Security</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="problems.html">Dealing with Problems</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="environment_variables.html">Environment Variables</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="self_voicing.html">Self-Voicing</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="editor.html">Text Editor Integration</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="skins.html">Skins</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="translating_renpy.html">Translating Ren'Py</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog (Ren'Py 7.x-)</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="changelog6.html">Changelog (Ren'Py 6.11 - 6.99)</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="incompatible.html">Incompatible Changes</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="distributor.html">Distributor Notes</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="credits.html">Credits</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="sponsors.html">Ren'Py Development Sponsors</a></li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="thequestion.html">Script of The Question</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="thequestion_nvl.html">NVL-mode script for The Question</a></li>
|
||
</ul>
|
||
</ul>
|
||
</li>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</ul>
|
||
|
||
|
||
|
||
<form class="navbar-form navbar-right" action="search.html" method="get">
|
||
<div class="form-group">
|
||
<input type="text" name="q" class="form-control" placeholder="Search" />
|
||
</div>
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="container">
|
||
<div class="row">
|
||
<div class="col-md-3">
|
||
<div id="sidebar" class="bs-sidenav" role="complementary"><ul>
|
||
<li><a class="reference internal" href="#">Text</a><ul>
|
||
<li><a class="reference internal" href="#escape-characters">Escape Characters</a></li>
|
||
<li><a class="reference internal" href="#interpolating-data">Interpolating Data</a></li>
|
||
<li><a class="reference internal" href="#styling-and-text-tags">Styling and Text Tags</a><ul>
|
||
<li><a class="reference internal" href="#general-text-tags">General Text Tags</a></li>
|
||
<li><a class="reference internal" href="#dialogue-text-tags">Dialogue Text Tags</a></li>
|
||
<li><a class="reference internal" href="#style-text-tags">Style Text Tags</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#non-english-languages">Non-English Languages</a><ul>
|
||
<li><a class="reference internal" href="#vertical-text">Vertical Text</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#ruby-text">Ruby Text</a></li>
|
||
<li><a class="reference internal" href="#fonts">Fonts</a><ul>
|
||
<li><a class="reference internal" href="#font-replacement">Font Replacement</a></li>
|
||
<li><a class="reference internal" href="#image-based-fonts">Image-Based Fonts</a></li>
|
||
<li><a class="reference internal" href="#font-groups">Font Groups</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#text-displayables">Text Displayables</a></li>
|
||
<li><a class="reference internal" href="#text-utility-functions">Text Utility Functions</a></li>
|
||
<li><a class="reference internal" href="#slow-text-concerns">Slow Text Concerns</a></li>
|
||
<li><a class="reference internal" href="#text-overflow-logging">Text Overflow Logging</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="col-md-9 content">
|
||
|
||
<div class="section" id="text">
|
||
<span id="id1"></span><h1>Text<a class="headerlink" href="#text" title="Permalink to this headline"> link</a></h1>
|
||
<p>Ren'Py contains several ways of displaying text. The <a class="reference internal" href="dialogue.html#say-statement"><span class="std std-ref">say</span></a>
|
||
and <a class="reference internal" href="menus.html"><span class="doc">menu</span></a> statements are primarily concerned with the
|
||
display of text to the user. The user interface often contains text,
|
||
displayed using the <a class="reference internal" href="screens.html#sl-text"><span class="std std-ref">text</span></a>, <a class="reference internal" href="screens.html#sl-textbutton"><span class="std std-ref">textbutton</span></a>,
|
||
and <a class="reference internal" href="screens.html#sl-label"><span class="std std-ref">label</span></a> screen language statements. These
|
||
functions, along with others, create <a class="reference internal" href="#Text" title="Text"><code class="xref py py-func docutils literal notranslate"><span class="pre">Text()</span></code></a> displayables, and
|
||
show them on the screen.</p>
|
||
<p>The Text displayable is responsible for managing the process of
|
||
showing the text to the user. The text displayable performs actions in
|
||
the following order:</p>
|
||
<ol class="arabic simple">
|
||
<li>Translating text.</li>
|
||
<li>Interpolating data into the text.</li>
|
||
<li>Styling the text using styles and text tags.</li>
|
||
<li>Laying out the styled text.</li>
|
||
<li>Drawing the text to the screen.</li>
|
||
</ol>
|
||
<p>This chapter discusses the process of text display in Ren'Py.</p>
|
||
<div class="section" id="escape-characters">
|
||
<h2>Escape Characters<a class="headerlink" href="#escape-characters" title="Permalink to this headline"> link</a></h2>
|
||
<p>There are three special characters that can control the way Ren'Py
|
||
displays text. A creator needs to be aware of these characters to
|
||
ensure that their writing is not accidentally misinterpreted by the engine.</p>
|
||
<dl class="docutils">
|
||
<dt>(backslash)</dt>
|
||
<dd><p class="first">The backslash character is used to introduce when writing a Ren'Py
|
||
or Python string. Some common escape codes are:</p>
|
||
<dl class="last docutils">
|
||
<dt>\" (backslash-doublequote)</dt>
|
||
<dd>Includes a doublequote in a double-quoted string.</dd>
|
||
<dt>\' (backslash-quote)</dt>
|
||
<dd>Includes a single quote in a single-quoted string.</dd>
|
||
<dt>\ (backslash-space)</dt>
|
||
<dd>Includes an additional space in a Ren'Py string. By default,
|
||
Ren'Py script text collapses adjacent whitespace into a single
|
||
space character.</dd>
|
||
<dt>\n (backslash-n)</dt>
|
||
<dd>Includes a newline character in the text.</dd>
|
||
<dt>\\ (backslash-backslash)</dt>
|
||
<dd>Includes a backslash character in the text.</dd>
|
||
<dt>\% (backslash-percent)</dt>
|
||
<dd>Includes a protected percent character in the text. It's also
|
||
possible to write it as %% : both protections will result in a
|
||
single % character being written in the end.</dd>
|
||
</dl>
|
||
</dd>
|
||
<dt>[ (left bracket)</dt>
|
||
<dd>The left bracket is used to introduce interpolation of a value
|
||
into the text. To include a single left bracket in your text,
|
||
double it – write <code class="docutils literal notranslate"><span class="pre">[[</span></code>.</dd>
|
||
<dt>{ (left brace)</dt>
|
||
<dd>The left brace is used to introduce a text tag. To include a left
|
||
brace in your text, double it – write <code class="docutils literal notranslate"><span class="pre">{{</span></code>.</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="section" id="interpolating-data">
|
||
<span id="text-interpolation"></span><h2>Interpolating Data<a class="headerlink" href="#interpolating-data" title="Permalink to this headline"> link</a></h2>
|
||
<p>Ren'Py supports interpolating data into the text string before it is
|
||
displayed. For example, if the player's name is stored in the
|
||
<code class="docutils literal notranslate"><span class="pre">playername</span></code> variable, one could write a line of dialogue like:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"Welcome to the Nekomimi Institute, [playername]!"</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Ren'Py will interpolate variables found in the global store. When
|
||
using a text widget in a screen, Ren'Py will also interpolate screen
|
||
local variables. (This can be overridden by supplying an explicit
|
||
scope argument to the Text displayable.)</p>
|
||
<p>Ren'Py isn't limited to interpolating simple variables. It can also
|
||
interpolate fields and components of tuples. So it's possible to have:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"My first name is [player.names[0]]."</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>It's possible to apply formatting when displaying numbers. This
|
||
will display a floating point number to two decimal places:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">$</span> <span class="n">percent</span> <span class="o">=</span> <span class="mf">100.0</span> <span class="o">*</span> <span class="n">points</span> <span class="o">/</span> <span class="n">max_points</span>
|
||
<span class="n">g</span> <span class="s2">"I like you [percent:.2] percent!"</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Ren'Py's string interpolation is taken from the <span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-3101"><strong>PEP 3101</strong></a> string
|
||
formatting syntax. Ren'Py uses [ to introduce string formatting
|
||
because { was taken by text tags.</p>
|
||
<p>Along with the <code class="docutils literal notranslate"><span class="pre">!s</span></code> and <code class="docutils literal notranslate"><span class="pre">!r</span></code> conversion flags supported by Python, Ren'Py
|
||
supports several more flags. The <code class="docutils literal notranslate"><span class="pre">!q</span></code> conversion flag ensures that
|
||
text tags are properly quoted, so that displaying a string will not
|
||
introduce unwanted formatting constructs. For example:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"Don't pull a fast one on me, [playername!q]."</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">!t</span></code> flag will translate the interpolated string:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">points</span> <span class="o">></span> <span class="mi">5</span><span class="p">:</span>
|
||
<span class="k">$</span> <span class="n">mood</span> <span class="o">=</span> <span class="n">_</span><span class="p">(</span><span class="s2">"happy"</span><span class="p">)</span>
|
||
<span class="k">else</span><span class="p">:</span>
|
||
<span class="k">$</span> <span class="n">mood</span> <span class="o">=</span> <span class="n">_</span><span class="p">(</span><span class="s2">"annoyed"</span><span class="p">)</span>
|
||
|
||
<span class="n">g</span> <span class="s2">"I'm [mood!t] to see you."</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">!i</span></code> flag will make additional interpolate for the interpolated string:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">define</span> <span class="n">earned_points_info</span> <span class="o">=</span> <span class="n">_</span><span class="p">(</span><span class="s2">"[points]{image=points.png} earned points"</span><span class="p">)</span>
|
||
<span class="n">g</span> <span class="s2">"I'm happy to see you you have [earned_points_info!ti]."</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>This should be used to substitute the text that has a substitution inside.
|
||
It's often useful in screen language, see <a class="reference internal" href="screen_optimization.html#const-text"><span class="std std-ref">Const Text</span></a>.</p>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">!u</span></code> flag forces the text to uppercase and the <code class="docutils literal notranslate"><span class="pre">!l</span></code> flag forces the
|
||
text to lowercase. The <code class="docutils literal notranslate"><span class="pre">!c</span></code> flag acts only on the first character,
|
||
capitalizing it. These flags may be combined, for example using <code class="docutils literal notranslate"><span class="pre">!cl</span></code> would
|
||
capitalize the first character, and force the remaining text to lowercase.</p>
|
||
<p>It should be noted that:</p>
|
||
<ul class="simple">
|
||
<li>the order in which the flags are given does not change the result : <code class="docutils literal notranslate"><span class="pre">!cl</span></code>
|
||
will do just the same as <code class="docutils literal notranslate"><span class="pre">!lc</span></code>.</li>
|
||
<li>Supplementarly exclamation marks will be ignored, and will not circumvent
|
||
the previuous rule : <code class="docutils literal notranslate"><span class="pre">!l!c</span></code> will do the same as <code class="docutils literal notranslate"><span class="pre">!c!l</span></code> or <code class="docutils literal notranslate"><span class="pre">!cl</span></code>.</li>
|
||
</ul>
|
||
<p>The transformations are done in the following order:</p>
|
||
<ol class="arabic simple">
|
||
<li><code class="docutils literal notranslate"><span class="pre">r</span></code>/<code class="docutils literal notranslate"><span class="pre">s</span></code> (repr or str)</li>
|
||
<li><code class="docutils literal notranslate"><span class="pre">t</span></code> (translate)</li>
|
||
<li><code class="docutils literal notranslate"><span class="pre">i</span></code> (recursive interpolation)</li>
|
||
<li><code class="docutils literal notranslate"><span class="pre">q</span></code> (quoting)</li>
|
||
<li><code class="docutils literal notranslate"><span class="pre">u</span></code> (uppercase)</li>
|
||
<li><code class="docutils literal notranslate"><span class="pre">l</span></code> (lowercase)</li>
|
||
<li><code class="docutils literal notranslate"><span class="pre">c</span></code> (capitalize)</li>
|
||
</ol>
|
||
</div>
|
||
<div class="section" id="styling-and-text-tags">
|
||
<h2>Styling and Text Tags<a class="headerlink" href="#styling-and-text-tags" title="Permalink to this headline"> link</a></h2>
|
||
<p>In Ren'Py, text gains style information in two ways. The first is from
|
||
the style that is applied to the entire block of text. Please see the
|
||
section about the <a class="reference internal" href="style.html"><span class="doc">style system</span></a> for more details,
|
||
especially the section on <a class="reference internal" href="style_properties.html#text-style-properties"><span class="std std-ref">text style properties</span></a>.</p>
|
||
<p>The second way is through text tags. Text tags are suitable for
|
||
styling a portion of text block, or a small fraction of the text
|
||
blocks in the program. If you find yourself applying the same text
|
||
tags to every line of text, consider using a style instead.</p>
|
||
<p>There are two types of text tags. Some text tags are self-closing, while others
|
||
require a closing tag. When multiple closing tags are used, they
|
||
should be closed last open, first closed order – Ren'Py will reject
|
||
incorrect nesting. For example:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="c1"># This line is correct.</span>
|
||
<span class="s2">"Plain </span><span class="si">{b}</span><span class="s2">Bold </span><span class="si">{i}</span><span class="s2">Bold-Italic{/i} Bold{/b} Plain"</span>
|
||
|
||
<span class="c1"># This line is incorrect, and will cause an error or incorrect</span>
|
||
<span class="c1"># behavior.</span>
|
||
<span class="s2">"Plain </span><span class="si">{b}</span><span class="s2">Bold </span><span class="si">{i}</span><span class="s2">Bold-Italic{/b} Italic{/i} Plain"</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Some text tags take an argument. In that case, the tag name is
|
||
followed by an equals sign (=), and the argument. The argument may
|
||
not contain the right-brace (}) character. The meaning of the
|
||
argument varies based on the text tag.</p>
|
||
<div class="section" id="general-text-tags">
|
||
<h3>General Text Tags<a class="headerlink" href="#general-text-tags" title="Permalink to this headline"> link</a></h3>
|
||
<p>Tags that apply to all text are:</p>
|
||
<span class="target" id="a-tag"></span><dl class="text-tag">
|
||
<dt id="text-tag-a">
|
||
<code class="descname">a</code><a class="headerlink" href="#text-tag-a" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The anchor tag creates a hyperlink between itself and its closing
|
||
tag. While the behavior of the hyperlink is controlled by the
|
||
<a class="reference internal" href="style_properties.html#style-property-hyperlink_functions"><code class="xref std std-propref docutils literal notranslate"><span class="pre">hyperlink_functions</span></code></a> style property, the default handler
|
||
has the following behavior.</p>
|
||
<ul class="simple">
|
||
<li>When the argument begins with <code class="docutils literal notranslate"><span class="pre">jump:</span></code>, the rest of the argument is a label to jump to.</li>
|
||
<li>When the argument begins with <code class="docutils literal notranslate"><span class="pre">call:</span></code>, the rest of the argument is a label
|
||
to call. As usual, a call ends the current Ren'Py statement.</li>
|
||
<li>When the argument begins with <code class="docutils literal notranslate"><span class="pre">call_in_new_context:</span></code>, the rest of the argument
|
||
is a label to call in a new context (using <a class="reference internal" href="label.html#renpy.call_in_new_context" title="renpy.call_in_new_context"><code class="xref py py-func docutils literal notranslate"><span class="pre">renpy.call_in_new_context()</span></code></a>).</li>
|
||
<li>When the argument begins with <code class="docutils literal notranslate"><span class="pre">show:</span></code>, the rest of the argument is a screen to show.</li>
|
||
<li>When the argument begins with <code class="docutils literal notranslate"><span class="pre">showmenu:</span></code>, the rest of the argument is a game menu
|
||
screen to show.</li>
|
||
<li>Otherwise, the argument is a URL that is opened by the system web browser.</li>
|
||
</ul>
|
||
<p>If there is no protocol section in the argument, <a class="reference internal" href="config.html#var-config.hyperlink_protocol"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.hyperlink_protocol</span></code></a>
|
||
is prepended to it. If config.hyperlink_protocol has been set to "jump",
|
||
{a=label} and {a=jump:label} become equivalent. Creators can define new
|
||
protocols using <a class="reference internal" href="config.html#var-config.hyperlink_handlers"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.hyperlink_handlers</span></code></a>.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">label</span> <span class="n">test</span><span class="p">:</span>
|
||
|
||
<span class="n">e</span> <span class="s2">"Why don't you visit {a=https://renpy.org}Ren'Py's home page{/a}?"</span>
|
||
|
||
<span class="n">e</span> <span class="s2">"Or {a=jump:more_text}here for more info{/a}."</span>
|
||
|
||
<span class="k">return</span>
|
||
|
||
<span class="k">label</span> <span class="n">more_text</span><span class="p">:</span>
|
||
|
||
<span class="n">e</span> <span class="s2">"In Hot Springs, Arkansas, there's a statue of Al Capone you can take a picture with."</span>
|
||
|
||
<span class="n">e</span> <span class="s2">"That's more info, but not the kind you wanted, is it?"</span>
|
||
|
||
<span class="k">return</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-alpha">
|
||
<code class="descname">alpha</code><a class="headerlink" href="#text-tag-alpha" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The alpha text tag renders the text between itself and its closing
|
||
tag in the specified opacity. The opacity should be a value between
|
||
0.0 and 1.0, corresponding to fully invisible and fully opaque,
|
||
respectively. If the value is prefixed by + or -, the opacity will
|
||
be changed by that amount instead of completely replaced. If
|
||
the value is prefixed by *, the opacity will be multiplied by
|
||
that amount.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"{alpha=0.1}This text is barely readable!{/alpha}"</span>
|
||
<span class="s2">"{alpha=-0.1}This text is 10 percent more transparent than the default.{/alpha}"</span>
|
||
<span class="s2">"{alpha=*0.5}This text is half as opaque as the default.{/alpha}"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-alt">
|
||
<code class="descname">alt</code><a class="headerlink" href="#text-tag-alt" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The alt tag prevents text from being rendered, while still making the
|
||
text available for the text-to-speech system.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"Good to see you! {image=heart.png}</span><span class="si">{alt}</span><span class="s2">heart{/alt}"</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>See also the <a class="reference internal" href="self_voicing.html#var-alt"><code class="xref std std-var docutils literal notranslate"><span class="pre">alt</span></code></a> character.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-art">
|
||
<code class="descname">art</code><a class="headerlink" href="#text-tag-art" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The alternate ruby top tag marks text between itself and its closing tag as
|
||
alternate ruby top text. See the section on <a class="reference internal" href="#ruby-text"><span class="std std-ref">Ruby Text</span></a> for
|
||
more information.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-b">
|
||
<code class="descname">b</code><a class="headerlink" href="#text-tag-b" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The bold tag renders the text between itself and its closing tag
|
||
in a bold font.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"An example of </span><span class="si">{b}</span><span class="s2">bold test{/b}."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-color">
|
||
<code class="descname">color</code><a class="headerlink" href="#text-tag-color" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The color text tag renders the text between itself and its closing
|
||
tag in the specified color. The color should be in #rgb, #rgba,
|
||
#rrggbb, or #rrggbbaa format.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"{color=#f00}Red{/color}, {color=#00ff00}Green{/color}, {color=#0000ffff}Blue{/color}"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-cps">
|
||
<code class="descname">cps</code><a class="headerlink" href="#text-tag-cps" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The characters per second tag sets the speed of text display, for
|
||
text between the tag and its closing tag. If the argument begins
|
||
with an asterisk, it's taken as a multiplier to the current text
|
||
speed. Otherwise, the argument gives the speed to show the text
|
||
at, in characters per second.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"{cps=20}Fixed Speed{/cps} {cps=*2}Double Speed{/cps}</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-font">
|
||
<code class="descname">font</code><a class="headerlink" href="#text-tag-font" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The font tag renders the text between itself and its closing tag
|
||
in the specified font. The argument is the filename of the font to
|
||
use.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"Try out the {font=mikachan.ttf}mikachan font{/font}."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-i">
|
||
<code class="descname">i</code><a class="headerlink" href="#text-tag-i" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The italics tag renders the text between itself and its closing tag
|
||
in italics.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"Visit the </span><span class="si">{i}</span><span class="s2">leaning tower of Pisa{/i}."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-image">
|
||
<code class="descname">image</code><a class="headerlink" href="#text-tag-image" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The image tag is a self-closing tag that inserts an image into the
|
||
text. The image should be the height of a single line of text. The
|
||
argument should be either the image filename, or the name of an
|
||
image defined with the image statement.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"Good to see you! {image=heart.png}</span><span class="si">{alt}</span><span class="s2">heart{/alt}"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-k">
|
||
<code class="descname">k</code><a class="headerlink" href="#text-tag-k" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The kerning tag is a tag that adjust the kerning of characters
|
||
between itself and its closing tag. It takes as an argument a
|
||
floating point number giving the number of pixels of kerning to add
|
||
to each kerning pair. (The number may be negative to decrease
|
||
kerning.)</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"{k=-.5}Negative{/k} Normal {k=.5}Positive{/k}"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-noalt">
|
||
<code class="descname">noalt</code><a class="headerlink" href="#text-tag-noalt" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The noalt tag prevents text from being spoken by the text-to-speech
|
||
system. This is often used in conjuction with the alt tag, to provide
|
||
accessible and visual optiopns</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"Good to see you! </span><span class="si">{noalt}</span><span class="s2"><3{/noalt}</span><span class="si">{alt}</span><span class="s2">heart{/alt}"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-outlinecolor">
|
||
<code class="descname">outlinecolor</code><a class="headerlink" href="#text-tag-outlinecolor" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The outline text tag changes all the outlines (including drop
|
||
shadows) to the given color. The color should be in #rgb, #rgba,
|
||
#rrggbb, or #rrggbbaa format.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"Let's have a {outlinecolor=#00ff00}Green{/outlinecolor} outline."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-plain">
|
||
<code class="descname">plain</code><a class="headerlink" href="#text-tag-plain" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The plain tag ensures the text does not have bold, italics, underline,
|
||
or strikethrough applied.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"</span><span class="si">{b}</span><span class="s2">This is bold. </span><span class="si">{plain}</span><span class="s2">This is not.{/plain} This is bold.{/b}"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-rb">
|
||
<code class="descname">rb</code><a class="headerlink" href="#text-tag-rb" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The ruby bottom tag marks text between itself and its closing tag
|
||
as ruby bottom text. See the section on <a class="reference internal" href="#ruby-text"><span class="std std-ref">Ruby Text</span></a>
|
||
for more information.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-rt">
|
||
<code class="descname">rt</code><a class="headerlink" href="#text-tag-rt" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The ruby top tag marks text between itself and its closing tag as
|
||
ruby top text. See the section on <a class="reference internal" href="#ruby-text"><span class="std std-ref">Ruby Text</span></a> for
|
||
more information.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-s">
|
||
<code class="descname">s</code><a class="headerlink" href="#text-tag-s" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The strikethrough tag draws a line through text between itself and
|
||
its closing tag.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"It's good </span><span class="si">{s}</span><span class="s2">to see you{/s}."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-size">
|
||
<code class="descname">size</code><a class="headerlink" href="#text-tag-size" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The size tag changes the size of text between itself and its
|
||
closing tag. The argument should be an integer, optionally preceded
|
||
by + or -. If the argument is just an integer, the size is set to
|
||
that many pixels high. Otherwise, the size is increased or
|
||
decreased by that amount.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"{size=+10}Bigger{/size} {size=-10}Smaller{/size} {size=24}24 px{/size}."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-space">
|
||
<code class="descname">space</code><a class="headerlink" href="#text-tag-space" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The space tag is a self-closing tag that inserts horizontal space
|
||
into a line of text. As an argument, it takes an integer giving the
|
||
number of pixels of space to add.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"Before the space.{space=30}After the space."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-u">
|
||
<code class="descname">u</code><a class="headerlink" href="#text-tag-u" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The underline tag underlines the text between itself and its
|
||
closing tag.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"It's good to </span><span class="si">{u}</span><span class="s2">see{/u} you."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-vspace">
|
||
<code class="descname">vspace</code><a class="headerlink" href="#text-tag-vspace" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The vspace tag is a self-closing tag that inserts vertical space
|
||
between lines of text. As an argument, it takes an integer giving
|
||
the number of pixels of space to add.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"Line 1{vspace=30}Line 2"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-#">
|
||
<code class="descname">#</code><a class="headerlink" href="#text-tag-#" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>Text tags beginning with # are ignored, but can be included to distinguish
|
||
strings for the purpose of translation.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"New{#playlist}"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="dialogue-text-tags">
|
||
<h3>Dialogue Text Tags<a class="headerlink" href="#dialogue-text-tags" title="Permalink to this headline"> link</a></h3>
|
||
<p>Text tags that only apply to dialogue are:</p>
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-done">
|
||
<code class="descname">done</code><a class="headerlink" href="#text-tag-done" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>Text after the done tag is not displayed. Why would you want this?
|
||
It's to allow text to avoid jumping around when <a class="reference internal" href="style_properties.html#style-property-adjust_spacing"><code class="xref std std-propref docutils literal notranslate"><span class="pre">adjust_spacing</span></code></a>
|
||
is True.</p>
|
||
<p>When the done tag is present, the line of dialogue is not added to the
|
||
history buffer. If the nw tag is present, it should be before the done
|
||
tag.:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"Looks like they're</span><span class="si">{nw}{done}</span><span class="s2"> playing with their trebuchet again."</span>
|
||
<span class="k">show</span> <span class="n">trebuchet</span>
|
||
<span class="n">g</span> <span class="s2">"Looks like they're</span><span class="si">{fast}</span><span class="s2"> playing with their trebuchet again."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-fast">
|
||
<code class="descname">fast</code><a class="headerlink" href="#text-tag-fast" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>If the fast tag is displayed in a line of text, then all text
|
||
before it is displayed instantly, even in slow text mode. The
|
||
fast tag is a self-closing tag.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"Looks like they're</span><span class="si">{nw}</span><span class="s2">"</span>
|
||
<span class="k">show</span> <span class="n">trebuchet</span>
|
||
<span class="n">g</span> <span class="s2">"Looks like they're</span><span class="si">{fast}</span><span class="s2"> playing with their trebuchet again."</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-nw">
|
||
<code class="descname">nw</code><a class="headerlink" href="#text-tag-nw" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The no-wait tag is a self-closing tag that causes the current line
|
||
of dialogue to automatically dismiss itself once the end of line
|
||
has been displayed.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="s2">"Looks like they're</span><span class="si">{nw}</span><span class="s2">"</span>
|
||
<span class="k">show</span> <span class="n">trebuchet</span>
|
||
<span class="n">g</span> <span class="s2">"Looks like they're</span><span class="si">{fast}</span><span class="s2"> playing with their trebuchet again."</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The no-wait tag will wait for voice and self-voicing to complete before
|
||
advancing.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-p">
|
||
<code class="descname">p</code><a class="headerlink" href="#text-tag-p" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The paragraph pause tag is a self-closing tag that terminates the
|
||
current paragraph, and waits for the user to click to continue. If
|
||
it is given an argument, the argument is interpreted as a number,
|
||
and the wait automatically ends after that many seconds have
|
||
passed.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"Line 1</span><span class="si">{p}</span><span class="s2">Line 2{p=1.0}Line 3"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-w">
|
||
<code class="descname">w</code><a class="headerlink" href="#text-tag-w" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The wait tag is a self-closing tag that waits for the user to
|
||
click to continue. If it is given an argument, the argument is
|
||
interpreted as a number, and the wait automatically ends after
|
||
that many seconds have passed.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="s2">"Line 1</span><span class="si">{w}</span><span class="s2"> Line 1{w=1.0} Line 1"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-clear">
|
||
<code class="descname">clear</code><a class="headerlink" href="#text-tag-clear" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>The clear text tag only makes sense on a line by itself in the <a class="reference internal" href="nvl_mode.html#nvl-monologue-mode"><span class="std std-ref">NVL monologue mode</span></a>.
|
||
It does the same thing at the <code class="docutils literal notranslate"><span class="pre">nvl</span> <span class="pre">clear</span></code> statement without ending the block of text.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="sd">"""</span>
|
||
<span class="sd">Block 1 on page 1.</span>
|
||
|
||
<span class="sd">Block 2 on page 1.</span>
|
||
|
||
<span class="sd">{clear}</span>
|
||
|
||
<span class="sd">Block 1 on page 2.</span>
|
||
|
||
<span class="sd">etc.</span>
|
||
<span class="sd">"""</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<p>It's also possible to define <a class="reference internal" href="custom_text_tags.html"><span class="doc">custom text tags</span></a> using
|
||
Python.</p>
|
||
</div>
|
||
<div class="section" id="style-text-tags">
|
||
<h3>Style Text Tags<a class="headerlink" href="#style-text-tags" title="Permalink to this headline"> link</a></h3>
|
||
<p>Ren'Py supports text tags that access styles. These are text tags
|
||
where the tag name is empty. In this case, the argument
|
||
is taken to be the name of a style. For example, the {=mystyle} tag
|
||
will acces the <code class="docutils literal notranslate"><span class="pre">mystyle</span></code> style.</p>
|
||
<p>The text between the tag and the corresponding closing tag has the following
|
||
properties set to those defined in the style:</p>
|
||
<ul class="simple">
|
||
<li>antialias</li>
|
||
<li>font</li>
|
||
<li>size</li>
|
||
<li>bold</li>
|
||
<li>italic</li>
|
||
<li>underline</li>
|
||
<li>strikethrough</li>
|
||
<li>color</li>
|
||
<li>black_color</li>
|
||
<li>kerning</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="non-english-languages">
|
||
<h2>Non-English Languages<a class="headerlink" href="#non-english-languages" title="Permalink to this headline"> link</a></h2>
|
||
<p>The default font for Ren'Py contains characters for English and many
|
||
other languages. For size reasons, it doesn't contain the characters
|
||
required to render other languages, including Chinese, Japanese, and
|
||
Korean. In order to support these languages, a project must first
|
||
change the fonts it uses.</p>
|
||
<p>Ren'Py should then support most world languages without further
|
||
configuration. However, Korean can be written with or without spacing
|
||
between words. Ren'Py has a special mode to support Korean with
|
||
spaces, which can be enabled by setting:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">define</span> <span class="n">gui</span><span class="o">.</span><span class="na">language</span> <span class="o">=</span> <span class="s2">"korean-with-spaces"</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>This can be changed from the default of "unicode" in gui.rpy.</p>
|
||
<p>Japanese has multiple rules for line breaking. We recommend starting with
|
||
"japanese-normal", and moving to "japanese-loose" or "japanese-strict" for
|
||
more or less break opportunities, respectively.</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">define</span> <span class="n">gui</span><span class="o">.</span><span class="na">language</span> <span class="o">=</span> <span class="s2">"japanese-loose"</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Ideographic languages provide a large number of opportunities
|
||
for line breaking. To enable a faster but less-accurate line-breaking
|
||
algorithm, use:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">define</span> <span class="n">gui</span><span class="o">.</span><span class="na">language</span> <span class="o">=</span> <span class="s2">"greedy"</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The faster line-breaking algorithm is not be necessary unless the
|
||
game is displaying huge amounts of text, such as in NVL-mode.</p>
|
||
<p>The line breaking algorithms can be further configured using the
|
||
<a class="reference internal" href="other.html#renpy.language_tailor" title="renpy.language_tailor"><code class="xref py py-func docutils literal notranslate"><span class="pre">renpy.language_tailor()</span></code></a> function.</p>
|
||
<div class="section" id="vertical-text">
|
||
<h3>Vertical Text<a class="headerlink" href="#vertical-text" title="Permalink to this headline"> link</a></h3>
|
||
<p>When the <a class="reference internal" href="style_properties.html#style-property-vertical"><code class="xref std std-propref docutils literal notranslate"><span class="pre">vertical</span></code></a> style property is set, Ren'Py will produce
|
||
vertically oriented text. The text is written top-to-bottom,
|
||
right-to-left.</p>
|
||
<p>There are two text tags that interact with vertical text.</p>
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-horiz">
|
||
<code class="descname">horiz</code><a class="headerlink" href="#text-tag-horiz" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>Includes horizontally-oriented text inside vertical text.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="text-tag">
|
||
<dt id="text-tag-vert">
|
||
<code class="descname">vert</code><a class="headerlink" href="#text-tag-vert" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>Includes vertically-oriented text inside horizontal text. (This will
|
||
not rotate the text to the vertical orientation.)</p>
|
||
</dd></dl>
|
||
|
||
<div class="admonition note">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">If the font does not contain vertical text spacing information, Ren'Py
|
||
will attempt to synthesize this information from horizontal text
|
||
information. The spacing may not remain constant between Ren'Py
|
||
releases.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="ruby-text">
|
||
<span id="id2"></span><h2>Ruby Text<a class="headerlink" href="#ruby-text" title="Permalink to this headline"> link</a></h2>
|
||
<p>Ruby text (also known as furigana or interlinear annotations) is a way
|
||
of placing small text above a character or word. There are several
|
||
steps required for your game to support ruby text.</p>
|
||
<p>First, you must set up styles for the ruby text. The following style
|
||
changes are required:</p>
|
||
<ol class="arabic simple">
|
||
<li>The <a class="reference internal" href="style_properties.html#style-property-line_leading"><code class="xref std std-propref docutils literal notranslate"><span class="pre">line_leading</span></code></a> property must be used to leave enough
|
||
vertical space for the ruby text.</li>
|
||
<li>A new named style must be created. The properties of this style,
|
||
such as <a class="reference internal" href="style_properties.html#style-property-size"><code class="xref std std-propref docutils literal notranslate"><span class="pre">size</span></code></a> should be set in a fashion appropriate
|
||
for ruby text.</li>
|
||
<li>The <a class="reference internal" href="style_properties.html#style-property-yoffset"><code class="xref std std-propref docutils literal notranslate"><span class="pre">yoffset</span></code></a> of the new style should be set, in order to move the
|
||
ruby text above the baseline.</li>
|
||
<li>The <a class="reference internal" href="style_properties.html#style-property-ruby_style"><code class="xref std std-propref docutils literal notranslate"><span class="pre">ruby_style</span></code></a> field of the text's style should be set
|
||
to the newly-created style, for both dialogue and history window
|
||
text.</li>
|
||
</ol>
|
||
<p>For example:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">style</span> <span class="na">ruby_style</span> <span class="k">is</span> <span class="k">default</span><span class="p">:</span>
|
||
<span class="na">size</span> <span class="mi">12</span>
|
||
<span class="na">yoffset</span> <span class="o">-</span><span class="mi">20</span>
|
||
|
||
<span class="k">style</span> <span class="n">say_dialogue</span><span class="p">:</span>
|
||
<span class="na">line_leading</span> <span class="mi">12</span>
|
||
<span class="na">ruby_style</span> <span class="k">style</span><span class="o">.</span><span class="na">ruby_style</span>
|
||
|
||
<span class="k">style</span> <span class="n">history_text</span><span class="p">:</span>
|
||
<span class="na">line_leading</span> <span class="mi">12</span>
|
||
<span class="na">ruby_style</span> <span class="k">style</span><span class="o">.</span><span class="na">ruby_style</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Use <code class="docutils literal notranslate"><span class="pre">style.style_name</span></code> to refer to a style for this purpose.)</p>
|
||
<p>Once Ren'Py has been configured, ruby text can be included using the
|
||
{rt} and {rb} text tags. The {rt} tag is used to mark one or more characters
|
||
to be displayed as ruby text. If the ruby text is preceded by text
|
||
enclosed in the {rb} tag, the ruby text is centered over that
|
||
text. Otherwise, it is centered over the preceding character.</p>
|
||
<p>For example:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">e</span> <span class="s2">"Ruby can be used for furigana (東</span><span class="si">{rt}</span><span class="s2">とう{/rt} 京</span><span class="si">{rt}</span><span class="s2">きょう{/rt})."</span>
|
||
|
||
<span class="n">e</span> <span class="s2">"It's also used for translations (</span><span class="si">{rb}</span><span class="s2">東京{/rb}</span><span class="si">{rt}</span><span class="s2">Tokyo{/rt})."</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>It's the creator's responsibility to ensure that ruby text does not
|
||
leave the boundaries of the text. It may be necessary to add leading
|
||
or spaces to the left and right of the text to prevent these errors
|
||
from occurring.</p>
|
||
<p>Ren'Py also supports alternate ruby text, which is a second kind of
|
||
ruby top text. This is introduced with the {art} text tag (instead of {rt}),
|
||
and the <a class="reference internal" href="style_properties.html#style-property-altruby_style"><code class="xref std std-propref docutils literal notranslate"><span class="pre">altruby_style</span></code></a> property (instead of <a class="reference internal" href="style_properties.html#style-property-ruby_style"><code class="xref std std-propref docutils literal notranslate"><span class="pre">ruby_style</span></code></a>).</p>
|
||
</div>
|
||
<div class="section" id="fonts">
|
||
<h2>Fonts<a class="headerlink" href="#fonts" title="Permalink to this headline"> link</a></h2>
|
||
<p>Ren'Py supports TrueType/OpenType fonts and collections, and
|
||
Image-Based fonts.</p>
|
||
<p>A TrueType or OpenType font is specified by giving the name of the font
|
||
file. The file must be present in the game directory or one of the archive
|
||
files.</p>
|
||
<p>Ren'Py also supports TrueType/OpenType collections that define more than one
|
||
font. When accessing a collection, use the 0-based font index,
|
||
followed by an at-sign and the file name. For example, "0@font.ttc" is
|
||
the first font in a collection, "1@font.ttc" the second, and so on.</p>
|
||
<div class="section" id="font-replacement">
|
||
<h3>Font Replacement<a class="headerlink" href="#font-replacement" title="Permalink to this headline"> link</a></h3>
|
||
<p>The <a class="reference internal" href="config.html#var-config.font_replacement_map"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.font_replacement_map</span></code></a> variable is used to map
|
||
fonts. The combination of font filename, boldness, and italics is
|
||
mapped to a similar combination. This allows a font with proper
|
||
italics to be used instead of the automatically-generated italics.</p>
|
||
<p>Once such mapping would be to replace the italic version of the Deja
|
||
Vu Sans font with the official oblique version (You'll need to
|
||
download the oblique font from the web):</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
|
||
<span class="n">config</span><span class="o">.</span><span class="n">font_replacement_map</span><span class="p">[</span><span class="s2">"DejaVuSans.ttf"</span><span class="p">,</span> <span class="kc">False</span><span class="p">,</span> <span class="kc">True</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"DejaVuSans-Oblique.ttf"</span><span class="p">,</span> <span class="kc">False</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>This mapping can improve the look of italic text.</p>
|
||
</div>
|
||
<div class="section" id="image-based-fonts">
|
||
<h3>Image-Based Fonts<a class="headerlink" href="#image-based-fonts" title="Permalink to this headline"> link</a></h3>
|
||
<p>Image based fonts can be registered by calling one of the following
|
||
registration functions. Registering an image-based font requires the
|
||
specification of a name, size, boldness, italicness, and
|
||
underline. When all of these properties match the registered font,
|
||
the registered font is used.</p>
|
||
<dl class="function">
|
||
<dt id="renpy.register_bmfont">
|
||
<code class="descclassname">renpy.</code><code class="descname">register_bmfont</code><span class="sig-paren">(</span><em>name=None</em>, <em>size=None</em>, <em>bold=False</em>, <em>italics=False</em>, <em>underline=False</em>, <em>filename=None</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.register_bmfont" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>This registers a BMFont with the given details. Please note that size, bold,
|
||
italic, and underline are all advisory (used for matching), and do not
|
||
change the appearance of the font.</p>
|
||
<p>Please see the <a class="reference external" href="http://www.angelcode.com/products/bmfont/">BMFont home page</a>
|
||
for the tool that creates BMFonts. Ren'Py expects that the filename
|
||
parameter will be to a file in the BMFont text format, that describes a
|
||
32-bit font. The Alpha channel should contain the font information, while
|
||
the Red, Green, and Blue channels should be set to one. The image files,
|
||
kerning, and other control information is read out of the BMFont file.</p>
|
||
<p>We recommend including Latin and General Punctuation as part of your BMFont,
|
||
to ensure all of the Ren'Py interface can render.</p>
|
||
<dl class="docutils">
|
||
<dt><cite>name</cite></dt>
|
||
<dd>The name of the font being registered, a string.</dd>
|
||
<dt><cite>size</cite></dt>
|
||
<dd>The size of the font being registered, an integer.</dd>
|
||
<dt><cite>bold</cite></dt>
|
||
<dd>The boldness of the font being registered, a boolean.</dd>
|
||
<dt><cite>italics</cite></dt>
|
||
<dd>The italicness of the font being registered, a boolean.</dd>
|
||
<dt><cite>underline</cite></dt>
|
||
<dd>An ignored parameter.</dd>
|
||
<dt><cite>filename</cite></dt>
|
||
<dd>The file containing BMFont control information.</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="renpy.register_mudgefont">
|
||
<code class="descclassname">renpy.</code><code class="descname">register_mudgefont</code><span class="sig-paren">(</span><em>name=None</em>, <em>size=None</em>, <em>bold=False</em>, <em>italics=False</em>, <em>underline=False</em>, <em>filename=None</em>, <em>xml=None</em>, <em>spacewidth=10</em>, <em>default_kern=0</em>, <em>kerns={}</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.register_mudgefont" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>This registers a MudgeFont with the given details. Please note that size,
|
||
bold, italic, and underline are all advisory (used for matching), and do not
|
||
change the appearance of the font.</p>
|
||
<p>Please see the <a class="reference external" href="http://www.larryhastings.com/programming/mudgefont/">MudgeFont home page</a>
|
||
for the tool that creates MudgeFonts. Ren'Py assumes that character codes
|
||
found in the MudgeFont xml file are unicode character numbers, and ignores
|
||
negative character codes.</p>
|
||
<dl class="docutils">
|
||
<dt><cite>name</cite></dt>
|
||
<dd>The name of the font being registered, a string.</dd>
|
||
<dt><cite>size</cite></dt>
|
||
<dd>The size of the font being registered, an integer.</dd>
|
||
<dt><cite>bold</cite></dt>
|
||
<dd>The boldness of the font being registered, a boolean.</dd>
|
||
<dt><cite>italics</cite></dt>
|
||
<dd>The italicness of the font being registered, a boolean.</dd>
|
||
<dt><cite>underline</cite></dt>
|
||
<dd>An ignored parameter.</dd>
|
||
<dt><cite>filename</cite></dt>
|
||
<dd>The file containing the MudgeFont image, a string. The image is usually
|
||
a TGA file, but could be a PNG or other format that Ren'Py supports.</dd>
|
||
<dt><cite>xml</cite></dt>
|
||
<dd>The xml file containing information generated by the MudgeFont tool.</dd>
|
||
<dt><cite>spacewidth</cite></dt>
|
||
<dd>The width of a space character, an integer in pixels.</dd>
|
||
<dt><cite>default_kern</cite></dt>
|
||
<dd>The default kern spacing between characters, in pixels.</dd>
|
||
<dt><cite>kerns</cite></dt>
|
||
<dd>A map from two-character strings to the kern that should be used between
|
||
those characters.</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="renpy.register_sfont">
|
||
<code class="descclassname">renpy.</code><code class="descname">register_sfont</code><span class="sig-paren">(</span><em>name=None</em>, <em>size=None</em>, <em>bold=False</em>, <em>italics=False</em>, <em>underline=False</em>, <em>filename=None</em>, <em>spacewidth=10</em>, <em>baseline=None</em>, <em>default_kern=0</em>, <em>kerns={}</em>, <em>charset=u'!"#$%&'()*+</em>, <em>-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.register_sfont" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>This registers an SFont with the given details. Please note that size, bold,
|
||
italic, and underline are all advisory (used for matching), and do not
|
||
change the appearance of the font.</p>
|
||
<p><a class="reference external" href="http://www.linux-games.com/sfont/">More information about SFont.</a></p>
|
||
<dl class="docutils">
|
||
<dt><cite>name</cite></dt>
|
||
<dd>The name of the font being registered, a string.</dd>
|
||
<dt><cite>size</cite></dt>
|
||
<dd>The size of the font being registered, an integer.</dd>
|
||
<dt><cite>bold</cite></dt>
|
||
<dd>The boldness of the font being registered, a boolean.</dd>
|
||
<dt><cite>italics</cite></dt>
|
||
<dd>The italicness of the font being registered, a boolean.</dd>
|
||
<dt><cite>underline</cite></dt>
|
||
<dd>An ignored parameter.</dd>
|
||
<dt><cite>filename</cite></dt>
|
||
<dd>The file containing the sfont image, a string.</dd>
|
||
<dt><cite>spacewidth</cite></dt>
|
||
<dd>The width of a space character, an integer in pixels.</dd>
|
||
<dt><cite>baseline</cite></dt>
|
||
<dd>The distance from the top of the font to the baseline (the invisible
|
||
line letters sit on), an integer in pixels. If this font is mixed with
|
||
other fonts, their baselines will be aligned. Negative values indicate
|
||
distance from the bottom of the font instead, and <code class="docutils literal notranslate"><span class="pre">None</span></code> means the
|
||
baseline equals the height (i.e., is at the very bottom of the font).</dd>
|
||
<dt><cite>default_kern</cite></dt>
|
||
<dd>The default kern spacing between characters, in pixels.</dd>
|
||
<dt><cite>kerns</cite></dt>
|
||
<dd>A map from two-character strings to the kern that should be used between
|
||
those characters.</dd>
|
||
<dt><cite>charset</cite></dt>
|
||
<dd><p class="first">The character set of the font. A string containing characters in
|
||
the order in which they are found in the image. The default character
|
||
set for a SFont is:</p>
|
||
<div class="last highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="err">!</span> <span class="s2">" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?</span>
|
||
<span class="o">@</span> <span class="n">A</span> <span class="n">B</span> <span class="n">C</span> <span class="n">D</span> <span class="n">E</span> <span class="n">F</span> <span class="n">G</span> <span class="n">H</span> <span class="n">I</span> <span class="n">J</span> <span class="n">K</span> <span class="n">L</span> <span class="n">M</span> <span class="n">N</span> <span class="n">O</span> <span class="n">P</span> <span class="n">Q</span> <span class="n">R</span> <span class="n">S</span> <span class="n">T</span> <span class="n">U</span> <span class="n">V</span> <span class="n">W</span> <span class="n">X</span> <span class="n">Y</span> <span class="n">Z</span> <span class="p">[</span> \ <span class="p">]</span> <span class="o">^</span> <span class="n">_</span>
|
||
<span class="err">`</span> <span class="n">a</span> <span class="n">b</span> <span class="n">c</span> <span class="n">d</span> <span class="n">e</span> <span class="n">f</span> <span class="n">g</span> <span class="n">h</span> <span class="n">i</span> <span class="n">j</span> <span class="n">k</span> <span class="n">l</span> <span class="n">m</span> <span class="n">n</span> <span class="n">o</span> <span class="n">p</span> <span class="n">q</span> <span class="n">r</span> <span class="n">s</span> <span class="n">t</span> <span class="n">u</span> <span class="n">v</span> <span class="n">w</span> <span class="n">x</span> <span class="n">y</span> <span class="n">z</span> <span class="p">{</span> <span class="o">|</span> <span class="p">}</span> <span class="o">~</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<p>As BMFont is the most complete of the three image font formats Ren'Py
|
||
supports, it's the one recommended for new projects. An example of
|
||
BMFont use is:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
|
||
<span class="n">renpy</span><span class="o">.</span><span class="n">register_bmfont</span><span class="p">(</span><span class="s2">"bmfont"</span><span class="p">,</span> <span class="mi">22</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s2">"bmfont.fnt"</span><span class="p">)</span>
|
||
|
||
<span class="k">define</span> <span class="n">ebf</span> <span class="o">=</span> <span class="n">Character</span><span class="p">(</span><span class="s1">'Eileen'</span><span class="p">,</span> <span class="n">what_font</span><span class="o">=</span><span class="s2">"bmfont"</span><span class="p">,</span> <span class="n">what_size</span><span class="o">=</span><span class="mi">22</span><span class="p">)</span>
|
||
|
||
<span class="k">label</span> <span class="n">demo_bmfont</span><span class="p">:</span>
|
||
|
||
<span class="n">ebf</span> <span class="s2">"Finally, Ren'Py supports BMFonts."</span>
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="font-groups">
|
||
<h3>Font Groups<a class="headerlink" href="#font-groups" title="Permalink to this headline"> link</a></h3>
|
||
<p>When creating a multilingual game, it may not be possible to find a single
|
||
font that covers every writing system the game use while projecting the
|
||
the mood the creator intends. To support this, Ren'Py supports font groups
|
||
that can take characters from two or more fonts and combine them into a
|
||
single font.</p>
|
||
<p>To create a font group, create a <a class="reference internal" href="#FontGroup" title="FontGroup"><code class="xref py py-class docutils literal notranslate"><span class="pre">FontGroup</span></code></a> object and call the <code class="docutils literal notranslate"><span class="pre">.add</span></code> method
|
||
on it once or more. A FontGroup can be used wherever a font name can be
|
||
used. The add method takes the start and end of a range of Unicode character
|
||
points, and the first range to cover a point is used.</p>
|
||
<p>For example:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">style</span> <span class="k">default</span><span class="p">:</span>
|
||
<span class="na">font</span> <span class="n">FontGroup</span><span class="p">()</span><span class="o">.</span><span class="k">add</span><span class="p">(</span><span class="s2">"english.ttf"</span><span class="p">,</span> <span class="mh">0x0020</span><span class="p">,</span> <span class="mh">0x007f</span><span class="p">)</span><span class="o">.</span><span class="k">add</span><span class="p">(</span><span class="s2">"japanese.ttf"</span><span class="p">,</span> <span class="mh">0x0000</span><span class="p">,</span> <span class="mh">0xffff</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<dl class="function">
|
||
<dt id="FontGroup">
|
||
<code class="descname">FontGroup</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#FontGroup" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>A group of fonts that can be used as a single font.</p>
|
||
<dl class="function">
|
||
<dt id="add">
|
||
<code class="descname">add</code><span class="sig-paren">(</span><em>font</em>, <em>start</em>, <em>end</em>, <em>target=None</em>, <em>target_increment=False</em><span class="sig-paren">)</span><a class="headerlink" href="#add" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>Associates a range of characters with a <cite>font</cite>.</p>
|
||
<dl class="docutils">
|
||
<dt><cite>start</cite></dt>
|
||
<dd>The start of the range. This may be a single-character string, or
|
||
an integer giving a unicode code point. If start is None, then the
|
||
font is used as the default.</dd>
|
||
<dt><cite>end</cite></dt>
|
||
<dd>The end of the range. This may be a single-character string, or an
|
||
integer giving a unicode code point. This is ignored if start is
|
||
None.</dd>
|
||
<dt><cite>target</cite></dt>
|
||
<dd>If given, associates the given range of characters with specific
|
||
characters from the given font, depending on target_increment.
|
||
This may be a single-character string, or an integer giving a
|
||
unicode code point. This is ignored if the character had already
|
||
been added.</dd>
|
||
<dt><cite>target_increment</cite></dt>
|
||
<dd>If True, the [start, end] range is mapped to the
|
||
[target, target+end-start] range. If False, every character from the
|
||
range is associated with the target character.</dd>
|
||
</dl>
|
||
<p>When multiple .add() calls include the same character, the first call
|
||
takes precedence.</p>
|
||
<p>This returns the FontGroup, so that multiple calls to .add() can be
|
||
chained together.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="remap">
|
||
<code class="descname">remap</code><span class="sig-paren">(</span><em>cha</em>, <em>target</em><span class="sig-paren">)</span><a class="headerlink" href="#remap" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>Remaps one or a set of characters to a single target character.</p>
|
||
<dl class="docutils">
|
||
<dt><cite>cha</cite></dt>
|
||
<dd>The character or characters to remap. This may be a single-character
|
||
string, or an integer giving a unicode code point, or an iterable of
|
||
either.</dd>
|
||
<dt><cite>target</cite></dt>
|
||
<dd>The character to remap to. This may be a single-character string, or
|
||
an integer giving a unicode code point.</dd>
|
||
</dl>
|
||
<p>Any given character having already been remapped (either with add or with
|
||
remap) will be ignored. However, if the FontGroup has no default font, any
|
||
given character must have been previously added.</p>
|
||
<p>This method also returns the FontGroup, for the same reasons.</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="section" id="text-displayables">
|
||
<span id="id3"></span><h2>Text Displayables<a class="headerlink" href="#text-displayables" title="Permalink to this headline"> link</a></h2>
|
||
<p>Text can also be used as a <a class="reference internal" href="displayables.html"><span class="doc">displayable</span></a>, which
|
||
allows you to apply transforms to text, displaying it as if it was an
|
||
image and moving it around the screen.</p>
|
||
<dl class="function">
|
||
<dt id="ParameterizedText">
|
||
<code class="descname">ParameterizedText</code><span class="sig-paren">(</span><em>style=u'default'</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#ParameterizedText" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>This is a displayable that can be shown with an additional string
|
||
parameter, which then shows that string as if it was an image.
|
||
This is usually used as part of the pre-defined <code class="docutils literal notranslate"><span class="pre">text</span></code> image.</p>
|
||
<p>For example, one can do:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">show</span> <span class="k">text</span> <span class="s2">"Hello, World"</span> <span class="k">at</span> <span class="n">truecenter</span>
|
||
<span class="k">with</span> <span class="n">dissolve</span>
|
||
<span class="k">pause</span> <span class="mi">1</span>
|
||
<span class="k">hide</span> <span class="k">text</span>
|
||
<span class="k">with</span> <span class="n">dissolve</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>You can use ParameterizedText directly to define similar images with
|
||
different style properties. For example, one can write:</p>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">top_text</span> <span class="o">=</span> <span class="n">ParameterizedText</span><span class="p">(</span><span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
|
||
|
||
<span class="k">label</span> <span class="n">start</span><span class="p">:</span>
|
||
<span class="k">show</span> <span class="n">top_text</span> <span class="s2">"This text is shown at the center-top of the screen"</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="Text">
|
||
<code class="descname">Text</code><span class="sig-paren">(</span><em>text</em>, <em>slow=None</em>, <em>scope=None</em>, <em>substitute=None</em>, <em>slow_done=None</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#Text" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>A displayable that displays text on the screen.</p>
|
||
<dl class="docutils">
|
||
<dt><cite>text</cite></dt>
|
||
<dd>The text to display on the screen. This may be a string, or a list of
|
||
strings and displayables.</dd>
|
||
<dt><cite>slow</cite></dt>
|
||
<dd>Determines if the text is displayed slowly, being typed out one character at the time.
|
||
If None, slow text mode is determined by the <a class="reference internal" href="style_properties.html#style-property-slow_cps"><code class="xref std std-propref docutils literal notranslate"><span class="pre">slow_cps</span></code></a> style property. Otherwise,
|
||
the truth value of this parameter determines if slow text mode is used.</dd>
|
||
<dt><cite>scope</cite></dt>
|
||
<dd>If not None, this should be a dictionary that provides an additional scope for text
|
||
interpolation to occur in.</dd>
|
||
<dt><cite>substitute</cite></dt>
|
||
<dd>If true, text interpolation occurs. If false, it will not occur. If
|
||
None, they are controlled by <a class="reference internal" href="config.html#var-config.new_substitutions"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.new_substitutions</span></code></a>.</dd>
|
||
<dt><cite>slow_done</cite></dt>
|
||
<dd>If not None, and if slow text mode is enabled (see the <cite>slow</cite> parameter), this is a
|
||
function or callable which is called with no arguments when the text finishes displaying.</dd>
|
||
<dt><cite>**properties</cite></dt>
|
||
<dd>Like other Displayables, Text takes style properties, including (among many others) the
|
||
<a class="reference internal" href="style_properties.html#style-property-mipmap"><code class="xref std std-propref docutils literal notranslate"><span class="pre">mipmap</span></code></a> property.</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="text-utility-functions">
|
||
<h2>Text Utility Functions<a class="headerlink" href="#text-utility-functions" title="Permalink to this headline"> link</a></h2>
|
||
<dl class="function">
|
||
<dt id="renpy.filter_text_tags">
|
||
<code class="descclassname">renpy.</code><code class="descname">filter_text_tags</code><span class="sig-paren">(</span><em>s</em>, <em>allow=None</em>, <em>deny=None</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.filter_text_tags" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>Returns a copy of <cite>s</cite> with the text tags filtered. Exactly one of the <cite>allow</cite> and <cite>deny</cite> keyword
|
||
arguments must be given.</p>
|
||
<dl class="docutils">
|
||
<dt><cite>allow</cite></dt>
|
||
<dd>A set of tags that are allowed. If a tag is not in this list, it is removed.</dd>
|
||
<dt><cite>deny</cite></dt>
|
||
<dd>A set of tags that are denied. If a tag is not in this list, it is kept in the string.</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="renpy.transform_text">
|
||
<code class="descclassname">renpy.</code><code class="descname">transform_text</code><span class="sig-paren">(</span><em>s</em>, <em>function</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.transform_text" title="Permalink to this definition"> link</a></dt>
|
||
<dd><p>Transforms <cite>s</cite>, while leaving text tags and interpolation the same.</p>
|
||
<dl class="docutils">
|
||
<dt><cite>function</cite></dt>
|
||
<dd>A function that is called with strings corresponding to runs of
|
||
text, and should return a second string that replaces that run
|
||
of text.</dd>
|
||
</dl>
|
||
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
|
||
<span class="k">def</span> <span class="nf">upper</span><span class="p">(</span><span class="n">s</span><span class="p">):</span>
|
||
<span class="k">return</span> <span class="n">s</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
|
||
|
||
<span class="k">$</span> <span class="n">upper_string</span> <span class="o">=</span> <span class="n">renpy</span><span class="o">.</span><span class="n">transform_text</span><span class="p">(</span><span class="s2">"</span><span class="si">{b}</span><span class="s2">Not Upper{/b}"</span><span class="p">,</span> <span class="n">upper</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="slow-text-concerns">
|
||
<h2>Slow Text Concerns<a class="headerlink" href="#slow-text-concerns" title="Permalink to this headline"> link</a></h2>
|
||
<p>Ren'Py allows the creator or user to indicate that text should be
|
||
displayed slowly. In this case, Ren'Py will render the text to a
|
||
texture, and then draw rectangles from the texture to the screen.</p>
|
||
<p>Unfortunately, this means that it's possible to get rendering
|
||
artifacts when characters overlap. To minimize these rendering
|
||
artifacts, ensure that the <a class="reference internal" href="style_properties.html#style-property-line_leading"><code class="xref std std-propref docutils literal notranslate"><span class="pre">line_leading</span></code></a> and
|
||
<a class="reference internal" href="style_properties.html#style-property-line_spacing"><code class="xref std std-propref docutils literal notranslate"><span class="pre">line_spacing</span></code></a> properties are large enough that lines do not
|
||
overlap. If the bottoms of characters on the first line are clipped,
|
||
especially if line_spacing is negative, consider increasing
|
||
<a class="reference internal" href="style_properties.html#style-property-line_overlap_split"><code class="xref std std-propref docutils literal notranslate"><span class="pre">line_overlap_split</span></code></a>.</p>
|
||
<p>Horizontal artifacts are also possible when characters are kerned
|
||
together, but these artifacts are less severe, as they exist for only
|
||
a single frame.</p>
|
||
<p>Artifacts aren't a problem for static text, like the text in menus and
|
||
other parts of the user interface.</p>
|
||
</div>
|
||
<div class="section" id="text-overflow-logging">
|
||
<h2>Text Overflow Logging<a class="headerlink" href="#text-overflow-logging" title="Permalink to this headline"> link</a></h2>
|
||
<p>Ren'Py can log cases where text expands outside of the area allocated
|
||
for it. To enable text overflow logging, the following steps are
|
||
necessary.</p>
|
||
<ol class="arabic simple">
|
||
<li>Set the <a class="reference internal" href="config.html#var-config.debug_text_overflow"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.debug_text_overflow</span></code></a> variable to true.</li>
|
||
<li>Set the <a class="reference internal" href="style_properties.html#style-property-xmaximum"><code class="xref std std-propref docutils literal notranslate"><span class="pre">xmaximum</span></code></a> and <a class="reference internal" href="style_properties.html#style-property-ymaximum"><code class="xref std std-propref docutils literal notranslate"><span class="pre">ymaximum</span></code></a> style properties on either the Text
|
||
displayable, or a container enclosing it.</li>
|
||
<li>Run the game.</li>
|
||
</ol>
|
||
<p>Whenever text is displayed that overflows the available area, Ren'Py
|
||
will log an error to the text_overflow.txt file.</p>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<footer class="footer">
|
||
<div class="container">
|
||
<p class="pull-right">
|
||
<a href="#">Back to top</a>
|
||
|
||
</p>
|
||
<p>
|
||
© Copyright 2012-2022, Tom Rothamel.<br/>
|
||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.6.<br/>
|
||
</p>
|
||
</div>
|
||
</footer>
|
||
</body>
|
||
</html> |