changeset 503:5d608412b003 feature_212

Pull out font name specifications from stylesheets and serve differently to different platforms (falling back to our usual web fonts). Fixes #212
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 14 Jul 2011 10:14:03 +0100
parents b9f81065a8e1
children 3cab7f3ad3c7 25847888f5ba
files app/helpers/application_helper.rb app/views/layouts/base.rhtml public/themes/soundsoftware/stylesheets/application.css public/themes/soundsoftware/stylesheets/fonts-generic.css public/themes/soundsoftware/stylesheets/fonts-mac.css public/themes/soundsoftware/stylesheets/fonts-ms.css
diffstat 6 files changed, 46 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/app/helpers/application_helper.rb	Wed Jul 13 14:37:14 2011 +0100
+++ b/app/helpers/application_helper.rb	Thu Jul 14 10:14:03 2011 +0100
@@ -913,6 +913,17 @@
     '<meta name="robots" content="noindex,follow,noarchive" />'
   end
 
+  def stylesheet_platform_font_tag
+    agent = request.env['HTTP_USER_AGENT']
+    name = 'fonts-generic'
+    if agent and agent =~ %r{Windows}
+      name = 'fonts-ms'
+    elsif agent and agent =~ %r{Macintosh}
+      name = 'fonts-mac'
+    end
+    stylesheet_link_tag name, :media => 'all'
+  end
+
   # Returns true if arg is expected in the API response
   def include_in_api_response?(arg)
     unless @included_in_api_response
--- a/app/views/layouts/base.rhtml	Wed Jul 13 14:37:14 2011 +0100
+++ b/app/views/layouts/base.rhtml	Thu Jul 14 10:14:03 2011 +0100
@@ -8,6 +8,7 @@
 <%= csrf_meta_tag %>
 <%= favicon %>
 <%= stylesheet_link_tag 'application', :media => 'all' %>
+<%= stylesheet_platform_font_tag %>
 <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
 <%= javascript_heads %>
 <%= heads_for_theme %>
--- a/public/themes/soundsoftware/stylesheets/application.css	Wed Jul 13 14:37:14 2011 +0100
+++ b/public/themes/soundsoftware/stylesheets/application.css	Thu Jul 14 10:14:03 2011 +0100
@@ -1,5 +1,4 @@
 @import url(../../../stylesheets/application.css);
-@import url(fonts.css);
 
 /* Colours:
 
@@ -31,13 +30,6 @@
 
 h1 {
   color: #3e442c;
-  font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
-  font-weight: normal;
-}    
-
-body,p,h2,h3,h4,li,table,.wiki h1 { 
-  font-family: DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
-  line-height: 1.34;
 }
 
 h2,h3,h4,.wiki h1 {
@@ -130,8 +122,6 @@
     margin-bottom: 0px;
     margin-left: 12px;
     margin-top: 6px;
-    font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
-    font-weight: normal;
 }
 
 #main-menu { position: absolute; top: 100px; /* background-color: #be5700; */ left: 0; border-top: 0; width: 100%;/* height: 1.82em; */ padding: 0; margin: 0; border: 0; }
@@ -183,7 +173,6 @@
 .NavBarCell1 { background-color: #ffe69b; color:#000000 }
 
 .embedded table { border: 0px solid #fff; }
-.embedded h1 { font-family: DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; }
 .embedded h3 { margin-top: 0.5em; }
 .embedded hr { color: #a9b680; background-color: #a9b680 }
 .embedded center { text-align: left; } /* haha */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/public/themes/soundsoftware/stylesheets/fonts-generic.css	Thu Jul 14 10:14:03 2011 +0100
@@ -0,0 +1,12 @@
+@import url(fonts.css);
+
+h1, #project-ancestors-title {
+  font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
+  font-weight: normal;
+}    
+
+body,p,h2,h3,h4,li,table,.wiki h1,.embedded h1 { 
+  font-family: DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
+  line-height: 1.34;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/public/themes/soundsoftware/stylesheets/fonts-mac.css	Thu Jul 14 10:14:03 2011 +0100
@@ -0,0 +1,11 @@
+@import url(fonts.css);
+
+h1, #project-ancestors-title {
+  font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
+  font-weight: normal;
+}    
+
+body,p,h2,h3,h4,li,table,.wiki h1,.embedded h1 { 
+  font-family: 'Lucida Grande', 'Lucida Sans Unicode', DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
+  line-height: 1.34;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/public/themes/soundsoftware/stylesheets/fonts-ms.css	Thu Jul 14 10:14:03 2011 +0100
@@ -0,0 +1,11 @@
+@import url(fonts.css);
+
+h1, #project-ancestors-title {
+  font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
+  font-weight: normal;
+}    
+
+body,p,h2,h3,h4,li,table,.wiki h1,.embedded h1 { 
+  font-family: Calibri, DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
+  line-height: 1.34;
+}