PDA

View Full Version : fribidi integration (hebrew)



mack
2006-01-06, 20:43
Hi,

I'm trying to get hebrew tags displayed on my SB3. I followed the instructions ( http://wiki.slimdevices.com/index.cgi?UnicodeFonts ) and verified that the test files from the SVN show hebrew chars on the SB display.

However, there are two problems:
1. Hebrew strings are reversed.
2. Most hebrew tags are ASCII-hebrew rather than Unicode. Therefore, they still show as accented latin chars rather than hebrew.

Both problems are solved in other applications by using the fribidi library ( http://imagic.weizmann.ac.il/~dov/freesw/FriBidi/ ). Fribidi can convert between the various types of hebrew and reverse the necessary parts.

Has anyone tried integrating fribidi into slimserv ? A perl library exists ( http://imagic.weizmann.ac.il/~dov/freesw/FriBidi/FriBidi-0.04.tar.gz ) so it should be possible.

Mack

kdf
2006-01-06, 20:58
On 6-Jan-06, at 7:43 PM, mack wrote:
>
> Has anyone tried integrating fribidi into slimserv ? A perl library
> exists (
> http://imagic.weizmann.ac.il/~dov/freesw/FriBidi/FriBidi-0.04.tar.gz )
> so it should be possible.
>
it's been mentioned, but no one stepped up to do it. Feel like being
the first? ;)

http://forums.slimdevices.com/showthread.php?t=17733

-kdf

mack
2006-01-06, 22:02
On 6-Jan-06, at 7:43 PM, mack wrote:
>
> Has anyone tried integrating fribidi into slimserv ? A perl library
> exists (
> http://imagic.weizmann.ac.il/~dov/freesw/FriBidi/FriBidi-0.04.tar.gz )
> so it should be possible.
>
it's been mentioned, but no one stepped up to do it. Feel like being
the first? ;)

http://forums.slimdevices.com/showthread.php?t=17733

-kdf

Yes, I've been trying to do it myself but since I have no experience with perl (if only slimserv was python... :) I have little success.

I did solve the non-unicode hebrew issue by patching the server to convert the hebrew ascii range to unicode. (Thanks to a tip from another forum member). Now I get the hebrew tags displayed, just reversed.

I also tried to use fribidi from inside perl now (in order to reverse these strings), but the FriBidi perl module seems broken somehow, or at least not coexist with recent versions of libfribidi. Still trying to figure it out. Any perl-guru wants to help ?

Triode
2006-01-07, 04:19
I agree fribidi didn't work for me. We've been looking at CPAN Local::Hebrew.

Could someone post a file with a Hebrew tag and description of how it should look? [preferably two - one which would scroll on the display and one which would not..]

Triode
2006-01-07, 11:47
OK I have a file.

Could a Hebrew reader have a look at the two attachments?

Unflipped is prior to flipping the reversed text, flipped is the result with flipping.

Does the flipped one look right? The library puts the numbers at the right hand end if there are numeric characters prepended to the string - is this correct? [not that I can do anything about it!]

slim9p3@cfftechnologies.com
2006-01-07, 13:27
Attachment 632 looks correct to me.


What happens if there is a number in the middle of the Hebrew string and
what happens if English words are in the middle?


Avi


Triode wrote:

> OK I have a file.
>
> Could a Hebrew reader have a look at the two attachments?
>
> Unflipped is prior to flipping the reversed text, flipped is the result
> with flipping.
>
> Does the flipped one look right? The library puts the numbers at the
> right hand end if there are numeric characters prepended to the string
> - is this correct? [not that I can do anything about it!]
>
>
> +-------------------------------------------------------------------+
> |Filename: flipped.png |
> |Download: http://forums.slimdevices.com/attachment.php?attachmentid=632|
> +-------------------------------------------------------------------+
>
--
Avi Schwartz
http://public.xdi.org/=avi.schwartz

Triode
2006-01-07, 13:47
Thanks Avi - its good to confirm it is correct!

I think the library should handle all the cases OK as it looks for embedded strings within the string which should be reversed.

I will look to get this into 6.5...

mack
2006-01-07, 13:47
OK I have a file.

Could a Hebrew reader have a look at the two attachments?

Unflipped is prior to flipping the reversed text, flipped is the result with flipping.

Does the flipped one look right? The library puts the numbers at the right hand end if there are numeric characters prepended to the string - is this correct? [not that I can do anything about it!]

Yes, it looks great. And yes, the number should be on the right. Thats the start of the string in hebrew.

Note that if you use Locale::Hebrew, it only works well for unicode hebrew, whereas most tags are still ISO hebrew. Therefore, I wrote my own patch which handles both unicode hebrew and iso hebrew. (Thanks for the note about Locale::Hebrew - it solved my problem). I'm not a perl developer so my code probably sucks, but here it is anyway. I put it in Graphics.pm, at the beginning of String(). My code is between the "Mack" comments.

<code>
sub string {
my $fontname = shift || return '';
my $string = shift || return '';

# Mack
use Locale::Hebrew;
for my $ord (unpack('U*', $string)) {
# Convert ASCII Hebrew to Unicode Hebrew if required.
if ($ord > 223 && $ord < 251) {
require Encode;
$string = Encode::decode('iso-8859-8', $string);
last;
}
}
$string = hebrewflip($string);
# /Mack

my $bits = '';
</code>

(Sorry about lack of indentation. The forum seems to drop the tabs upon submitting).

This code seems to produce correct results in all files I checked. The manual test for ASCII hebrew was added because Encode::decode crashed on certain unicode strings.

Now, the only problem I failed to solve is the scrolling. When a long hebrew string needs scrolling, it should start by showing the rightmost part of the string first, and scroll towards the leftmost part of the string. I can't find the part that controls scrolling. Is it handled by the firmware itself ? Any way to change the scrolling behavior as described here ?

Thanks,
Mack

Triode
2006-01-07, 14:11
Thanks Mack,

I'm also planning some changes to the scrolling code to allow it to go backwards. Are you availble for offline email discussion on how things look - if so PM me.

Adrian

mack
2006-01-07, 14:44
Thanks Mack,

I'm also planning some changes to the scrolling code to allow it to go backwards. Are you availble for offline email discussion on how things look - if so PM me.

Adrian

OK, sent you a PM.

ganjastone
2006-01-07, 17:51
I'm messing with the same code at the moment to achieve the same goal (Hebrew). If you need help or assistance, please send me PM too.

Avi