<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[SpriteKit]]></title><description><![CDATA[How to use Glyph Designer with SpriteKit]]></description><link>https://forum.71squared.com/category/15</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 18:10:36 GMT</lastBuildDate><atom:link href="https://forum.71squared.com/category/15.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Nov 2015 21:55:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[SSBitmapFont now Open Source]]></title><description><![CDATA[<p>We have released a code version of the SSBitmapFont library. This will enable developers to update the library as needed and also fixes a few problems, including tvOS compatibility.</p>
<p>The new source can be found in the attached project which also provides an example of using SSBitmapFont with tvOS which is why the example project is called tvOSFontTest.</p>
<p>This version of SSBitmapFont doesn't try to do anything clever in terms of identifying the device being used and then picking the right font size. This caused nothing but issues in the old version so this time we have left the decision on which font control file to use up to the developer <img src="https://forum.71squared.com/plugins/nodebb-plugin-emoji-one/static/images/1f600.png" class="not-responsive emoji emoji-parsed" data-set-id="emoji-one" data-emoji-id="grinning" alt=":)" title=":)" /></p>
<p>You can use this code version by simply copying in the SSBitmapFont group into your project.</p>
<p><a href="https://www.dropbox.com/s/67vdreaxmcnv1e0/tvOSFontTest.zip?dl=0" rel="nofollow">tvOSFontTest.zip</a></p>
]]></description><link>https://forum.71squared.com/topic/63/ssbitmapfont-now-open-source</link><guid isPermaLink="true">https://forum.71squared.com/topic/63/ssbitmapfont-now-open-source</guid><dc:creator><![CDATA[Mike]]></dc:creator><pubDate>Thu, 12 Nov 2015 21:55:07 GMT</pubDate></item><item><title><![CDATA[Using Glyph Designer 1.8 with Sprite Kit]]></title><description><![CDATA[<p><img src="/uploads/files/1445720687060-screen-shot-2013-10-30-at-16.48.55.png" alt="Screen Shot 2013-10-30 at 16.48.55.png" class="img-responsive img-markdown" /></p>
<p>To allow the output from <strong>Glyph Designer 1.8</strong> to be used with Sprite Kit we have created a universal static library that can be used in your projects. This provides two classes that can be used to render bitmap fonts using Sprite Kit.</p>
<p><code>SSBitmapFont</code><br />
<code>SSBitmapFontLabelNode</code></p>
<p>An instance of <code>SSBitmapFont</code> is created for each font that you want to use within your project. It is created using the output from Glyph Designer as shown below</p>
<pre><code>NSString *path = &lsqb;&lsqb;NSBundle mainBundle] pathForResource:@&quot;myFont&quot;
                                        ofType:@&quot;skf&quot;];
NSURL *url = [NSURL fileURLWithPath:path];
NSError *error;
SSBitmapFont *bitmapFont = &lsqb;&lsqb;SSBitmapFont alloc] initWithFile:url
                                                 error:&amp;error];

if (error)
{
    NSLog(@&quot;%@ : %@&quot;, error.domain, error.localizedDescription);
    return nil;
}
</code></pre>
<p>The filename to be used when creating the path is the name of the control file that is generated by Glyph Designer. You should always use the plain file name e.g. without @2x etc being added. <code>SSBitmapFont</code> will automatically add those modifiers to try and find the right control file and glyph images to use for the device type e.g. Retina iPad.</p>
<p>Within Glyph Designer there are four Sprite Kit output options available. These are shown at the bottom of the list in the screen show below:</p>
<p><img src="/uploads/files/1445720803670-screenshot-2013-12-09-15.22.09.png" alt="Screenshot 2013-12-09 15.22.09.png" class="img-responsive img-markdown" /></p>
<p>When you generate output for Sprite Kit two resources are generated. One is a folder containing the individual glyph images for the font you are exporting and other is the control file.</p>
<p>The Save As name in the export panel is used as the folder name and it also has the .atlas extension added. When using Sprite Kit a folder that has the .atlas extension and is added to the project is used to generate texture atlases. These atlases are then used by <code>SSBitmapFont</code> to load the glyph images needed. If the texture atlas folder contains images with different modifiers (@2x, @2x-iphone, @2x-ipad) then a texture atlas is created for each modifier.</p>
<p>This enables SSBitmapFont to load the right texture atlas and font size automatically based on the device your app is running on. If a texture atlas for the specific device is not found e.g. Retina iPad, then the next largest texture atlas is used. This means you do not have to create texture for all four output types, you could simply create a non-retina output type which would be used on all device types if that meets your needs.</p>
<p><strong>NOTE: When exporting fonts at different sizes it is important to make sure the Save As name is the same for all of them. This will cause all the images to be placed in the same atlas folder with the appropriate modifiers automatically added to their file names.</strong></p>
<p>The second resource that gets created is the control file. A single control file is generated for each of the different export types that is used. While there will only be a single texture atlas folder, there will be a control file for each export type.</p>
<p>Once the files have been exported they need to be added to your Xcode project so that <code>SSBitmapFont</code> can find them.</p>
<p>Using GDCL within the build process allows you to automatically generate both the retina and non-retina versions of the font during project build. More information on using GDCL can be found here.</p>
<p>The instance of <code>SSBitmapFont</code> can be used to generate as many labels as necessary that use that font. To use multiple fonts you need to create multiple instances of <code>SSBitmapFont</code>, each using the appropriate control file and images.</p>
<p><strong>Generating a label</strong></p>
<p>Once an instance of SSBitmapFont has been created you can then start creating labels e.g.</p>
<pre><code>SSBitmapFontLabelNode *myLabel = [bitmapFont nodeFromString:@&quot;Hello World!!&quot;];
[self addChild:myLabel];
</code></pre>
<p>The node that is created can be used just like an SKLabelNode and supports properties such as horizontal and vertical alignment e.g.</p>
<pre><code>myLabel.horizontalAlignment = SSBMFLabelHorizontalAlignmentModeCenter;
myLabel.verticalAlignment = SSBMFLabelVerticalAlignmentModeLeft;
</code></pre>
<p>By default both the horizontal and vertical alignment modes are set to centre.</p>
<p>That's all there is too it. Create the font of your dreams in Glyph Designer, export the files and then use it in Sprite Kit as described.</p>
<p>The following links can be used to get the iOS and OSX libraries as well as an example file.</p>
<p><a href="https://www.dropbox.com/s/drdbf0hcua6cni2/BitmapFonts.zip?dl=0" rel="nofollow">libSSBitmapFont.zip</a> (347KB)<br />
<a href="https://www.dropbox.com/s/jjpm5imzit34ad2/libSSBitmapFontOSX.zip?dl=0" rel="nofollow">libSSBitmapFontOSX.zip</a> (53KB)<br />
<a href="https://www.dropbox.com/s/gf37lr2jyaevs2a/libSSBitmapFont.zip?dl=0" rel="nofollow">BitmapFontsDemo.zip</a> (1.3 MB)</p>
]]></description><link>https://forum.71squared.com/topic/42/using-glyph-designer-1-8-with-sprite-kit</link><guid isPermaLink="true">https://forum.71squared.com/topic/42/using-glyph-designer-1-8-with-sprite-kit</guid><dc:creator><![CDATA[Mike]]></dc:creator><pubDate>Sat, 24 Oct 2015 21:08:18 GMT</pubDate></item></channel></rss>