© 2011 steveostudios

CSS Custom fonts in Windows

Posted on June 24, 2011 by in HTML/CSS | 3 Comments

Apparently either IE or something in Windows doesn’t like custom fonts in CSS. I discovered this while trying to place a custom font in a Titanium Desktop app using the (so I thought) standard:

1
2
3
4
@font-face {
font-family: 'MyFont';
src: url('myfont.ttf');
}

This works great in Firefox and Safari, as well as Titanium’s application, until I tried it in Windows. Apparently it doesn’t like .ttf’s. This website outlines a little about why Windows doesn’t like .ttf’s, which lead me to this handy site that you can use to convert your font to all standards and it outputs a CSS for you to use. Here is mine:

1
2
3
4
5
6
7
8
9
10
@font-face {
font-family: 'MyFont';
src: url('myfont.eot');
src: url('myfont.eot?#iefix') format('embedded-opentype'),
url('myfont.woff') format('woff'),
url('myfont.ttf') format('truetype'),
url('myfont.svg#MyFont') format('svg');
font-weight: normal;
font-style: normal;
}

Wallah! Magically it works. I don’t understand why, though.

3 Responses to "CSS Custom fonts in Windows"

  1. Mike
    - September 19, 2011 at 2:21 pm

    Did this work for you in Titanium’s Desktop application on Windows? This works for me in IE but not through Titanium’s Desktop

    • Steve
      - September 19, 2011 at 2:38 pm

      It appeared to. I’ll have to double-check to see, but so far it looks good!

      • Mike
        - September 19, 2011 at 5:33 pm

        Actually I think you are correct. Which version of your font is loading? Because the svg version will load, but truetypes won’t. SVG fonts aren’t any good in Titanium Desktop for Windows though, since you can’t use your mouse to position your cursor anywhere in the middle of text in a textarea.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">