{"id":397,"date":"2010-06-11T07:01:20","date_gmt":"2010-06-11T07:01:20","guid":{"rendered":"https://www.divydovy.com/?p=397"},"modified":"2020-01-23T10:30:14","modified_gmt":"2020-01-23T10:30:14","slug":"cufon-for-thematic-with-no-plugins","status":"publish","type":"post","link":"https://www.divydovy.com/2010/06/cufon-for-thematic-with-no-plugins/","title":{"rendered":"Cufón for Thematic with no plugins"},"content":{"rendered":"<p>UPDATE: a new, improved version of this post is available here: <a href=\"https://www.divydovy.com/2011/07/cufon-for-thematic-with-no-plugins-improved/\" title=\"Cufon for Thematic with no plugins, improved\">https://www.divydovy.com/2011/07/cufon-for-thematic-with-no-plugins-improved/</a></p>\n<p>I like Cufón. As long as the page loads and the JavaScript executes quickly, it&#8217;s a really slick solution to using any font you want (and have a license for) on your website. I haven&#8217;t really used it for body text, but I used it on the <a title=\"Brandwatch portfolio page\" href=\"/2010/04/brandwatch/\">Brandwatch</a> site for headers, and I&#8217;m currently using it for another site (to be added to the portfolio soon).</p>\n<p>Both times I&#8217;ve used it, I&#8217;ve initially relied on plugins: <a title=\"WP-Cufon\" href=\"http://wordpress.org/extend/plugins/wp-cufon/\">WP-Cufon</a> and <a title=\"All-In-One Cufon\" href=\"http://wordpress.org/extend/plugins/all-in-one-cufon/\">All-In-One Cufon</a>, as they&#8217;ve seemed the only viable options. However, I&#8217;ve never been able to make All-In-One Cufon work, and WP-Cufon seems really unreliable. Often it would detect my font in the /fonts/ folder, but would not then add the font as a JavaScript call to the DOM. Obviously, without that, the Cufon didn&#8217;t work.</p>\n<p>I&#8217;m still using Thematic/child themes for most of my WordPress development and I realised by looking at what the plugins did to the DOM that it wouldn&#8217;t be hard to do manually. So, in the end I decided just to use my child theme&#8217;s functions.php file to add the necessary JavaScript. Turns out it&#8217;s not that hard. Here it is:</p>\n<pre>// Cufon\r\n\t//Load Header JS files and stylings\r\n\tfunction load_cufon_js() {?&gt;\r\n\t    &lt;script type=\"text/javascript\" src=\"&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/cufon-yui.js\"&gt;&lt;/script&gt; //Loads the main Cufon JS file\r\n\t    &lt;script type=\"text/javascript\" src=\"&lt;?php bloginfo('stylesheet_directory'); ?&gt;/js/vegur.font.js\"&gt;&lt;/script&gt; //Loads the font JS file\r\n\t\t&lt;script type=\"text/javascript\"&gt; //Various arbitrary text replacement statements\r\n\t\t\tCufon('h1#blog-title a', { hover: { color:'red' } });\r\n\t\t\tCufon.replace('h1', { fontFamily: 'Vegur' });\r\n\t\t\tCufon.replace('h2', { fontFamily: 'Vegur' });\r\n\t\t&lt;/script&gt;\r\n\t&lt;?php }\r\n\tadd_action('wp_head','load_cufon_js'); //add the function to the head\r\n\r\n\t//Load Footer function call\r\n\tfunction load_cufon_call_js() {?&gt;\r\n\t    &lt;script type=\"text/javascript\"&gt; Cufon.now(); &lt;/script&gt; //This shortens the conversion delay in IE\r\n\t&lt;?php }\r\n\tadd_action('thematic_after','load_cufon_call_js'); //Add it just before the body ends</pre>\n<p>Remember that any hover statements need to come FIRST, as described <a title=\"Cufon hover fix\" href=\"https://www.divydovy.com/2010/04/cufon-hover-fix/\">here</a>.</p>\n<p>Just copy and paste all that into your child theme&#8217;s functions.php, then add the JS files to the right folder in your child theme.This worked straight away for me and seems simple and lightweight. No reliance on plugins that&#8217;ll need to be updated (even when you can get them to work)!</p>\n<p>If this helps, leave me a comment. It&#8217;ll encourage me to post more juicy Thematic functions&#8230;</p>\n","protected":false},"excerpt":{"rendered":"<p>UPDATE: a new, improved version of this post is available here: https://www.divydovy.com/2011/07/cufon-for-thematic-with-no-plugins-improved/ I like Cufón. As long as the page loads and the JavaScript executes quickly, it&#8217;s a really slick solution to using any font you want (and have a license for) on your website. I haven&#8217;t really used it for body text, but I used it on the Brandwatch site for headers, and I&#8217;m currently using it for another site (to be added to the portfolio soon). Both times I&#8217;ve used it, I&#8217;ve initially relied on plugins: WP-Cufon and All-In-One Cufon, as they&#8217;ve seemed the only viable options. However, [&hellip;]</p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","clkt_auto_upload":"0","_clkt_publish_and_upload":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wordproof_timestamp":false},"categories":[7],"tags":[151,31,142,166,165,167,140,125],"my_content_publications":[],"class_list":["post-397","type-post","status-publish","format-standard","hentry","category-web","tag-child-theme","tag-css","tag-cufon","tag-fonts","tag-functions","tag-styling","tag-thematic","tag-wordpress"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"clkt_attachments":{"featured_image":null,"inline_attachments":[],"upload_candidates":[],"max_free_size":102400,"max_allowed_size":104857600},"_clkt_upload_mode":"new_only","clkt_content_hash":"b33bb2fb8d72435b8ba77d3175eb038de69952803c82368316a82042486bb928","customFields":{"clkt_auto_upload":"0","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"processed_attachments":{"total_attachments":0,"uploaded_to_arweave":0,"kept_original_urls":0,"upload_summary":{"total":0,"uploaded":0,"failed":0,"too_large":0,"reused":0}}},"paymentAddress":"8_-tV4d15kVVq9Gd-Al2MAIC3LqNtJ_KgFol71TzxPw"}