3

In a given word, I want to show one or more Perso-Arabic letters with different formatting (e.g., different color, larger size, etc.). This breaks the combining characters though. In the 3 items below: 1) the word wrapped in a <Span/> and it displays correctly 2) The word's middle letter wrapped in a <Span/> and it displays correctly 3) The word's middle letter wrapped in a <Span/> with it's color changed to red - it does not display correctly

        <TextBlock xml:lang="fa-IR" Language="fa-IR" FontSize="60" FlowDirection="RightToLeft">
            <TextBlock.Inlines>
                <Span Foreground="Yellow">حال</Span>
                ح<Span>ا</Span>ل
                ح<Span Foreground="Red">ا</Span>ل
            </TextBlock.Inlines>
        </TextBlock>

The XAML I'm using is WP8 variant. Is there anyway around this issue to have formatting applied and not break combining characters?

Todd Main
  • 28,951
  • 11
  • 82
  • 146
  • Just as an additional note, this doesn't not happen with Latin letters, e.g. `health` works as expected. – Todd Main Feb 28 '14 at 17:00
  • If it's based on like SL xaml, it respects the linebreaks as spaces like it would in xml. Try putting the elements to be non-spaced on the same line. Although personally I'm not familiar with using SPAN in SL style xaml, more so instead opting for like instead. Worth a shot, and since I had no time to test, entered as comment instead of answer. – Chris W. Feb 28 '14 at 19:29
  • @ChrisW., everything on one line is exactly the same result. I've tried with Runs, Spans, everything in Runs/Spans, only formatted text in Runs/Spans, etc. Nothing works once formatting is set. For example `` (all on one line or each run on a separate line) **does not work**. `` **does work** however - the only difference is that I removed `Foreground="Red"` from the middle `` – Todd Main Feb 28 '14 at 19:47
  • Well that's interesting, I'll tinker with it later if I get some free time since now I'm curious. – Chris W. Feb 28 '14 at 21:19
  • Not an answer but, FWIW, this seems like a Silverlight specific issue. Your XAML seems to work fine with WPF but not in Silverlight (web) and WP. – keyboardP Mar 02 '14 at 17:36

1 Answers1

2

I'm afraid if there a complete solution, but as a workaround you can use 2 special Unicode characters. Use ARABIC TATWEEL character after ح and use ZERO WIDTH JOINER character after ا.

In HTML you should try this:

ح&#1600;<strong>ا&#8205;</strong>ل

You can try it here. For more info refer to Iranian national standards ISIRI 6219 and ISIRI 9147. You can also try asking question in Persian Computing Community.

Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
  • Good links, but solutions like coding my own ZWJ, ZWNJ, etc are not really an option. You'll see similar solutions like http://stackoverflow.com/questions/12886663/why-do-arabic-characters-behave-as-separate-characters-when-styling-single-arabi/, but having tried this, there is too much logic to consider in accounting for every scenario. – Todd Main Mar 02 '14 at 15:51
  • Yeah, you're right. But seems no real solution exists. Another workaround would be creating an engine for rendering characters instead of WPF/SL. Can not examine how many coding it may need. – Afshar Mohebi Mar 02 '14 at 15:54