SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Responsive
                            Web Fonts

                                Richard Rutter


                                  Responsive Day Out 2013


I’ve got under ten minutes to talk about web fonts. So here goes. I'm going to start with
something slow.
Who has had this experience? Loading in several web fonts over a slow connection can be…
slow. The browser lays out the page but doesn’t display text until the web font loads.
1. Default: text appears as each web
       font loads

    2. Don’t send web fonts to small screens

    3. Show text in the fallback fonts until
       all the web fonts load

    4. Swap out the fallback font as each
       web font loads


You have some choices.
Stopping web fonts
      downloading to small screens


      <link
      	
  	
  href="webfonts.css"
      	
  	
  rel="stylesheet"
      	
  	
  media="all	
  and	
  (min-­‐width:	
  569px)"
      />




There’s lots of ways to do this. This way assumes that webfonts.css contains your @font-face
rules, as if you were using Fontdeck or another webfont service.
Show text in the fallback font
      until all the web fonts load


      <script>
      //	
  WebFont	
  Loader
      //	
  http://goo.gl/zT2YJ
      </script>




Javascript solution. Uses Webfont Loader. Loads all the fonts.
Can use it with any web font service, including Google webfonts or Fontdeck and it comes
built into Typekit. Also with self-hosted.
WebFont Loader
       <script	
  type="text/javascript">
       WebFontConfig	
  =	
  {	
  fontdeck:	
  {	
  id:	
  '11761'	
  }	
  };

       (function()	
  {
       	
  	
  var	
  wf	
  =	
  document.createElement('script');
       	
  	
  wf.src	
  =	
  ('https:'	
  ==	
  document.location.protocol	
  ?	
  'https'	
  :	
  
       'http')	
  +
       	
  	
  '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
       	
  	
  wf.type	
  =	
  'text/javascript';
       	
  	
  wf.async	
  =	
  'true';
       	
  	
  var	
  s	
  =	
  document.getElementsByTagName('script')[0];
       	
  	
  s.parentNode.insertBefore(wf,	
  s);
       })();
       </script>




Looks like this. But that’s not important right now - it’s just a cut a paste and job.
WebFont Loader
       <html	
  class="wf-­‐loading">

       .wf-­‐loading	
  	
  //	
  When	
  the	
  fonts	
  start	
  to	
  load
       .wf-­‐active	
  	
  	
  //	
  All	
  fonts	
  have	
  loaded	
  (or	
  some	
  timed	
  out)
       .wf-­‐inactive	
  //	
  If	
  all	
  the	
  fonts	
  failed	
  to	
  load




