2013-01-28

How to use custom fonts within iOS and Cocos2D

Recently I was working on an iOS project using the Cocos2d framework.  Cocos2d has a rather simple object called CCLabelTTF.  The CCLabelTTF object allows you to easily create text that you can write to your screen using a TTF font.

While working on this project I needed to implement a label with a custom font.  However, I quickly found that there are quite a few "gotchas" that may prevent your custom font from working in Cocos2d.  The really annoying part is that when these gotchas occur, the Cocos2d framework will only output a very generic message stating that your font couldn't be loaded.

This can be a bit problematic.  After banging my head against my keyboard for four hours, and after quite a few web searches, I found out that adding and using fonts to an iOS project can be rather tedious.  After reading through numerous support sites and web forum threads, it seems that my scenario hit almost every gotcha scenario that I could find.

After a few hours of adding/removing fonts and configuration keys, I eventually found the perfect setup.  Below is a link to a Q&A post I made on StackOverflow on this topic.  If you need to use custom fonts in your Cocos2d project, following these instructions should get your font in your project without any trouble.

2012-10-25

Quick Post: Apple's Solar Array in Maiden, NC

Today I just have a simple post.  While driving down Highway 321, in North Carolina, my wife and I past the Apple solar farm.  You can see it from 321, if you look back as you are heading south.

While my wife drove, I snapped this photo.  This is just a portion of the entire facility.

Apple's Solar Array in Maiden, NC


This solar array is used to also power the Data Center that is across the street.  I have driven past that facility but, unfortunately, there isn't much to see. :(  That location is barricaded with huge mounds of dirt that block near-full visibility from the road.

2012-06-21

Having Trouble Taking a Screenshot on your iPhone/iPad? Here's the solution


Recently I've acquired an iPhone 4S that I use for my work.  As a developer, I often need to take screenshots of what is displayed on my device.  The iPhone user's manual states:
"Press and release the On/Off button and the Home button  at the same time. The screenshot is added to your Camera Roll album."
Sounds easy enough.  However, I encountered a problem when I tried to take my first screenshot. After following these simple instructions, my phone would not take the image!  Instead, it would lock my phone each time I pushed these buttons together.  I tried again and again, but with the same results each time. What was the deal?!

However, there was good news. After a bit of searching, I eventually found a support post on Apple.com (see here) where another user and his fellow employees were experiencing the same problem.  Eventually, someone found a way to solve the problem.

The easiest way to take a guaranteed screenshot is to follow these  rather specific steps.


  1. Press and hold the power button.
  2. Tap the home button.  (The image will be saved.)
  3. Release the home button.


After posting this solution on AskDifferent and a bit of discussion, I wanted to further experiment a just to get a better understanding of this problem.  It turns out there are two other methods that will give you a screenshot.

Option #2

  1. Press and hold the home button.
  2. Press and hold the power button.
  3. Release the home button.  (Image is saved)
  4. Release the power button.


Option #3

  1. Press and hold the power button.
  2. Press and hold the home button.
  3. Release the power button.  (Image is saved)
  4. Release the home button.


It was the logical fourth, and final, sequence of operation that does not work and would lock the device every time.


  1. Press and hold the home button.
  2. Tap and release the power button. (iOS locks the device)
  3. Release the home button.


This might be a bug or it may be intentional.  It seems that that I, and numerous others, have been 'tapping' the power button, while holding the home.  When trying to press and release both buttons quickly, this goes unnoticed and would lock our devices.

This is an easy fix so long as you are aware of the scope of the problem.  I assume this behavior is true for the iPad and possibly all other iOS devices. Let me know if this helps or if you've seen alternative behavior with either the iPhone 4/4S or any other iOS device.

2012-05-03

Double-Inbox 0 Achieved!


Yesterday, for the first time in my recollection I managed to clear out not just my personal inbox, but my work inbox as well.

MEGA GOLD ACHIEVEMENT BADGE EARNED!

Clearing out your inbox always provides such a feeling of peace.  All of the little tasks that have accumulated have been cleared and I can sit back and breath for few minutes because… nobody immediately needs anything from me. 

Aaah...

So what did I do with my few moments of freedom?  I sat down and read a few chapters of a tech book on Objective-C that I've intended to read for a while.

Alas, though, all moments of peace must eventually pass.  After leaving work with a cleared inbox yesterday evening, I returned this morning to find a couple emails already in queue.  Both minor but, still, work needing to be done.  It's 11:15 and I've yet to clear my inbox from the slow trickle of requests to create and update accounts, tweak server settings and updating an MSDN subscription.

