2012-08-12 50 views
2

我得到了我使用的Cufón將文本轉換爲我自己的字體這個site的CufónLTR到RTL

問題是文本顯示爲反向。

我使用的JavaScript文件cunfonRTL.js,內容是:

var CufonRTLClass=(function(){ 
     this.RTL = RTL; 

    function RTL(tagName) { 
     $(tagName)/*.css('font-size', '19px')*/.wrapInner('<bdo class="cufon" dir=ltr></bdo>'); 

     $('bdo.cufon').each(function() { 
     var word = $(this).text(); 
     var splittext = word.split(""); 
     var reversedtext = splittext.reverse(); 
     var newtext = reversedtext.join(""); 
     $(this).text(newtext); 
     }); 

    } 
}); 

CufonRTL = new CufonRTLClass; 

渲染的文字是這樣的:

<cufon class="cufon cufon-canvas" alt="כותרת " style="width: 80px; height: 28px; "><canvas width="110" height="28" style="width: 110px; height: 28px; top: 4px; left: -8px; "></canvas><cufontext>כותרת </cufontext></cufon> 

它 '的Cufón' 好吧,但它不是RTL ..其LTR .. 我有語法問題?

幫助將非常感激。

UPDATE: 在Chrome的控制檯我發現這一點: enter image description here

這就是我所說的功能:

Cufon.replace('H1'); 
CufonRTL.RTL('H1'); 

UPDATE: 據我所知,是與一個jQuery衝突$選擇器。 我將所有的$ sings換算成jQuery 現在沒有例外,它只是不運行。

我做了一些調試,發現他沒有得到這個循環裏: jQuery('bdo.cufon').each(function()

var CufonRTLClass=(function(){ 
     this.RTL = RTL; 

    function RTL(tagName) { 
     jQuery(tagName)/*.css('font-size', '19px')*/.wrapInner('<bdo class="cufon" dir=ltr></bdo>'); 

     jQuery('bdo.cufon').each(function() { 
     var word = jQuery(this).text(); 
     var splittext = word.split(""); 
     var reversedtext = splittext.reverse(); 
     var newtext = reversedtext.join(""); 
     jQuery(this).text(newtext); 
     }); 

    } 
}); 

CufonRTL = new CufonRTLClass; 

幫助?

回答

2

改變這一行

$(tagName)/*.css('font-size', '19px')*/.wrapInner('<bdo class="cufon" dir=ltr></bdo>'); 

對此

$(tagName)/*.css('font-size', '19px')*/.wrapInner('<bdo class="cufon" dir=rtl></bdo>'); 
+0

環在我更新 – 2012-08-12 21:22:13

+0

你使用'jQuery.noConflict();'改變所有的'$'和'jQuery'過嗎? – 2012-08-12 23:47:22

+0

把它放在這裏'jQuery.noConflict() function RTL(tagName){'。我認爲有衝突,並且因爲那個 – 2012-08-13 00:11:09