gm-docs-parser 1.0.0

A collection of typings for GameMaker Studio 2 manual pages
Documentation
<?xml version="1.0" encoding="utf-8" ?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>

  <script type="text/javascript" language="JavaScript">
    //<![CDATA[
    function reDo() {
      if (innerWidth != origWidth || innerHeight != origHeight)
        location.reload();
    }
    if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
      origWidth = innerWidth;
      origHeight = innerHeight;
      onresize = reDo;
    }
    onerror = null;
  //]]>
  </script>
  <style type="text/css">/*<![CDATA[*/

    < !-- div.WebHelpPopupMenu {
      position: absolute;
      left: 0px;
      top: 0px;
      z-index: 4;
      visibility: hidden;
    }

    p.WebHelpNavBar {
      text-align: right;
    }

    -->
  
/*]]>*/</style>

  <script type="text/javascript">//<![CDATA[

    gRootRelPath = "../../../..";
    gCommonRootRelPath = "../../../..";
    gTopicId = "9.2.2.10.0_14";
  
//]]></script>

  <script type="text/javascript" src="../../../../template/scripts/rh.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/common.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/topic.min.js"></script>
  <script type="text/javascript" src="../../../../template/scripts/topicwidgets.min.js"></script>
<script type="text/javascript" src="../../../../whxdata/projectsettings.js"></script>
  <link rel="stylesheet" type="text/css" href="../../../../template/styles/topic.min.css"/>
  <link rel="stylesheet" type="text/css" href="../../../../template/Charcoal_Grey/topicheader.css"/>
  <meta name="topic-status" content="Draft"/>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>font_add</title>
  <meta name="generator" content="Adobe RoboHelp 2019"/>
  <link rel="stylesheet" href="../../../../assets/css/default.css" type="text/css"/>
  <meta name="rh-authors" content="Mark Alexander"/>
  <meta name="topic-comment" content="Page outlining the function font_add"/>
  <meta name="rh-index-keywords" content="font_add"/>
  <meta name="search-keywords" content="font_add"/>
</head>

