Stylize text to use different fonts for different languages?

前端 未结 5 996
一整个雨季
一整个雨季 2021-01-19 10:44

Is there a way to stylize text on an HTML page such that it automatically uses a different font for different languages? My website uses both English and Arabic. I\'d like t

5条回答
  •  旧时难觅i
    2021-01-19 11:20

    below function will wrap the different languages with in a span create .en and .ar css classes with respective font

    function formatString(string) {
        var output = "";
        var ar_start = parseInt("0x00600", 16);
        var ar_end = parseInt("0x006FF", 16);
        var currentLang = "en";
        for (var i=0; i ar_start && code < ar_end){
                    if (currentLang != "ar"){
                        currentLang = "ar";
                        output += ""
                    }
                    }else{
                        if (currentLang != "en"){
                            currentLang = "en";
                            output += ""
                        }
                    }
                }
                output += string.charAt(i);
            }
        }
    
        return (output);
    }
    

提交回复
热议问题