os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/ushape.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
******************************************************************************
sl@0
     3
*
sl@0
     4
*   Copyright (C) 2000-2004, International Business Machines
sl@0
     5
*   Corporation and others.  All Rights Reserved.
sl@0
     6
*
sl@0
     7
******************************************************************************
sl@0
     8
*   file name:  ushape.h
sl@0
     9
*   encoding:   US-ASCII
sl@0
    10
*   tab size:   8 (not used)
sl@0
    11
*   indentation:4
sl@0
    12
*
sl@0
    13
*   created on: 2000jun29
sl@0
    14
*   created by: Markus W. Scherer
sl@0
    15
*/
sl@0
    16
sl@0
    17
#ifndef __USHAPE_H__
sl@0
    18
#define __USHAPE_H__
sl@0
    19
sl@0
    20
#include "unicode/utypes.h"
sl@0
    21
sl@0
    22
/**
sl@0
    23
 * \file
sl@0
    24
 * \brief C API:  Arabic shaping
sl@0
    25
 * 
sl@0
    26
 */
sl@0
    27
sl@0
    28
/**
sl@0
    29
 * Shape Arabic text on a character basis.
sl@0
    30
 *
sl@0
    31
 * <p>This function performs basic operations for "shaping" Arabic text. It is most
sl@0
    32
 * useful for use with legacy data formats and legacy display technology
sl@0
    33
 * (simple terminals). All operations are performed on Unicode characters.</p>
sl@0
    34
 *
sl@0
    35
 * <p>Text-based shaping means that some character code points in the text are
sl@0
    36
 * replaced by others depending on the context. It transforms one kind of text
sl@0
    37
 * into another. In comparison, modern displays for Arabic text select
sl@0
    38
 * appropriate, context-dependent font glyphs for each text element, which means
sl@0
    39
 * that they transform text into a glyph vector.</p>
sl@0
    40
 *
sl@0
    41
 * <p>Text transformations are necessary when modern display technology is not
sl@0
    42
 * available or when text needs to be transformed to or from legacy formats that
sl@0
    43
 * use "shaped" characters. Since the Arabic script is cursive, connecting
sl@0
    44
 * adjacent letters to each other, computers select images for each letter based
sl@0
    45
 * on the surrounding letters. This usually results in four images per Arabic
sl@0
    46
 * letter: initial, middle, final, and isolated forms. In Unicode, on the other
sl@0
    47
 * hand, letters are normally stored abstract, and a display system is expected
sl@0
    48
 * to select the necessary glyphs. (This makes searching and other text
sl@0
    49
 * processing easier because the same letter has only one code.) It is possible
sl@0
    50
 * to mimic this with text transformations because there are characters in
sl@0
    51
 * Unicode that are rendered as letters with a specific shape
sl@0
    52
 * (or cursive connectivity). They were included for interoperability with
sl@0
    53
 * legacy systems and codepages, and for unsophisticated display systems.</p>
sl@0
    54
 *
sl@0
    55
 * <p>A second kind of text transformations is supported for Arabic digits:
sl@0
    56
 * For compatibility with legacy codepages that only include European digits,
sl@0
    57
 * it is possible to replace one set of digits by another, changing the
sl@0
    58
 * character code points. These operations can be performed for either
sl@0
    59
 * Arabic-Indic Digits (U+0660...U+0669) or Eastern (Extended) Arabic-Indic
sl@0
    60
 * digits (U+06f0...U+06f9).</p>
sl@0
    61
 *
sl@0
    62
 * <p>Some replacements may result in more or fewer characters (code points).
sl@0
    63
 * By default, this means that the destination buffer may receive text with a
sl@0
    64
 * length different from the source length. Some legacy systems rely on the
sl@0
    65
 * length of the text to be constant. They expect extra spaces to be added
sl@0
    66
 * or consumed either next to the affected character or at the end of the
sl@0
    67
 * text.</p>
sl@0
    68
 *
sl@0
    69
 * <p>For details about the available operations, see the description of the
sl@0
    70
 * <code>U_SHAPE_...</code> options.</p>
sl@0
    71
 *
sl@0
    72
 * @param source The input text.
sl@0
    73
 *
sl@0
    74
 * @param sourceLength The number of UChars in <code>source</code>.
sl@0
    75
 *
sl@0
    76
 * @param dest The destination buffer that will receive the results of the
sl@0
    77
 *             requested operations. It may be <code>NULL</code> only if
sl@0
    78
 *             <code>destSize</code> is 0. The source and destination must not
sl@0
    79
 *             overlap.
sl@0
    80
 *
sl@0
    81
 * @param destSize The size (capacity) of the destination buffer in UChars.
sl@0
    82
 *                 If <code>destSize</code> is 0, then no output is produced,
sl@0
    83
 *                 but the necessary buffer size is returned ("preflighting").
sl@0
    84
 *
sl@0
    85
 * @param options This is a 32-bit set of flags that specify the operations
sl@0
    86
 *                that are performed on the input text. If no error occurs,
sl@0
    87
 *                then the result will always be written to the destination
sl@0
    88
 *                buffer.
sl@0
    89
 *
sl@0
    90
 * @param pErrorCode must be a valid pointer to an error code value,
sl@0
    91
 *        which must not indicate a failure before the function call.
sl@0
    92
 *
sl@0
    93
 * @return The number of UChars written to the destination buffer.
sl@0
    94
 *         If an error occured, then no output was written, or it may be
sl@0
    95
 *         incomplete. If <code>U_BUFFER_OVERFLOW_ERROR</code> is set, then
sl@0
    96
 *         the return value indicates the necessary destination buffer size.
sl@0
    97
 * @stable ICU 2.0
sl@0
    98
 */
