Custom Fonts in WPF Applications

I am working on a WPF application and wanted to use Font Awesome for the icons within the application. Font Awesome is a series of 369 scalable icons that are distributed in font form and mainly used in web development. I am using it to add modern looking icons to my application, but you can use this technique for embedding any font in your WPF application.

imageFirst, download Font Awesome, extract the ZIP file and copy fonts/fontawesome-webfont.ttf into a Fonts folder in your solution. Set the Build Action in the properties to Resource if it isn’t already.

imageNext, add a Style to the Resources in App.xaml. Don’t forget the # at the front of the font name and remember to use the internal name of the font, not the name of the file. To check the name of the font, just double click on the font file and it will open in the Windows Font Viewer. The font name will be at the top.

    <style x:key="FontAwesome">
        <setter property="TextElement.FontFamily" 
            value="pack://application:,,,/fonts/#FontAwesome" />

Now you can use add this style to your WPF controls.

    Style="{StaticResource FontAwesome}"
    Text="&#xf09b;" />

If you are using a regular text font, just add the text as you normally would. If it is an image font, then use the unicode values for the images you want, for example &#xf09b; for the GitHub icon. For Font Awesome, you can look up the values on the Cheat Sheet.

Here is the result in the application I am working on.


Gas Mileage Android App

Gas MilieageGas Mileage calculates your vehicle’s fuel economy using your trip odometer. Tracking your fuel usage helps you keep an eye on the health of your vehicle and see how changes to how you drive affects your mileage. Gas mileage is a simple application that does one thing and does it well.

Other mileage tracking calculators require you to add entries every time you fill up and if you forget, it is difficult to catch up. Gas Mileage is different, just remember to reset your trip odometer every time you fill up your tank and then add entries when you remember.


  • Enter and display values in any common unit
  • List of fill-ups are color coded based on the mileage
  • Supports as many vehicles as you like
  • Icons for each of your vehicles
  • Shows your best mileage, average mileage, worst mileage and the last mileage you entered
  • Easily edit, delete or update any of your fill-ups
  • Add notes to fill-ups and view them later

Get it on Google Play

.NET Application Settings

Application Settings are the recommended way to save state between runs of your program. Long gone are the days of using the registry or INI files to save information. The only problem with Application Settings though is that they tend to disappear whenever you release a new version of your application. Fortunately, it is easy to fix this with some boiler plate code.

First, we need to make sure that our project has a settings file. It is usually under the Properties node of the project. If it is not, right click on the solution and Add | New Item… | Visual C# Items | General | Settings File and name it Settings.settings. Next, drag it and drop it in your project’s Properties folder.

Next, you need to add a bool User setting called UpgradeRequired and default it to true. Next, at the very beginning of your Main, you check if UpgradeRequired is true, and if it is, upgrade the settings, set UpgradeRequired to false and save out the settings. This will pull in the settings from previous versions of your application.

Your settings should look like this,


The code should look like this,

static void Main( string[] args )
   // Upgrade settings if required
   if ( Properties.Settings.Default.UpgradeRequired )
      Properties.Settings.Default.UpgradeRequired = false;

   // Do work...

   // At the end of main, save out any changes to settings

Now you just need to create new settings and use them in your application. Any setting with Application scope will be set in your app.config and will be read-only. This is often used for connection strings and other information that is unlikely to change. User scoped settings also have their default values in app.config, but any changes are written out to an XML file in the user’s AppData folder.

Also, notice that code gets generated for any setting that you create and you access it through a property on Properties.Settings.Default. You can use any complex type for a setting, including classes in your application, as long as they are Serializable.

Debugging Ruby on Windows using RubyMine

