Slide 1

Slide 1 text

N Bulletproof C E U R N

Slide 2

Slide 2 text

LET’S LEARN EVERYTHING ABOUT @FONT-FACE

Slide 3

Slide 3 text

@zachleat zachleat.com

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

If you wish to make a font icon from scratch, you must first invent the universe. —Carl Sagan, probably https://www.flickr.com/photos/scott-s_photos/11763686274 “ ”

Slide 6

Slide 6 text

@Font-face THIS ONE WEIRD TRICK A G EN D A CAT FANCY UNICODE LOADING.. . .. .

Slide 7

Slide 7 text

1997 @font-­‐face

Slide 8

Slide 8 text

1995

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

@font-­‐face

Slide 11

Slide 11 text

CSS3 CSS2.1 CSS2

Slide 12

Slide 12 text

@font-­‐face  {   !   font-­‐family:  The  Font  that  Could;     src:url('icanfont.ttf')           format('truetype'),         url('icanfont.woff')           format('woff');     font-­‐weight:  normal;     font-­‐style:  normal;   ! }

Slide 13

Slide 13 text

@font-­‐face  {   !   font-­‐family:  The  Font  that  Could;     src:url('icanfont.ttf')           format('truetype'),         url('icanfont.woff')           format('woff');     font-­‐weight:  normal;     font-­‐style:  normal;   ! }

Slide 14

Slide 14 text

@font-­‐face  {   !   font-­‐family:  The  Font  that  Could;     src:url('icanfont.ttf')           format('truetype'),         url('icanfont.woff')           format('woff');     font-­‐weight:  normal;     font-­‐style:  normal;   ! }

Slide 15

Slide 15 text

David Hasselwoff USE WOFF

Slide 16

Slide 16 text

Woff caniuse.com 5.0! 6.0 7.0! 7.5!

Slide 17

Slide 17 text

WOFF BY ONE ERROR

Slide 18

Slide 18 text

Woff + TTF caniuse.com 5.0! 6.0 7.0! 7.5!

Slide 19

Slide 19 text

NEED IE8? Add EOT

Slide 20

Slide 20 text

@font-­‐face  {   !   font-­‐family:  The  Font  that  Could;     src:url('icanfont.eot?#iefix')           format('embedded-­‐opentype'),         url('icanfont.ttf')           format('truetype'),         url('icanfont.woff')           format('woff');     font-­‐weight:  normal;     font-­‐style:  normal;   ! }

Slide 21

Slide 21 text

Woff + TTF + EOT caniuse.com 5.0! 6.0 7.0! 7.5!

Slide 22

Slide 22 text

NEED Chrome + Windows? Add SVG http://www.fontspring.com/blog/smoother-web-font-rendering-chrome

Slide 23

Slide 23 text

34 8.1 WOFF SVG ISSU E XP

Slide 24

Slide 24 text

Woff + EOT + TTF + SVG https://code.google.com/p/chromium/issues/detail?id=137692 caniuse.com 5.0 7.0! 7.5! 6.0 6.0

Slide 25

Slide 25 text

@font-­‐face  {     font-­‐family:  The  Font  that  Could;     src:url('icanfont.eot?#iefix')           format('embedded-­‐opentype'),         url('icanfont.ttf')           format('truetype'),         url('icanfont.woff')           format('woff'),         url('icanfont.svg#icanfont')           format('svg');     font-­‐weight:  normal;     font-­‐style:  normal;   } W R O N G

Slide 26

Slide 26 text

@media  (-­‐webkit-­‐min-­‐device-­‐pixel-­‐ratio:0)  {   !   @font-­‐face  {       font-­‐family:  The  Font  That  Could;       src:  url('icanfont.svg#icomoon')           format('svg');       font-­‐weight:  normal;       font-­‐style:  normal;     }   ! }

Slide 27

Slide 27 text

https://github.com/scottjehl/Device-Bugs/issues/43 ISSU E

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