sl@0
    99
U_STABLE int32_t U_EXPORT2
sl@0
   100
u_shapeArabic(const UChar *source, int32_t sourceLength,
sl@0
   101
              UChar *dest, int32_t destSize,
sl@0
   102
              uint32_t options,
sl@0
   103
              UErrorCode *pErrorCode);
sl@0
   104
sl@0
   105
/**
sl@0
   106
 * Memory option: allow the result to have a different length than the source.
sl@0
   107
 * @stable ICU 2.0
sl@0
   108
 */
sl@0
   109
#define U_SHAPE_LENGTH_GROW_SHRINK              0
sl@0
   110
sl@0
   111
/**
sl@0
   112
 * Memory option: the result must have the same length as the source.
sl@0
   113
 * If more room is necessary, then try to consume spaces next to modified characters.
sl@0
   114
 * @stable ICU 2.0
sl@0
   115
 */
sl@0
   116
#define U_SHAPE_LENGTH_FIXED_SPACES_NEAR        1
sl@0
   117
sl@0
   118
/**
sl@0
   119
 * Memory option: the result must have the same length as the source.
sl@0
   120
 * If more room is necessary, then try to consume spaces at the end of the text.
sl@0
   121
 * @stable ICU 2.0
sl@0
   122
 */
sl@0
   123
#define U_SHAPE_LENGTH_FIXED_SPACES_AT_END      2
sl@0
   124
sl@0
   125
/**
sl@0
   126
 * Memory option: the result must have the same length as the source.
sl@0
   127
 * If more room is necessary, then try to consume spaces at the beginning of the text.
sl@0
   128
 * @stable ICU 2.0
sl@0
   129
 */
sl@0
   130
#define U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING 3
sl@0
   131
sl@0
   132
/** Bit mask for memory options. @stable ICU 2.0 */
sl@0
   133
#define U_SHAPE_LENGTH_MASK                     3
sl@0
   134
sl@0
   135
sl@0
   136
/** Direction indicator: the source is in logical (keyboard) order. @stable ICU 2.0 */
sl@0
   137
#define U_SHAPE_TEXT_DIRECTION_LOGICAL          0
sl@0
   138
sl@0
   139
/**
sl@0
   140
 * Direction indicator:
sl@0
   141
 * the source is in visual LTR order,
sl@0
   142
 * the leftmost displayed character stored first.
sl@0
   143
 * @stable ICU 2.0
sl@0
   144
 */
sl@0
   145
#define U_SHAPE_TEXT_DIRECTION_VISUAL_LTR       4
sl@0
   146
sl@0
   147
/** Bit mask for direction indicators. @stable ICU 2.0 */
sl@0
   148
#define U_SHAPE_TEXT_DIRECTION_MASK             4
sl@0
   149
sl@0
   150
sl@0
   151
/** Letter shaping option: do not perform letter shaping. @stable ICU 2.0 */
sl@0
   152
#define U_SHAPE_LETTERS_NOOP                    0
sl@0
   153
sl@0
   154
/** Letter shaping option: replace abstract letter characters by "shaped" ones. @stable ICU 2.0 */
sl@0
   155
#define U_SHAPE_LETTERS_SHAPE                   8
sl@0
   156
sl@0
   157
/** Letter shaping option: replace "shaped" letter characters by abstract ones. @stable ICU 2.0 */
sl@0
   158
#define U_SHAPE_LETTERS_UNSHAPE                 0x10
sl@0
   159
sl@0
   160