Most of the installation instructions for the ruby debugger that I found were out of date for Windows, so I thought it would be useful to document how I got it working.

  1. First, you should start with Ruby installed from the RubyInstaller. If you have any problems with getting debugging working, I would suggest installing Ruby fresh from here and trying again.
  2. Second, you need to install DevKit. Download DevKit from the RubyInstaller page, then follow the installation instructions on the Development Kit page. Their instructions are thorough, so I won’t reproduce them here. The DevKit install has changed recently and this was part of my problem getting the debugging gem installed.
  3. Install the ruby-debug-ide19 gem with the following command line.
    gem install ruby-debug-ide19 –platform=ruby
  4. You should now be able to debug in RubyMine. When I started debugging in RubyMine, it prompted to install additional debugging gems. I allowed it and they installed fine and debugging started.

    1. Set a breakpoint by clicking in the gutter where you want the breakpoint


    2. Select your run/debug configuration in the toolbar and click on the Debug button


    3. Visit the page you want to debug in your browser. You should hit the breakpoint and see the callstack and the values of all the variables in scope.


    4. You should now be able to step through the code. See the RubyMine debugging documentation for more help.

Debugging PHP on Windows with NetBeans

It seems that whenever I set up a new computer to debug PHP, I need to Google around to remind myself of the steps, so I thought I would document them here for reference. The following is for an XAMPP Apache/PHP install, but the basic steps are the same for any PHP install.

Install and Configure Xdebug for PHP

The first thing you need to do is get the Xdebug extension for PHP installed and configured. Luckily, XAMPP ships with Xdebug and has the configuration already in php.ini, so you just need to make some minor changes and restart Apache.

  1. If you are also using XAMPP, skip this step. If you are using an install of PHP without the Xdebug extension, go to the Xdebug Find Binary page, paste in the output of phpinfo() or php –i and they will provide a link to the extension and custom installation instructions.
  2. Open php.ini in your favourite editor. For XAMPP, it is likely in C:\xampp\php.
  3. Find and uncomment the extension.
    zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
  4. Find the [XDebug] section and uncomment and/or edit the following values. Many of these are defaults, but I am listing them just in case you have different values.
    xdebug.profiler_enable = 1
    xdebug.profiler_enable_trigger = 1
    xdebug.remote_enable = 1
    xdebug.remote_host = "localhost"
    xdebug.remote_handler = "dbgp"
    xdebug.remote_mode = "req"
    xdebug.remote_port = 9000
    xdebug.trace_output_dir = "C:\xampp\tmp"
  5. Restart Apache with the XAMPP control panel.
  6. Bring up http://localhost/xampp/ and view phpinfo(). You should see Xdebug mentioned twice, once under the Zend engine and then as a PHP module.zend


  7. You are done and ready to debug.

Debug with NetBeans

What is not to love about NetBeans? You can use it for Java, PHP, Ruby, Html and C/C++. It integrates well with many bug tracking and source control systems. It provides IntelliSense, database management, works great with Smarty templates and allows you to debug your code. If you haven’t tried NetBeans yet, I highly recommend it.

  1. Start the IDE and load your PHP project. In the Project window, right click on your project and select Properties. Go to the Run Configuration node. You should be running as a Local Web Site. The Project URL should point to the root of your project directory and the Index File should be the file you want to launch
  2. Right click again on your project. You can select Debug from here and get going right away, but if you first select Set as Main Project, you can just launch into the debugger with the Debug Main Project button on the toolbar or Ctrl+F5. (If Debug is not enabled, you probably need to enable the PHP plugin in NetBeans. Go to Tools | Plugins, click the Installed tab and make sure PHP is enabled.project
  3. When you start debugging, NetBeans will launch the browser to your start page. Notice how it appended the variable XDEBUG_SESSION_START=netbeans-xdebug to the end of the URL to start Apache debugging. If you see any Windows Firewall prompts at this point, accept them.
  4. As the page loads, NetBeans will break on the first line of PHP code. The line will be highlighted and there will be a little green arrow in the margin to indicate the current line of execution.


  5. Congratulations, you are debugging. From here, you can set breakpoints by right clicking on the margin of your code and selecting Breakpoint | Toggle Line Breakpoint. You can step through code (F8) using the debug toolbar (if you don’t see it, right click on the toolbars and enable it.) You can inspect or even change variables and view the call stack.debug2
  6. If you are new to debugging code, read more about what you can do in the article on the NetBeans site,Debugging PHP Source Code in the NetBeans IDE.

If I missed anything or you have any other suggestions, I would love to hear about it in the comments.