@media  (-­‐webkit-­‐min-­‐device-­‐pixel-­‐ratio:0)     and  (min-­‐resolution:  .001dpcm)  {   !   @font-­‐face  {       font-­‐family:  The  Font  That  Could;       src:  url('icanfont.svg#icomoon')           format('svg');       font-­‐weight:  normal;       font-­‐style:  normal;     }   ! }

Slide 30

Slide 30 text

Supports   -­‐webkit-­‐min-­‐device-­‐pixel-­‐ratio Supports   min-­‐resolution Yes No Yes No

Slide 31

Slide 31 text

Woff + EOT + TTF + SVG https://code.google.com/p/chromium/issues/detail?id=137692 caniuse.com 5.0 7.0! 7.5! 6.0 6.0

Slide 32

Slide 32 text

WHEW.

Slide 33

Slide 33 text

A QUICK REVIEW

Slide 34

Slide 34 text

@font-­‐face  {     font-­‐family:  The  Font  that  Could;     src:url('icanfont.eot?#iefix')           format('embedded-­‐opentype'),         url('icanfont.ttf')           format('truetype'),         url('icanfont.woff')           format('woff');     font-­‐weight:  normal;     font-­‐style:  normal;   }   ! @media  (-­‐webkit-­‐min-­‐device-­‐pixel-­‐ratio:0)     and  (min-­‐resolution:  .001dpcm)  {   !   @font-­‐face  {       font-­‐family:  The  Font  That  Could;       src:  url('icanfont.svg#icomoon')           format('svg');       font-­‐weight:  normal;       font-­‐style:  normal;     }   }

Slide 35

Slide 35 text

@font-­‐face  {     font-­‐family:  The  Font  that  Could;     src:url('icanfont.eot?#iefix')           format('embedded-­‐opentype'),         url('icanfont.ttf')           format('truetype'),         url('icanfont.woff')           format('woff');     font-­‐weight:  normal;     font-­‐style:  normal;   }   ! @media  (-­‐webkit-­‐min-­‐device-­‐pixel-­‐ratio:0)     and  (min-­‐resolution:  .001dpcm)  {   !   @font-­‐face  {       font-­‐family:  The  Font  That  Could;       src:  url('icanfont.svg#icomoon')           format('svg');       font-­‐weight:  normal;       font-­‐style:  normal;     }   } REMOVE AFTER CHROME DIRECTWRITE

Slide 36

Slide 36 text

GO TO YOUR HAPPY PLACE

Slide 37

Slide 37 text

LET’s PUT THE @FONT-FACE BLOCK ON OUR WEB PAGE

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

NO FONT-FAMILY NO DOWNLOAD

Slide 40

Slide 40 text

34 28 9, 10, 11 20 6.1, 7 2.3, 4.1 7 8

Slide 41

Slide 41 text

body  {     font-­‐family:  My  Icon  Font,  serif;   }

Slide 42

Slide 42 text

var  b  =  document.body;   ! b.style.fontFamily  =  "My  Icon  Font";

Slide 43

Slide 43 text

@Font-face THIS ONE WEIRD TRICK A G EN D A CAT FANCY UNICODE LOADING…

Slide 44

Slide 44 text

BASIC LATIN CODE POINT Arial Chunk Five x41 A A x42 B B x43 C C x44 D D x45 E E

Slide 45

Slide 45 text

Higher UNICODE Ranges x2261 ≡ x2605 ˒ x2665 ♥ x2713 ✓

Slide 46

Slide 46 text

Arial Chunk Five 0x1F300 0x1F302 0x1F350 Arial Chunk Five 0x1F300 0x1F302 0x1F350 EMOJI http://doeschromesupportemojiyet.com/ https://code.google.com/p/chromium/issues/detail?id=62435

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

CONSISTENCY

Slide 49

Slide 49 text

unicode.johnholtripley.co.uk

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

READ AS x2261 ≡ IDENTICAL TO x2605 ˒ BLACK STAR or STAR x2665 ♥ HEART SUIT ACCESSIBILITY

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

PRIVATE USE AREA

