Friday, May 21, 2010

geenat.com Dina TTF

If you're looking for the Dina TTF Download, it's here.

zvolkov asked what's different about the Dina TTF from the version at http://www.geenat.com/?p=66.
The way I created the TTF version of Dina is really just a big hack. True Type Fonts are composed of vectors that describe the font instead of a pixel by pixel drawing of a bitmap font. However there is a feature of True Type Fonts that allow Bitmap Font information to be embedded. See here under the East Asian Text heading. I embedded the 8pt, 9pt, and 10pt raster fonts which is why the font only works at those sizes.
I don't actually know how Nathan did it but I would venture to guess that he opened the Dina.fon file with a program like Font Forge, let it approximate the Vectors, tweaked it until he got it to a usable state then generated the .TTF. This created a "true" TTF font which has good and bad aspects.
The Good
  • It's Scalable. This is one of the primary features of TTF. The geenat version works at 6pt to 72pt+.
  • It's available in a wider range of programs.Not every text rendering API supports the bitmap font embedding. I noticed Java Swing on Windows doesn't render the embedded version. 
The Bad
  • Scaling at many sizes causes visual artifacts to appear. At smaller sizes many of the lines blur together.


    6pt12pt
  • Anti Alias/ClearType: Bitmap fonts do not anti alias or get clear type applied to them. They are strictly monochrome, the color doesn't have to black of course but there is no lightened color in the angles to provide a soft look. Bitmap fonts are designed for this and they tend to look a little funny when these effects are applied.Visual Studio 2002-2008 will always apply these effects according to the Windows Settings. It would be great if Windows was more granular and could apply different settings on a per app basis or even by window class. Here are some examples:
      

Friday, May 7, 2010

Visual Studio Color Scheme Gallery

http://studiostyles.info

Pretty new site with user submitted VS (2005-2010) Color Schemes downloadable in .vssettings format. People can vote on them too. This site was sorely needed especially after Ning screwed over IDE Hot or Not.

It also includes a web based editor that is way more intuitive than the one in the options screen of Visual Studio. I have both a light and dark scheme I intend to submit.

Friday, March 26, 2010

Dina font for Visual Studio 2010

Updated: I've verified it works with VS2010 Release as well.
Thanks to the hard work of Erik Olofsson decoding the mystery of Embedded Bitmap Fonts I was able to convert one of my all time favorite programming fonts Dina into TTF usable by Visual Studio. The beauty of this technique is that it preserves the bitmap glyphs perfectly and the text rendering does not try to apply anti-aliasing or cleartype. See?

Visual Studio 2010
*bonus* I found that this font can also be used with any .NET application (WPF or Windows Forms) that normally can't handle raster fonts. Here's Dina used as the Grid font for SQL Server Management Studio


Download from my File Cabinet If anyone wants to re-host this file let me know and I'll update the link

Tuesday, March 23, 2010

Cool motion blur


I ran across this picture while backing up Katie's phone. It's of me and Gracie at the vet. Gracie was just a tiny baby here and apparently I'm headbanging. The motion blur is pretty neat looking. It almost makes me look like I have Donald Trump hair.
Posted by Picasa

Friday, October 16, 2009

WinForms/WPF Timers

I find myself using a lot of timers when doing GUI programming. Usually these timers are used to invoke a block of code only once. Sometimes there’s a good reason to delay a call, say you show a tooltip for 1sec then hide it (though in WPF animations should be used). Usually it’s to solve a tricky problem, like you have to let the callstack unwind for some dependent state to take effect. This is usually considered bad practice and there are very few times when no other legitimate techniques can be used. However when deadlines start closing in the number of timers increase. I like to think of Timers as the duct tape of GUI programming.

Using timers, especially for one-off calls is tedious and verbose

DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(10);
timer.Tick += (delegate(object s, EventArgs args)
{
    timer.Stop();
    timer = null;
    DoSomethingCool();
});
timer.Start();

SetTimeout to the rescue.

The HTML DOM has a handy method called setTimeout. It's really easy to use, just pass it a function (or string) and the timeout value. That's it. There is no such time as setTimeout in .NET. But with some Extension methods combined with Lambda expressions we can get pretty close:
new Action(() => DoSomethingCool()).SetTimeout(10);

Here's the code. It comes in 2 flavors: Windows Forms and WPF

namespace SetTimeout.Wpf
{
    using System;
    using System.Windows.Threading;
 
    public static class SettimeoutDelegateExtension
    {
        /// <summary>
        /// Inspired by HTML DOM, executes a delegate via a DispatcherTimer once.
        /// </summary>
        /// <example>new Action(() => someObject.DoSomethingCool()).SetTimeout(100);
        /// </example>
        /// <remarks>Frequently things need to be executed in a timeout, but constructing a Timer is a pain especially for
        /// one-off calls. Combined with Lambda expressions this makes the whole process relativey painless.
        /// </remarks>
        /// <param name="action">Any delegate to execute</param>
        /// <param name="timeout">How long to wait to execute</param>
        /// <param name="args">Any arguments to pass to the delegate</param>
        public static void SetTimeout(this Delegate action, TimeSpan timeout, params object[] args)
        {
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = timeout;
            timer.Tick += new EventHandler(delegate(object sender, EventArgs e)
            {
                timer.Stop();
                timer = null;
                action.DynamicInvoke(args);
            });
            timer.Start();
        }
 
        /// <summary>
        /// Inspired by HTML DOM, executes a delegate via a DispatcherTimer once.
        /// </summary>
        /// <example>new Action(() => someObject.DoSomethingCool()).SetTimeout(100);
        /// </example>
        /// <remarks>Frequently things need to be executed in a timeout, but constructing a Timer is a pain especially for
        /// one-off calls. Combined with Lambda expressions this makes the whole process relativey painless.
        /// </remarks>
        /// <param name="action">Any delegate to execute</param>
        /// <param name="timeout">How long to wait to execute in milliseconds</param>
        /// <param name="args">Any arguments to pass to the delegate</param>
        public static void SetTimeout(this Delegate action, int timeout, params object[] args)
        {
            SetTimeout(action, TimeSpan.FromMilliseconds(timeout), args);
        }
    }
}

p.s. I hope you enjoy the pretty print. I spent way too much time on it

Friday, February 20, 2009

Chuck’s Low Flow Seinfeld Hair

Let’s take a break from the techie stuff for a sec and focus on one of my other passions:TV. Specifically “Chuck”. Even more specifically, Chuck’s hair. It’s changed a little bit since season 1 and now looks like this:

image

This hairstyle strikes me as familiar…

image

Looks like he got a low-flow shower head installed since season 1.

Thursday, August 14, 2008

Old School Wait Animation

I noticed today something a little funny about the Visual Studio 2008 SP1 setup screen:

Notice the little black line at the below the 2nd progress bar at the bottom right? It's actually an old school ASCII wait animation that consists of displaying /-\|.

I'm not sure why they felt a need to add it under a progress bar, the fact that there is a progress bar is kind of a tip off that I need to wait. But like I said, it's funny and may have just been some humor on a programmer's part.