FriBidi's rendering pipeline (was Re: [FriBidi] what encoding? where are the docs?)

Behdad Esfahbod behdad at cs.toronto.edu
Tue Sep 20 20:26:37 PDT 2005


On Tue, 20 Sep 2005, Shachar Shemesh wrote:

> A while back we discussed a change in the interface, where labeling the
> characters would be a different pass than reordering them. We also
> discussed doing it in such a way that the reordering algorithm can work
> directly with any width characters, transparently.

Hi Shachar,

The code in fribidi2 module already separates many things, now
you would do:

=========================

  /* analyze */
  fribidi_get_bidi_types
  fribidi_get_par_embedding_levels

  /* shape */
  fribidi_get_joining_types
  fribidi_join_arabic
  fribidi_shape

  break lines

  /* reorder */
  fribidi_reorder_line

=========================

To draw the pipeline:

  in:paragraph_characters[]  in:par_base_dir
        |			|
,-------+-----------------------|---------------.
|	|			|		|
|	v			|		v
|  fribidi_get_bidi_types()	|   fribidi_get_joining_types()
|	|			|		|
|  bidi_types[]			|	  joining_types[]
|	|			|		|
|	|			|		|
|	+-----------------------|-------+-------|-------.
|	|			|	|	|	|
|	v			v	|	|	|
|  fribidi_get_par_embedding_levels()	|	|	|
|	|			|	|	|	|
|	|    out:resolved_par_base_dir	|	|	|
|	|				|	|	|
|	v				|	|	|
|  [embedding_levels]			|	|	|
|	|				|	|	|
|	+---------------+-------.	|	|	|
|	|		|	|	|	|	|
|	|		|	v	v	v	|
|	|		|      fribidi_join_arabic()	|
|	|		|		|		|
|	|		|	 arabic_props[]		|
|	|		|		|		|
'---.	|   ,-----(under|construction)--'		|
    |	|   |		|				|
    v	v   v		|	,-----------------------'
  fribidi_shape()	|	|
	|		|	|
  glyph_characters[]	|	|
	|		|	|
	|		|	|
	v		|	|
   break_lines()	|	|
	|		|	|
   line_glyphs[][]	|	|
	|		|	|
	|	,-------'	|
	|	|		|
	|	|	,-------'
	|	|	|
      (loop over each line)
	|	|	|
	v	v	v
      fribidi_reorder_line()
	|	|	|
	|	|	|
	|  out:LtoV[] out:VtoL[]
	|
out:visual_line_glyphs[]



The whole Arabic part is optional, needless to say.  The good
thing about this very low-level and verbose API is that you have
full control over the data flow and can change data in the middle
steps, if need be.  For example, after getting the bidi types,
you can go on and change the types for new line characters to
make them line breaks, and two consecutive new line characters
paragraph separators.  I would like to make a few changes though:
I like to make mirroring verbose too, such that you call
fribidi_get_mirroring on the str and pass the result to
fribidi_shape, but I'm not sure it's a good idea, since what a
hypothetical fribidi_get_mirroring returns, practically replaces
the original string.  In other words, mirroring is really part of
the shaping process itself. I'm not sure whether a convenience
layer on top to hide most of the details is a good idea.  The
important point about this API is that you never need to loop
over the string yourself, all loopings is done in FriBidi
functions.


So, what do people think?  Does it make sense?


> While we are on the subject, what about line breaks? I'm not sure what
> the proper way to do line breaks should be. Off the top of my head, we
> would like to assign the BiDi levels to each character, then perform
> line breaks, and then reorder each line accoridng to the precalculated
> levels. I have not run any test to see how well this algorithm lives up
> to the real world.
>
> Ideas?

Basically, yes, that's true.  We are actually working on it to
make it more explicit in the bidi spec.


>           Shachar

--behdad
http://behdad.org/


More information about the fribidi mailing list