It was fun while it lasted but thus is the plight of a technical worker.  Those moments where you can take a break, breathe and rest in that place of not being pulled by 100 needs are so rare.

This past year has been crazy.  Believe it or not, I've never abandoned this blog.  I've had quite a few, major life and career changes so I have neither had the time to write much nor have I had many topics worth discussing.

In April last year, my wife and I had our first daughter.  It's been a happy yet busy year learning to take care of a beautiful baby girl.  I've also migrated from being primarily a C#/WinForms developer to becoming both an Embedded C and iOS developer.  Both roles have had their challenges but it's been quite fun.

I feel like I'm finally at a point where start writing a bit of beneficial tech articles related to my C, Objective-C and iOS development experiences.

Stay tuned.  More will follow soon.

2011-04-13

ClickOnce and Publishing Tests Editions of Applications

I'm not sure of how many ClickOnce user's there are out there but, as my last post suggests, I have been an avid user of the system for years now, in spite of it's short comings.

While working with the multiple applications that I manage, I have had times where it would have been convenient for me to be able to publish an application to a test location so that key users could test an update before it is published to the primary install point.  This can be done, but you have to change a few application settings before publishing your test application.  The changes are simple but can be prone to user error.

In response to this need, I've posted a Feature Request on the Microsoft Connect site for the ability to create a secondary or multiple install points for ClickOnce applications.  If you would find such a feature useful, please follow the link and vote-up the feature.

Thanks!

MS Connect: Allow ClickOnce Applications to be Published to a Secondary, Test Location

2011-03-30

ClickOnce Application Reinstaller API

When Microsoft released Visual Studio 2005, it also included an application publishing and installation system called ClickOnce.  At that time I was working on a major WinForms application in .Net 2.0, and ClickOnce was an excellent discovery that perfectly met the needs of my application.  Fast forward a couple years and I had to make a couple updates to my application that required changing some prerequisite* software for the end user's PC.

These changes didn't break the application, but it did break the installation process.  All of my users had to uninstall and reinstall their application instance because the application would update my code but would not automatically install the new prerequisite file.  This was quite a headache but I fortunately had only about 100 users to help update, instead of some number that would have been legitimately unmanageable.

After a bit of research I found that ClickOnce has worked well for most users.  Developers can dig deep into the nuts-and-bolts of a ClickOnce application installation instance.  However, under certain circumstances, your application must be uninstalled and reinstalled when certain changes to the ClickOnce publication are made.

The application that I mentioned above is still in use by many users.  Recently I had to make another prerequisite change and I knew that I'd have to update all of my user's computers again.

Since ClickOnce does not provide a way to automate this update process, other's (see RobinDotNet's and Jim Harte's original blog posts on the mechanics of this solution) have found solutions to implement a forced uninstall/reinstall process for a ClickOnce app.

In response to this annoyance, and the fact that Microsoft has yet to manufacture a streamlined reinstall process, I've created an API which can easily be added to a ClickOnce application and called to check for and run reinstall-required application updates.

Checking for a required reinstall with the API is simple.  All you need to do is link the API, add one line of code to check your server.  When it's time to reinstall your application, add a text file named 'reinstall' at the root of the applications installation directory on the first line of the file, include the web address for the new installation.  That's it!

If you'd like to check out the API, head over to the ClickOnce Application Reinstaller API Google Projects page**.  I'm welcome to feedback and I am willing to expand the API if changes are requested.  One limitation of the API is that it's restricted to ClickOnce applications that have been installed with an Englished-based culture profile.  This is because of the uninstall process and if you're interested in the details, I recommend reading any of the above mentioned blog posts that inspired this project.

* For the uninformed, a ClickOnce prerequisite is any mandatory software that must be pre-installed on an end users PC before the application will run.  In my case, I had to update a Crystal Reports engine.

** This is my first open source project.  I intend to publish the source through Mercurial but I've hit a few snags.  The source is available from within the Download section of the project in a zip file.

2011-02-02

My Take on a Tech Blog

I'll be honest.  I'm not one for blogging or putting my personal life on the internet but I felt it was time to finally commit to a blog that I could use to post various discoveries, tech solutions and maybe just a few bits of information about my personal life.

Hopefully, this will be the first of many posts to come.  New entries will probably be sparse but intend to use this site as a place where I can post information that I've acquired that I've found particularly useful.