काही गोष्टी, काही गमती ........

Monday, August 15, 2005

मोझिला फायरफॉक्स र्‍हस्व वेलांटी


जर आपण "Complex Indic Script Support" आपल्या संगणकावरती प्रतिष्ठित (install) केला नसेल तर मोझिला फायरफॉक्स किंवा ओपेरा वरती देवनागरी युनिकोड र्‍हस्व वेलांटी बरोबर दिसत नाही. जर आपल्या वेबसाईट वर आपण देवनागरी लिपी वापरत असाल तर अशा लोकांना ही र्‍हस्व वेलांटी कशी बरोबर दाखवावी? देवनागरी युनिकोड हे माईक्रोसॉफ्ट्च्या इंटरनेट एक्स्प्लोरर वर बरोबर दिसतं. पण मोझिला फायरफॉक्स किंवा ओपेरा अशा इंटरनेट ब्रॉउजर वरती देवनागरी बरोबर uniscribe केले जात नाही. त्यामुळे र्‍हस्व वेलांट्या ह्या अक्षरांनंतर अवतरतात आणि अख्खे संकेतपत्र (web-page) हे विचित्र दिसते. ते दुरूस्त करण्यासाठीच मी एक javascript तयार केली आहे आणि तिचा वापर ह्या संकेतस्थला (web-site)वरती करण्याची मुभा आहे. जर "Complex Indic Script Support" वापरात नसेल तर येथे वर कोपऱ्यात असलेल्या "link" वर टिचकी दिल्यानंतर येथील र्‍ह्स्व वेलांट्या बरोबर जागेवर दिसतात.

ही javascript अशी:




<script language="javascript">
// Put the devanagari vowel i before the letter it was inserted after
function transcribe(text)
{
if(navigator.appName == "Microsoft Internet Explorer")
{
return text;
} else
{
var lastChar = text.charAt(0);
var newString = text.charAt(0);
var letter;
for (var i=1; i < (text.length - 1); i++)
{
letter = text.charAt(i+1);

if (letter == '\u093f')
{
newString = newString + letter + text.charAt(i);
i++;
} else
{
newString = newString + text.charAt(i);
}
}

if(letter != '\uo93f')
{
newString += text.charAt(text.length-1);
}
}
return newString;
}

// This function is passed a DOM Node object and checks to see if that node
// represents a string of text; i.e., if the node is a Text object it changes
// the text to make an adjustment to vowel i of Devanagari Script for non
// Microsoft Internet Explorer browsers which cannot adjust the position of this
// vowel so that it appears before the letter after which the vowel was introduced.
// This causes the vowel to show at right places for Internet Explorer and non-
// IE browsers alike.
// If the Node is not a Text Node , it recursively calls
// itself on each of the children of the node for altering the children text.
// It enumerates the children of a node
// using the firstChild and nextSibling properties. The
// function does not recurse when it finds a Text node, because Text nodes
// never have children.
function changeText(n) { // n is a Node

if (n.nodeType == 3 /*Node.TEXT_NODE*/)
{
// n is a Text object
var str = n.nodeValue;
n.nodeValue = transcribe(str);
return;
}
// Otherwise, n may have children text Nodes the text of which needs to be changed
for(var m = n.firstChild; m != null; m = m.nextSibling) {
changeText(m); // Chnage the text of enclosed Text Nodes
}
return;
}

function startChange(n)
{
if(navigator.appName == "Microsoft Internet Explorer")
{
return;
}
changeText(n);
}

</script>

</head>
<body> ......
............




ह्यानंतर प्रेक्षकांना ही "script" वापरण्याची मुभा अशी द्यावी:



<script language="javascript">

if(navigator.appName != "Microsoft Internet Explorer")
{
document.writeln('<font size="-2"><A onCLick="startChange(document);"style="color: white; decoration:none;">
&#2332;&#2352;&#32;&#2352;&#2381;&#8205;&#2361;&#2360;&#2381;&#2357;
&#2357;&#2375;&#2354;&#2366;&#2306;&#2335;&#2368;
&#2332;&#2366;&#2327;&#2375;&#2357;&#2352;
&#2342;&#2367;&#2360;&#2340;&#32;&#2344;&#2360;&#2375;&#2354;
&#2340;&#2381;&#2340;&#2352;
&#2340;&#2370;&#2352;&#2381;&#2340;&#2366;&#2360;
&#2352;&#2381;&#8205;&#2361;&#2360;&#2381;&#2357;
&#2357;&#2375;&#2354;&#2366;&#2306;&#2335;&#2381;&#2351;&#2366;
&#2332;&#2366;&#2327;&#2375;&#2357;&#2352;
&#2310;&#2339;&#2339;&#2381;&#2351;&#2366;&#2360;&#2366;&#2336;&#2368;
&#2351;&#2375;&#2341;&#2375;&#32;&#2335;&#2367;&#2330;&#2325;&#2367;
&#2342;&#2381;&#2351;&#2366;

</A> </font>');
}
</script>


5 Comments:

At Monday, August 15, 2005 6:10:00 PM, Blogger Mayuresh said...

Hi,

This seems to have done the trick - though not completely. However, do check out my blog for what i mean.

I am also curious as to why the javascript does what it does.

 
At Friday, August 26, 2005 2:11:00 PM, Anonymous Anonymous said...

I still cannot see the text properly on this page (http://goshtigamti.blogspot.com/).

On your homepage (http://www.pkls.com/) and my website (http://priyank.com/marathi/), however the text looks correctly rendered by Firefox. I have not used any javascript.

I'm willing to help further testing of this javascript, if required. Contact me, so I can send you screenshots of the three sites.

-Priyank (http://www.priyank.com/)

 
At Monday, August 29, 2005 2:28:00 PM, Blogger Pawan said...

Well, the javascript only brings the Vowel i before the letter it was used on instead of keeping it after the letter. E.g. "vishhay", which is normally displayed as "वषिय" when INDIC font support is NOT installed, is displayed as "विषय" after the script is run.

I see that this will only be helpful when the user has no Dynamic Font support for INDIC scripts installed.

If INDIC Scripting support is installed, Devanagari unicode will be displayed without problem on the Firefox browsers and running the javascript will be problematic on such machines.

Better way will be to give an "option link" on the webpage where people would click to re-arrange the vowel i or "rhasva velaanTi" before the letter in case user cannot get dynamic font support installed on their machines and still is not able to see the Vowel i in right places.

 
At Monday, January 09, 2006 1:07:00 PM, Anonymous nandan said...

namaskaar,
bahuteka haa rhaswa welaaMTiichaa problema naahii. mI yaasaaThI greasemonkey ase firefox che plugin waaparato. hyaa plugin madhye tumhaalaa hawI tI javascript hawyaa tyaa page(s) waratI chaalawataa yete. hI script waaparUna sarwa sahii disate.

 
At Monday, January 09, 2006 11:41:00 PM, Blogger Pawan said...

Nandan,

That's interesting; i.e. using GreaseMonkey to run this script. Glad that you are finding the script useful.

Remember though that you do not have to use the script if you already have Indic Script Support enabled on your Operating System. The script is only meant to temporarily help website visitors who do not have the Indic Script support enabled and are still using Firefox to visit the website.

Cheers,
Pawan

 

Post a Comment

<< Home