Slide 54

Slide 54 text

YOUR ICON FONT HERE 0xe001 0xe002 0xe003 0xe004 PRIVATE USE AREA

Slide 55

Slide 55 text

@Font-face THIS ONE WEIRD TRICK A G EN D A CAT FANCY UNICODE LOADING…

Slide 56

Slide 56 text

https://www.flickr.com/photos/79157069@N03/11616536203/ OUR @FONT-FACE REQUEST LEAVES THE NEST

Slide 57

Slide 57 text

LOCAL FONT { @FONT-FACE {

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

FOIT Flash of Invisible Text

Slide 60

Slide 60 text

@FONT-FACE LOAD

Slide 61

Slide 61 text

https://twitter.com/aanand/status/465182499577286656

Slide 62

Slide 62 text

LOCAL FONT { @FONT-FACE {

Slide 63

Slide 63 text

FOUT Flash of UNSTYLED Text

Slide 64

Slide 64 text

3 S @FONT-FACE LOAD ABCDEFGH ABCDEFGH

Slide 65

Slide 65 text

3 S @FONT-FACE LOAD

Slide 66

Slide 66 text

https://twitter.com/raganwald/status/452092613529567233 Screenshot of GitHub

Slide 67

Slide 67 text

LOCAL FONT { @FONT-FACE {

Slide 68

Slide 68 text

Timeouts/CURFEWS 34 > 60 s 36 28 9, 10, 11 N/A 20 > 60 s 3 s 3 s 7 60 s 4.1 > 60 s * 6 > 60 s 60 s* 7

Slide 69

Slide 69 text

if font loads after 60 seconds SAFARI IGNORES IT 7 *Timeout ISSU E 7

Slide 70

Slide 70 text

WHAT HAPPENS WHEN A USER HITS THE STOP BUTTON?

Slide 71

Slide 71 text

LOCAL FONT { @FONT-FACE { ISSU E

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

@Font-face THIS ONE WEIRD TRICK A G EN D A CAT FANCY UNICODE LOADING…

Slide 74

Slide 74 text

LET’S FIX EVERYTHING

Slide 75

Slide 75 text

DECORATIVE ICON U SE C A SE

Slide 76

Slide 76 text

  Share  on  Twitter

Slide 77

Slide 77 text

  Share  on  Twitter

Slide 78

Slide 78 text

FILAMENTGROUP/A-Font-Garde https://github.com/filamentgroup/a-font-garde

Slide 79

Slide 79 text

FontFaceOnload(  "My  Icon  Font",     {       glyphs:  "\uE600\uE601\uE602\uE605",       success:  function()  {         var  docEl  =  document.documentElement;         docEl.className  +=  "  my-­‐icon-­‐font";       }     }); // requires http://filamentgroup.github.io/a-font-garde/src/fontfaceonload.js

Slide 80

Slide 80 text

/*  @font-­‐face  omitted  */   ! .my-­‐icon-­‐font  .icon-­‐twitter:before  {     font-­‐family:  My  Icon  Font;     content:  "\e600";   }

Slide 81

Slide 81 text

typekit/webfontloader https://github.com/typekit/webfontloader

Slide 82

Slide 82 text

CSS Font Loading Module Level 3 http://dev.w3.org/csswg/css-font-loading/

Slide 83

Slide 83 text

document.fonts.load("1em  My  Icon  Font")     .then(function()  {   !     var  docEl  =  document.documentElement;       docEl.className  +=  "  my-­‐icon-­‐font";   !   });

Slide 84

Slide 84 text

BRAMSTEIN/FONTLOADER https://github.com/bramstein/fontloader FOLLOW HE’S WORKING ON A POLYFILL. https://twitter.com/bram_stein/status/465560158723395584

Slide 85

Slide 85 text

my-­‐icon-­‐font   SOLVES OUR PROBLEMS

Slide 86

Slide 86 text

WE NOW CONTROL FOIT & FOUT

Slide 87

Slide 87 text

NO MORE UNICODE SURPRISES TIMEOUT SURPRISES STOP BUTTON SURPRISES

Slide 88

Slide 88 text

DECORATIVE ICON 3 S @FONT-FACE LOAD FOIT FOUT

Slide 89

Slide 89 text

@Font-face THIS ONE WEIRD TRICK A G EN D A LET’S GET FANCY UNICODE LOADING…

Slide 90

Slide 90 text

LET’S GET CAT FANCY

Slide 91

Slide 91 text

TEXT to ICON @FONT-FACE LOAD U SE C A SE

Slide 92

Slide 92 text

  .facebook  .icon  {     display:  none;   }   .my-­‐icon-­‐font  .facebook  .icon  {     display:  inline-­‐block;   }   .my-­‐icon-­‐font  .facebook  .text  {     /*  Visually  hide  but  keep  for  screen  readers  */     clip:  rect(0  0  0  0);  overflow:  hidden;       position:  absolute;  height:  1px;  width:  1px;   }             Facebook   https://github.com/h5bp/html5-boilerplate/blob/master/css/main.css#L127

Slide 93

Slide 93 text

  .facebook  .icon  {     display:  none;   }   .my-­‐icon-­‐font  .facebook  .icon  {     display:  inline-­‐block;   }   .my-­‐icon-­‐font  .facebook  .text  {     /*  Visually  hide  but  keep  for  screen  readers  */     clip:  rect(0  0  0  0);  overflow:  hidden;       position:  absolute;  height:  1px;  width:  1px;   }             Facebook   https://github.com/h5bp/html5-boilerplate/blob/master/css/main.css#L127

Slide 94

Slide 94 text

GLYPH to ICON ≡ U SE C A SE

Slide 95

Slide 95 text

https://twitter.com/bjankord/status/451367657493647361 Hamburger Helper

Slide 96

Slide 96 text

Hamburger Emoji

Slide 97

Slide 97 text

= Veggieburger

Slide 98

Slide 98 text

– Gluten Free Hamburger https://twitter.com/brouxhaha/status/464787128334180354

Slide 99

Slide 99 text

Facebook’s Manburger https://twitter.com/jedschmidt/status/455871778267463680

Slide 100

Slide 100 text

Hungryman Burger

Slide 101

Slide 101 text

@FONT-FACE LOAD GLYPH to ICON ≡

Slide 102

Slide 102 text

  .hamburger  .icon:before  {     content:  "\2261";     /*  Adjust  font-­‐size  and  line-­‐height  to  match  */   }   .hamburger  .text  {     /*  Visually  hide  but  keep  for  screen  readers  */     clip:  rect(0  0  0  0);  overflow:  hidden;       position:  absolute;  height:  1px;  width:  1px;   }   .my-­‐icon-­‐font  .hamburger  .icon:before  {     font-­‐family:  My  Icon  Font;     content:  "\e601";   !   /*  Reset  font-­‐size  and  line-­‐height  */     font-­‐size:  inherit;     line-­‐height:  inherit;   }             Menu  

Slide 103

Slide 103 text

  .hamburger  .icon:before  {     content:  "\2261";     /*  Adjust  font-­‐size  and  line-­‐height  to  match  */   }   .hamburger  .text  {     /*  Visually  hide  but  keep  for  screen  readers  */     clip:  rect(0  0  0  0);  overflow:  hidden;       position:  absolute;  height:  1px;  width:  1px;   }   .my-­‐icon-­‐font  .hamburger  .icon:before  {     font-­‐family:  My  Icon  Font;     content:  "\e601";   !   /*  Reset  font-­‐size  and  line-­‐height  */     font-­‐size:  inherit;     line-­‐height:  inherit;   }             Menu      

Slide 104

Slide 104 text

@Font-face THIS ONE WEIRD TRICK A G EN D A LET’S GET FANCY UNICODE LOADING…

Slide 105

Slide 105 text

Different GOALS FOR CONTENT ICONFONTS CONTENT ICON

Slide 106

Slide 106 text

@zachleat Thank you!