User Tools

Site Tools


outputting_20arabic_20text

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
outputting_20arabic_20text [2018/03/31 13:19] – external edit 127.0.0.1outputting_20arabic_20text [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 //by Richard Russell, April 2012//\\ \\  BBC BASIC for Windows supports outputting **Unicode** text to the main output window or to the printer, and it also supports **right-to-left** printing, so in principle it ought to be able to output Arabic text. However there is a complication: in Arabic the shapes of characters (their //glyphs//) can depend on their placement within a word, i.e. depending on whether they are at the start of a word, at the end of a word, in the middle of a word or on their own (isolated).\\ \\  Because BBC BASIC outputs text as a **VDU stream** each character is treated in isolation and therefore when outputting Arabic the 'isolated' forms of the characters are used and the text is not rendered correctly. For example try running this program (copy-and-paste it into the BB4W editor):\\  //by Richard Russell, April 2012//\\ \\  BBC BASIC for Windows supports outputting **Unicode** text to the main output window or to the printer, and it also supports **right-to-left** printing, so in principle it ought to be able to output Arabic text. However there is a complication: in Arabic the shapes of characters (their //glyphs//) can depend on their placement within a word, i.e. depending on whether they are at the start of a word, at the end of a word, in the middle of a word or on their own (isolated).\\ \\  Because BBC BASIC outputs text as a **VDU stream** each character is treated in isolation and therefore when outputting Arabic the 'isolated' forms of the characters are used and the text is not rendered correctly. For example try running this program (copy-and-paste it into the BB4W editor):\\ 
 +<code bb4w>
         VDU 23,22,640;512;8,16,16,128+8 : REM Select UTF-8 output         VDU 23,22,640;512;8,16,16,128+8 : REM Select UTF-8 output
         *FONT Times New Roman, 28         *FONT Times New Roman, 28
Line 12: Line 13:
         VDU 23,16,0;0;0;0;13 : REM Select left-to-right printing         VDU 23,16,0;0;0;0;13 : REM Select left-to-right printing
         END         END
 +</code>
 This is what is displayed:{{arabic1.gif}}\\  The isolated forms of the characters have been used and the result is not correct.\\ \\  Fortunately there is a solution to this problem. By pre-processing the strings before output the correct glyphs can be generated. Here is a revised version of the program (the function **FNarabic** is listed later):\\  This is what is displayed:{{arabic1.gif}}\\  The isolated forms of the characters have been used and the result is not correct.\\ \\  Fortunately there is a solution to this problem. By pre-processing the strings before output the correct glyphs can be generated. Here is a revised version of the program (the function **FNarabic** is listed later):\\ 
 +<code bb4w>
         VDU 23,22,640;512;8,16,16,128+8 : REM Select UTF-8 output         VDU 23,22,640;512;8,16,16,128+8 : REM Select UTF-8 output
         *FONT Times New Roman, 28         *FONT Times New Roman, 28
Line 23: Line 26:
         VDU 23,16,0;0;0;0;13 : REM Select left-to-right printing         VDU 23,16,0;0;0;0;13 : REM Select left-to-right printing
         END         END
 +</code>
 This is what is displayed:{{arabic2.gif}}\\  The correct cursive script has been produced.\\ \\  Here is the **FNarabic** function:\\  This is what is displayed:{{arabic2.gif}}\\  The correct cursive script has been produced.\\ \\  Here is the **FNarabic** function:\\ 
 +<code bb4w>
         DEF FNarabic(A$)         DEF FNarabic(A$)
         LOCAL A%, B%, O%, P%, U%, B$         LOCAL A%, B%, O%, P%, U%, B$
Line 55: Line 60:
         NEXT         NEXT
         = LEFT$(B$)         = LEFT$(B$)
 +</code>
outputting_20arabic_20text.1522502371.txt.gz · Last modified: 2024/01/05 00:17 (external edit)