Sunday, June 26, 2011

Style Safari Input Type=Submit Buttons

In my HTML forms, I like to allow users to submit the form by pressing the Enter key, without JavaScript. The easiest way to do that is to include an <input type=submit> button.
<form>
  <input name="x">
  <input type="submit">
</form>
But beware: on Safari (and other WebKit browsers?), <input type=submit> buttons resist CSS styling.
<form>
  <input name="x">
  <style>
  .button {
    font-weight: bolder; /* THIS LINE DOES NOTHING IN SAFARI :-( */
  }
  </style>
  <input class="button" type="submit">
</form>
TIL: if you want to force them to be styled, you can use a WebKit proprietary CSS property, -webkit-appearance: none.
<form>
  <input name="x">
  <style>
  .button {
    -webkit-appearance: none;
    font-weight: bolder;
  }
  </style>
  <input class="button" type="submit">
</form>
If you do that, your buttons will look pretty ugly at first, but with a little work, you can make really cool CSS buttons.

Sunday, March 06, 2011

Convert PS1 Font from Mac to Windows

It's not uncommon to receive a font from a designer that works fine on the Mac, but can't be opened on Windows.

This happened to me today. When I viewed the font in the Finder, the font had no filename extension, but Get Info said its Kind was "Postcript Type 1 outline font." Unfortunately, when I zipped the file and opened the zip file on Windows, the file was 0KB long; not very useful!

Here's how I fixed the problem.

To convert it, I used FontForge. FontForge is a Unix utility that kinda sorta works on OSX. They don't provide an installer for OSX, so the easiest way to install it is by using MacPorts. MacPorts comes with an installer, but you have to install Xcode in order to use it. Xcode can be found on your original OSX install DVDs, on DVD 2. If you can't find those, you can download Xcode for free from Apple, but you have to register as an Apple developer. It's a hassle.

Anyway, assuming you can find and install a copy of Xcode and MacPorts, you should be able to run "sudo port install fontforge" and wait an hour for macports to download a bunch of code from the Internet, compile it, and install it on your machine.

Finally, finally, you can run "fontforge" to open the program. Double-click on your font, and select the File / Generate Fonts ... menu. Select "TrueType" in the list of font types, and save it. It might give you some warnings; I ignored all warnings with no ill effects, but your mileage may vary. This created a .ttf font which worked great on my Windows machine.

Saturday, January 29, 2011

Play YouTube Videos at Double Speed

I enjoy watching video lectures on YouTube at double speed. (It saves a lot of time!)

Here's how. Download VLC and run it. Under the File menu, "Open Network ..." and paste in the YouTube URL. Then, under Playback, select Faster or Slower as needed.

Unfortunately, there's a catch: YouTube throttles download speeds. You can only download one second of video per second. So you'll have to wait for the video to finish downloading and then watch it. (Hey, at least you don't have to sit there and watch it download!)

Alternately, you can use VLC's Streaming/Exporting wizard to save the video to disk first.

Have fun!