<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SDL_TTF | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/sdl_ttf/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Tue, 24 Nov 2020 08:41:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>SDL_TTF | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>How slow is SDL_TTF 2.0?</title>
		<link>https://learncgames.com/how-slow-is-sdl_ttf-2-0/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-slow-is-sdl_ttf-2-0</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 24 Nov 2020 00:00:03 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[SDL_TTF]]></category>
		<category><![CDATA[truetype]]></category>
		<category><![CDATA[ttf]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1876</guid>

					<description><![CDATA[<p>When  I created the Asteroids game, I deliberately didn&#8217;t use SDL_TTF instead I took a Monospaced font and saved it out as a PNG file which was loaded into a SDL Texture. I then created my own character printing routines by figuring out which character I wanted and then blitting it. The image shows the [&#8230;]</p>
The post <a href="https://learncgames.com/how-slow-is-sdl_ttf-2-0/">How slow is SDL_TTF 2.0?</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:356,&quot;href&quot;:&quot;https:\/\/scripts.sil.org\/cms\/scripts\/page.php?site_id=nrsi&amp;id=IWS-Chapter08&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20240303165052\/https:\/\/scripts.sil.org\/cms\/scripts\/page.php?site_id=nrsi&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 14:22:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-09 18:24:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-13 06:08:27&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-16 11:16:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 12:21:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-24 05:09:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 11:01:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-05 06:10:51&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-08 08:14:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-12 08:11:20&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-20 00:47:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-24 19:27:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-27 20:51:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 16:42:32&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-07 22:42:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-11 13:43:42&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 23:39:19&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-15 23:39:19&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img fetchpriority="high" decoding="async" class="alignleft size-medium wp-image-1879" src="https://learncgames.com/wp-content/uploads/2020/11/fixedfont-1-300x183.png" alt="F" width="300" height="183" srcset="https://learncgames.com/wp-content/uploads/2020/11/fixedfont-1-300x183.png 300w, https://learncgames.com/wp-content/uploads/2020/11/fixedfont-1.png 669w" sizes="(max-width: 300px) 100vw, 300px" />When  I created the Asteroids game, I deliberately didn&#8217;t use SDL_TTF instead I took a Monospaced font and saved it out as a PNG file which was loaded into a SDL Texture. I then created my own character printing routines by figuring out which character I wanted and then blitting it. The image shows the font I used zoomed in.</p>
<p>You probably can&#8217;t get much faster than that, although I wasn&#8217;t really doing that much output. Every frame, the score is output and if an asteroid is hit, the value of the hit scrolls upward for a few frames.</p>
<p>Also when you lost a life, it would print using a scaled up version of the font. The only problem with that is scaling up a bit map font just shows off the deficiencies of the font scaling as a bitmap, as the image shows. Not exactly smooth is it?</p>
<p>So I&#8217;ve decided to write a small program that uses SDL_TTF 2.0 and does high resolution timing to determine exactly how long it takes to draw text using a TTF font. The big advantage of doing that in a game is you can draw different sizes, weight (<em>bold etc</em>) and colour compared to a bitmap font.</p>
<p>But TTF <a title="Link to Sil.org introduction to Truetype" href="https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=IWS-Chapter08" target="_blank" rel="nofollow noopener noreferrer">is an interesting format</a>, there&#8217;s a lot going on. Letters are drawn using mathematical equations so it is bound to be a bit slower than pure blitting and I&#8217;m interested in knowing just how long it takes. It&#8217;s all relative, if you view a page of text in MS Word (<em>or just in Windows generally</em>), Windows renders it pretty fast.  But its still important to know just how fast. For what I used text for in Asteroids, it probably could have used TTF text but in another game with more text it might be too slow for 60 frames per second.</p>
<p>If it was too slow then perhaps a hybrid approach might work. Figure out what text you&#8217;ll need, prerender it into bitmaps (<em>when the program starts up</em>) then use those bitmaps.</p>
<p>So I&#8217;ll publish the speed test program once written. Watch this space.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/how-slow-is-sdl_ttf-2-0/">How slow is SDL_TTF 2.0?</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1876</post-id>	</item>
	</channel>
</rss>
