🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #3599

Word wrapping RTL and LTR mixed scripts with Uniscribe

#3599
From: eric67
Date: Fri, 19 May 2006 18:20
51 lines
3228 bytes
I need a custom win32 component to display unicode text on both W9X 
and XP.
I've been working on a Uniscribe based component last week (using 
catch22.net tutorial and CSSamp from Microsoft SDK).
I've written from scratch a word wrapping algorithm (since CSSamp is 
buggy: it works only for LTR scripts)
Everything works fine but word wrapping on bidi RTL scripts (my 
algorithm actually works on simple LTR or RTL scripts: the problem is 
word wrapping on mixed RTL and LTR scripts).
Both TextOutW and Gdiplus::DrawString produce wrong output when word 
wrapping bidi RTL scripts.

I found a test page here:
http://people.w3.org/rishida/scripts/samples/wrapping.html

My component works fine on all LTR scripts and gives partially wrong 
results on the the arabic and hebrew scripts (actually it doesn't work 
when i need to wrap between two words of an embedded LTR script; 
everything works fine if embedded LTR scripts are one word long).

Uniscribe ScriptItemize breaks the arabic text  from the above test 
page into 9 items:
|ARABIC A|456|-|123|ARABIC B| (|global design|) |ARABIC C|
the Uniscribe bidi algorithm says that all uppercase items, <-> are 
RTL (numbers are LTR with RTL layout) while lowercase english  and the 
two brake items around and are LTR items

When word wrapping between "global" and "design" i get:
line 1: | global|) |ARABIC C|
line 2: |-|123|ARABIC B| (|design|
line 3: |ARABIC A||456|

I don't understand how to implement this logic in Uniscribe i.e.:
1) how to interpret valid break points using fSoftBreak and 
fWhiteSpace in SCRIPT_LOGATTR when this flags are set on LTR-RTL item 
boundaries
2) i've understand how to break an item to perform simple wrapping but 
i can't understand the reordering logic needed to get < global> and <) 
 > on the first line and < (> and <design> on the second (note that 
Explorer keeps the blank between global and design as the trailing 
blank - before global- on the first line!)

Is there any Unicode guru out there?
I need HELP!
Thanks in advance.

(I'm sorry for my latin english :-)

P.S.1 I don't understand why wrapping 456-123 on the hyphen in the 
arabic text behaves different from wrapping 123-456 in the hebrew 
text. On both 456 goes on new line and 123 stays over! Why?
Technical Details
Message-ID: <446e0c88$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5a52130f35794284,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "eric67" <myfantasy@libero.it>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Word wrapping RTL and LTR mixed scripts with Uniscribe
Date: Fri, 19 May 2006 20:20:56 +0200
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 217.56.76.227
Message-ID: <446e0c88$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1148062856 217.56.76.227 (19 May 2006 11:20:56 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail