Tizen(Headless) Native API
6.0
|
Ushape module provides Arabic shaping functionality.
Required Header
#include <utils_i18n.h>
Overview
Ushape module provides Arabic shaping functionality.
Functions | |
int | i18n_ushape_shape_arabic (const i18n_uchar *source, int32_t source_len, uint32_t options, int32_t dest_size, i18n_uchar *dest, int32_t *dest_len) |
Shapes Arabic text on a character basis. | |
Defines | |
#define | I18N_USHAPE_LENGTH_GROW_SHRINK 0 |
Memory option: allow the result to have a different length than the source. | |
#define | I18N_USHAPE_LAMALEF_RESIZE 0 |
Memory option: allow the result to have a different length than the source. | |
#define | I18N_USHAPE_LENGTH_FIXED_SPACES_NEAR 1 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_LAMALEF_NEAR 1 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_LENGTH_FIXED_SPACES_AT_END 2 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_LAMALEF_END 2 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING 3 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_LAMALEF_BEGIN 3 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_LAMALEF_AUTO 0x10000 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_LENGTH_MASK 0x10003 |
Bit mask for memory options. | |
#define | I18N_USHAPE_LAMALEF_MASK 0x10003 |
Bit mask for LamAlef memory options. | |
#define | I18N_USHAPE_TEXT_DIRECTION_LOGICAL 0 |
Direction indicator: the source is in logical (keyboard) order. | |
#define | I18N_USHAPE_TEXT_DIRECTION_VISUAL_RTL 0 |
Direction indicator: the source is in visual RTL order, the rightmost displayed character stored first. | |
#define | I18N_USHAPE_TEXT_DIRECTION_VISUAL_LTR 4 |
Direction indicator: the source is in visual LTR order, the leftmost displayed character stored first. | |
#define | I18N_USHAPE_TEXT_DIRECTION_MASK 4 |
Bit mask for direction indicators. | |
#define | I18N_USHAPE_LETTERS_NOOP 0 |
Letter shaping option: do not perform letter shaping. | |
#define | I18N_USHAPE_LETTERS_SHAPE 8 |
Letter shaping option: replace abstract letter characters by "shaped" ones. | |
#define | I18N_USHAPE_LETTERS_UNSHAPE 0x10 |
Letter shaping option: replace "shaped" letter characters by abstract ones. | |
#define | I18N_USHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED 0x18 |
Letter shaping option: replace abstract letter characters by "shaped" ones. | |
#define | I18N_USHAPE_LETTERS_MASK 0x18 |
Bit mask for letter shaping options. | |
#define | I18N_USHAPE_DIGITS_NOOP 0 |
Digit shaping option: do not perform digit shaping. | |
#define | I18N_USHAPE_DIGITS_EN2AN 0x20 |
Digit shaping option: replace European digits (U+0030...) by Arabic-Indic digits. | |
#define | I18N_USHAPE_DIGITS_AN2EN 0x40 |
Digit shaping option: replace Arabic-Indic digits by European digits (U+0030...). | |
#define | I18N_USHAPE_DIGITS_ALEN2AN_INIT_LR 0x60 |
Digit shaping option: replace European digits (U+0030...) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter. | |
#define | I18N_USHAPE_DIGITS_ALEN2AN_INIT_AL 0x80 |
Digit shaping option: replace European digits (U+0030...) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter. | |
#define | I18N_USHAPE_DIGITS_RESERVED 0xa0 |
Not a valid option value. May be replaced by a new option. | |
#define | I18N_USHAPE_DIGITS_MASK 0xe0 |
Bit mask for digit shaping options. | |
#define | I18N_USHAPE_DIGIT_TYPE_AN 0 |
Digit type option: Use Arabic-Indic digits (U+0660...U+0669). | |
#define | I18N_USHAPE_DIGIT_TYPE_AN_EXTENDED 0x100 |
Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9). | |
#define | I18N_USHAPE_DIGIT_TYPE_RESERVED 0x200 |
Not a valid option value. May be replaced by a new option. | |
#define | I18N_USHAPE_DIGIT_TYPE_MASK 0x300 |
Bit mask for digit type options. | |
#define | I18N_USHAPE_AGGREGATE_TASHKEEL 0x4000 |
Tashkeel aggregation option: replace any combination of U+0651 with one of U+064C, U+064D, U+064E, U+064F, U+0650 with U+FC5E, U+FC5F, U+FC60, U+FC61, U+FC62 consecutively. | |
#define | I18N_USHAPE_AGGREGATE_TASHKEEL_NOOP 0 |
Tashkeel aggregation option: do not aggregate tashkeels. | |
#define | I18N_USHAPE_AGGREGATE_TASHKEEL_MASK 0x4000 |
Bit mask for tashkeel aggregation. | |
#define | I18N_USHAPE_PRESERVE_PRESENTATION 0x8000 |
Presentation form option: don't replace Arabic Presentation Forms-A and Arabic Presentation Forms-B characters with 0+06xx characters, before shaping. | |
#define | I18N_USHAPE_PRESERVE_PRESENTATION_NOOP 0 |
Presentation form option: replace Arabic Presentation Forms-A and Arabic Presentationo Forms-B with their unshaped correspondants in range 0+06xx, before shaping. | |
#define | I18N_USHAPE_PRESERVE_PRESENTATION_MASK 0x8000 |
Bit mask for preserve presentation form. | |
#define | I18N_USHAPE_SEEN_TWOCELL_NEAR 0x200000 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_SEEN_MASK 0x700000 |
Bit mask for Seen memory options. | |
#define | I18N_USHAPE_YEHHAMZA_TWOCELL_NEAR 0x1000000 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_YEHHAMZA_MASK 0x3800000 |
Bit mask for YehHamza memory options. | |
#define | I18N_USHAPE_TASHKEEL_BEGIN 0x40000 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_TASHKEEL_END 0x60000 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_TASHKEEL_RESIZE 0x80000 |
Memory option: allow the result to have a different length than the source. | |
#define | I18N_USHAPE_TASHKEEL_REPLACE_BY_TATWEEL 0xC0000 |
Memory option: the result must have the same length as the source. | |
#define | I18N_USHAPE_TASHKEEL_MASK 0xE0000 |
Bit mask for Tashkeel replacement with Space or Tatweel memory options. | |
#define | I18N_USHAPE_SPACES_RELATIVE_TO_TEXT_BEGIN_END 0x4000000 |
This option affect the meaning of BEGIN and END options. | |
#define | I18N_USHAPE_SPACES_RELATIVE_TO_TEXT_MASK 0x4000000 |
Bit mask for swapping BEGIN and END for Visual LTR text. | |
#define | I18N_USHAPE_TAIL_NEW_UNICODE 0x8000000 |
If this option is used, shaping will use the new Unicode code point for TAIL (i.e. 0xFE73). | |
#define | I18N_USHAPE_TAIL_TYPE_MASK 0x8000000 |
Bit mask for new Unicode Tail option. |
Define Documentation
#define I18N_USHAPE_AGGREGATE_TASHKEEL 0x4000 |
Tashkeel aggregation option: replace any combination of U+0651 with one of U+064C, U+064D, U+064E, U+064F, U+0650 with U+FC5E, U+FC5F, U+FC60, U+FC61, U+FC62 consecutively.
- Since :
- 3.0
#define I18N_USHAPE_AGGREGATE_TASHKEEL_MASK 0x4000 |
Bit mask for tashkeel aggregation.
- Since :
- 3.0
#define I18N_USHAPE_AGGREGATE_TASHKEEL_NOOP 0 |
Tashkeel aggregation option: do not aggregate tashkeels.
- Since :
- 3.0
#define I18N_USHAPE_DIGIT_TYPE_AN 0 |
Digit type option: Use Arabic-Indic digits (U+0660...U+0669).
- Since :
- 3.0
#define I18N_USHAPE_DIGIT_TYPE_AN_EXTENDED 0x100 |
Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).
- Since :
- 3.0
#define I18N_USHAPE_DIGIT_TYPE_MASK 0x300 |
Bit mask for digit type options.
- Since :
- 3.0
#define I18N_USHAPE_DIGIT_TYPE_RESERVED 0x200 |
Not a valid option value. May be replaced by a new option.
- Since :
- 3.0
#define I18N_USHAPE_DIGITS_ALEN2AN_INIT_AL 0x80 |
Digit shaping option: replace European digits (U+0030...) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter.
The direction of "preceding" depends on the direction indicator option. For the first characters, the preceding strongly directional character (initial state) is assumed to be an Arabic letter.
- Since :
- 3.0
#define I18N_USHAPE_DIGITS_ALEN2AN_INIT_LR 0x60 |
Digit shaping option: replace European digits (U+0030...) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter.
The direction of "preceding" depends on the direction indicator option. For the first characters, the preceding strongly directional character (initial state) is assumed to be not an Arabic letter (it is I18N_UCHAR_U_LEFT_TO_RIGHT [L] or I18N_UCHAR_U_RIGHT_TO_LEFT [R]).
- Since :
- 3.0
#define I18N_USHAPE_DIGITS_AN2EN 0x40 |
Digit shaping option: replace Arabic-Indic digits by European digits (U+0030...).
- Since :
- 3.0
#define I18N_USHAPE_DIGITS_EN2AN 0x20 |
Digit shaping option: replace European digits (U+0030...) by Arabic-Indic digits.
- Since :
- 3.0
#define I18N_USHAPE_DIGITS_MASK 0xe0 |
Bit mask for digit shaping options.
- Since :
- 3.0
#define I18N_USHAPE_DIGITS_NOOP 0 |
Digit shaping option: do not perform digit shaping.
- Since :
- 3.0
#define I18N_USHAPE_DIGITS_RESERVED 0xa0 |
Not a valid option value. May be replaced by a new option.
- Since :
- 3.0
#define I18N_USHAPE_LAMALEF_AUTO 0x10000 |
Memory option: the result must have the same length as the source.
Shaping Mode: For each LAMALEF character found, expand LAMALEF using space at end. If there is no space at end, use spaces at beginning of the buffer. If there is no space at beginning of the buffer, use spaces at the near (i.e. the space after the LAMALEF character). If there are no spaces found, an I18N_ERROR_NO_SPACE_AVAILABLE error will be returned by the i18n_ushape_shape_arabic() function.
Deshaping Mode: Perform the same function as the flag equals I18N_USHAPE_LAMALEF_END.
Affects: LamAlef options
- Since :
- 3.0
#define I18N_USHAPE_LAMALEF_BEGIN 3 |
Memory option: the result must have the same length as the source.
If more room is necessary, then try to consume spaces at the beginning of the text.
Affects: LamAlef options
This option is an alias to I18N_USHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING.
- Since :
- 3.0
#define I18N_USHAPE_LAMALEF_END 2 |
Memory option: the result must have the same length as the source.
If more room is necessary, then try to consume spaces at the end of the text.
Affects: LamAlef options
This option is an alias to I18N_USHAPE_LENGTH_FIXED_SPACES_AT_END.
- Since :
- 3.0
#define I18N_USHAPE_LAMALEF_MASK 0x10003 |
Bit mask for LamAlef memory options.
- Since :
- 3.0
#define I18N_USHAPE_LAMALEF_NEAR 1 |
Memory option: the result must have the same length as the source.
If more room is necessary, then try to consume spaces next to modified characters.
Affects: LamAlef options
This option is an alias to I18N_USHAPE_LENGTH_FIXED_SPACES_NEAR.
- Since :
- 3.0
#define I18N_USHAPE_LAMALEF_RESIZE 0 |
Memory option: allow the result to have a different length than the source.
Affects: LamAlef options
This option is an alias to I18N_USHAPE_LENGTH_GROW_SHRINK.
- Since :
- 3.0
Memory option: the result must have the same length as the source.
If more room is necessary, then try to consume spaces at the beginning of the text.
- Since :
- 3.0
#define I18N_USHAPE_LENGTH_FIXED_SPACES_AT_END 2 |
Memory option: the result must have the same length as the source.
If more room is necessary, then try to consume spaces at the end of the text.
- Since :
- 3.0
#define I18N_USHAPE_LENGTH_FIXED_SPACES_NEAR 1 |
Memory option: the result must have the same length as the source.
If more room is necessary, then try to consume spaces next to modified characters.
- Since :
- 3.0
#define I18N_USHAPE_LENGTH_GROW_SHRINK 0 |
Memory option: allow the result to have a different length than the source.
Affects: LamAlef options
- Since :
- 3.0
#define I18N_USHAPE_LENGTH_MASK 0x10003 |
Bit mask for memory options.
- Since :
- 3.0
#define I18N_USHAPE_LETTERS_MASK 0x18 |
Bit mask for letter shaping options.
- Since :
- 3.0
#define I18N_USHAPE_LETTERS_NOOP 0 |
Letter shaping option: do not perform letter shaping.
- Since :
- 3.0
#define I18N_USHAPE_LETTERS_SHAPE 8 |
Letter shaping option: replace abstract letter characters by "shaped" ones.
- Since :
- 3.0
#define I18N_USHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED 0x18 |
Letter shaping option: replace abstract letter characters by "shaped" ones.
The only difference with I18N_USHAPE_LETTERS_SHAPE is that Tashkeel letters are always "shaped" into the isolated form instead of the medial form (selecting code points from the Arabic Presentation Forms-B block).
- Since :
- 3.0
#define I18N_USHAPE_LETTERS_UNSHAPE 0x10 |
Letter shaping option: replace "shaped" letter characters by abstract ones.
- Since :
- 3.0
#define I18N_USHAPE_PRESERVE_PRESENTATION 0x8000 |
Presentation form option: don't replace Arabic Presentation Forms-A and Arabic Presentation Forms-B characters with 0+06xx characters, before shaping.
- Since :
- 3.0
#define I18N_USHAPE_PRESERVE_PRESENTATION_MASK 0x8000 |
Bit mask for preserve presentation form.
- Since :
- 3.0
#define I18N_USHAPE_PRESERVE_PRESENTATION_NOOP 0 |
Presentation form option: replace Arabic Presentation Forms-A and Arabic Presentationo Forms-B with their unshaped correspondants in range 0+06xx, before shaping.
- Since :
- 3.0
#define I18N_USHAPE_SEEN_MASK 0x700000 |
Bit mask for Seen memory options.
- Since :
- 3.0
#define I18N_USHAPE_SEEN_TWOCELL_NEAR 0x200000 |
Memory option: the result must have the same length as the source.
Shaping mode: The SEEN family character will expand into two characters using space near the SEEN family character (i.e. the space after the character).
If there are no spaces found, an I18N_ERROR_NO_SPACE_AVAILABLE error will be returned by the i18n_ushape_shape_arabic() function.
De-shaping mode: Any Seen character followed by Tail character will be replaced by one cell Seen and a space will replace the Tail.
Affects: Seen options
- Since :
- 3.0
#define I18N_USHAPE_SPACES_RELATIVE_TO_TEXT_BEGIN_END 0x4000000 |
This option affect the meaning of BEGIN and END options.
If this option is not used the default for BEGIN and END will be as following: The Default (for both Visual LTR, Visual RTL and Logical Text) 1. BEGIN always refers to the start address of physical memory. 2. END always refers to the end address of physical memory.
If this option is used it will swap the meaning of BEGIN and END only for Visual LTR text.
The effect on BEGIN and END Memory Options will be as following: A. BEGIN For Visual LTR text: This will be the beginning (right side) of the visual text (corresponding to the physical memory address end for Visual LTR text, Same as END in default behavior). B. BEGIN For Logical text: Same as BEGIN in default behavior. C. END For Visual LTR text: This will be the end (left side) of the visual text (corresponding to the physical memory address beginning for Visual LTR text, Same as BEGIN in default behavior). D. END For Logical text: Same as END in default behavior.
Affects: All LamAlef BEGIN, END and AUTO options.
- Since :
- 3.0
#define I18N_USHAPE_SPACES_RELATIVE_TO_TEXT_MASK 0x4000000 |
Bit mask for swapping BEGIN and END for Visual LTR text.
- Since :
- 3.0
#define I18N_USHAPE_TAIL_NEW_UNICODE 0x8000000 |
If this option is used, shaping will use the new Unicode code point for TAIL (i.e. 0xFE73).
If this option is not specified (Default), old unofficial Unicode TAIL code point is used (i.e. 0x200B).
De-shaping will not use this option as it will always search for both the new Unicode code point for the TAIL (i.e. 0xFE73) or the old unofficial Unicode TAIL code point (i.e. 0x200B) and de-shape the Seen-Family letter accordingly.
Shaping Mode: Only shaping.
De-shaping Mode: N/A.
Affects: All Seen options
- Since :
- 3.0
#define I18N_USHAPE_TAIL_TYPE_MASK 0x8000000 |
Bit mask for new Unicode Tail option.
- Since :
- 3.0
#define I18N_USHAPE_TASHKEEL_BEGIN 0x40000 |
Memory option: the result must have the same length as the source.
Shaping mode: Tashkeel characters will be replaced by spaces. Spaces will be placed at beginning of the buffer.
De-shaping mode: N/A
Affects: Tashkeel options
- Since :
- 3.0
#define I18N_USHAPE_TASHKEEL_END 0x60000 |
Memory option: the result must have the same length as the source.
Shaping mode: Tashkeel characters will be replaced by spaces. Spaces will be placed at end of the buffer.
De-shaping mode: N/A
Affects: Tashkeel options
- Since :
- 3.0
#define I18N_USHAPE_TASHKEEL_MASK 0xE0000 |
Bit mask for Tashkeel replacement with Space or Tatweel memory options.
- Since :
- 3.0
#define I18N_USHAPE_TASHKEEL_REPLACE_BY_TATWEEL 0xC0000 |
Memory option: the result must have the same length as the source.
Shaping mode: Tashkeel characters will be replaced by Tatweel if it is connected to adjacent characters (i.e. shaped on Tatweel) or replaced by space if it is not connected.
De-shaping mode: N/A
Affects: YehHamza options
- Since :
- 3.0
#define I18N_USHAPE_TASHKEEL_RESIZE 0x80000 |
Memory option: allow the result to have a different length than the source.
Shaping mode: Tashkeel characters will be removed, buffer length will shrink.
De-shaping mode: N/A
Affect: Tashkeel options
- Since :
- 3.0
#define I18N_USHAPE_TEXT_DIRECTION_LOGICAL 0 |
Direction indicator: the source is in logical (keyboard) order.
- Since :
- 3.0
#define I18N_USHAPE_TEXT_DIRECTION_MASK 4 |
Bit mask for direction indicators.
- Since :
- 3.0
#define I18N_USHAPE_TEXT_DIRECTION_VISUAL_LTR 4 |
Direction indicator: the source is in visual LTR order, the leftmost displayed character stored first.
- Since :
- 3.0
#define I18N_USHAPE_TEXT_DIRECTION_VISUAL_RTL 0 |
Direction indicator: the source is in visual RTL order, the rightmost displayed character stored first.
This option is an alias to I18N_USHAPE_TEXT_DIRECTION_LOGICAL.
- Since :
- 3.0
#define I18N_USHAPE_YEHHAMZA_MASK 0x3800000 |
Bit mask for YehHamza memory options.
- Since :
- 3.0
#define I18N_USHAPE_YEHHAMZA_TWOCELL_NEAR 0x1000000 |
Memory option: the result must have the same length as the source.
Shaping mode: The YEHHAMZA character will expand into two characters using space near it (i.e. the space after the character).
If there are no spaces found, an I18N_ERROR_NO_SPACE_AVAILABLE error will be returned by the i18n_ushape_shape_arabic() function.
De-shaping mode: Any Yeh (final or isolated) character followed by Hamza character will be replaced by one cell YehHamza and space will replace the Hamza.
Affects: YehHamza options
- Since :
- 3.0
Function Documentation
int i18n_ushape_shape_arabic | ( | const i18n_uchar * | source, |
int32_t | source_len, | ||
uint32_t | options, | ||
int32_t | dest_size, | ||
i18n_uchar * | dest, | ||
int32_t * | dest_len | ||
) |
Shapes Arabic text on a character basis.
This function performs basic operations for "shaping" Arabic text. It is most useful for use with legacy data formats and legacy display technology (simple terminals). All operations are performed on Unicode characters.
Text-based shaping means that some character code points in the text are replaced by others depending on the context. It transforms one kind of text into another. In comparison, modern displays for Arabic text select appropriate, context-dependent font glyphs for each text element, which means that they transform text into a glyph vector.
Text transformations are necessary when modern display technology is not available or when text needs to be transformed to or from legacy formats that use "shaped" characters. Since the Arabic script is cursive, connecting adjacent letters to each other, computers select images for each letter based on the surrounding letters. This usually results in four images per Arabic letter: initial, middle, final, and isolated forms. In Unicode, on the other hand, letters are normally stored abstract, and a display system is expected to select the necessary glyphs. (This makes searching and other text processing easier because the same letter has only one code.) It is possible to mimic this with text transformations because there are characters in Unicode that are rendered as letters with a specific shape (or cursive connectivity). They were included for interoperability with legacy systems and codepages, and for unsophisticated display systems.
A second kind of text transformations is supported for Arabic digits: For compatibility with legacy codepages that only include European digits, it is possible to replace one set of digits by another, changing the character code points. These operations can be performed for either Arabic-Indic Digits (U+0660...U+0669) or Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).
Some replacements may result in more or fewer characters (code points). By default, this means that the destination buffer may receive text with a length different from the source length. Some legacy systems rely on the length of the text to be constant. They expect extra spaces to be added or consumed either next to the affected character or at the end of the text.
For details about the available operations, see the description of the I18N_USHAPE_... options.
- Since :
- 3.0
- Remarks:
- The dest buffer, if not
NULL
, should be allocated by the user before calling this function.
- Parameters:
-
[in] source The input text [in] source_len The number of Unicode characters in the given source buffer, or -1 if the source buffer is NULL-terminated. [in] options A 32-bit set of flags that specify the operations that are performed on the input text. If no error occurs, then the result will always be written to the dest buffer. [in] dest_size The size (capacity) of the dest buffer in Unicode characters. If dest_size is 0, then no output is produced, but the dest_len is set to the necessary buffer size ("preflighting"). [out] dest The destination buffer that will receive the results of the requested operations. It may be NULL
only if dest_size is 0. The source and destination must not overlap.[out] dest_len The number of Unicode characters written to the dest buffer. If an error occurred, then no output was written, or it may be incomplete. If the I18N_ERROR_BUFFER_OVERFLOW error code is returned, then the dest_len value indicates the necessary dest buffer size. dest_len may be NULL
if not needed, however please note that if both dest and dest_len areNULL
, then I18N_ERROR_INVALID_PARAMETER error will be returned as such a call would produce no useful result.
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter I18N_ERROR_BUFFER_OVERFLOW Buffer overflow I18N_ERROR_NO_SPACE_AVAILABLE No space available for in-buffer expansion