cufon LTR到RTL

时间:2012-08-12 20:38:48

标签: javascript jquery wordpress right-to-left cufon

我得到了这个site

我正在使用cufon将文本转换为我自己的字体。

问题是文本反向显示。

我正在使用名为cunfonRTL.js的JavaScript文件,内容为:

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>

它的'cufon'好吧但它不是RTL ..它的LTR .. 我有语法问题?

非常感谢帮助。

更新: 在chrome的控制台中我发现了这个: enter image description here

这就是我调用函数的方式:

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

更新: 据我所知,与$ selectors存在jQuery冲突。 我用jQuery转换了所有的$ sings 现在没有例外,它只是不运行。

我做了一些调试,发现他没有进入这个循环: 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;

帮助?

1 个答案:

答案 0 :(得分: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>');
相关问题