(root)/
fribidi-1.0.13/
lib/
fribidi-bidi.h
       1  /* FriBidi
       2   * fribidi-bidi.h - bidirectional algorithm
       3   *
       4   * Authors:
       5   *   Behdad Esfahbod, 2001, 2002, 2004
       6   *   Dov Grobgeld, 1999, 2000
       7   *
       8   * Copyright (C) 2004 Sharif FarsiWeb, Inc
       9   * Copyright (C) 2001,2002 Behdad Esfahbod
      10   * Copyright (C) 1999,2000 Dov Grobgeld
      11   * 
      12   * This library is free software; you can redistribute it and/or
      13   * modify it under the terms of the GNU Lesser General Public
      14   * License as published by the Free Software Foundation; either
      15   * version 2.1 of the License, or (at your option) any later version.
      16   * 
      17   * This library is distributed in the hope that it will be useful,
      18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
      19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      20   * Lesser General Public License for more details.
      21   * 
      22   * You should have received a copy of the GNU Lesser General Public License
      23   * along with this library, in a file named COPYING; if not, write to the
      24   * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      25   * Boston, MA 02110-1301, USA
      26   * 
      27   * For licensing issues, contact <fribidi.license@gmail.com>.
      28   */
      29  #ifndef _FRIBIDI_BIDI_H
      30  #define _FRIBIDI_BIDI_H
      31  
      32  #include "fribidi-common.h"
      33  
      34  #include "fribidi-types.h"
      35  #include "fribidi-flags.h"
      36  #include "fribidi-bidi-types.h"
      37  
      38  #include "fribidi-begindecls.h"
      39  
      40  /* fribidi_get_par_direction - get base paragraph direction
      41   *
      42   * This function finds the base direction of a single paragraph,
      43   * as defined by rule P2 of the Unicode Bidirectional Algorithm available at
      44   * http://www.unicode.org/reports/tr9/#P2.
      45   *
      46   * You typically do not need this function as
      47   * fribidi_get_par_embedding_levels() knows how to compute base direction
      48   * itself, but you may need this to implement a more sophisticated paragraph
      49   * direction handling.  Note that you can pass more than a paragraph to this
      50   * function and the direction of the first non-neutral paragraph is returned,
      51   * which is a very good heuristic to set direction of the neutral paragraphs
      52   * at the beginning of text.  For other neutral paragraphs, you better use the
      53   * direction of the previous paragraph.
      54   *
      55   * Returns: Base pargraph direction.  No weak paragraph direction is returned,
      56   * only LTR, RTL, or ON.
      57   */
      58  FRIBIDI_ENTRY FriBidiParType fribidi_get_par_direction (
      59    const FriBidiCharType *bidi_types,	/* input list of bidi types as returned by
      60  					   fribidi_get_bidi_types() */
      61    const FriBidiStrIndex len	/* input string length */
      62  );
      63  
      64  /* fribidi_get_par_embedding_levels_ex - get bidi embedding levels of a paragraph
      65   *
      66   * This function finds the bidi embedding levels of a single paragraph,
      67   * as defined by the Unicode Bidirectional Algorithm available at
      68   * http://www.unicode.org/reports/tr9/.  This function implements rules P2 to
      69   * I1 inclusive, and parts 1 to 3 of L1, except for rule X9 which is
      70   *  implemented in fribidi_remove_bidi_marks().  Part 4 of L1 is implemented
      71   *  in fribidi_reorder_line().
      72   *
      73   * There are a few macros defined in fribidi-bidi-types.h to work with this
      74   * embedding levels.
      75   *
      76   * Returns: Maximum level found plus one, or zero if any error occurred
      77   * (memory allocation failure most probably).
      78   */
      79  FRIBIDI_ENTRY FriBidiLevel
      80  fribidi_get_par_embedding_levels_ex (
      81    const FriBidiCharType *bidi_types,	/* input list of bidi types as returned by
      82  					   fribidi_get_bidi_types() */
      83    const FriBidiBracketType *bracket_types,	/* input list of bracket types as returned by
      84  					   fribidi_get_bracket_types() */
      85    const FriBidiStrIndex len,	/* input string length of the paragraph */
      86    FriBidiParType *pbase_dir,	/* requested and resolved paragraph
      87  				 * base direction */
      88    FriBidiLevel *embedding_levels	/* output list of embedding levels */
      89  ) FRIBIDI_GNUC_WARN_UNUSED;
      90  
      91  /* fribidi_reorder_line - reorder a line of logical string to visual
      92   *
      93   * This function reorders the characters in a line of text from logical to
      94   * final visual order.  This function implements part 4 of rule L1, and rules
      95   * L2 and L3 of the Unicode Bidirectional Algorithm available at
      96   * http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels.
      97   *
      98   * As a side effect it also sets position maps if not NULL.
      99   *
     100   * You should provide the resolved paragraph direction and embedding levels as
     101   * set by fribidi_get_par_embedding_levels().  Also note that the embedding
     102   * levels may change a bit.  To be exact, the embedding level of any sequence
     103   * of white space at the end of line is reset to the paragraph embedding level
     104   * (That is part 4 of rule L1).
     105   *
     106   * Note that the bidi types and embedding levels are not reordered.  You can
     107   * reorder these (or any other) arrays using the map later.  The user is
     108   * responsible to initialize map to something sensible, like an identity
     109   * mapping, or pass NULL if no map is needed.
     110   *
     111   * There is an optional part to this function, which is whether non-spacing
     112   * marks for right-to-left parts of the text should be reordered to come after
     113   * their base characters in the visual string or not.  Most rendering engines
     114   * expect this behavior, but console-based systems for example do not like it.
     115   * This is controlled by the FRIBIDI_FLAG_REORDER_NSM flag.  The flag is on
     116   * in FRIBIDI_FLAGS_DEFAULT.
     117   *
     118   * Returns: Maximum level found in this line plus one, or zero if any error
     119   * occurred (memory allocation failure most probably).
     120   */
     121  FRIBIDI_ENTRY FriBidiLevel fribidi_reorder_line (
     122    FriBidiFlags flags, /* reorder flags */
     123    const FriBidiCharType *bidi_types,	/* input list of bidi types as returned by
     124  					   fribidi_get_bidi_types() */
     125    const FriBidiStrIndex len,	/* input length of the line */
     126    const FriBidiStrIndex off,	/* input offset of the beginning of the line
     127  				   in the paragraph */
     128    const FriBidiParType base_dir,	/* resolved paragraph base direction */
     129    FriBidiLevel *embedding_levels,	/* input list of embedding levels,
     130  					   as returned by
     131  					   fribidi_get_par_embedding_levels */
     132    FriBidiChar *visual_str,	/* visual string to reorder */
     133    FriBidiStrIndex *map		/* a map of string indices which is reordered
     134  				 * to reflect where each glyph ends up. */
     135  ) FRIBIDI_GNUC_WARN_UNUSED;
     136  
     137  #include "fribidi-enddecls.h"
     138  
     139  #endif /* !_FRIBIDI_BIDI_H */
     140  /* Editor directions:
     141   * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
     142   */