Sets classes according to status of fonts
Swap out fallbacks when all
      web fonts have loaded
      p	
  {
      	
  	
  font-­‐family:	
  serif;
      }
      .wf-­‐active	
  p	
  {
      	
  	
  font-­‐family:	
  'Abril	
  Text',	
  serif;
      }
      h1	
  {
      	
  	
  font-­‐family:	
  sans-­‐serif;
      }
      .wf-­‐active	
  h1	
  {
      	
  	
  font-­‐family:	
  'Tablet	
  Gothic	
  Condensed',	
  sans-­‐serif;
      }
      h2	
  {
      	
  	
  font-­‐family:	
  sans-­‐serif;
      }
      .wf-­‐active	
  h2	
  {
      	
  	
  font-­‐family:	
  'Tablet	
  Gothic	
  Condensed',	
  sans-­‐serif;
Swap out fallback fonts for webfonts once all webfonts have loaded.
Have to do it everywhere you're specifying a webfont.
Swap out fallbacks when
      each webfont loads
       <html	
  class="wf-­‐loading	
  wf-­‐abriltext-­‐n4-­‐active">


       p	
  {
       	
  	
  font-­‐family:	
  serif;
       }
       . wf-­‐abriltext-­‐n4-­‐active	
  p	
  {
       	
  	
  font-­‐family:	
  'Abril	
  Text',	
  serif;
       }
       h1	
  {
       	
  	
  font-­‐family:	
  sans-­‐serif;
       }
       .wf-­‐tabletgothiccondensed-­‐active	
  h1	
  {
       	
  	
  font-­‐family:	
  'Tablet	
  Gothic	
  Condensed',	
  sans-­‐serif;
       }
       h2	
  {
       	
  	
  font-­‐family:	
  sans-­‐serif;
Webfont loader also tells you statuses of each individual font
Only use WebFont Loader
      on larger screens


      <script>
      if	
  (window.innerWidth>548)	
  {
      	
  	
  //	
  WebFont	
  Loader
      	
  	
  //	
  http://goo.gl/zT2YJ
      }
      </script>




Do a check for screen size.
Let's look at the fallbacks again.
Fallback fonts

      Main Heading Set in the
      Webfont
      Main Heading Set in the Fallback

      Tablet Gothic Condensed
      Extra Bold
      Helvetica Neue Condensed Black
The changes weren't that big, even the main headline font.
Tweak fallback metrics
      to match webfont
      h1	
  {
      	
  	
  font-­‐family:	
  'HelveticaNeue-­‐CondensedBlack',	
  sans-­‐serif;
      	
  	
  font-­‐size:86px;
      	
  	
  line-­‐height:1.01;
      	
  	
  font-­‐weight:800;
      }
      .wf-­‐tabletgothiccondensed-­‐active	
  h1	
  {
      	
  	
  font-­‐family:	
  'Tablet	
  Gothic	
  Condensed',
      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  'HelveticaNeue-­‐CondensedBlack',	
  sans-­‐serif;
      	
  	
  font-­‐size:96px;
      	
  	
  line-­‐height:0.9;
      }




Can use webloader classes not just to change fonts but to tweak sizes to match more closely.
Fallback fonts – iOS 6.1
     American Typewriter                Helvetica
     Arial                              Helvetica Neue
     Avenir                             Hoefler Text
     Avenir Next                        Marion
                                        Marker Felt
     Avenir Next Condensed
     Baskerville                        Noteworthy
     Bodoni 72                          Optima
     Bradley Hand                       Palatino
     Chalkboard SE                      Papyrus

        Chalkduster                      Party LET
        Cochin                           Snell Roundhand
Lots of Copperplate even more with iOS 6. These are justRoman ones.
        fonts come with iOS,             Times New the Latin
But iPhones aren't the only smartphones.
        Courier                          Trebuchet MS
Windows.
We have a problem with heading in particular.
Fallback fonts

       Main Heading Set in the
       Webfont
       Main Heading Set in the
       Fallback

       Tablet Gothic Condensed
       Extra Bold
The best we could do is fall back to Segoe UI Bold.
Fallback fonts – Win Phone 7
      Arial                                    Courier New
      Arial Black                              Georgia
      Calibri                                  Lucida Grande
      Cambria                                  Lucida Sans Unicode
      Comic Sans MS                            Segoe UI
                                               Tahoma
      Candara
      Consolas                                 Times New Roman
                                               Trebuchet MS
      Constantia
                                               Verdana
      Corbel



These are the fonts that ship with Windows Phone 7.
Decent selection but nothing narrow or condensed, not even Arial Narrow.
Of course on Android phones there's even less choice.
The Android fallback.
Fallback fonts – Android 4
      Droid Sans
      Droid Sans Mono
      Droid Serif
      Roboto




Most just ship with the three flavours of Droid.
Android 4 comes with Roboto (designed for high res screens).
Font stack

      .wf-­‐active	
  h1	
  {
      	
  	
  font-­‐family:
      	
  	
  	
  'Tablet	
  Gothic	
  Condensed',
      	
  	
  	
  'HelveticaNeue-­‐CondensedBlack',
      	
  	
  	
  'Helvetica	
  Neue',
      	
  	
  	
  'Segoe	
  UI',
      	
  	
  	
  'Roboto',
      	
  	
  	
  sans-­‐serif;
      	
  	
  font-­‐weight:800;
      	
  	
  font-­‐stretch:condensed;
      }



Here a potential font stack including fallbacks for iOS, WP7 and Android 4.
No need to include Droid Sans (ever).
1. Default: text appears as each web
        font loads

     2. Don’t send web fonts to small screens

     3. Show text in the fallback fonts until
        all the web fonts load

     4. Swap out the fallback font as each
        web font loads


Here are your choices again.
Richard Rutter, Fontdeck.com
        @clagnut


        http://webtypography.net/talks/rdo13/




Richard Rutter is cofounder of Fontdeck.com, the professional webfont service.

I thank you.

Weitere ähnliche Inhalte

Ähnlich wie Responsive Web Fonts

The NEW Web Typography: Where the Sexy Is
The NEW Web Typography: Where the Sexy IsThe NEW Web Typography: Where the Sexy Is
The NEW Web Typography: Where the Sexy IsJason CranfordTeague
 
The New Web Typography
The New Web TypographyThe New Web Typography
The New Web TypographyForum One
 
New Web Typography
New Web TypographyNew Web Typography
New Web TypographyMonotype
 
Web programming by kiran and team
Web programming by kiran and teamWeb programming by kiran and team
Web programming by kiran and teamHemanth Kumar N
 
The type revolutionary's cookbook
The type revolutionary's cookbookThe type revolutionary's cookbook
The type revolutionary's cookbookFour Kitchens
 
Fonts on the Web - a guide to web fonts
Fonts on the Web - a guide to web fontsFonts on the Web - a guide to web fonts
Fonts on the Web - a guide to web fontsPrototype Interactive
 
Web font services: March 2011
Web font services: March 2011Web font services: March 2011
Web font services: March 2011RZasadzinski
 
Cool Stuff for Web Typography
Cool Stuff for Web TypographyCool Stuff for Web Typography
Cool Stuff for Web TypographyOliver Linke
 
Cordova and PhoneGap Insights
Cordova and PhoneGap InsightsCordova and PhoneGap Insights
Cordova and PhoneGap InsightsMonaca
 
To Hell with Web Safe Fonts
To Hell with Web Safe FontsTo Hell with Web Safe Fonts
To Hell with Web Safe FontsLennart Schoors
 
用Flutter 開發Linux Desktop Application
用Flutter 開發Linux Desktop Application用Flutter 開發Linux Desktop Application
用Flutter 開發Linux Desktop ApplicationWan Leung Wong
 
Why CSS Was Invented (Håkon Wium Lie)
Why CSS Was Invented (Håkon Wium Lie)Why CSS Was Invented (Håkon Wium Lie)
Why CSS Was Invented (Håkon Wium Lie)Future Insights
 
The state of web typography
The state of web typographyThe state of web typography
The state of web typographyFour Kitchens
 
Drupal Camp LA 2011: Typography modules for Drupal
Drupal Camp LA 2011: Typography modules for DrupalDrupal Camp LA 2011: Typography modules for Drupal
Drupal Camp LA 2011: Typography modules for DrupalAshok Modi
 

Ähnlich wie Responsive Web Fonts (20)

The NEW Web Typography: Where the Sexy Is
The NEW Web Typography: Where the Sexy IsThe NEW Web Typography: Where the Sexy Is
The NEW Web Typography: Where the Sexy Is
 
The New Web Typography
The New Web TypographyThe New Web Typography
The New Web Typography
 
New Web Typography
New Web TypographyNew Web Typography
New Web Typography
 
WEB and FONTS
WEB and FONTSWEB and FONTS
WEB and FONTS
 
CSS font-stacks
CSS font-stacksCSS font-stacks
CSS font-stacks
 
Web programming by kiran and team
Web programming by kiran and teamWeb programming by kiran and team
Web programming by kiran and team
 
The type revolutionary's cookbook
The type revolutionary's cookbookThe type revolutionary's cookbook
The type revolutionary's cookbook
 
Fonts on the Web - a guide to web fonts
Fonts on the Web - a guide to web fontsFonts on the Web - a guide to web fonts
Fonts on the Web - a guide to web fonts
 
Web font services: March 2011
Web font services: March 2011Web font services: March 2011
Web font services: March 2011
 
Web Typography
Web TypographyWeb Typography
Web Typography
 
Cool Stuff for Web Typography
Cool Stuff for Web TypographyCool Stuff for Web Typography
Cool Stuff for Web Typography
 
Web fonts
Web fontsWeb fonts
Web fonts
 
Cordova and PhoneGap Insights
Cordova and PhoneGap InsightsCordova and PhoneGap Insights
Cordova and PhoneGap Insights
 
To Hell with Web Safe Fonts
To Hell with Web Safe FontsTo Hell with Web Safe Fonts
To Hell with Web Safe Fonts
 
用Flutter 開發Linux Desktop Application
用Flutter 開發Linux Desktop Application用Flutter 開發Linux Desktop Application
用Flutter 開發Linux Desktop Application
 
Why CSS Was Invented (Håkon Wium Lie)
Why CSS Was Invented (Håkon Wium Lie)Why CSS Was Invented (Håkon Wium Lie)
Why CSS Was Invented (Håkon Wium Lie)
 
The state of web typography
The state of web typographyThe state of web typography
The state of web typography
 
Drupal Camp LA 2011: Typography modules for Drupal
Drupal Camp LA 2011: Typography modules for DrupalDrupal Camp LA 2011: Typography modules for Drupal
Drupal Camp LA 2011: Typography modules for Drupal
 
Cgi perl
Cgi  perlCgi  perl
Cgi perl
 
Web Typography
Web TypographyWeb Typography
Web Typography
 

Kürzlich hochgeladen

ARt app | UX Case Study
ARt app | UX Case StudyARt app | UX Case Study
ARt app | UX Case StudySophia Viganò
 
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...katerynaivanenko1
 
Pharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfPharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfAayushChavan5
 
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书zdzoqco
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Rndexperts
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一z xss
 
shot list for my tv series two steps back
shot list for my tv series two steps backshot list for my tv series two steps back
shot list for my tv series two steps back17lcow074
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdfvaibhavkanaujia
 
Architecture case study India Habitat Centre, Delhi.pdf
Architecture case study India Habitat Centre, Delhi.pdfArchitecture case study India Habitat Centre, Delhi.pdf
Architecture case study India Habitat Centre, Delhi.pdfSumit Lathwal
 
How to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our SiteHow to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our Sitegalleryaagency
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)jennyeacort
 
Untitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxUntitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxmapanig881
 
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
PORTAFOLIO   2024_  ANASTASIYA  KUDINOVAPORTAFOLIO   2024_  ANASTASIYA  KUDINOVA
PORTAFOLIO 2024_ ANASTASIYA KUDINOVAAnastasiya Kudinova
 
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证nhjeo1gg
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造kbdhl05e
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree 毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree ttt fff
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一diploma 1
 
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改yuu sss
 

Kürzlich hochgeladen (20)

ARt app | UX Case Study
ARt app | UX Case StudyARt app | UX Case Study
ARt app | UX Case Study
 
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
 
Pharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfPharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdf
 
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
 
Call Girls in Pratap Nagar, 9953056974 Escort Service
Call Girls in Pratap Nagar,  9953056974 Escort ServiceCall Girls in Pratap Nagar,  9953056974 Escort Service
Call Girls in Pratap Nagar, 9953056974 Escort Service
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
 
shot list for my tv series two steps back
shot list for my tv series two steps backshot list for my tv series two steps back
shot list for my tv series two steps back
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdf
 
Architecture case study India Habitat Centre, Delhi.pdf
Architecture case study India Habitat Centre, Delhi.pdfArchitecture case study India Habitat Centre, Delhi.pdf
Architecture case study India Habitat Centre, Delhi.pdf
 
How to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our SiteHow to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our Site
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
 
Untitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxUntitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptx
 
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
PORTAFOLIO   2024_  ANASTASIYA  KUDINOVAPORTAFOLIO   2024_  ANASTASIYA  KUDINOVA
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
 
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
 
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree 毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
 
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
 

Responsive Web Fonts

  • 1. Responsive Web Fonts Richard Rutter Responsive Day Out 2013 I’ve got under ten minutes to talk about web fonts. So here goes. I'm going to start with something slow.
  • 2. Who has had this experience? Loading in several web fonts over a slow connection can be… slow. The browser lays out the page but doesn’t display text until the web font loads.
  • 3. 1. Default: text appears as each web font loads 2. Don’t send web fonts to small screens 3. Show text in the fallback fonts until all the web fonts load 4. Swap out the fallback font as each web font loads You have some choices.
  • 4. Stopping web fonts downloading to small screens <link    href="webfonts.css"    rel="stylesheet"    media="all  and  (min-­‐width:  569px)" /> There’s lots of ways to do this. This way assumes that webfonts.css contains your @font-face rules, as if you were using Fontdeck or another webfont service.
  • 5. Show text in the fallback font until all the web fonts load <script> //  WebFont  Loader //  http://goo.gl/zT2YJ </script> Javascript solution. Uses Webfont Loader. Loads all the fonts. Can use it with any web font service, including Google webfonts or Fontdeck and it comes built into Typekit. Also with self-hosted.
  • 6. WebFont Loader <script  type="text/javascript"> WebFontConfig  =  {  fontdeck:  {  id:  '11761'  }  }; (function()  {    var  wf  =  document.createElement('script');    wf.src  =  ('https:'  ==  document.location.protocol  ?  'https'  :   'http')  +    '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';    wf.type  =  'text/javascript';    wf.async  =  'true';    var  s  =  document.getElementsByTagName('script')[0];    s.parentNode.insertBefore(wf,  s); })(); </script> Looks like this. But that’s not important right now - it’s just a cut a paste and job.
  • 7. WebFont Loader <html  class="wf-­‐loading"> .wf-­‐loading    //  When  the  fonts  start  to  load .wf-­‐active      //  All  fonts  have  loaded  (or  some  timed  out) .wf-­‐inactive  //  If  all  the  fonts  failed  to  load Sets classes according to status of fonts
  • 8. Swap out fallbacks when all web fonts have loaded p  {    font-­‐family:  serif; } .wf-­‐active  p  {    font-­‐family:  'Abril  Text',  serif; } h1  {    font-­‐family:  sans-­‐serif; } .wf-­‐active  h1  {    font-­‐family:  'Tablet  Gothic  Condensed',  sans-­‐serif; } h2  {    font-­‐family:  sans-­‐serif; } .wf-­‐active  h2  {    font-­‐family:  'Tablet  Gothic  Condensed',  sans-­‐serif; Swap out fallback fonts for webfonts once all webfonts have loaded. Have to do it everywhere you're specifying a webfont.
  • 9.
  • 10. Swap out fallbacks when each webfont loads <html  class="wf-­‐loading  wf-­‐abriltext-­‐n4-­‐active"> p  {    font-­‐family:  serif; } . wf-­‐abriltext-­‐n4-­‐active  p  {    font-­‐family:  'Abril  Text',  serif; } h1  {    font-­‐family:  sans-­‐serif; } .wf-­‐tabletgothiccondensed-­‐active  h1  {    font-­‐family:  'Tablet  Gothic  Condensed',  sans-­‐serif; } h2  {    font-­‐family:  sans-­‐serif; Webfont loader also tells you statuses of each individual font
  • 11.
  • 12. Only use WebFont Loader on larger screens <script> if  (window.innerWidth>548)  {    //  WebFont  Loader    //  http://goo.gl/zT2YJ } </script> Do a check for screen size.
  • 13. Let's look at the fallbacks again.
  • 14. Fallback fonts Main Heading Set in the Webfont Main Heading Set in the Fallback Tablet Gothic Condensed Extra Bold Helvetica Neue Condensed Black The changes weren't that big, even the main headline font.
  • 15. Tweak fallback metrics to match webfont h1  {    font-­‐family:  'HelveticaNeue-­‐CondensedBlack',  sans-­‐serif;    font-­‐size:86px;    line-­‐height:1.01;    font-­‐weight:800; } .wf-­‐tabletgothiccondensed-­‐active  h1  {    font-­‐family:  'Tablet  Gothic  Condensed',                              'HelveticaNeue-­‐CondensedBlack',  sans-­‐serif;    font-­‐size:96px;    line-­‐height:0.9; } Can use webloader classes not just to change fonts but to tweak sizes to match more closely.
  • 16. Fallback fonts – iOS 6.1 American Typewriter Helvetica Arial Helvetica Neue Avenir Hoefler Text Avenir Next Marion Marker Felt Avenir Next Condensed Baskerville Noteworthy Bodoni 72 Optima Bradley Hand Palatino Chalkboard SE Papyrus Chalkduster Party LET Cochin Snell Roundhand Lots of Copperplate even more with iOS 6. These are justRoman ones. fonts come with iOS, Times New the Latin But iPhones aren't the only smartphones. Courier Trebuchet MS
  • 17. Windows. We have a problem with heading in particular.
  • 18. Fallback fonts Main Heading Set in the Webfont Main Heading Set in the Fallback Tablet Gothic Condensed Extra Bold The best we could do is fall back to Segoe UI Bold.
  • 19. Fallback fonts – Win Phone 7 Arial Courier New Arial Black Georgia Calibri Lucida Grande Cambria Lucida Sans Unicode Comic Sans MS Segoe UI Tahoma Candara Consolas Times New Roman Trebuchet MS Constantia Verdana Corbel These are the fonts that ship with Windows Phone 7. Decent selection but nothing narrow or condensed, not even Arial Narrow. Of course on Android phones there's even less choice.
  • 21. Fallback fonts – Android 4 Droid Sans Droid Sans Mono Droid Serif Roboto Most just ship with the three flavours of Droid. Android 4 comes with Roboto (designed for high res screens).
  • 22. Font stack .wf-­‐active  h1  {    font-­‐family:      'Tablet  Gothic  Condensed',      'HelveticaNeue-­‐CondensedBlack',      'Helvetica  Neue',      'Segoe  UI',      'Roboto',      sans-­‐serif;    font-­‐weight:800;    font-­‐stretch:condensed; } Here a potential font stack including fallbacks for iOS, WP7 and Android 4. No need to include Droid Sans (ever).
  • 23. 1. Default: text appears as each web font loads 2. Don’t send web fonts to small screens 3. Show text in the fallback fonts until all the web fonts load 4. Swap out the fallback font as each web font loads Here are your choices again.
  • 24. Richard Rutter, Fontdeck.com @clagnut http://webtypography.net/talks/rdo13/ Richard Rutter is cofounder of Fontdeck.com, the professional webfont service. I thank you.