<body>
  <div class="topic-header rh-hide" id="rh-topic-header" onclick="rh._.goToFullLayout()">
    <div class="logo">
    </div>
    <div class="nav">
      <div class="title" title="font_add">
        <span>font_add</span>
      </div>
      <div class="gotohome" title="Click here to see this page in full context">
        <span>Click here to see this page in full context</span>
      </div>
    </div>
  </div>
  <div class="topic-header-shadow rh-hide" id="rh-topic-header-shadow"></div>



  <!--<div class="body-scroll" style="top: 150px;">-->
  <h1>font_add</h1>
  <p>This function can be used to add a font to your game from those fonts that are installed on the system it is running on. You can define the size of the font (in points), as well as whether the font should be <b>bold</b> or <i>italic</i>, and you can
    also define the range of characters to include. The function returns an <i>index</i> value that should be stored in a variable as this will be needed in all further codes that refer to this font, or it will return -1 if the function fails for any
    reason.</p>
  <p>For the HTML5 target module, this function <b>can only be used to add <i>Web Fonts</i></b>, and will only work if WebGL is <b>not</b> enabled - if WebGL is enabled then you must use a general font resource (ie: using <a href="../../Drawing/Text/draw_set_font.htm"><tt>draw_set_font()</tt></a>    along with a font from the Asset Browser) or bitmap fonts (see <a href="font_add_sprite.htm"><tt>font_add_sprite()</tt></a>).</p>
  <p class="note"><b>IMPORTANT!</b> When targeting HTML5, italics and bold text is only supported if the font asset or web font itself has these characters included. They will not be synthesised from the base font.</p>
  <p>The following table shows the fonts that are standard across all browsers and that should be be available for use without problems. Any other font may or may not exist on the computer or device that is running your game, so the use of this function
    should be limited to these standard fonts:</p>
  <p> </p>
  <table>
    <tbody>
      <tr>
        <th>Windows Font Name</th>
        <th>Mac Font Name</th>
        <th>Font Family</th>
      </tr>
      <tr>
        <td>Arial</td>
        <td>Arial / Helvetica</td>
        <td>sans-serif</td>
      </tr>
      <tr>
        <td>Arial Black</td>
        <td>Arial Black / Gadget</td>
        <td>sans-serif</td>
      </tr>
      <tr>
        <td>Comic Sans MS</td>
        <td>Comic Sans MS</td>
        <td>cursive</td>
      </tr>
      <tr>
        <td>Courier New</td>
        <td>Courier New</td>
        <td>monospaced</td>
      </tr>
      <tr>
        <td>Georgia</td>
        <td>Georgia</td>
        <td>serif</td>
      </tr>
      <tr>
        <td>Impact</td>
        <td>Impact / Charcoal</td>
        <td>sans-serif</td>
      </tr>
      <tr>
        <td>Lucida Console</td>
        <td>Monaco</td>
        <td>monospaced</td>
      </tr>
      <tr>
        <td>Lucida Sans Unicode</td>
        <td>Lucida Grande</td>
        <td>sans-serif</td>
      </tr>
      <tr>
        <td>Palatino Linotype / Book Antiqua</td>
        <td>Palatino</td>
        <td>serif</td>
      </tr>
      <tr>
        <td>Tahoma</td>
        <td>Geneva</td>
        <td>sans-serif</td>
      </tr>
      <tr>
        <td>Times New Roman</td>
        <td>Times New Roman / Times</td>
        <td>serif</td>
      </tr>
      <tr>
        <td>Trebuchet MS</td>
        <td>Trebuchet MS</td>
        <td>sans-serif</td>
      </tr>
      <tr>
        <td>Verdana</td>
        <td>Verdana / Geneva</td>
        <td>sans-serif</td>
      </tr>
      <tr>
        <td>Georgia</td>
        <td>Georgia</td>
        <td>serif</td>
      </tr>
      <tr>
        <td>Symbol</td>
        <td>Symbol</td>
        <td>N/A</td>
      </tr>
      <tr>
        <td>Webdings</td>
        <td>Webdings</td>
        <td>N/A</td>
      </tr>
      <tr>
        <td>Wingdings</td>
        <td>Zapf Dingbats</td>
        <td>N/A</td>
      </tr>
      <tr>
        <td>MS Sans Serif</td>
        <td>Geneva</td>
        <td>sans-serif</td>
      </tr>
      <tr>
        <td>MS Serif</td>
        <td>New York</td>
        <td>sans-serif</td>
      </tr>
    </tbody>
  </table>
  <p><br/>
    <br/> On all other (non Web) targets, you can use this function to add a font from a file. The file <b>must be included in the game bundle</b> using the <a href="../../../../Settings/Included_Files.htm">Included Files</a> functionality of GameMaker
    Studio 2, and must be a <tt>*.ttf</tt> format font file, useful for adding non-standard fonts like Asian or Arabic.</p>
  <p class="note"><b>WARNING!: </b>If you include a font in <tt>*.ttf</tt> format with a game, it <b>must be licensed</b> for distribution with the game.</p>
  <p>When loading a font from a file in this way the <i>size</i> of the font is in <b>pixels</b> and the <i>first</i> and <i>last</i> values are ignored, meaning all glyphs in the font will be added. Fonts added in this way are assigned to their own texture
    page, so care should be taken when using this function as it will increment the number of texture swaps when drawing. It is also worth noting that fonts may appear slightly larger when drawn, since glyphs may have parts that are drawn outside of the
    bounding box defined for the font. You should be aware too that there is a limitation of around 200 glyphs that can be rendered in a single frame for a particular font.</p>
  <p>By default, added fonts will have anti-aliasing enabled. However you can check the state of AA at any time using the function <a href="font_add_get_enable_aa.htm"><tt>font_add_get_enable_aa()</tt></a> and you can enable/disable AA using the function
    <a href="font_add_enable_aa.htm"><tt>font_add_enable_aa()</tt></a>.</p>
  <p class="note"><b>NOTE: </b>When you load a font into GameMaker Studio 2: Studio you must remember to remove it again (with <span style="font-size:1px;"><a href="font_delete.htm"><tt style="font-size: 14px">font_delete()</tt></a></span>) when no longer needed, otherwise
    there is risk of a memory leak which will slow down and eventually crash your game.</p>
  <p> </p>
  <h4>Syntax:</h4>
  <p class="code">font_add(name, size, bold, italic, first, last);</p>
  <table>
    <tbody>
      <tr>
        <th>Argument</th>
        <th>Description</th>
      </tr>
      <tr>
        <td>name</td>
        <td>The name of the font to be added (eg &#39;Arial&#39;), or the file path if the font is an included <tt>*.ttf</tt> file.</td>
      </tr>
      <tr>
        <td>size</td>
        <td>The size of the font - points for Web Fonts, pixels for <tt>*.ttf</tt> fonts.</td>
      </tr>
      <tr>
        <td>bold</td>
        <td>Whether the font is bold (true) or not (false).</td>
      </tr>
      <tr>
        <td>italics</td>
        <td>Whether the font is italic (true) or not (false).</td>
      </tr>
      <tr>
        <td>first</td>
        <td>The first character to include (if you&#39;re unsure, go for 32).</td>
      </tr>
      <tr>
        <td>last</td>
        <td>The last character to include (if you&#39;re unsure, go for 128).</td>
      </tr>
    </tbody>
  </table>
  <p> </p>
  <h4>Returns:</h4>
  <p class="code">Real</p>
  <p> </p>
  <h4>Example:</h4>
  <p class="code">newfont = font_add(&quot;Arial&quot;, 24, true, true, 32, 128);</p>
  <p>This will create a new font that is 24pt in size, uses &quot;Arial&quot; which is bold and italic and the index for this new font is stored in the variable &quot;newfont&quot;. The font range includes capital and lower case letters, numbers and all
    common punctuation.</p>
  <p> </p>
  <p> </p>
  <p> </p>
  <div class="footer">
    <div class="buttons">
      <div class="clear">
        <div style="float:left">Back: <a href="Fonts.htm">Fonts</a></div>
        <div style="float:right">Next: <a href="font_add_sprite.htm">font_add_sprite</a></div>
      </div>
    </div>
    <h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
  </div>
  <!-- KEYWORDS
font_add
-->
  <!-- TAGS
font_add
-->

</body></html>