/**
sl@0
   161
 * Letter shaping option: replace abstract letter characters by "shaped" ones.
sl@0
   162
 * The only difference with U_SHAPE_LETTERS_SHAPE is that Tashkeel letters
sl@0
   163
 * are always "shaped" into the isolated form instead of the medial form
sl@0
   164
 * (selecting code points from the Arabic Presentation Forms-B block).
sl@0
   165
 * @stable ICU 2.0
sl@0
   166
 */
sl@0
   167
#define U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED 0x18
sl@0
   168
sl@0
   169
/** Bit mask for letter shaping options. @stable ICU 2.0 */
sl@0
   170
#define U_SHAPE_LETTERS_MASK                    0x18
sl@0
   171
sl@0
   172
sl@0
   173
/** Digit shaping option: do not perform digit shaping. @stable ICU 2.0 */
sl@0
   174
#define U_SHAPE_DIGITS_NOOP                     0
sl@0
   175
sl@0
   176
/**
sl@0
   177
 * Digit shaping option:
sl@0
   178
 * Replace European digits (U+0030...) by Arabic-Indic digits.
sl@0
   179
 * @stable ICU 2.0
sl@0
   180
 */
sl@0
   181
#define U_SHAPE_DIGITS_EN2AN                    0x20
sl@0
   182
sl@0
   183
/**
sl@0
   184
 * Digit shaping option:
sl@0
   185
 * Replace Arabic-Indic digits by European digits (U+0030...).
sl@0
   186
 * @stable ICU 2.0
sl@0
   187
 */
sl@0
   188
#define U_SHAPE_DIGITS_AN2EN                    0x40
sl@0
   189
sl@0
   190
/**
sl@0
   191
 * Digit shaping option:
sl@0
   192
 * Replace European digits (U+0030...) by Arabic-Indic digits if the most recent
sl@0
   193
 * strongly directional character is an Arabic letter
sl@0
   194
 * (<code>u_charDirection()</code> result <code>U_RIGHT_TO_LEFT_ARABIC</code> [AL]).<br>
sl@0
   195
 * The direction of "preceding" depends on the direction indicator option.
sl@0
   196
 * For the first characters, the preceding strongly directional character
sl@0
   197
 * (initial state) is assumed to be not an Arabic letter
sl@0
   198
 * (it is <code>U_LEFT_TO_RIGHT</code> [L] or <code>U_RIGHT_TO_LEFT</code> [R]).
sl@0
   199
 * @stable ICU 2.0
sl@0
   200
 */
sl@0
   201
#define U_SHAPE_DIGITS_ALEN2AN_INIT_LR          0x60
sl@0
   202
sl@0
   203
/**
sl@0
   204
 * Digit shaping option:
sl@0
   205
 * Replace European digits (U+0030...) by Arabic-Indic digits if the most recent
sl@0
   206
 * strongly directional character is an Arabic letter
sl@0
   207
 * (<code>u_charDirection()</code> result <code>U_RIGHT_TO_LEFT_ARABIC</code> [AL]).<br>
sl@0
   208
 * The direction of "preceding" depends on the direction indicator option.
sl@0
   209
 * For the first characters, the preceding strongly directional character
sl@0
   210
 * (initial state) is assumed to be an Arabic letter.
sl@0
   211
 * @stable ICU 2.0
sl@0
   212
 */
sl@0
   213
#define U_SHAPE_DIGITS_ALEN2AN_INIT_AL          0x80
sl@0
   214
sl@0
   215
/** Not a valid option value. May be replaced by a new option. @stable ICU 2.0 */
sl@0
   216
#define U_SHAPE_DIGITS_RESERVED                 0xa0
sl@0
   217
sl@0
   218
/** Bit mask for digit shaping options. @stable ICU 2.0 */
sl@0
   219
#define U_SHAPE_DIGITS_MASK                     0xe0
sl@0
   220
sl@0
   221
sl@0
   222
/** Digit type option: Use Arabic-Indic digits (U+0660...U+0669). @stable ICU 2.0 */
sl@0
   223
#define U_SHAPE_DIGIT_TYPE_AN                   0
sl@0
   224
sl@0
   225
/** Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9). @stable ICU 2.0 */
sl@0
   226
#define U_SHAPE_DIGIT_TYPE_AN_EXTENDED          0x100
sl@0
   227
sl@0
   228
/** Not a valid option value. May be replaced by a new option. @stable ICU 2.0 */
sl@0
   229
#define U_SHAPE_DIGIT_TYPE_RESERVED             0x200
sl@0
   230
sl@0
   231
/** Bit mask for digit type options. @stable ICU 2.0 */
sl@0
   232
#define U_SHAPE_DIGIT_TYPE_MASK                 0x3f00
sl@0
   233
sl@0
   234
#endif