-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
306 lines (206 loc) · 13.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Bryan Alvarado's Blog</title>
<meta name="author" content="Bryan Alvarado">
<meta name="description" content="Bryan Alvarado's Blog">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:site_name" content="Bryan Alvarado's Blog"/>
<meta property="og:image" content="undefined"/>
<link href="/favicon.png" rel="icon">
<link rel="alternate" href="/atom.xml" title="Bryan Alvarado's Blog" type="application/atom+xml">
<link rel="stylesheet" href="/css/style.css" media="screen" type="text/css">
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
</head>
<body>
<header id="header" class="inner"><div class="alignleft">
<h1><a href="/">Bryan Alvarado's Blog</a></h1>
<h2><a href="/"></a></h2>
</div>
<nav id="main-nav" class="alignright">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/archives">Archives</a></li>
</ul>
<div class="clearfix"></div>
</nav>
<div class="clearfix"></div></header>
<div id="content" class="inner">
<div id="main-col" class="alignleft"><div id="wrapper">
<article class="post">
<div class="post-content">
<header>
<div class="icon"></div>
<time datetime="2013-08-19T00:02:16.000Z"><a href="/2013/08/18/how-to-load-truetype-fonts-in-libgdx/">Aug 18 2013</a></time>
<h1 class="title"><a href="/2013/08/18/how-to-load-truetype-fonts-in-libgdx/">How to Load TrueType Fonts in Libgdx</a></h1>
</header>
<div class="entry">
<p>I was having some trouble with coloring Bitmap Fonts using the iOS backend of libgdx, so after a couple of days trying to fix it without solution, I decided to try using TrueType Fonts instead.</p>
<p>The thing was that the only way to use TTF's in libgdx is using the libgdx extension called "FreeType Fonts" included in the nightlies of libgdx, but I was having some trouble integrating it into my project, I finally managed to do it, so this post is a summary of the steps I found across the web that helped me getting it to work along with a few more tips from me that caused me some troubles during the integration. </p>
<h3>Including FreeType In Your Game</h3>
<p>First download the latest <a href="http://libgdx.badlogicgames.com/nightlies/libgdx-nightly-latest.zip">nightly build</a> </p>
<p>Once downloaded, navigate to <em>extensions/gdx-freetype</em> and do the following: </p>
<ul>
<li><p>extract gdx-freetype.jar and gdx-freetype-natives.jar to your core project's libs folder </p>
</li>
<li><p>link gdx-freetype.jar to your core, android and desktop project </p>
</li>
<li><p>link gdx-freetype-natives.jar to your desktop project </p>
</li>
<li><p>copy armeabi/libgdx-freetype.so to your android project's libs/armeabi folder </p>
</li>
<li><p>copy armeabi-v7a/libgdx-freetype.so to your android project's libs/armeabi-v7a folder </p>
</li>
</ul>
<h3>Steps To Make It Work With iOS Games</h3>
<p>Navigate to your game-ios folder, then open your <strong>convert.properties</strong> file and add the freetype jar to the classpath and the freetype dll, the file should looks like this: </p>
<pre><code><figure class="highlight"><pre>SRC = ..<span class="regexp">/my-gdx-game/src/</span>
CLASSPATH = ..<span class="regexp">/my-gdx-game/libs/gdx.jar;../my-gdx-game/libs/g</span>dx-freetype.jar
EXCLUDE =
IN = -r:libs<span class="regexp">/ios/gdx.dll -r:libs/ios/gdx-freetype.dll -recurse:target/</span>*.<span class="class"><span class="keyword">class</span>
<span class="title">OUT</span> = <span class="title">target</span>/<span class="title">my</span>-<span class="title">gdx</span>-<span class="title">game</span>.<span class="title">dll</span></span>
</pre></figure></code></pre>
<p>Now you have to link your native file, the <strong>libgdx-freetype.a</strong> to your monotouch/xamarin project's libs/ folder. Then you have to add it to your monotouch/xamarin project in the solution explorer, just like you add any file to a solution. </p>
<p>Then open your <strong>game-ios.csproj</strong> and for each configuration (e.g. Release|IPhone, Debug|Simulator) you'll need to modify it to link to <em>gdx-freetype</em> in the same way it already links to libgdx.a and libikvm-natives.a </p>
<p>It should looks something like this: </p>
<pre><code><figure class="highlight"><pre>-nosymbolstrip -nostrip -cxx -gcc_flags <span class="string">"-L<span class="subst">${ProjectDir}</span>/libs/ios -L<span class="subst">${ProjectDir}</span>/libs/ios/ikvm/bin -likvm-natives -lgdx -lgdx-freetype -force_load <span class="subst">${ProjectDir}</span>/libs/ios/libgdx.a -force_load <span class="subst">${ProjectDir}</span>/libs/ios/ikvm/bin/libikvm-natives.a -force_load <span class="subst">${ProjectDir}</span>/libs/libgdx-freetype.a"</span>
</pre></figure></code></pre>
<p>Finally, you have to open your project, right click the “References” entry in your project, select Edit References, then go to “.Net Assemblies” and find the gdx-freetype.dll. Click the add button so it appears on the right sidebar which shows you which assemblies are currently referenced. </p>
<h3>How to use it</h3>
<p>Now remember to include the TTF file inside your data or assets folders on both <em>game-android</em> and <em>game-ios</em> projects, and also remember to change the build action inside Monotouch/Xamarin of the TFF file to <strong>Content</strong> in order to use it inside of the game. </p>
<p>Here is a little example on how to use the extension: </p>
<pre><code><figure class="highlight"><pre>FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx<span class="preprocessor">.files</span><span class="preprocessor">.internal</span>(<span class="string">"fonts/myfont.ttf"</span>))<span class="comment">;</span>
BitmapFont font12 = generator<span class="preprocessor">.generateFont</span>(<span class="number">12</span>)<span class="comment">; // font size 12 pixels</span>
BitmapFont font25 = generator<span class="preprocessor">.generateFont</span>(<span class="number">25</span>)<span class="comment">; // font size 25 pixels</span>
generator<span class="preprocessor">.dispose</span>()<span class="comment">; // don't forget to dispose to avoid memory leaks!</span>
</pre></figure></code></pre>
<p>And that's it, now you can use TrueType Fonts in your libgdx game, and manage their size as much as you want! </p>
<p>Here are the links of the sites I used to assemble this post: </p>
<p><a href="https://code.google.com/p/libgdx/wiki/GdxFreeType">GdxFreeType</a> </p>
<p><a href="http://www.badlogicgames.com/wordpress/?p=2819">Gdx FreeType Supported on iOS</a></p>
</div>
<footer>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="post-content">
<header>
<div class="icon"></div>
<time datetime="2013-05-25T06:02:06.000Z"><a href="/2013/05/25/installing-a-jar-in-maven-local-repository/">May 25 2013</a></time>
<h1 class="title"><a href="/2013/05/25/installing-a-jar-in-maven-local-repository/">Installing a Jar in Maven local repository</a></h1>
</header>
<div class="entry">
<p>You have to run the following command in the terminal:</p>
<pre><code>mvn install:install-file -Dfile=<span class="xml"><span class="tag"><<span class="title">path-to-file</span>></span> -DgroupId=<span class="tag"><<span class="title">group-id</span>></span> \
-DartifactId=<span class="tag"><<span class="title">artifact-id</span>></span> -Dversion=<span class="tag"><<span class="title">version</span>></span> -Dpackaging=<span class="tag"><<span class="title">packaging</span>></span></span>
</code></pre>
<p>where:</p>
<p><em>path-to-file</em>: is the path to the jar you want to install in the local repository</p>
<p><em>group-id</em>: the group in the maven repository you want to use</p>
<p><em>artifact-id</em>: the name that the jar will receive when you want to use it in a pom.xml</p>
<p><em>version</em>: the version of the jar/library</p>
<p><em>packaging</em>: the type of package it is, usually is a jar</p>
</div>
<footer>
<div class="alignleft">
<a href="/2013/05/25/installing-a-jar-in-maven-local-repository/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<article class="post">
<div class="post-content">
<header>
<div class="icon"></div>
<time datetime="2013-05-25T05:11:04.000Z"><a href="/2013/05/24/android_library_maven/">May 24 2013</a></time>
<h1 class="title"><a href="/2013/05/24/android_library_maven/">Using Android Library Projects with Maven</a></h1>
</header>
<div class="entry">
<p>Ok so I've decided to start with a new blog (again) and to make a good first post I'm going to explain how to use Android Library Projects integrated with Maven.</p>
<p>Your Android project has to have the android maven plugin in its pom.xml file in order to unpack the android library project that you are going to package as an apklib.</p>
<p>The first thing you have to make is go to the root directory of your Android Library Project, compress it all in a zip file, and rename to the extension apklib</p>
<p>The files included in this gist are the maven script to convert your new apklib file into a dependency in your maven repo and the second one is the structure to add the dependency on the android pom.xml file.</p>
<p>This is the script to generate the apklib in your local maven repository</p>
<pre><code><span class="comment">mvn</span> <span class="comment">install:install</span>-<span class="comment">file</span> <span class="comment">\</span>
<span class="literal">-</span><span class="comment">DgroupId=org</span>.<span class="comment">abc</span> <span class="comment">\</span>
<span class="literal">-</span><span class="comment">DartifactId=mywidget</span> <span class="comment">\</span>
<span class="literal">-</span><span class="comment">Dpackaging=apklib</span> <span class="comment">\</span>
<span class="literal">-</span><span class="comment">Dversion=1</span>.<span class="comment">0</span>.<span class="comment">0</span> <span class="comment">\</span>
<span class="literal">-</span><span class="comment">Dfile=mylib</span>.<span class="comment">apklib</span> <span class="comment">\</span>
<span class="literal">-</span><span class="comment">DgeneratePom=true
</code></pre>
<p>and this is how you add the dependency in your pom.xml</p>
<pre><code> <span class="tag"><<span class="title">dependency</span>></span>
<span class="tag"><<span class="title">groupId</span>></span>org.abc<span class="tag"></<span class="title">groupId</span>></span>
<span class="tag"><<span class="title">artifactId</span>></span>mywidget<span class="tag"></<span class="title">artifactId</span>></span>
<span class="tag"><<span class="title">version</span>></span>1.0.0<span class="tag"></<span class="title">version</span>></span>
<span class="tag"><<span class="title">type</span>></span>mylib.apklib<span class="tag"></<span class="title">type</span>></span>
<span class="tag"></<span class="title">dependency</span>></span>
</code></pre>
</div>
<footer>
<div class="alignleft">
<a href="/2013/05/24/android_library_maven/#more" class="more-link">Read More</a>
</div>
<div class="clearfix"></div>
</footer>
</div>
</article>
<nav id="pagination">
<div class="clearfix"></div>
</nav></div></div>
<aside id="sidebar" class="alignright">
<div class="search">
<form action="//google.com/search" method="get" accept-charset="utf-8">
<input type="search" name="q" results="0" placeholder="Search">
<input type="hidden" name="q" value="site:foobraco.github.io">
</form>
</div>
<div class="widget tag">
<h3 class="title">Tags</h3>
<ul class="entry">
<li><a href="/tags/android/">android</a><small>1</small></li>
<li><a href="/tags/android%2C-maven%2C-java/">android, maven, java</a><small>1</small></li>
<li><a href="/tags/fonts/">fonts</a><small>1</small></li>
<li><a href="/tags/game-development/">game development</a><small>1</small></li>
<li><a href="/tags/ios/">ios</a><small>1</small></li>
<li><a href="/tags/jar/">jar</a><small>1</small></li>
<li><a href="/tags/java/">java</a><small>3</small></li>
<li><a href="/tags/libgdx/">libgdx</a><small>1</small></li>
<li><a href="/tags/maven/">maven</a><small>2</small></li>
<li><a href="/tags/maven%2C-java%2C-jar/">maven, java, jar</a><small>1</small></li>
</ul>
</div>
</aside>
<div class="clearfix"></div>
</div>
<footer id="footer" class="inner"><div class="alignleft">
© 2013 Bryan Alvarado
</div>
<div class="clearfix"></div></footer>
<script src="/js/jquery.imagesloaded.min.js"></script>
<script src="/js/gallery.js"></script>
<script type="text/javascript">
var disqus_shortname = 'foobracoblog';
(function(){
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
(function($){
$('.fancybox').fancybox();
})(jQuery);
</script>
</body>
</html>