From 36167be7e6b734fd0f41d6b81000fc14befb6455 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Tue, 5 Mar 2019 18:18:54 +0800 Subject: [PATCH] Tune APIs of Achar32 --- include/gdi.h | 1324 +++++++++++++++++------------------ src/control/bidiedit.c | 782 ++++++++++----------- src/control/bidiedit_impl.h | 72 +- src/font/charset-arabic.c | 32 +- src/font/charset-bidi.c | 99 ++- src/font/charset.c | 98 +-- src/include/bidi.h | 20 +- src/include/devfont.h | 67 +- src/include/glyph.h | 3 - src/newgdi/Makefile.am | 2 +- src/newgdi/achar.c | 198 ++++++ src/newgdi/bidi.c | 657 ++++++++--------- src/newgdi/drawtext.h | 2 +- src/newgdi/glyph-unicode.c | 378 +++++----- src/newgdi/glyph.c | 348 ++++----- 15 files changed, 2017 insertions(+), 2065 deletions(-) create mode 100644 src/newgdi/achar.c diff --git a/include/gdi.h b/include/gdi.h index 6708e410..14c34b7f 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -9558,74 +9558,36 @@ MG_EXPORT void GUIAPI DestroyBMPFont (DEVFONT* dev_font); */ /** - * \defgroup glyph Glyph defines and operations - * - * MiniGUI maintains some glyph defines and operations - * - * @{ - */ + * \defgroup mchar_glyph Abstract Character and Glyph definitions + * + * MiniGUI uses Achar32 type for a abstract character index value + * under a certain charset/encoding, and uses Glyph32 type + * for the glyph index value in a device font. + * + * Under Unicode charset or encodings, the abstract character index value + * will be identical to the Unicode code point, i.e., Achar32 + * is equivalent to Uchar32 under this situation. + * + * @{ + */ +typedef Uint32 Achar32; typedef Uint32 Glyph32; +/** + * \def INV_ACHAR_VALUE + */ +#define INV_ACHAR_VALUE 0xFFFFFFFF + /** * \def INV_GLYPH_VALUE */ #define INV_GLYPH_VALUE 0xFFFFFFFF -#define GLYPH_DEVFONT_INDEX_MASK 0xF0000000 -#define GLYPH_DEVFONT_INDEX_SHIFT 28 - /** - * \def REAL_GLYPH(glyph) - * \brief Get the real (DEVFONT) glyph value from a LOGFONT glyph. - * - * \param glyph The LOGFONT glyph value - */ -#define REAL_GLYPH(glyph) ((glyph) & ~GLYPH_DEVFONT_INDEX_MASK) - -/** - * \def SELECT_DEVFONT(logfont, glyph) - * \brief Select a DEVFONT according to the LOGFONT glyph value. - * - * \param logfont The pointer to a logical font. - * \param glyph The logical glyph value. - * - */ -#define SELECT_DEVFONT(logfont, glyph) \ - (logfont)->devfonts[((glyph) >> GLYPH_DEVFONT_INDEX_SHIFT) & 0x07] - -#define DFI_IN_GLYPH(glyph) \ - (((glyph) >> GLYPH_DEVFONT_INDEX_SHIFT) & 0x07) - -/** - * \def IS_MBC_GLYPH(glyph) - * \brief Determine wether the glyph is multibyte glyph - * - * \param glyph The logfont glyph value - */ -#define IS_MBC_GLYPH(glyph) ((glyph) & GLYPH_DEVFONT_INDEX_MASK) - -#define SET_GLYPH_DFI(glyph, dfi) \ - (((glyph) & ~GLYPH_DEVFONT_INDEX_MASK) | \ - (((Glyph32)((dfi) & 0x07)) << GLYPH_DEVFONT_INDEX_SHIFT)) - -/** - * \var typedef struct _GLYPHMAPINFO GLYPHMAPINFO - * \brief Data type of struct _GLYPHMAPINFO. - */ -typedef struct _GLYPHMAPINFO { - /** The index of the character in the text string. */ - int byte_index; - /** The length of the character in bytes. */ - int char_len; - /** The direction of the glyph; TRUE for RTL, FALSE for LTR. */ - BOOL is_rtol; -} GLYPHMAPINFO; - -/** - * \fn Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, const char* mchar, \ + * \fn Achar32 GUIAPI GetACharValue (LOGFONT* logfont, const char* mchar, \ * int mchar_len, const char* pre_mchar, int pre_len) - * \brief Get the glyph value of a multi-byte character. + * \brief Get the character value of a multi-byte character. * * \param logfont The logical font. * \param mchar The pointer to the multi-byte character. @@ -9633,84 +9595,25 @@ typedef struct _GLYPHMAPINFO { * \param pre_mchar The pointer to the multi-byte character before \a mchar. * \param pre_len The length of \a per_mchar in bytes. * - * \return The glyph value of the multi-byte character. + * \return The character value of the multi-byte character. */ -MG_EXPORT Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, const char* mchar, +MG_EXPORT Achar32 GUIAPI GetACharValue (LOGFONT* logfont, const char* mchar, int mchar_len, const char* pre_mchar, int pre_len); -/** The glyph bitmap structure. */ -typedef struct _GLYPHBITMAP { - /** The bounding box of the glyph. */ - int bbox_x, bbox_y, bbox_w, bbox_h; - /** The advance measure of the glyph. */ - int advance_x, advance_y; - - /** - * The type of glyph bitmap, one of the following values: - * - GLYPHBMP_TYPE_MONO - * - GLYPHBMP_TYPE_GREY - * - GLYPHBMP_TYPE_SUBPIXEL - * - GLYPHBMP_TYPE_PRERENDER - */ - int bmp_type; - /** The size of the glyph bitmap. */ - unsigned int bmp_size; - /* The pitch of the glyph bitmap. */ - int bmp_pitch; - /** The pointer to the buffer of glyph bitmap bits. */ - const unsigned char* bits; - - /** - * The prerender bitmap object. - * It is only valid if bmp_type is GLYPHBMP_TYPE_PRERENDER - */ - BITMAP prbitmap; -} GLYPHBITMAP; - /** - * \fn void GUIAPI GetGlyphBitmap (LOGFONT* log_font, \ - const char* mchar, int mchar_len, \ - GLYPHBITMAP* glyph_bitmap) - * \brief Gets the glyph bitmap information when using a logical font to - * output a character. - * - * This function gets the glyph bitmap of one multi-byte character - * (specified by \a mchar and \a mchar_len) and returns the bitmap information - * through \a font_bitmap when using \a log_font to render the character. - * - * \param log_font The logical font used to render the character. - * \param mchar The pointer to the multi-byte character. - * \param mchar_len The length of the multi-byte character. - * \param glyph_bitmap The buffer receives the glyph bitmap information. - * \return None. - * - * Example: - * \code - * GLYPHBITMAP glyph_bitmap = {0}; - * - * GetGlyphBitmap (log_font, "A", 1, &glyph_bitmap); - * \endcode - * - * \sa GetFontMetrics, GLYPHBITMAP, GetGlyphInfo - */ -MG_EXPORT void GUIAPI GetGlyphBitmap (LOGFONT* log_font, - const char* mchar, int mchar_len, - GLYPHBITMAP* glyph_bitmap); - -/** - * \var typedef enum GLYPHSHAPETYPE - * \brief Glyph shape type. + * \var typedef enum ACHARSHAPETYPE + * \brief Achar32 shape type. */ typedef enum { - GLYPH_ISOLATED, - GLYPH_FINAL, - GLYPH_INITIAL, - GLYPH_MEDIAL -} GLYPHSHAPETYPE; + ACHAR_ISOLATED, + ACHAR_FINAL, + ACHAR_INITIAL, + ACHAR_MEDIAL +} ACHARSHAPETYPE; /** - * \fn Glyph32 GUIAPI GetShapedGlyph (LOGFONT* logfont, const char* mchar, \ - * int mchar_len, GLYPHSHAPETYPE shape_type) + * \fn Achar32 GUIAPI GetShapedAChar (LOGFONT* logfont, const char* mchar, \ + * int mchar_len, ACHARSHAPETYPE shape_type) * \brief Get the glyph shape of a character. * * \param logfont The logical font. @@ -9718,25 +9621,515 @@ typedef enum { * \param mchar_len The length of \a mchar in bytes. * \param shape_type The requested shape type. * - * \return The multi-byte character's glyph shape value. + * \return The shaped character value. */ -MG_EXPORT Glyph32 GUIAPI GetShapedGlyph (LOGFONT* logfont, const char* mchar, - int mchar_len, GLYPHSHAPETYPE shape_type); +MG_EXPORT Achar32 GUIAPI GetShapedAChar (LOGFONT* logfont, const char* mchar, + int mchar_len, ACHARSHAPETYPE shape_type); /** - * \fn BOOL GUIAPI GetMirrorGlyph (LOGFONT* logfont, Glyph32 glyph, - * Glyph32* mirrored) - * \brief Get the mirror glyph if possible. + * \fn BOOL GUIAPI GetMirrorAChar (LOGFONT* logfont, Achar32 chv, + * Achar32* mirrored) + * \brief Get the mirrored abstract character if possible. * * \param logfont The logical font. * \param glyph The glyph value. - * \param mirrored The buffer to store the mirrored glyph if \a glyph - * has a mirrored glyph. + * \param mirrored The buffer to store the mirrored Achar32 value if + * the multi-byte character has a mirrored character. * * \return TRUE if success, FALSE on failure. */ -MG_EXPORT BOOL GUIAPI GetMirrorGlyph (LOGFONT* logfont, Glyph32 glyph, - Glyph32* mirrored); +MG_EXPORT BOOL GUIAPI GetMirrorAChar (LOGFONT* logfont, Achar32 chv, + Achar32* mirrored); + +/** + * \fn Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv) + * \brief Retrieve the basic type and break type of an abtract character. + * + * This function retrieves the basic type and break type of a glyph. + * + * \param logfont The logical font. + * \param glyph_value The glyph value. + * + * \return The type of the specified glyph. + * + * \sa GetACharInfo, GetACharBIDIType, char_types + */ +MG_EXPORT Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv); + +/* + * Define some bit masks, that character types are based on, each one has + * only one bit on. + */ + +#define BIDI_TYPE_INVALID 0x00000000L + +#define BIDI_MASK_RTL 0x00000001L /* Is right to left */ +#define BIDI_MASK_ARABIC 0x00000002L /* Is arabic */ + +/* Each char can be only one of the three following. */ +#define BIDI_MASK_STRONG 0x00000010L /* Is strong */ +#define BIDI_MASK_WEAK 0x00000020L /* Is weak */ +#define BIDI_MASK_NEUTRAL 0x00000040L /* Is neutral */ +#define BIDI_MASK_SENTINEL 0x00000080L /* Is sentinel: SOT, EOT */ + +/* Each char can be only one of the five following. */ +#define BIDI_MASK_LETTER 0x00000100L /* Is letter: L, R, AL */ +#define BIDI_MASK_NUMBER 0x00000200L /* Is number: EN, AN */ +#define BIDI_MASK_NUMSEPTER 0x00000400L /* Is number separator or terminator: ES, ET, CS */ +#define BIDI_MASK_SPACE 0x00000800L /* Is space: BN, BS, SS, WS */ +#define BIDI_MASK_EXPLICIT 0x00001000L /* Is expilict mark: LRE, RLE, LRO, RLO, PDF */ + +/* Can be on only if BIDI_MASK_SPACE is also on. */ +#define BIDI_MASK_SEPARATOR 0x00002000L /* Is test separator: BS, SS */ +/* Can be on only if BIDI_MASK_EXPLICIT is also on. */ +#define BIDI_MASK_OVERRIDE 0x00004000L /* Is explicit override: LRO, RLO */ + +#define BIDI_MASK_ES 0x00010000L +#define BIDI_MASK_ET 0x00020000L +#define BIDI_MASK_CS 0x00040000L + +#define BIDI_MASK_NSM 0x00080000L +#define BIDI_MASK_BN 0x00100000L + +#define BIDI_MASK_BS 0x00200000L +#define BIDI_MASK_SS 0x00400000L +#define BIDI_MASK_WS 0x00800000L + + /** + * \defgroup glyph_bidi_types Glyph BIDI types + * + * Values for BIDI glyph type. + * + * @{ + */ + +/** + * \def BIDI_TYPE_LTR + * \brief Strong left to right + */ +#define BIDI_TYPE_LTR (BIDI_MASK_STRONG + BIDI_MASK_LETTER) + +/** + * \def BIDI_TYPE_RTL + * \brief Right to left characters + */ +#define BIDI_TYPE_RTL (BIDI_MASK_STRONG + BIDI_MASK_LETTER \ + + BIDI_MASK_RTL) + +/** + * \def BIDI_TYPE_AL + * \brief Arabic characters + */ +#define BIDI_TYPE_AL (BIDI_MASK_STRONG + BIDI_MASK_LETTER \ + + BIDI_MASK_RTL + BIDI_MASK_ARABIC) + +/** + * \def BIDI_TYPE_LRE + * \brief Left-To-Right embedding + */ +#define BIDI_TYPE_LRE (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT) + +/** + * \def BIDI_TYPE_RLE + * \brief Right-To-Left embedding + */ +#define BIDI_TYPE_RLE (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \ + + BIDI_MASK_RTL) + +/** + * \def BIDI_TYPE_LRO + * \brief Left-To-Right override + */ +#define BIDI_TYPE_LRO (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \ + + BIDI_MASK_OVERRIDE) + +/** + * \def BIDI_TYPE_RLO + * \brief Right-To-Left override + */ +#define BIDI_TYPE_RLO (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \ + + BIDI_MASK_RTL + BIDI_MASK_OVERRIDE) + +/** + * \def BIDI_TYPE_PDF + * \brief Pop directional override + */ +#define BIDI_TYPE_PDF (BIDI_MASK_WEAK + BIDI_MASK_EXPLICIT) + +/** + * \def BIDI_TYPE_EN + * \brief European digit + */ +#define BIDI_TYPE_EN (BIDI_MASK_WEAK + BIDI_MASK_NUMBER) + +/** + * \def BIDI_TYPE_AN + * \brief Arabic digit + */ +#define BIDI_TYPE_AN (BIDI_MASK_WEAK + BIDI_MASK_NUMBER \ + + BIDI_MASK_ARABIC) + +/** + * \def BIDI_TYPE_ES + * \brief European number separator + */ +#define BIDI_TYPE_ES (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \ + + BIDI_MASK_ES) + +/** + * \def BIDI_TYPE_ET + * \brief European number terminator + */ +#define BIDI_TYPE_ET (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \ + + BIDI_MASK_ET) + +/** + * \def BIDI_TYPE_CS + * \brief Common Separator + */ +#define BIDI_TYPE_CS (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \ + + BIDI_MASK_CS) + +/** + * \def BIDI_TYPE_NSM + * \brief Non spacing mark + */ +#define BIDI_TYPE_NSM (BIDI_MASK_WEAK + BIDI_MASK_NSM) + +/** + * \def BIDI_TYPE_BN + * \brief Boundary neutral + */ +#define BIDI_TYPE_BN (BIDI_MASK_WEAK + BIDI_MASK_SPACE \ + + BIDI_MASK_BN) + +/** + * \def BIDI_TYPE_BS + * \brief Block separator + */ +#define BIDI_TYPE_BS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \ + + BIDI_MASK_SEPARATOR + BIDI_MASK_BS) + +/** + * \def BIDI_TYPE_SS + * \brief Segment separator + */ +#define BIDI_TYPE_SS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \ + + BIDI_MASK_SEPARATOR + BIDI_MASK_SS) +/** + * \def BIDI_TYPE_WS + * \brief Whitespace + */ +#define BIDI_TYPE_WS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \ + + BIDI_MASK_WS) + +/** + * \def BIDI_TYPE_ON + * \brief Other Neutral + */ +#define BIDI_TYPE_ON (BIDI_MASK_NEUTRAL) + + /** @} end of glyph_bidi_types */ + +/* The following are used to identify the paragraph direction, + types L, R, N are not used internally anymore, and recommended to use + LTR, RTL and ON instead, didn't removed because of compatability. */ + +#define BIDI_TYPE_L (BIDI_TYPE_LTR) +#define BIDI_TYPE_R (BIDI_TYPE_RTL) +#define BIDI_TYPE_N (BIDI_TYPE_ON) +/* Weak left to right */ +#define BIDI_TYPE_WL (BIDI_MASK_WEAK) +/* Weak right to left */ +#define BIDI_TYPE_WR (BIDI_MASK_WEAK + BIDI_MASK_RTL) + +/* The following are only used internally */ + +/* Start of text */ +#define BIDI_TYPE_SOT (BIDI_MASK_SENTINEL) +/* End of text */ +#define BIDI_TYPE_EOT (BIDI_MASK_SENTINEL + BIDI_MASK_RTL) + +/* Is private-use value? */ +#define BIDI_TYPE_PRIVATE(p) ((p) < 0) + +/* Return the direction of the level number, BIDI_TYPE_LTR for even and + BIDI_TYPE_RTL for odds. */ +#define BIDI_LEVEL_TO_DIR(lev) (BIDI_TYPE_LTR | (lev & 1)) + +/* Return the minimum level of the direction, 0 for BIDI_TYPE_LTR and + 1 for BIDI_TYPE_RTL and BIDI_TYPE_AL. */ +#define BIDI_DIR_TO_LEVEL(dir) ((BYTE)(dir & 1)) + +/* Is right to left? */ +#define BIDI_IS_RTL(p) ((p) & BIDI_MASK_RTL) +/* Is arabic? */ +#define BIDI_IS_ARABIC(p) ((p) & BIDI_MASK_ARABIC) + +/* Is strong? */ +#define BIDI_IS_STRONG(p) ((p) & BIDI_MASK_STRONG) +/* Is weak? */ +#define BIDI_IS_WEAK(p) ((p) & BIDI_MASK_WEAK) +/* Is neutral? */ +#define BIDI_IS_NEUTRAL(p) ((p) & BIDI_MASK_NEUTRAL) +/* Is sentinel? */ +#define BIDI_IS_SENTINEL(p) ((p) & BIDI_MASK_SENTINEL) + +/* Is letter: L, R, AL? */ +#define BIDI_IS_LETTER(p) ((p) & BIDI_MASK_LETTER) +/* Is number: EN, AN? */ +#define BIDI_IS_NUMBER(p) ((p) & BIDI_MASK_NUMBER) +/* Is number separator or terminator: ES, ET, CS? */ +#define BIDI_IS_NUMBER_SEPARATOR_OR_TERMINATOR(p) \ + ((p) & BIDI_MASK_NUMSEPTER) + +/* Is space: BN, BS, SS, WS? */ +#define BIDI_IS_SPACE(p) ((p) & BIDI_MASK_SPACE) +/* Is explicit mark: LRE, RLE, LRO, RLO, PDF? */ +#define BIDI_IS_EXPLICIT(p) ((p) & BIDI_MASK_EXPLICIT) + +/* Is test separator: BS, SS? */ +#define BIDI_IS_SEPARATOR(p) ((p) & BIDI_MASK_SEPARATOR) + +/* Is explicit override: LRO, RLO? */ +#define BIDI_IS_OVERRIDE(p) ((p) & BIDI_MASK_OVERRIDE) + +/* Some more: */ + +/* Is left to right letter: LTR? */ +#define BIDI_IS_LTR_LETTER(p) \ + ((p) & (BIDI_MASK_LETTER | BIDI_MASK_RTL) == BIDI_MASK_LETTER) + +/* Is right to left letter: RTL, AL? */ +#define BIDI_IS_RTL_LETTER(p) \ + ((p) & (BIDI_MASK_LETTER | BIDI_MASK_RTL) \ + == (BIDI_MASK_LETTER | BIDI_MASK_RTL)) + +/* Is ES or CS: ES, CS? */ +#define BIDI_IS_ES_OR_CS(p) \ + ((p) & (BIDI_MASK_ES | BIDI_MASK_CS)) + +/* Change numbers: EN, AN to RTL. */ +#define BIDI_NUMBER_TO_RTL(p) \ + (BIDI_IS_NUMBER(p) ? BIDI_TYPE_RTL : (p)) + +/** + * \fn Uint32 GUIAPI GetACharBIDIType (LOGFONT* logfont, Achar32 chv) + * \brief Retriev the BIDI type of an abstract character. + * + * This function retrieves the BIDI type of an abstract character. + * + * \param logfont The logical font. + * \param glyph_value The glyph value. + * + * \return The BIDI type of the Achar32; BIDI_TYPE_INVALID on failure. + * + * \sa GetACharInfo, GetACharType + */ +MG_EXPORT Uint32 GUIAPI GetACharBIDIType (LOGFONT* log_font, Achar32 chv); + +/** + * \var typedef struct _ACHARMAPINFO ACHARMAPINFO + * \brief Data type of struct _ACHARMAPINFO. + */ +typedef struct _ACHARMAPINFO { + /** The index of the character in the text string. */ + int byte_index; + /** The length of the character in bytes. */ + int char_len; + /** The direction of the character; TRUE for RTL, FALSE for LTR. */ + BOOL is_rtol; +} ACHARMAPINFO; + +/** + * \fn int GUIAPI BIDIGetTextLogicalAChars(LOGFONT* log_font, + * const char* text, int text_len, Achar32** achars, + * ACHARMAPINFO** achars_map) + * \brief Get logical achars string of the text. + * + * \param log_font The logical font. + * \param text The logical text string. + * \param text_len The lenght of the logical text string in bytes. + * \param achars The pointer to the logical glyph string. + * \param achars_map The position map from the logical achars string to + * the logical text. + * + * \return The length of the logical glyph string. + * + * \sa ACHARMAPINFO + */ +MG_EXPORT int GUIAPI BIDIGetTextLogicalAChars (LOGFONT* log_font, + const char* text, int text_len, Achar32** achars, + ACHARMAPINFO** achars_map); + +/** + * \fn void GUIAPI BIDIGetTextRangesLog2Vis (LOGFONT* log_font, + * const char* text, int text_len, + * int start_index, int end_index, + * int** ranges, int* nr_ranges) + * \brief Get a list of visual ranges corresponding to a given logical range. + * + * \param log_font The logical font. + * \param text The pointer to the logical text string. + * \param text_len The length of the logical text string in bytes. + * \param start_index The start index of the logical range. + * \param end_index The end index of the logical range. + * \param ranges The pointer to store a pointer to an array of arranges. + * \param nr_ranges The number of ranges stored in \a ranges. + * + * \return None. + */ +MG_EXPORT void GUIAPI BIDIGetTextRangesLog2Vis (LOGFONT* log_font, + const char* text, int text_len, int start_index, int end_index, + int** ranges, int* nr_ranges); + +/** \fn int GUIAPI BIDIGetTextVisualAChars (LOGFONT* log_font, + * const char* text, int text_len, Achar32** achars, + * ACHARMAPINFO** achars_map) + * \brief Get visual achars and glyph_map info relative with logical + * string byte index. + * + * \param log_font The logical font. + * \param text The logical text string. + * \param text_len The length of the logical text string in bytes. + * \param achars The pointer to the visual glyph string. + * \param achars_map The position map from visual achars string to + * the logical text. + * + * \return The length of the visual glyph string. + */ +MG_EXPORT int GUIAPI BIDIGetTextVisualAChars (LOGFONT* log_font, + const char* text, int text_len, Achar32** achars, + ACHARMAPINFO** achars_map); + +/* + * \var typedef void (*CB_REVERSE_EXTRA) (void* extra, int len, int pos) + * \brief The prototype of the user defined function to reverse an array. + * + * The function reverse an array pointed by \a extra from the position + * specified by \a pos for the length specified by \a len. + * + * \sa BIDILogAChars2VisACharsEx + */ +typedef void (*CB_REVERSE_EXTRA) (void* extra, int len, int pos); + +/** \fn BOOL GUIAPI BIDILogAChars2VisACharsEx (LOGFONT* log_font, + * Achar32* achars, int nr_achars, int pel, + * void* extra, CB_REVERSE_EXTRA cb_reverse_extra) + * \brief Reorder the specified logical glyph string in visual order and + * reorder an extra array to reflect the visule order of the achars. + * + * This function reorders the logical glyph string in place to visual order. + * If \a extra and \a cb_reverse_extra are both not NULL, it also reorders + * the array pointed by \a extra by calling the callback function + * \a cb_reverse_extra. + * + * \param log_font The logical font. + * \param achars The pointer to the glyph string. + * \param nr_achars The length of the glyph string. + * \param pel The paragraph embedding level, can be one of the following values: + * - 0: Level 0 (left to right) + * - 1: Level 1 (right to left) + * - others: Determine according to the heuristic given in + * steps P2 and P3 of the Unicode bidirectional algorithm. + * \param extra The pointer to the extra array to reorder; can be NULL. + * \param cb_reverse_extra The callback function to reverse the extra array. + * + * \return TRUE on success, otherwise FALSE. + */ +MG_EXPORT BOOL GUIAPI BIDILogAChars2VisACharsEx (LOGFONT* log_font, + Achar32* achars, int nr_achars, int pel, + void* extra, CB_REVERSE_EXTRA cb_reverse_extra); + +/** \fn BOOL GUIAPI BIDILogAChars2VisAChars (LOGFONT* log_font, + * Achar32* achars, int nr_achars, ACHARMAPINFO* achars_map) + * \brief Reorder the specified logical glyph string in visual order and + * reorder glyph map if specified. + * + * This function reorders the logical glyph string in place to visual order. + * If \a achars_map is not NULL, it also reorders + * the map to reflect the visual order. + * + * \param log_font The logical font. + * \param achars The pointer to the glyph string. + * \param nr_achars The length of the glyph string. + * \param achars_map The position map returned by \a BIDIGetTextLogicalAChars; + * can be NULL. + * + * \return The pointer to the visual achars; NULL when error. + */ +MG_EXPORT Achar32* GUIAPI BIDILogAChars2VisAChars (LOGFONT* log_font, + Achar32* achars, int nr_achars, ACHARMAPINFO* achars_map); + +/** + * \fn void GUIAPI BIDIGetLogicalEmbedLevelsEx (LOGFONT* log_font, \ + const Achar32* achars, int nr_achars, int pel, Uint8** embed_levels) + * \brief Get the logical embedding levels for the logical glyph string + * and generate runs by embedding levels, the for reorder to get + * visual glyph string. + * + * \param log_font The logical font. + * \param achars The pointer to the logical glyph string. + * \param nr_achars The length of the glyph string. + * \param pel The paragraph embedding level, can be one of the following values: + * - 0: Level 0 (left to right) + * - 1: Level 1 (right to left) + * - others: Determine according to the heuristic given in + * steps P2 and P3 of the Unicode bidirectional algorithm. + * \param embed_levels The logical embedding level. + * + * \return None. + */ +MG_EXPORT void GUIAPI BIDIGetLogicalEmbedLevelsEx (LOGFONT* log_font, + Achar32* achars, int nr_achars, int pel, Uint8** embed_levels); + +static inline void BIDIGetLogicalEmbeddLevels (LOGFONT* log_font, + Achar32* achars, int nr_achars, Uint8** embed_levels) +{ + BIDIGetLogicalEmbedLevelsEx (log_font, achars, nr_achars, -1, embed_levels); +} + +/** + * \fn void GUIAPI BIDIGetVisualEmbedLevelsEx (LOGFONT* log_font, + const Achar32* achars, int nr_achars, int pel, Uint8** embed_levels) + * \brief Get the visual embedding levels for the given logical glyph + * string, then you can get the edge for visual achars. + * + * \param log_font The logical font. + * \param achars The pointer to the logical glyph string. + * \param nr_achars The length of the glyph string. + * \param pel The paragraph embedding level, can be one of the following values: + * - 0\n + * Level 0 (left to right) + * - 1\n + * Level 1 (right to left) + * - others\n + * Determine according to the heuristic given in + * steps P2 and P3 of the Unicode bidirectional algorithm. + * \param embed_levels The embedding level logical to visual. + * + * \return void. + */ +MG_EXPORT void GUIAPI BIDIGetVisualEmbedLevelsEx (LOGFONT* log_font, + Achar32* achars, int nr_achars, int pel, Uint8** embed_levels); + +static inline void BIDIGetVisualEmbeddLevels (LOGFONT* log_font, + Achar32* achars, int nr_achars, Uint8** embed_levels) +{ + BIDIGetVisualEmbedLevelsEx (log_font, achars, nr_achars, -1, embed_levels); +} + +/** + * \fn void GUIAPI GetGlyphValue (LOGFONT* logfont, Achar32 chv) + * \brief Get the LOGFONT glyph value of an abstract character. + * + * \param logfont The logical font. + * \param chv The value of the abstract character. + * + * \return The glyph value of the abstract character; + * INV_GLYPH_VALUE on failure. + */ +MG_EXPORT Glyph32 GUIAPI GetGlyphValue(LOGFONT* logfont, Achar32 chv); /** * \fn int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, \ @@ -9762,6 +10155,7 @@ MG_EXPORT int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, /* * \fn int GUIAPI DrawGlyphString (HDC hdc, int x, int y, \ * Glyph32* glyphs, int nr_glyphs, int* adv_x, int* adv_y); + * * \brief Draw a glyph string. * * This function draws a glyph string to the specific postion of a DC. @@ -9782,25 +10176,8 @@ MG_EXPORT int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, MG_EXPORT int GUIAPI DrawGlyphString (HDC hdc, int x, int y, Glyph32* glyphs, int nr_glyphs, int* adv_x, int* adv_y); -/** - * \fn Uint32 GUIAPI GetGlyphType (LOGFONT* logfont, Glyph32 glyph_value) - * \brief Retrieve the basic type and break type of a glyph. - * - * This function retrieves the basic type and break type of a glyph. - * - * \param logfont The logical font. - * \param glyph_value The glyph value. - * - * \return The type of the specified glyph. - * - * \sa GetGlyphInfo, GetGlyphBIDIType, char_types - */ -MG_EXPORT Uint32 GUIAPI GetGlyphType (LOGFONT* logfont, Glyph32 glyph_value); - -#define GLYPH_INFO_TYPE 0x01 -#define GLYPH_INFO_BIDI_TYPE 0x02 -#define GLYPH_INFO_METRICS 0x04 -#define GLYPH_INFO_BMP 0x10 +#define GLYPH_INFO_METRICS 0x01 +#define GLYPH_INFO_BMP 0x02 /** The type of glyph bitmap: monochrome */ #define GLYPHBMP_TYPE_MONO 0x00 @@ -9819,28 +10196,13 @@ MG_EXPORT Uint32 GUIAPI GetGlyphType (LOGFONT* logfont, Glyph32 glyph_value); */ typedef struct _GLYPHINFO { /** - * The mask indicates if you want to get glyph type info, metrics, - * or bitmap infomation you want. Or'ed with the following values: - * - GLYPH_INFO_TYPE - * - GLYPH_INFO_BIDI_TYPE + * The mask indicates if you want to get glyph metrics, + * or bitmap infomation. Or'ed with the following values: * - GLYPH_INFO_METRICS * - GLYPH_INFO_BMP */ Uint32 mask; - /** The glyph type */ - Uint32 char_type; - - /** The BIDI glyph type */ - Uint32 bidi_char_type; - -#if 0 // VincentWei: removed since 3.4.0 - /** The height of the glyph */ - int height; - /** the descent of the glyph */ - int descent; -#endif - /** The bounding box of the glyph. */ int bbox_x, bbox_y, bbox_w, bbox_h; /** The advance measure of the glyph. */ @@ -9854,10 +10216,14 @@ typedef struct _GLYPHINFO { * - GLYPHBMP_TYPE_PRERENDER */ int bmp_type; - /** The size of the glyph bitmap. */ - unsigned int bmp_size; + + /** The width of the glyph bitmap. */ + int bmp_width; + /** The height of the glyph bitmap. */ + int bmp_height; /* The pitch of the glyph bitmap. */ int bmp_pitch; + /** The pointer to the buffer of glyph bitmap bits. */ const unsigned char* bits; @@ -9932,7 +10298,7 @@ MG_EXPORT int GUIAPI GetGlyphsExtentPoint (HDC hdc, Glyph32* glyphs, /** * \defgroup language_code Language Code * - * The language code specifies the content lanuage for \a GetGlyphsAndBreaks. + * The language code specifies the content language. * * @{ */ @@ -10269,7 +10635,7 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) /** * \defgroup white_space_rules White Space Rules * - * The white space rule indicates \a GetGlyphsAndBreaks. + * The white space rule indicates \a GetUCharsAndBreaks. * * - whether and how white space inside the string is collapsed. * - whether lines may wrap at unforced soft wrap opportunities. @@ -10279,7 +10645,7 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) /** * \def WSR_NORMAL * - * \brief This value directs \a GetGlyphsAndBreaks + * \brief This value directs \a GetUCharsAndBreaks * collapses sequences of white space into a single character. * Lines may wrap at allowed soft wrap opportunities. */ @@ -10288,7 +10654,7 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) /** * \def WSR_PRE * - * \brief This value prevents \a GetGlyphsAndBreaks from collapsing + * \brief This value prevents \a GetUCharsAndBreaks from collapsing * sequences of white space. Segment breaks such as line feeds are * preserved as forced line breaks. Lines only break at forced line breaks; * content that does not fit within the specified extent overflows it. @@ -10322,7 +10688,7 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) * white space glyph, including between white space characters. * * When white space rule is specified to be WSR_BREAK_SPACES, the manner - * of \a GetGlyphsAndBreaks will conform + * of \a GetUCharsAndBreaks will conform * to UNICODE LINE BREAKING ALGORITHM. */ #define WSR_BREAK_SPACES 0x04 @@ -10341,7 +10707,7 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) /** * \defgroup char_transform_rules Character Transformation Rules * - * The character transformation rule indicates how \a GetGlyphsAndBreaks + * The character transformation rule indicates how \a GetUCharsAndBreaks * transforms text for styling purposes; can be * * - CTR_NONE, @@ -10408,7 +10774,7 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) /** * \defgroup word_break_rules Word Breaking Rules * - * The word breaking rule indicates how \a GetGlyphsAndBreaks + * The word breaking rule indicates how \a GetUCharsAndBreaks * creates soft wrap opportunities between letters. * * @{ @@ -10576,17 +10942,18 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) #define BOV_LB_NOTALLOWED 0x0003 /** - * \fn int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, + * \fn int GUIAPI GetUCharsAndBreaks(LOGFONT* logfont, * const char* mstr, unsigned int mstr_len, * LanguageCode content_language, UCharScriptType writing_system, * Uint8 wsr, Uint8 ctr, Uint8 wbr, Uint8 lbp, - * Glyph32** glyphs, Uchar32** uchars, Uint16** break_oppos, - * int* nr_glyphs); - * \brief Calculate the glyph string and the breaking opportunities under - * the specified rules and line breaking policy. + * Uchar32** uchars, Uint16** break_oppos, + * int* nr_uchars); + * \brief Convert a multi-byte character string to a Unicode character string + * and calculate the breaking opportunities under the specified rules and + * line breaking policy. * - * This function calculates and allocates the glyph string and the breaking - * opportunities of the glyphs from a multi-byte string under the specified + * This function calculates and allocates the Uchar32 string and the breaking + * opportunities of the characters from a multi-byte string under the specified * content language \a content_language, the writing system \a writing_system, * the white space rule \a wsr, the text transformation rule * \a ctr, the word breaking rule \a wbr, and the line breaking policy \a lbp. @@ -10605,10 +10972,10 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) * https://www.w3.org/TR/css-text-3/ * * The function will return if it encounters any hard line break or the null - * character. The hard line break will be included in the returned glyphs if + * character. The hard line break will be included in the returned Uchar32 if * there was one. * - * Note that you are responsible for freeing the glyph string and the + * Note that you are responsible for freeing the Uchar32 string and the * break opportunities array allocated by this function. * * \param logfont The logfont used to parse the string. @@ -10622,11 +10989,8 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) * \param wbr The word breaking rule; see \a word_break_rules. * \param lbp The line breaking policy; * see \a line_break_policies. - * \param glyphs The pointer to a buffer to store the address of the - * allocated glyph string. * \param uchars The pointer to a buffer to store the address of the - * UChar32 array which contains the Unicode character values - * of the glyphs; can be NULL. + * UChar32 array which contains the Unicode character values. * \param break_oppos The pointer to a buffer to store the address of the * Uint16 array which contains the break opportunities of the glyphs. * Note that the length of this array is always one longer than @@ -10648,27 +11012,44 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) * * \sa DrawGlyphStringEx, white_space_rules, char_transform_rule */ -MG_EXPORT int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, - const char* mstr, int mstr_len, - LanguageCode content_language, UCharScriptType writing_system, - Uint8 wsr, Uint8 ctr, Uint8 wbr, Uint8 lbp, - Glyph32** glyphs, Uchar32** uchars, Uint16** break_oppos, - int* nr_glyphs); +MG_EXPORT int GUIAPI GetUCharsAndBreaks(LOGFONT* logfont, + const char* mstr, int mstr_len, + LanguageCode content_language, UCharScriptType writing_system, + Uint8 wsr, Uint8 ctr, Uint8 wbr, Uint8 lbp, + Uchar32** uchars, Uint16** break_oppos, int* nr_ucs); /** - * \fn Glyph2UChar(LOGFONT* logfont, Glyph32 gv) - * \brief Get Uchar32 value (whide character value) from a LOGFONT glyph value. + * \fn AChar2UChar(LOGFONT* logfont, Achar32 chv) + * \brief Get Uchar32 value (Unicode whide character value) from + * a LOGFONT abstract character value. * * Only valid for UNICODE. * * \param logfont The LOGFONT object - * \param glyph The LOGFONT glyph value. + * \param chv The LOGFONT character value. * * \return The Uchar32 value (Unicode code point) of the glyph. * * \note Only available when support for UNICODE is enabled. */ -MG_EXPORT Uchar32 GUIAPI Glyph2UChar(LOGFONT* logfont, Glyph32 gv); +MG_EXPORT Uchar32 GUIAPI AChar2UChar(LOGFONT* logfont, Achar32 chv); + +/** + * \fn int AChars2UChars(LOGFONT* logfont, const Achar32* achs, + * Uchar32* ucs, int n) + * \brief Convert an Achar32 array to Unicode character array. + * + * Only valid for UNICODE. + * + * \param logfont The LOGFONT object + * \param chs The array of LOGFONT character values. + * + * \return The number of characters converted successfully. + * + * \note Only available when support for UNICODE is enabled. + */ +MG_EXPORT int GUIAPI AChars2UChars(LOGFONT* logfont, const Achar32* chs, + Uchar32* ucs, int n); /** * \defgroup glyph_render_flags Glyph Rendering Flags @@ -10859,6 +11240,58 @@ MG_EXPORT Uchar32 GUIAPI Glyph2UChar(LOGFONT* logfont, Glyph32 gv); #define GLYPH_ORIENTATION_UPRIGHT 0 #define GLYPH_ORIENTATION_SIDEWAYS 1 +typedef struct _SHAPEDGLYPHS { + int nr_glyphs; + /** The shaped glyphs */ + Glyph32* glyphs; + /** The break opportunities */ + Uint8* break_oppos; + /** The Unicode general categories. */ + Uint8* ugc; + /** The Unicode Indic syllabic categories. */ + Uint8* uics; + /** The Unicode Indic positional categories. */ + Uint8* uipc; +} SHAPEDGLYPHS; + +MG_EXPORT int GUIAPI GetShapedGlyphs(LOGFONT* logfont, + LanguageCode content_language, UCharScriptType writing_system, + const Uchar32 ucs, int nr_chars, + SHAPEDGLYPHS* shaped_glyphs); + +/** + * The glyph extent information. + */ +typedef struct _GLYPHEXTENT { + /** The bounding box of the glyph. */ + int bbox_x, bbox_y, bbox_w, bbox_h; + /** The advance values of the glyph. */ + int adv_x, adv_y; + /** The advance value of the glyph along the line direction. */ + int line_adv; + /** + * The orientation of the glyph; can be one of the following values: + * - GLYPH_ORIENTATION_UPRIGHT\n + * the glyph is in the standard horizontal orientation. + * - GLYPH_ORIENTATION_SIDEWAYS\n + * the glyph rotates 90° clockwise from horizontal. + */ + Uint8 orientation:2; + /** + * Whether is a whitespace glyph. + */ + Uint8 whitespace:1; + /** + * Whether suppress the glyph. + */ + Uint8 suppressed:1; +} GLYPHEXTENT; + +MG_EXPORT int GUIAPI GetGlyphsExtentInfo(LOGFONT* logfont, + const SHAPEDGLYPHS* shaped_glyphs, Uint32 render_flags, + GLYPHEXTENT** glyph_extents, + LOGFONT** logfont_sideways); + /** * The glyph extent information. */ @@ -10885,6 +11318,14 @@ typedef struct _GLYPHPOS { * The y coordinate of the glyph position. */ int y; + /** + * The orientation of the glyph; can be one of the following values: + * - GLYPH_ORIENTATION_UPRIGHT\n + * the glyph is in the standard horizontal orientation. + * - GLYPH_ORIENTATION_SIDEWAYS\n + * the glyph rotates 90° clockwise from horizontal. + */ + Uint8 orientation:2; /** * Whether is a whitespace glyph. */ @@ -10903,16 +11344,14 @@ typedef struct _GLYPHPOS { * the glyph is hanged at the end of the line. */ Uint8 hanged:2; - /** - * The orientation of the glyph; can be one of the following values: - * - GLYPH_ORIENTATION_UPRIGHT\n - * the glyph is in the standard horizontal orientation. - * - GLYPH_ORIENTATION_SIDEWAYS\n - * the glyph rotates 90° clockwise from horizontal. - */ - Uint8 orientation:2; } GLYPHPOS; +MG_EXPORT int GUIAPI GetGlyphsPositionInfo(LOGFONT* logfont_upright, + const Glyph32* glyphs, const Uint16* break_oppos, + const GLYPHEXTINFO* glyph_ext_info, int nr_glyphs, + Uint32 render_flags, int x, int y, + int letter_spacing, int word_spacing, int tab_size, int max_extent, + SIZE* line_size, GLYPHPOS* glyph_pos, LOGFONT** logfont_sideways); /** * \fn int GUIAPI GetGlyphsExtentPointEx(LOGFONT* logfont_upright, * const Glyph32* glyphs, int nr_glyphs, const Uint16* break_oppos, @@ -10931,7 +11370,7 @@ typedef struct _GLYPHPOS { * as visual ones by calling BIDI functions. * \param nr_glyphs The number of the glyphs. * \param break_oppos The pointer to the break opportunities array of the glyphs. - * It should be returned by \a GetGlyphsAndBreaks. However, the caller + * It should be returned by \a GetUCharsAndBreaks. However, the caller * should skip the first unit (the break opportunity before the first glyph) * before passing the pointer to this function. * \param render_flags The render flags; see \a glyph_render_flags. @@ -10979,7 +11418,7 @@ typedef struct _GLYPHPOS { * the positions contained in \a glyph_pos are always with respect to * the top-left corner of the resulting output line rectangle. * - * \sa GetGlyphsAndBreaks, DrawGlyphStringEx, GLYPHEXTINFO, glyph_render_flags + * \sa GetUCharsAndBreaks, DrawGlyphStringEx, GLYPHEXTINFO, glyph_render_flags */ MG_EXPORT int GUIAPI GetGlyphsExtentPointEx(LOGFONT* logfont_upright, const Glyph32* glyphs, int nr_glyphs, const Uint16* break_oppos, @@ -11019,459 +11458,6 @@ MG_EXPORT int GUIAPI DrawGlyphStringEx (HDC hdc, LOGFONT* logfont_upright, LOGFONT* logfont_sideways, const Glyph32* glyphs, int nr_glyphs, const GLYPHPOS* glyph_pos); -/* - * Define some bit masks, that character types are based on, each one has - * only one bit on. - */ - -#define BIDI_TYPE_INVALID 0x00000000L - -#define BIDI_MASK_RTL 0x00000001L /* Is right to left */ -#define BIDI_MASK_ARABIC 0x00000002L /* Is arabic */ - -/* Each char can be only one of the three following. */ -#define BIDI_MASK_STRONG 0x00000010L /* Is strong */ -#define BIDI_MASK_WEAK 0x00000020L /* Is weak */ -#define BIDI_MASK_NEUTRAL 0x00000040L /* Is neutral */ -#define BIDI_MASK_SENTINEL 0x00000080L /* Is sentinel: SOT, EOT */ - -/* Each char can be only one of the five following. */ -#define BIDI_MASK_LETTER 0x00000100L /* Is letter: L, R, AL */ -#define BIDI_MASK_NUMBER 0x00000200L /* Is number: EN, AN */ -#define BIDI_MASK_NUMSEPTER 0x00000400L /* Is number separator or terminator: ES, ET, CS */ -#define BIDI_MASK_SPACE 0x00000800L /* Is space: BN, BS, SS, WS */ -#define BIDI_MASK_EXPLICIT 0x00001000L /* Is expilict mark: LRE, RLE, LRO, RLO, PDF */ - -/* Can be on only if BIDI_MASK_SPACE is also on. */ -#define BIDI_MASK_SEPARATOR 0x00002000L /* Is test separator: BS, SS */ -/* Can be on only if BIDI_MASK_EXPLICIT is also on. */ -#define BIDI_MASK_OVERRIDE 0x00004000L /* Is explicit override: LRO, RLO */ - -#define BIDI_MASK_ES 0x00010000L -#define BIDI_MASK_ET 0x00020000L -#define BIDI_MASK_CS 0x00040000L - -#define BIDI_MASK_NSM 0x00080000L -#define BIDI_MASK_BN 0x00100000L - -#define BIDI_MASK_BS 0x00200000L -#define BIDI_MASK_SS 0x00400000L -#define BIDI_MASK_WS 0x00800000L - - /** - * \defgroup glyph_bidi_types Glyph BIDI types - * - * Values for BIDI glyph type. - * - * @{ - */ - -/** - * \def BIDI_TYPE_LTR - * \brief Strong left to right - */ -#define BIDI_TYPE_LTR (BIDI_MASK_STRONG + BIDI_MASK_LETTER) - -/** - * \def BIDI_TYPE_RTL - * \brief Right to left characters - */ -#define BIDI_TYPE_RTL (BIDI_MASK_STRONG + BIDI_MASK_LETTER \ - + BIDI_MASK_RTL) - -/** - * \def BIDI_TYPE_AL - * \brief Arabic characters - */ -#define BIDI_TYPE_AL (BIDI_MASK_STRONG + BIDI_MASK_LETTER \ - + BIDI_MASK_RTL + BIDI_MASK_ARABIC) - -/** - * \def BIDI_TYPE_LRE - * \brief Left-To-Right embedding - */ -#define BIDI_TYPE_LRE (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT) - -/** - * \def BIDI_TYPE_RLE - * \brief Right-To-Left embedding - */ -#define BIDI_TYPE_RLE (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \ - + BIDI_MASK_RTL) - -/** - * \def BIDI_TYPE_LRO - * \brief Left-To-Right override - */ -#define BIDI_TYPE_LRO (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \ - + BIDI_MASK_OVERRIDE) - -/** - * \def BIDI_TYPE_RLO - * \brief Right-To-Left override - */ -#define BIDI_TYPE_RLO (BIDI_MASK_STRONG + BIDI_MASK_EXPLICIT \ - + BIDI_MASK_RTL + BIDI_MASK_OVERRIDE) - -/** - * \def BIDI_TYPE_PDF - * \brief Pop directional override - */ -#define BIDI_TYPE_PDF (BIDI_MASK_WEAK + BIDI_MASK_EXPLICIT) - -/** - * \def BIDI_TYPE_EN - * \brief European digit - */ -#define BIDI_TYPE_EN (BIDI_MASK_WEAK + BIDI_MASK_NUMBER) - -/** - * \def BIDI_TYPE_AN - * \brief Arabic digit - */ -#define BIDI_TYPE_AN (BIDI_MASK_WEAK + BIDI_MASK_NUMBER \ - + BIDI_MASK_ARABIC) - -/** - * \def BIDI_TYPE_ES - * \brief European number separator - */ -#define BIDI_TYPE_ES (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \ - + BIDI_MASK_ES) - -/** - * \def BIDI_TYPE_ET - * \brief European number terminator - */ -#define BIDI_TYPE_ET (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \ - + BIDI_MASK_ET) - -/** - * \def BIDI_TYPE_CS - * \brief Common Separator - */ -#define BIDI_TYPE_CS (BIDI_MASK_WEAK + BIDI_MASK_NUMSEPTER \ - + BIDI_MASK_CS) - -/** - * \def BIDI_TYPE_NSM - * \brief Non spacing mark - */ -#define BIDI_TYPE_NSM (BIDI_MASK_WEAK + BIDI_MASK_NSM) - -/** - * \def BIDI_TYPE_BN - * \brief Boundary neutral - */ -#define BIDI_TYPE_BN (BIDI_MASK_WEAK + BIDI_MASK_SPACE \ - + BIDI_MASK_BN) - -/** - * \def BIDI_TYPE_BS - * \brief Block separator - */ -#define BIDI_TYPE_BS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \ - + BIDI_MASK_SEPARATOR + BIDI_MASK_BS) - -/** - * \def BIDI_TYPE_SS - * \brief Segment separator - */ -#define BIDI_TYPE_SS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \ - + BIDI_MASK_SEPARATOR + BIDI_MASK_SS) -/** - * \def BIDI_TYPE_WS - * \brief Whitespace - */ -#define BIDI_TYPE_WS (BIDI_MASK_NEUTRAL + BIDI_MASK_SPACE \ - + BIDI_MASK_WS) - -/** - * \def BIDI_TYPE_ON - * \brief Other Neutral - */ -#define BIDI_TYPE_ON (BIDI_MASK_NEUTRAL) - - /** @} end of glyph_bidi_types */ - -/* The following are used to identify the paragraph direction, - types L, R, N are not used internally anymore, and recommended to use - LTR, RTL and ON instead, didn't removed because of compatability. */ - -#define BIDI_TYPE_L (BIDI_TYPE_LTR) -#define BIDI_TYPE_R (BIDI_TYPE_RTL) -#define BIDI_TYPE_N (BIDI_TYPE_ON) -/* Weak left to right */ -#define BIDI_TYPE_WL (BIDI_MASK_WEAK) -/* Weak right to left */ -#define BIDI_TYPE_WR (BIDI_MASK_WEAK + BIDI_MASK_RTL) - -/* The following are only used internally */ - -/* Start of text */ -#define BIDI_TYPE_SOT (BIDI_MASK_SENTINEL) -/* End of text */ -#define BIDI_TYPE_EOT (BIDI_MASK_SENTINEL + BIDI_MASK_RTL) - -/* Is private-use value? */ -#define BIDI_TYPE_PRIVATE(p) ((p) < 0) - -/* Return the direction of the level number, BIDI_TYPE_LTR for even and - BIDI_TYPE_RTL for odds. */ -#define BIDI_LEVEL_TO_DIR(lev) (BIDI_TYPE_LTR | (lev & 1)) - -/* Return the minimum level of the direction, 0 for BIDI_TYPE_LTR and - 1 for BIDI_TYPE_RTL and BIDI_TYPE_AL. */ -#define BIDI_DIR_TO_LEVEL(dir) ((BYTE)(dir & 1)) - -/* Is right to left? */ -#define BIDI_IS_RTL(p) ((p) & BIDI_MASK_RTL) -/* Is arabic? */ -#define BIDI_IS_ARABIC(p) ((p) & BIDI_MASK_ARABIC) - -/* Is strong? */ -#define BIDI_IS_STRONG(p) ((p) & BIDI_MASK_STRONG) -/* Is weak? */ -#define BIDI_IS_WEAK(p) ((p) & BIDI_MASK_WEAK) -/* Is neutral? */ -#define BIDI_IS_NEUTRAL(p) ((p) & BIDI_MASK_NEUTRAL) -/* Is sentinel? */ -#define BIDI_IS_SENTINEL(p) ((p) & BIDI_MASK_SENTINEL) - -/* Is letter: L, R, AL? */ -#define BIDI_IS_LETTER(p) ((p) & BIDI_MASK_LETTER) -/* Is number: EN, AN? */ -#define BIDI_IS_NUMBER(p) ((p) & BIDI_MASK_NUMBER) -/* Is number separator or terminator: ES, ET, CS? */ -#define BIDI_IS_NUMBER_SEPARATOR_OR_TERMINATOR(p) \ - ((p) & BIDI_MASK_NUMSEPTER) - -/* Is space: BN, BS, SS, WS? */ -#define BIDI_IS_SPACE(p) ((p) & BIDI_MASK_SPACE) -/* Is explicit mark: LRE, RLE, LRO, RLO, PDF? */ -#define BIDI_IS_EXPLICIT(p) ((p) & BIDI_MASK_EXPLICIT) - -/* Is test separator: BS, SS? */ -#define BIDI_IS_SEPARATOR(p) ((p) & BIDI_MASK_SEPARATOR) - -/* Is explicit override: LRO, RLO? */ -#define BIDI_IS_OVERRIDE(p) ((p) & BIDI_MASK_OVERRIDE) - -/* Some more: */ - -/* Is left to right letter: LTR? */ -#define BIDI_IS_LTR_LETTER(p) \ - ((p) & (BIDI_MASK_LETTER | BIDI_MASK_RTL) == BIDI_MASK_LETTER) - -/* Is right to left letter: RTL, AL? */ -#define BIDI_IS_RTL_LETTER(p) \ - ((p) & (BIDI_MASK_LETTER | BIDI_MASK_RTL) \ - == (BIDI_MASK_LETTER | BIDI_MASK_RTL)) - -/* Is ES or CS: ES, CS? */ -#define BIDI_IS_ES_OR_CS(p) \ - ((p) & (BIDI_MASK_ES | BIDI_MASK_CS)) - -/* Change numbers: EN, AN to RTL. */ -#define BIDI_NUMBER_TO_RTL(p) \ - (BIDI_IS_NUMBER(p) ? BIDI_TYPE_RTL : (p)) - -/** - * \fn BOOL GUIAPI GetGlyphBIDIType (LOGFONT* logfont, - * Glyph32 glyph_value, Uint32 *bidi_type) - * \brief Retriev the BIDI type of a glyph. - * - * This function retrieves the BIDI type of a glyph. - * - * \param logfont The logical font. - * \param glyph_value The glyph value. - * \param bidi_type The buffer storing the BIDI type of the glyph. - * - * \return TRUE if success, FALSE on failure. - * - * \sa GetGlyphInfo, GetGlyphType - */ -MG_EXPORT BOOL GUIAPI GetGlyphBIDIType (LOGFONT* log_font, - Glyph32 glyph_value, Uint32 *bidi_type); - -/** - * \fn int GUIAPI BIDIGetTextLogicalGlyphs(LOGFONT* log_font, - * const char* text, int text_len, Glyph32** glyphs, - * GLYPHMAPINFO** glyphs_map) - * \brief Get logical glyphs string of the text. - * - * \param log_font The logical font. - * \param text The logical text string. - * \param text_len The lenght of the logical text string in bytes. - * \param glyphs The pointer to the logical glyph string. - * \param glyphs_map The position map from the logical glyphs string to - * the logical text. - * - * \return The length of the logical glyph string. - * - * \sa GLYPHMAPINFO - */ -MG_EXPORT int GUIAPI BIDIGetTextLogicalGlyphs (LOGFONT* log_font, - const char* text, int text_len, Glyph32** glyphs, - GLYPHMAPINFO** glyphs_map); - -/** - * \fn void GUIAPI BIDIGetTextRangesLog2Vis (LOGFONT* log_font, - * const char* text, int text_len, - * int start_index, int end_index, - * int** ranges, int* nr_ranges) - * \brief Get a list of visual ranges corresponding to a given logical range. - * - * \param log_font The logical font. - * \param text The pointer to the logical text string. - * \param text_len The length of the logical text string in bytes. - * \param start_index The start index of the logical range. - * \param end_index The end index of the logical range. - * \param ranges The pointer to store a pointer to an array of arranges. - * \param nr_ranges The number of ranges stored in \a ranges. - * - * \return None. - */ -MG_EXPORT void GUIAPI BIDIGetTextRangesLog2Vis (LOGFONT* log_font, - const char* text, int text_len, int start_index, int end_index, - int** ranges, int* nr_ranges); - -/** \fn int GUIAPI BIDIGetTextVisualGlyphs (LOGFONT* log_font, - * const char* text, int text_len, Glyph32** glyphs, - * GLYPHMAPINFO** glyphs_map) - * \brief Get visual glyphs and glyph_map info relative with logical - * string byte index. - * - * \param log_font The logical font. - * \param text The logical text string. - * \param text_len The length of the logical text string in bytes. - * \param glyphs The pointer to the visual glyph string. - * \param glyphs_map The position map from visual glyphs string to - * the logical text. - * - * \return The length of the visual glyph string. - */ -MG_EXPORT int GUIAPI BIDIGetTextVisualGlyphs (LOGFONT* log_font, - const char* text, int text_len, Glyph32** glyphs, - GLYPHMAPINFO** glyphs_map); - -/* - * \var typedef void (*CB_REVERSE_EXTRA) (void* extra, int len, int pos) - * \brief The prototype of the user defined function to reverse an array. - * - * The function reverse an array pointed by \a extra from the position - * specified by \a pos for the length specified by \a len. - * - * \sa BIDILogGlyphs2VisGlyphsEx - */ -typedef void (*CB_REVERSE_EXTRA) (void* extra, int len, int pos); - -/** \fn BOOL GUIAPI BIDILogGlyphs2VisGlyphsEx (LOGFONT* log_font, - * Glyph32* glyphs, int nr_glyphs, int pel, - * void* extra, CB_REVERSE_EXTRA cb_reverse_extra) - * \brief Reorder the specified logical glyph string in visual order and - * reorder an extra array to reflect the visule order of the glyphs. - * - * This function reorders the logical glyph string in place to visual order. - * If \a extra and \a cb_reverse_extra are both not NULL, it also reorders - * the array pointed by \a extra by calling the callback function - * \a cb_reverse_extra. - * - * \param log_font The logical font. - * \param glyphs The pointer to the glyph string. - * \param nr_glyphs The length of the glyph string. - * \param pel The paragraph embedding level, can be one of the following values: - * - 0: Level 0 (left to right) - * - 1: Level 1 (right to left) - * - others: Determine according to the heuristic given in - * steps P2 and P3 of the Unicode bidirectional algorithm. - * \param extra The pointer to the extra array to reorder; can be NULL. - * \param cb_reverse_extra The callback function to reverse the extra array. - * - * \return TRUE on success, otherwise FALSE. - */ -MG_EXPORT BOOL GUIAPI BIDILogGlyphs2VisGlyphsEx (LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, int pel, - void* extra, CB_REVERSE_EXTRA cb_reverse_extra); - -/** \fn BOOL GUIAPI BIDILogGlyphs2VisGlyphs (LOGFONT* log_font, - * Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyphs_map) - * \brief Reorder the specified logical glyph string in visual order and - * reorder glyph map if specified. - * - * This function reorders the logical glyph string in place to visual order. - * If \a glyphs_map is not NULL, it also reorders - * the map to reflect the visual order. - * - * \param log_font The logical font. - * \param glyphs The pointer to the glyph string. - * \param nr_glyphs The length of the glyph string. - * \param glyphs_map The position map returned by \a BIDIGetTextLogicalGlyphs; - * can be NULL. - * - * \return The pointer to the visual glyphs; NULL when error. - */ -MG_EXPORT Glyph32* GUIAPI BIDILogGlyphs2VisGlyphs (LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyphs_map); - -/** - * \fn void GUIAPI BIDIGetLogicalEmbedLevelsEx (LOGFONT* log_font, \ - const Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embed_levels) - * \brief Get the logical embedding levels for the logical glyph string - * and generate runs by embedding levels, the for reorder to get - * visual glyph string. - * - * \param log_font The logical font. - * \param glyphs The pointer to the logical glyph string. - * \param nr_glyphs The length of the glyph string. - * \param pel The paragraph embedding level, can be one of the following values: - * - 0: Level 0 (left to right) - * - 1: Level 1 (right to left) - * - others: Determine according to the heuristic given in - * steps P2 and P3 of the Unicode bidirectional algorithm. - * \param embed_levels The logical embedding level. - * - * \return None. - */ -MG_EXPORT void GUIAPI BIDIGetLogicalEmbedLevelsEx (LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embed_levels); - -static inline void BIDIGetLogicalEmbeddLevels (LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, Uint8** embed_levels) -{ - BIDIGetLogicalEmbedLevelsEx (log_font, glyphs, nr_glyphs, -1, embed_levels); -} - -/** - * \fn void GUIAPI BIDIGetVisualEmbedLevelsEx (LOGFONT* log_font, - const Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embed_levels) - * \brief Get the visual embedding levels for the given logical glyph - * string, then you can get the edge for visual glyphs. - * - * \param log_font The logical font. - * \param glyphs The pointer to the logical glyph string. - * \param nr_glyphs The length of the glyph string. - * \param pel The paragraph embedding level, can be one of the following values: - * - 0\n - * Level 0 (left to right) - * - 1\n - * Level 1 (right to left) - * - others\n - * Determine according to the heuristic given in - * steps P2 and P3 of the Unicode bidirectional algorithm. - * \param embed_levels The embedding level logical to visual. - * - * \return void. - */ -MG_EXPORT void GUIAPI BIDIGetVisualEmbedLevelsEx (LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embed_levels); - -static inline void BIDIGetVisualEmbeddLevels (LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, Uint8** embed_levels) -{ - BIDIGetVisualEmbedLevelsEx (log_font, glyphs, nr_glyphs, -1, embed_levels); -} - /** @} end of glyph */ /* * \var typedef struct _COMP_CTXT COMP_CTXT diff --git a/src/control/bidiedit.c b/src/control/bidiedit.c index ce7209f3..008a1080 100644 --- a/src/control/bidiedit.c +++ b/src/control/bidiedit.c @@ -1,33 +1,33 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * This file is part of MiniGUI, a mature cross-platform windowing * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. - * + * * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * Or, - * + * * As this program is a library, any link to this program must follow * GNU General Public License version 3 (GPLv3). If you cannot accept * GPLv3, you need to be licensed from FMSoft. - * + * * If you have got a commercial license of this program, please use it * under the terms and conditions of the commercial license. - * + * * For more information about the commercial license, please refer to * . */ @@ -76,10 +76,10 @@ static void sledit_refresh_caret (HWND hWnd, PBIDISLEDITDATA sled, BOOL bInited) else \ ShowCaret(hWnd); -/* simple macro to access glyphs string.*/ -#define GLYPHS (sled->glyph_content.glyphs) -#define GLYPHSMAP (sled->glyph_content.glyph_map) -#define GLYPHSLEN (sled->glyph_content.glyphs_len) +/* simple macro to access achars string.*/ +#define ACHARS (sled->achar_content.achars) +#define ACHARSMAP (sled->achar_content.achar_map) +#define ACHARSLEN (sled->achar_content.achars_len) /* simple macro to access text string.*/ #define TEXT (sled->str_content.string) @@ -104,88 +104,88 @@ BOOL RegisterBIDISLEditControl (void) } -static int get_line_rl_type (GLYPHMAPINFO* map, int len); +static int get_line_rl_type (ACHARMAPINFO* map, int len); -static int get_glyph_text_index (PBIDISLEDITDATA sled, int glyph_index) +static int get_achar_text_index (PBIDISLEDITDATA sled, int achar_index) { - if (glyph_index < 0 || glyph_index > GLYPHSLEN) + if (achar_index < 0 || achar_index > ACHARSLEN) return -1; - if(glyph_index >= GLYPHSLEN){ - int line_type = get_line_rl_type (GLYPHSMAP, GLYPHSLEN); + if(achar_index >= ACHARSLEN){ + int line_type = get_line_rl_type (ACHARSMAP, ACHARSLEN); if(!line_type){ return TEXTLEN; } else{ return 0; } - //return (GLYPHSMAP[glyph_index - 1].byte_index); - //return (GLYPHSMAP[glyph_index - 1].byte_index - // + GLYPHSMAP[glyph_index - 1].char_len); + //return (ACHARSMAP[achar_index - 1].byte_index); + //return (ACHARSMAP[achar_index - 1].byte_index + // + ACHARSMAP[achar_index - 1].char_len); } - - return (*(GLYPHSMAP + glyph_index)).byte_index; + + return (*(ACHARSMAP + achar_index)).byte_index; } -static int get_text_glyph_index (PBIDISLEDITDATA sled, int text_index) +static int get_text_achar_index (PBIDISLEDITDATA sled, int text_index) { int min, max; int i = 0; - GLYPHMAPINFO* map = GLYPHSMAP; - + ACHARMAPINFO* map = ACHARSMAP; + if (text_index < 0 || text_index > TEXTLEN) return -1; - - for (; i < GLYPHSLEN; i++) { + + for (; i < ACHARSLEN; i++) { min = (map + i)->byte_index; max = (map + i)->byte_index + ((map + i)->char_len - 1); if ( text_index >= min && text_index <= max) - return i; + return i; } return -1; } -int get_glyph_char_len(PBIDISLEDITDATA sled, int glyph_index) +int get_achar_char_len(PBIDISLEDITDATA sled, int achar_index) { - if (glyph_index<0 || glyph_index > GLYPHSLEN) + if (achar_index<0 || achar_index > ACHARSLEN) return -1; - - return (*(GLYPHSMAP + glyph_index)).char_len; + + return (*(ACHARSMAP + achar_index)).char_len; } -/* Update glyph sring and glyph map info */ -static void update_glyph_info (HWND hWnd, PBIDISLEDITDATA sled) +/* Update achar sring and achar map info */ +static void update_achar_info (HWND hWnd, PBIDISLEDITDATA sled) { PLOGFONT log_font = GetWindowFont(hWnd); if (TEXT == NULL || TEXTLEN <= 0){ - GLYPHSLEN = 0; - return; + ACHARSLEN = 0; + return; } - if (!glyphbuf_realloc (&sled->glyph_content, TEXTLEN)) + if (!acharbuf_realloc (&sled->achar_content, TEXTLEN)) return; - GLYPHSLEN = BIDIGetTextVisualGlyphs (log_font, (const char*)TEXT, TEXTLEN, - &GLYPHS, &GLYPHSMAP); + ACHARSLEN = BIDIGetTextVisualAChars (log_font, + (const char*)TEXT, TEXTLEN, &ACHARS, &ACHARSMAP); return; } -#define CHAR_TYPE_RTL 1 +#define CHAR_TYPE_RTL 1 #define CHAR_TYPE_LTR 0 #define CHAR_TYPE_UNKKOWN -1 -static int get_char_type (PBIDISLEDITDATA sled, int glyph_index) +static int get_char_type (PBIDISLEDITDATA sled, int achar_index) { - if (glyph_index < 0 || glyph_index >= GLYPHSLEN) + if (achar_index < 0 || achar_index >= ACHARSLEN) return CHAR_TYPE_UNKKOWN; - - if (GLYPHSMAP[glyph_index].is_rtol) + + if (ACHARSMAP[achar_index].is_rtol) return CHAR_TYPE_RTL; - else + else return CHAR_TYPE_LTR; } @@ -197,7 +197,7 @@ static void setup_dc (HWND hWnd, BIDISLEDITDATA *sled, HDC hdc, BOOL bSel) if (!bSel) { if (dwStyle & WS_DISABLED) - SetTextColor (hdc, + SetTextColor (hdc, GetWindowElementPixel (hWnd, WE_FGC_DISABLED_ITEM)); else SetTextColor (hdc, GetWindowElementPixel (hWnd, WE_FGC_WINDOW)); @@ -209,17 +209,17 @@ static void setup_dc (HWND hWnd, BIDISLEDITDATA *sled, HDC hdc, BOOL bSel) SetBkMode (hdc, BM_OPAQUE); if (dwStyle & WS_DISABLED) - SetTextColor (hdc, + SetTextColor (hdc, GetWindowElementPixel (hWnd, WE_FGC_DISABLED_ITEM)); else - SetTextColor (hdc, + SetTextColor (hdc, GetWindowElementPixel (hWnd, WE_FGC_SELECTED_ITEM)); if (sled->status & EST_FOCUSED) SetBkColor (hdc, GetWindowElementPixel (hWnd, WE_BGC_SELECTED_ITEM)); else - SetBkColor (hdc, + SetBkColor (hdc, GetWindowElementPixel (hWnd, WE_BGC_SELECTED_LOSTFOCUS)); } } @@ -234,26 +234,26 @@ static int sledit_settext (HWND hWnd, PBIDISLEDITDATA sled, const char *newtext) if (sled->hardLimit >= 0 && txtlen > sled->hardLimit) { return -1; } - + /* free the old text */ if (TEXT){ testr_free (&sled->str_content); - glyphbuf_free (&sled->glyph_content); + acharbuf_free (&sled->achar_content); } if (!testr_alloc (&sled->str_content, len, sled->nBlockSize)) return -1; - - if (!glyphbuf_alloc (&sled->glyph_content, len, sled->nBlockSize)) + + if (!acharbuf_alloc (&sled->achar_content, len, sled->nBlockSize)) return -1; if (newtext && txtlen > 0){ testr_setstr (&sled->str_content, newtext, txtlen); - update_glyph_info(hWnd, sled); + update_achar_info(hWnd, sled); } else { TEXTLEN = 0; - GLYPHSLEN = 0; + ACHARSLEN = 0; } return 0; @@ -280,7 +280,7 @@ static void recalcSize (HWND hWnd, PBIDISLEDITDATA sled, BOOL bInited) set_line_width (hWnd, sled); - sled->starty = sled->topMargin + ( sled->rcVis.bottom - + sled->starty = sled->topMargin + ( sled->rcVis.bottom - sled->rcVis.top - GetWindowFont (hWnd)->size - 1 ) / 2; sledit_refresh_caret (hWnd, sled, bInited); @@ -313,7 +313,7 @@ static int sledit_init (HWND hWnd, PBIDISLEDITDATA sled) sled->nBlockSize = DEF_LINE_BLOCK_SIZE; sled->hardLimit = -1; - + if (pCtrl->dwStyle & ES_TIP) { sled->tiptext = FixStrAlloc (DEF_TIP_LEN + 1); sled->tiptext[0] = 0; @@ -324,12 +324,12 @@ static int sledit_init (HWND hWnd, PBIDISLEDITDATA sled) sled->str_content.string = NULL; sled->str_content.buffsize = 0; sled->str_content.txtlen = 0; - - sled->glyph_content.glyphs = NULL; - sled->glyph_content.glyph_map = NULL; - sled->glyph_content.glyphs_len = 0; - sled->glyph_content.glyphs_buffsize = 0; - sled->glyph_content.glyphmap_buffsize = 0; + + sled->achar_content.achars = NULL; + sled->achar_content.achar_map = NULL; + sled->achar_content.achars_len = 0; + sled->achar_content.achars_buffsize = 0; + sled->achar_content.acharmap_buffsize = 0; sledit_settext (hWnd, sled, pCtrl->spCaption); @@ -350,7 +350,7 @@ static void sledit_destroy (HWND hWnd, PBIDISLEDITDATA sled) if ( (GetWindowStyle(hWnd) & ES_TIP) && sled->tiptext) FreeFixStr (sled->tiptext); testr_free (&sled->str_content); - glyphbuf_free (&sled->glyph_content); + acharbuf_free (&sled->achar_content); return; } @@ -417,7 +417,7 @@ static int get_caretpos_x(HWND hWnd) static BOOL check_sel_edge(int* p, int* num, PBIDISLEDITDATA sled) { int i = 0; - if(p && sled->selStart == 0 && sled->selEnd >= GLYPHSLEN){ + if(p && sled->selStart == 0 && sled->selEnd >= ACHARSLEN){ p[0] = 0; p[1] = sled->selEnd; *num = 1; @@ -427,9 +427,9 @@ static BOOL check_sel_edge(int* p, int* num, PBIDISLEDITDATA sled) /* check the ranges. */ if(!p || *num <= 0) return FALSE; for(i = 0; i < *num; i++){ - if(p[i] < 0 || p[i] > GLYPHSLEN) + if(p[i] < 0 || p[i] > ACHARSLEN) return FALSE; - if(p[i+1] < 0 || p[i+1] > GLYPHSLEN) + if(p[i+1] < 0 || p[i+1] > ACHARSLEN) return FALSE; } @@ -438,8 +438,8 @@ static BOOL check_sel_edge(int* p, int* num, PBIDISLEDITDATA sled) p[1] -= 1; } - if(p[1] == GLYPHSLEN){ - sled->selEnd = GLYPHSLEN; + if(p[1] == ACHARSLEN){ + sled->selEnd = ACHARSLEN; } return TRUE; } @@ -448,10 +448,10 @@ static BOOL check_sel_edge(int* p, int* num, PBIDISLEDITDATA sled) static void print_ranges(int* ranges, int nr_ranges, PBIDISLEDITDATA sled) { int i = 0; - int start_byte_index = get_glyph_text_index(sled, sled->selStart); - int end_byte_index = get_glyph_text_index (sled, sled->selEnd); + int start_byte_index = get_achar_text_index(sled, sled->selStart); + int end_byte_index = get_achar_text_index (sled, sled->selEnd); if(ranges){ - _MG_PRINTF("sel_glyph-[%d,%d], sel_byte = [%d, %d]\n", + _MG_PRINTF("sel_achar-[%d,%d], sel_byte = [%d, %d]\n", sled->selStart, sled->selEnd, start_byte_index, end_byte_index); @@ -464,7 +464,7 @@ static void print_ranges(int* ranges, int nr_ranges, PBIDISLEDITDATA sled) _MG_PRINTF("\n"); } } -#endif +#endif static void slePaint (HWND hWnd, HDC hdc, PBIDISLEDITDATA sled) { @@ -475,11 +475,11 @@ static void slePaint (HWND hWnd, HDC hdc, PBIDISLEDITDATA sled) int startx = 0; int* ranges = NULL; int nr_ranges = 0; - Glyph32* glyph_string = GLYPHS; + Achar32* achar_string = ACHARS; int i = 0; int* p = NULL; - - if (dwStyle & ES_TIP && TEXTLEN <= 0 && + + if (dwStyle & ES_TIP && TEXTLEN <= 0 && GetFocus(GetParent(hWnd)) != hWnd) { setup_dc (hWnd, sled, hdc, FALSE); TextOut (hdc, sled->leftMargin, starty, sled->tiptext); @@ -498,23 +498,23 @@ static void slePaint (HWND hWnd, HDC hdc, PBIDISLEDITDATA sled) MoveTo (hdc, sled->leftMargin, sled->rcVis.bottom); LineTo (hdc, sled->rcVis.right, sled->rcVis.bottom); #else - DrawHDotLine (hdc, + DrawHDotLine (hdc, sled->leftMargin, sled->rcVis.bottom, sled->rcVis.right - sled->rcVis.left); #endif } - /*some glyphs of arabic font have pixels out of them widths*/ + /*some achars of arabic font have pixels out of them widths*/ //sled->rcVis.right += 4; ClipRectIntersect (hdc, &sled->rcVis); - if (sled->selStart != sled->selEnd) { + if (sled->selStart != sled->selEnd) { PLOGFONT log_font = GetWindowFont(hWnd); - int start_byte_index = get_glyph_text_index(sled, sled->selStart); - int end_byte_index = get_glyph_text_index (sled, sled->selEnd); + int start_byte_index = get_achar_text_index(sled, sled->selStart); + int end_byte_index = get_achar_text_index (sled, sled->selEnd); BIDIGetTextRangesLog2Vis(log_font, (char*)TEXT, TEXTLEN, - start_byte_index, end_byte_index, + start_byte_index, end_byte_index, &ranges, &nr_ranges); p = ranges; @@ -523,9 +523,9 @@ static void slePaint (HWND hWnd, HDC hdc, PBIDISLEDITDATA sled) ranges = p = NULL; } -#ifdef _DEBUG +#ifdef _DEBUG print_ranges (p, nr_ranges, sled); -#endif +#endif startx = sled->startx; sleContentToWindow (sled, &startx); while (p && i < nr_ranges){ @@ -538,44 +538,44 @@ static void slePaint (HWND hWnd, HDC hdc, PBIDISLEDITDATA sled) /* draw normal string. */ setup_dc (hWnd, sled, hdc, FALSE); outw += DrawGlyphString (hdc, startx + outw, starty, - glyph_string, len, NULL, NULL); + achar_string, len, NULL, NULL); /* draw selected string.*/ setup_dc (hWnd, sled, hdc, TRUE); - outw += DrawGlyphString (hdc, startx + outw, starty, - glyph_string + len, *(p + 1) - *p, NULL, NULL); + outw += DrawGlyphString (hdc, startx + outw, starty, + achar_string + len, *(p + 1) - *p, NULL, NULL); - glyph_string = GLYPHS + *(p + 1); + achar_string = ACHARS + *(p + 1); - p += 2; - i++; + p += 2; + i++; } /* draw the last rest normal string if necessary.*/ - if (p && GLYPHSLEN > *(p-1)) { + if (p && ACHARSLEN > *(p-1)) { setup_dc (hWnd, sled, hdc, FALSE); outw += DrawGlyphString (hdc, startx + outw, starty, - glyph_string, GLYPHSLEN - *(p - 1), NULL, NULL); + achar_string, ACHARSLEN - *(p - 1), NULL, NULL); } else if(!p || nr_ranges == 0){ /* draw first normal chars */ if (sled->selStart > 0) { setup_dc (hWnd, sled, hdc, FALSE); outw += DrawGlyphString (hdc, startx + outw, starty, - glyph_string, sled->selStart, NULL, NULL); - glyph_string += sled->selStart; + achar_string, sled->selStart, NULL, NULL); + achar_string += sled->selStart; } /* draw selected chars */ setup_dc (hWnd, sled, hdc, TRUE); outw += DrawGlyphString (hdc, startx + outw, starty, - glyph_string, sled->selEnd - sled->selStart, NULL, NULL); - glyph_string += sled->selEnd - sled->selStart; + achar_string, sled->selEnd - sled->selStart, NULL, NULL); + achar_string += sled->selEnd - sled->selStart; /* draw others */ - if (sled->selEnd < GLYPHSLEN) { + if (sled->selEnd < ACHARSLEN) { setup_dc (hWnd, sled, hdc, FALSE); outw += DrawGlyphString (hdc, startx + outw, starty, - glyph_string, GLYPHSLEN - sled->selEnd, NULL, NULL); + achar_string, ACHARSLEN - sled->selEnd, NULL, NULL); } } @@ -587,23 +587,23 @@ static void slePaint (HWND hWnd, HDC hdc, PBIDISLEDITDATA sled) setup_dc (hWnd, sled, hdc, FALSE); startx = sled->startx; sleContentToWindow (sled, &startx); - DrawGlyphString (hdc, startx, starty, glyph_string, GLYPHSLEN, NULL, NULL); + DrawGlyphString (hdc, startx, starty, achar_string, ACHARSLEN, NULL, NULL); } if (dwStyle & ES_PASSWORD) FreeFixStr (passwdBuffer); } -static int +static int sleSetSel (HWND hWnd, PBIDISLEDITDATA sled, int sel_start, int sel_end) { - if (GLYPHSLEN <= 0) + if (ACHARSLEN <= 0) return -1; if (sel_start < 0) sel_start = 0; if (sel_end < 0) - sel_end = GLYPHSLEN; + sel_end = ACHARSLEN; if (sel_start == sel_end) return -1; @@ -615,7 +615,7 @@ sleSetSel (HWND hWnd, PBIDISLEDITDATA sled, int sel_start, int sel_end) return sled->selEnd - sled->selStart; } -/* +/* * set caret position according to the new desired x coordinate. */ static void set_caret_pos (HWND hWnd, PBIDISLEDITDATA sled, int x, BOOL bSel) @@ -623,10 +623,10 @@ static void set_caret_pos (HWND hWnd, PBIDISLEDITDATA sled, int x, BOOL bSel) #ifdef _DEBUG int out_chars = 0; #endif - int out_glyphs = 0; + int out_achars = 0; HDC hdc; SIZE txtsize; - + hdc = GetClientDC (hWnd); sleWindowToContent (sled, &x); @@ -638,28 +638,28 @@ static void set_caret_pos (HWND hWnd, PBIDISLEDITDATA sled, int x, BOOL bSel) txtsize.cx = 0; } else { - out_glyphs = GetGlyphsExtentPoint (hdc, GLYPHS, GLYPHSLEN, + out_achars = GetGlyphsExtentPoint (hdc, ACHARS, ACHARSLEN, x - sled->startx, &txtsize); #ifdef _DEBUG - if(out_glyphs <= GLYPHSLEN){ - out_chars = get_glyph_text_index(sled, out_glyphs); + if(out_achars <= ACHARSLEN){ + out_chars = get_achar_text_index(sled, out_achars); } #endif - _MG_PRINTF ("editPos=%d,out_chars=%d\n", out_glyphs, out_chars); + _MG_PRINTF ("editPos=%d,out_chars=%d\n", out_achars, out_chars); } if (!bSel) { sled->selStart = sled->selEnd = 0; - sled->editPos = out_glyphs; + sled->editPos = out_achars; mySetCaretPos (hWnd, sled, txtsize.cx + sled->startx); } else { - if (out_glyphs > sled->editPos) { + if (out_achars > sled->editPos) { sled->selStart = sled->editPos; - sled->selEnd = out_glyphs; + sled->selEnd = out_achars; } else { sled->selEnd = sled->editPos; - sled->selStart = out_glyphs; + sled->selStart = out_achars; } } @@ -680,30 +680,30 @@ static BOOL make_pos_visible (HWND hWnd, PBIDISLEDITDATA sled, int x) } -static BOOL -make_charpos_visible (HWND hWnd, PBIDISLEDITDATA sled, int glyph_pos, int *cx) +static BOOL +make_charpos_visible (HWND hWnd, PBIDISLEDITDATA sled, int achar_pos, int *cx) { - SIZE glyphs_size; + SIZE achars_size; HDC hdc; - if (glyph_pos <= 0) - glyphs_size.cx = 0; + if (achar_pos <= 0) + achars_size.cx = 0; else { - /* check the glyph_pos. */ - if(glyph_pos > GLYPHSLEN) - glyph_pos = GLYPHSLEN; + /* check the achar_pos. */ + if(achar_pos > ACHARSLEN) + achar_pos = ACHARSLEN; hdc = GetClientDC (hWnd); - GetGlyphsExtent (hdc, GLYPHS, glyph_pos, &glyphs_size); + GetGlyphsExtent (hdc, ACHARS, achar_pos, &achars_size); ReleaseDC (hdc); } if (cx) - *cx = sled->startx + glyphs_size.cx; + *cx = sled->startx + achars_size.cx; - return make_pos_visible (hWnd, sled, sled->startx + glyphs_size.cx); + return make_pos_visible (hWnd, sled, sled->startx + achars_size.cx); } -static void +static void calc_content_width(HWND hWnd, PBIDISLEDITDATA sled, int charPos, int *cx) { SIZE txtsize; @@ -722,22 +722,22 @@ calc_content_width(HWND hWnd, PBIDISLEDITDATA sled, int charPos, int *cx) return; } -static void -calc_glyph_pos_cx (HWND hWnd, PBIDISLEDITDATA sled, int glyph_pos, int *cx) +static void +calc_achar_pos_cx (HWND hWnd, PBIDISLEDITDATA sled, int achar_pos, int *cx) { - SIZE glyphs_size; + SIZE achars_size; HDC hdc; - if (glyph_pos <= 0) - glyphs_size.cx = 0; + if (achar_pos <= 0) + achars_size.cx = 0; else { hdc = GetClientDC (hWnd); - GetTextExtent (hdc, (const char*)GLYPHS, glyph_pos, &glyphs_size); + GetTextExtent (hdc, (const char*)ACHARS, achar_pos, &achars_size); ReleaseDC (hdc); } if (cx) - *cx = sled->startx + glyphs_size.cx; - + *cx = sled->startx + achars_size.cx; + } /* @@ -776,7 +776,7 @@ static int sleMouseMove (HWND hWnd, PBIDISLEDITDATA sled, LPARAM lParam) ScreenToClient(hWnd, &mouseX, &mouseY); GetClientRect(hWnd, &rcClient); - + if(mouseX >= 0 && mouseX < rcClient.right && mouseY >= 0 && mouseY < rcClient.bottom) {//in edit window set_caret_pos (hWnd, sled, mouseX, TRUE); @@ -796,17 +796,17 @@ static int sleMouseMove (HWND hWnd, PBIDISLEDITDATA sled, LPARAM lParam) HDC hdc; SIZE size; sled->selStart = sled->editPos; - sled->selEnd = GLYPHSLEN; - //sled->nContX = sled->nContW - (sled->rcVis.right - sled->rcVis.left); + sled->selEnd = ACHARSLEN; + //sled->nContX = sled->nContW - (sled->rcVis.right - sled->rcVis.left); hdc = GetClientDC (hWnd); - sled->nContX = GetGlyphsExtent (hdc, GLYPHS, GLYPHSLEN, &size) - (sled->rcVis.right - sled->rcVis.left); + sled->nContX = GetGlyphsExtent (hdc, ACHARS, ACHARSLEN, &size) - (sled->rcVis.right - sled->rcVis.left); ReleaseDC (hdc); - printf ("nContX = %d. nContW = %d, rcVis.right = %d, rcVis.left = %d.\n", + printf ("nContX = %d. nContW = %d, rcVis.right = %d, rcVis.left = %d.\n", sled->nContX, sled->nContW, sled->rcVis.right, sled->rcVis.left); #endif } else if (mouseX < 0) { - if (sled->selEnd == GLYPHSLEN) { + if (sled->selEnd == ACHARSLEN) { set_caret_pos (hWnd, sled, 0, TRUE); make_charpos_visible (hWnd, sled, sled->selStart, NULL); goto quit; @@ -819,10 +819,10 @@ static int sleMouseMove (HWND hWnd, PBIDISLEDITDATA sled, LPARAM lParam) refresh = make_charpos_visible (hWnd, sled, sled->selStart, NULL); } else if (mouseX >= rcClient.right) { - if (sled->selStart == 0) + if (sled->selStart == 0) set_caret_pos (hWnd, sled, rcClient.right - 1, TRUE); - if (sled->selEnd == GLYPHSLEN) + if (sled->selEnd == ACHARSLEN) return 0; sled->selEnd++; @@ -839,7 +839,7 @@ quit: static void set_line_width (HWND hWnd, PBIDISLEDITDATA sled) { - SIZE glyphs_size; + SIZE achars_size; HDC hdc; DWORD dwStyle = GetWindowStyle(hWnd); int old_w = sled->nContW; @@ -847,13 +847,13 @@ static void set_line_width (HWND hWnd, PBIDISLEDITDATA sled) hdc = GetClientDC (hWnd); SelectFont (hdc, GetWindowFont(hWnd)); - update_glyph_info(hWnd, sled); + update_achar_info(hWnd, sled); - GetGlyphsExtent (hdc, GLYPHS, GLYPHSLEN, &glyphs_size); + GetGlyphsExtent (hdc, ACHARS, ACHARSLEN, &achars_size); ReleaseDC (hdc); - if (glyphs_size.cx > sled->nVisW) - sled->nContW = glyphs_size.cx; + if (achars_size.cx > sled->nVisW) + sled->nContW = achars_size.cx; else sled->nContW = sled->nVisW; @@ -873,10 +873,10 @@ static void set_line_width (HWND hWnd, PBIDISLEDITDATA sled) if (sled->nContW > sled->nVisW) sled->startx = 0; else if (dwStyle & ES_RIGHT) { - sled->startx = sled->nVisW - glyphs_size.cx; + sled->startx = sled->nVisW - achars_size.cx; } else if (dwStyle & ES_CENTER) { - sled->startx = (sled->nVisW - glyphs_size.cx) >> 1; + sled->startx = (sled->nVisW - achars_size.cx) >> 1; } else { sled->startx = 0; @@ -887,7 +887,7 @@ static void set_line_width (HWND hWnd, PBIDISLEDITDATA sled) static inline void edtChangeCont (HWND hWnd, PBIDISLEDITDATA sled) { - update_glyph_info (hWnd, sled); + update_achar_info (hWnd, sled); set_line_width (hWnd, sled); } @@ -902,16 +902,16 @@ static void check_valid_passwd (char *newtext) } } -static int get_glyph_bytes (PBIDISLEDITDATA sled, int glyph_index) +static int get_achar_bytes (PBIDISLEDITDATA sled, int achar_index) { - if (glyph_index < 0 || glyph_index > GLYPHSLEN) + if (achar_index < 0 || achar_index > ACHARSLEN) return 0; - if(glyph_index >= GLYPHSLEN){ + if(achar_index >= ACHARSLEN){ return 0; } - - return (*(GLYPHSMAP + glyph_index)).char_len; + + return (*(ACHARSMAP + achar_index)).char_len; } static void del_selected_text (HWND hWnd, PBIDISLEDITDATA sled) @@ -926,25 +926,25 @@ static void del_selected_text (HWND hWnd, PBIDISLEDITDATA sled) if (sled->selStart < 0 || sled->selEnd < 0) return; - if(sled->selStart == 0 && sled->selEnd == GLYPHSLEN){ - s = 0; - e = TEXTLEN; + if(sled->selStart == 0 && sled->selEnd == ACHARSLEN){ + s = 0; + e = TEXTLEN; } else{ - s = get_glyph_text_index(sled, sled->selStart); - e = get_glyph_text_index(sled, sled->selEnd); - /*add end glyph char_len.*/ + s = get_achar_text_index(sled, sled->selStart); + e = get_achar_text_index(sled, sled->selEnd); + /*add end achar char_len.*/ if(s > e) - end_byte_index += get_glyph_bytes(sled, sled->selStart); + end_byte_index += get_achar_bytes(sled, sled->selStart); else - end_byte_index += get_glyph_bytes(sled, sled->selEnd); + end_byte_index += get_achar_bytes(sled, sled->selEnd); } start_byte_index = MIN(s, e); end_byte_index = MAX (s, e); - _MG_PRINTF("delete: sel_glyph-[%d,%d], sel_byte = [%d, %d]\n", + _MG_PRINTF("delete: sel_achar-[%d,%d], sel_byte = [%d, %d]\n", sled->selStart, sled->selEnd, start_byte_index, end_byte_index); @@ -959,17 +959,17 @@ static void del_selected_text (HWND hWnd, PBIDISLEDITDATA sled) ShowCaret(hWnd); } - return; + return; } -static int -sleBackspaceText (HWND hWnd, PBIDISLEDITDATA sled, int del_char_num, +static int +sleBackspaceText (HWND hWnd, PBIDISLEDITDATA sled, int del_char_num, BOOL refresh, BOOL is_del) { int del_pos; unsigned char *pIns, *str_content = TEXT; - int old_glyphs_len = GLYPHSLEN; + int old_achars_len = ACHARSLEN; int edit_pos_offset = 0; if(sled->selStart != sled->selEnd) { @@ -977,7 +977,7 @@ sleBackspaceText (HWND hWnd, PBIDISLEDITDATA sled, int del_char_num, del_char_num = 0; } - del_pos = get_glyph_text_index(sled, sled->editPos - 1) + 1; + del_pos = get_achar_text_index(sled, sled->editPos - 1) + 1; if (del_char_num > 0) { pIns = str_content + del_pos; @@ -994,7 +994,7 @@ sleBackspaceText (HWND hWnd, PBIDISLEDITDATA sled, int del_char_num, sled->editPos --; } else { - edit_pos_offset = old_glyphs_len - GLYPHSLEN; + edit_pos_offset = old_achars_len - ACHARSLEN; if (del_char_num > 0 && edit_pos_offset > 0 && sled->editPos >= edit_pos_offset ) sled->editPos -= edit_pos_offset; @@ -1018,70 +1018,70 @@ sleBackspaceText (HWND hWnd, PBIDISLEDITDATA sled, int del_char_num, } static int ascii_bidi_type[] = { - /*0x00~0x0f*/ - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_SS, BIDI_TYPE_BS, BIDI_TYPE_SS, + /*0x00~0x0f*/ + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_SS, BIDI_TYPE_BS, BIDI_TYPE_SS, BIDI_TYPE_WS, BIDI_TYPE_BS, BIDI_TYPE_BN, BIDI_TYPE_BN, - /*0x10~0x1f*/ - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + /*0x10~0x1f*/ + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BS, BIDI_TYPE_BS, BIDI_TYPE_BS, BIDI_TYPE_SS, - /*0x20~0x2f*/ - BIDI_TYPE_WS, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ET, - BIDI_TYPE_ET, BIDI_TYPE_ET, BIDI_TYPE_ON, BIDI_TYPE_ON, - BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ES, + /*0x20~0x2f*/ + BIDI_TYPE_WS, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ET, + BIDI_TYPE_ET, BIDI_TYPE_ET, BIDI_TYPE_ON, BIDI_TYPE_ON, + BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ES, BIDI_TYPE_CS, BIDI_TYPE_ES, BIDI_TYPE_CS, BIDI_TYPE_CS, - /*0x30~0x3f*/ - BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, - BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, - BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_CS, BIDI_TYPE_ON, + /*0x30~0x3f*/ + BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, + BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, + BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_CS, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, - /*0x40~0x4f*/ + /*0x40~0x4f*/ BIDI_TYPE_ON, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, - /*0x50~0x6f*/ + /*0x50~0x6f*/ BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, - BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_ON, + BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, - /*0x60~0x6f*/ + /*0x60~0x6f*/ BIDI_TYPE_ON, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, - /*0x70~0x7f*/ + /*0x70~0x7f*/ BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, - BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_ON, + BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_BN, }; -static int inline get_glyph_bidi_type (LOGFONT* logfont, Glyph32 glyph) +static int inline get_char_bidi_type (LOGFONT* logfont, Achar32 chv) { DEVFONT* devfont; - if (IS_MBC_GLYPH(glyph)) { + if (IS_MBCHV(chv)) { devfont = logfont->devfonts[1]; if (devfont->charset_ops->bidi_char_type) { - return devfont->charset_ops->bidi_char_type (glyph); + return devfont->charset_ops->bidi_char_type (chv); } else { return BIDI_TYPE_LTR; } } else { - return ascii_bidi_type[glyph]; + return ascii_bidi_type[chv]; } } @@ -1089,13 +1089,13 @@ static int get_text_rl_type (PLOGFONT logfont, char* newtext, int l_char_type, int r_char_type, int line_type) { int bidi_type; - Glyph32 glyph; - glyph = GetGlyphValue (logfont, newtext, strlen(newtext), NULL, 0); + Achar32 chv; + chv = GetACharValue (logfont, newtext, strlen(newtext), NULL, 0); - if (glyph == INV_GLYPH_VALUE) + if (chv == INV_ACHAR_VALUE) return -1; - bidi_type = get_glyph_bidi_type (logfont, glyph); + bidi_type = get_char_bidi_type (logfont, chv); if (BIDI_IS_STRONG(bidi_type)) { @@ -1118,7 +1118,7 @@ static int get_text_rl_type (PLOGFONT logfont, char* newtext, int l_char_type, { return l_char_type; } - /*no left glyph*/ + /* no left char */ else if (l_char_type == -1) { if (BIDI_IS_WEAK (bidi_type)) @@ -1126,7 +1126,7 @@ static int get_text_rl_type (PLOGFONT logfont, char* newtext, int l_char_type, else return line_type; } - /*no right glyph*/ + /* no right char */ else if (r_char_type == -1) { if (BIDI_IS_WEAK (bidi_type)) @@ -1141,7 +1141,7 @@ static int get_text_rl_type (PLOGFONT logfont, char* newtext, int l_char_type, } -static int get_line_rl_type (GLYPHMAPINFO* map, int len) +static int get_line_rl_type (ACHARMAPINFO* map, int len) { int i; for (i=0; iglyph_content.glyph_map[cur_glyph_index].byte_index ) +#define INSERTPOS_BEFORE(sled, cur_achar_index) \ + ( (sled)->achar_content.achar_map[cur_achar_index].byte_index ) -#define INSERTPOS_AFTER(sled, cur_glyph_index) \ - ( (sled)->glyph_content.glyph_map[cur_glyph_index].byte_index + \ - (sled)->glyph_content.glyph_map[cur_glyph_index].char_len ) +#define INSERTPOS_AFTER(sled, cur_achar_index) \ + ( (sled)->achar_content.achar_map[cur_achar_index].byte_index + \ + (sled)->achar_content.achar_map[cur_achar_index].char_len ) #define INSERTPOS_LINE_END(sled) \ ((sled)->str_content.txtlen) - -static int -get_insert_pos (PLOGFONT logfont, PBIDISLEDITDATA sled, char *newtext, + +static int +get_insert_pos (PLOGFONT logfont, PBIDISLEDITDATA sled, char *newtext, int* cur_type) { - int l_glyph_index = sled->editPos - 1; - int r_glyph_index = sled->editPos; + int l_achar_index = sled->editPos - 1; + int r_achar_index = sled->editPos; - int l_char_type = get_char_type (sled, l_glyph_index); - int r_char_type = get_char_type (sled, r_glyph_index); + int l_char_type = get_char_type (sled, l_achar_index); + int r_char_type = get_char_type (sled, r_achar_index); - int line_type = get_line_rl_type (GLYPHSMAP, GLYPHSLEN); + int line_type = get_line_rl_type (ACHARSMAP, ACHARSLEN); *cur_type = get_text_rl_type (logfont, newtext, l_char_type, r_char_type, line_type); if (*cur_type == CHAR_TYPE_RTL) { if (l_char_type == CHAR_TYPE_RTL) { - return INSERTPOS_BEFORE (sled, l_glyph_index); + return INSERTPOS_BEFORE (sled, l_achar_index); } else if (r_char_type == CHAR_TYPE_RTL) { - return INSERTPOS_AFTER (sled, r_glyph_index); + return INSERTPOS_AFTER (sled, r_achar_index); } else { /*L|L, or L|0(must in a L line)*/ if (l_char_type == CHAR_TYPE_LTR) { - return INSERTPOS_AFTER (sled, l_glyph_index); + return INSERTPOS_AFTER (sled, l_achar_index); } /*0|L*/ else if (r_char_type == CHAR_TYPE_LTR) { @@ -1211,15 +1211,15 @@ get_insert_pos (PLOGFONT logfont, PBIDISLEDITDATA sled, char *newtext, } else { if (l_char_type == CHAR_TYPE_LTR) { - return INSERTPOS_AFTER (sled, l_glyph_index); + return INSERTPOS_AFTER (sled, l_achar_index); } else if (r_char_type == CHAR_TYPE_LTR) { - return INSERTPOS_BEFORE (sled, r_glyph_index); + return INSERTPOS_BEFORE (sled, r_achar_index); } else { /*R|R or 0|R(must in R line)*/ if (r_char_type == CHAR_TYPE_RTL) { - return INSERTPOS_AFTER (sled, r_glyph_index); + return INSERTPOS_AFTER (sled, r_achar_index); } /*R|0*/ else if (l_char_type == CHAR_TYPE_RTL) { @@ -1255,8 +1255,8 @@ static void print_text(PBIDISLEDITDATA sled) } #endif -static int -sleInsertText (HWND hWnd, PBIDISLEDITDATA sled, char *newtext, +static int +sleInsertText (HWND hWnd, PBIDISLEDITDATA sled, char *newtext, int inserting, BOOL refresh) { int insert_pos; @@ -1273,17 +1273,17 @@ sleInsertText (HWND hWnd, PBIDISLEDITDATA sled, char *newtext, //delete the seleted if(sled->selStart != sled->selEnd) { del_selected_text (hWnd, sled); - update_glyph_info (hWnd, sled); + update_achar_info (hWnd, sled); } insert_pos = get_insert_pos (GetWindowFont(hWnd), sled, newtext, &cur_type); -#ifdef _DEBUG +#ifdef _DEBUG print_text (sled); -#endif +#endif /* insert and total char len > hardLimit in INSERT state */ - if ( !(sled->status & EST_REPLACE) && + if ( !(sled->status & EST_REPLACE) && sled->hardLimit >= 0 && ((TEXTLEN + inserting) > sled->hardLimit)) { Ping (); @@ -1293,7 +1293,7 @@ sleInsertText (HWND hWnd, PBIDISLEDITDATA sled, char *newtext, if (!refresh) return 0; } /* insert and total char len > hardLimit in REPLACE state */ - else if ( (sled->status & EST_REPLACE) && + else if ( (sled->status & EST_REPLACE) && sled->hardLimit >= 0 && (insert_pos + inserting > sled->hardLimit) ) { Ping (); @@ -1325,10 +1325,10 @@ sleInsertText (HWND hWnd, PBIDISLEDITDATA sled, char *newtext, /* RTL */ if (cur_type == CHAR_TYPE_RTL) { - sled->editPos = get_text_glyph_index (sled, insert_pos); + sled->editPos = get_text_achar_index (sled, insert_pos); } else { /*LTR*/ - sled->editPos = get_text_glyph_index (sled, insert_pos) + 1; + sled->editPos = get_text_achar_index (sled, insert_pos) + 1; } sled->selStart = sled->selEnd = sled->editPos; @@ -1338,9 +1338,9 @@ sleInsertText (HWND hWnd, PBIDISLEDITDATA sled, char *newtext, int i = 0; _MG_PRINTF ("string = %s.\n", TEXT); _MG_PRINTF ("editPos = %d.\n", sled->editPos); - for (i = 0; i < sled->glyph_content.glyphs_len; i++) { - _MG_PRINTF ("map[%d] = %d,", i, - sled->glyph_content.glyph_map[i].byte_index); + for (i = 0; i < sled->achar_content.achars_len; i++) { + _MG_PRINTF ("map[%d] = %d,", i, + sled->achar_content.achar_map[i].byte_index); _MG_PRINTF ("\n"); } } @@ -1391,8 +1391,8 @@ static void esright_backspace_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) if (sled->nContW <= sled->nVisW){ if (sled->selStart != sled->selEnd){ - calc_glyph_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); - calc_glyph_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); + calc_achar_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); + calc_achar_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); if (sled->selStart < sled->selEnd){ scroll_rc.right = sel_end_x + 1; } @@ -1412,10 +1412,10 @@ static void esright_backspace_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) edtSetCaretPos (hWnd, sled); } else{ - calc_glyph_pos_cx(hWnd, sled, sled->editPos, &old_editpos_x); + calc_achar_pos_cx(hWnd, sled, sled->editPos, &old_editpos_x); scroll_rc.left = sled->rcVis.left; - calc_glyph_pos_cx(hWnd, sled, sled->editPos + del, &cur_editpos_x); - + calc_achar_pos_cx(hWnd, sled, sled->editPos + del, &cur_editpos_x); + sleBackspaceText (hWnd, sled, del,TRUE, FALSE); edtSetCaretPos (hWnd, sled); @@ -1424,7 +1424,7 @@ static void esright_backspace_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) scroll_len = abs(cur_editpos_x - old_editpos_x); ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); - /* Add for redraw glyph string. ES_RIGHT backspace/del error */ + /* Add for redraw achar string. ES_RIGHT backspace/del error */ InvalidateRect(hWnd, NULL, TRUE); } @@ -1441,8 +1441,8 @@ static void esright_backspace_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) scroll_rc.right = sled->rcVis.right; - calc_glyph_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); - calc_glyph_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); + calc_achar_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); + calc_achar_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); if (sled->selStart < sled->selEnd){ scroll_rc.left = sel_start_x + 1; } @@ -1495,8 +1495,8 @@ static void esright_backspace_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) refresh_rc.bottom = sled->rcVis.bottom; refresh_rc.left = sled->rcVis.left; - calc_glyph_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); - calc_glyph_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); + calc_achar_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); + calc_achar_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); if (sled->selStart < sled->selEnd){ scroll_rc.right = sel_end_x + 1 - sled->nContX; } @@ -1532,7 +1532,7 @@ static void esright_backspace_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) old_ncontw = sled->nContW; sleBackspaceText (hWnd, sled, del, TRUE, FALSE); edtSetCaretPos (hWnd, sled); - cur_caret_x = get_caretpos_x(hWnd); + cur_caret_x = get_caretpos_x(hWnd); scroll_rc.right = cur_caret_x; scroll_len = abs(sled->nContW - old_ncontw); @@ -1571,8 +1571,8 @@ static void esright_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) if (sled->nContW <= sled->nVisW){ if (sled->selStart != sled->selEnd){ - calc_glyph_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); - calc_glyph_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); + calc_achar_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); + calc_achar_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); if (sled->selStart < sled->selEnd){ scroll_rc.right = sel_end_x + 1; } @@ -1587,16 +1587,16 @@ static void esright_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); edtSetCaretPos (hWnd, sled); - /* Add for redraw glyph string. ES_RIGHT backspace/del error */ + /* Add for redraw achar string. ES_RIGHT backspace/del error */ InvalidateRect(hWnd, NULL, TRUE); - + } else{ old_caret_x = get_caretpos_x(hWnd); scroll_rc.left = sled->rcVis.left; sleBackspaceText (hWnd, sled, del, TRUE, TRUE); edtSetCaretPos (hWnd, sled); - cur_caret_x = get_caretpos_x(hWnd); + cur_caret_x = get_caretpos_x(hWnd); scroll_rc.right = cur_caret_x; scroll_len = cur_caret_x - old_caret_x; @@ -1618,8 +1618,8 @@ static void esright_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) scroll_rc.right = sled->rcVis.right; - calc_glyph_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); - calc_glyph_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); + calc_achar_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); + calc_achar_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); if (sled->selStart < sled->selEnd){ scroll_rc.left = sel_start_x + 1; } @@ -1647,11 +1647,11 @@ static void esright_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) scroll_rc.right = sled->rcVis.right; - scroll_rc.left = get_caretpos_x(hWnd); - calc_glyph_pos_cx(hWnd, sled, sled->editPos, &old_editpos_x); + scroll_rc.left = get_caretpos_x(hWnd); + calc_achar_pos_cx(hWnd, sled, sled->editPos, &old_editpos_x); sleBackspaceText (hWnd, sled, del, TRUE, TRUE); - calc_glyph_pos_cx(hWnd, sled, sled->editPos, &cur_editpos_x); + calc_achar_pos_cx(hWnd, sled, sled->editPos, &cur_editpos_x); edtSetCaretPos (hWnd, sled); scroll_len = old_editpos_x - cur_editpos_x; @@ -1672,8 +1672,8 @@ static void esright_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) refresh_rc.bottom = sled->rcVis.bottom; refresh_rc.left = sled->rcVis.left; - calc_glyph_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); - calc_glyph_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); + calc_achar_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); + calc_achar_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); if (sled->selStart < sled->selEnd){ scroll_rc.right = sel_end_x + 1 - sled->nContX; } @@ -1711,7 +1711,7 @@ static void esright_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) scroll_rc.left = sled->rcVis.left; sleBackspaceText (hWnd, sled, del, TRUE, TRUE); edtSetCaretPos (hWnd, sled); - cur_caret_x = get_caretpos_x(hWnd); + cur_caret_x = get_caretpos_x(hWnd); scroll_rc.right = cur_caret_x; scroll_len = cur_caret_x - old_caret_x; @@ -1739,7 +1739,7 @@ static void esleft_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) { int old_nContX = sled->nContX; RECT scroll_rc, del_rc, refresh_rc; - int glyphs_len_x; + int achars_len_x; int sel_start_x, sel_end_x; int old_caret_x, cur_caret_x; int scroll_len; @@ -1747,36 +1747,36 @@ static void esleft_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) scroll_rc.top = sled->rcVis.top; scroll_rc.bottom = sled->rcVis.bottom; del_rc.bottom = sled->rcVis.bottom; - del_rc.top = sled->rcVis.top; + del_rc.top = sled->rcVis.top; refresh_rc.top = sled->rcVis.top; refresh_rc.bottom = sled->rcVis.bottom; if (sled->selStart != sled->selEnd){ if (sled->selStart < sled->selEnd){ - calc_glyph_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); + calc_achar_pos_cx(hWnd, sled, sled->selEnd, &sel_end_x); scroll_rc.left = sel_end_x; } else{ - calc_glyph_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); + calc_achar_pos_cx(hWnd, sled, sled->selStart, &sel_start_x); scroll_rc.left = sel_start_x; } scroll_rc.right = sled->rcVis.right; } else{ - calc_glyph_pos_cx(hWnd, sled, sled->editPos, &scroll_rc.left); + calc_achar_pos_cx(hWnd, sled, sled->editPos, &scroll_rc.left); scroll_rc.left = scroll_rc.left - old_nContX; scroll_rc.right = sled->rcVis.right; } old_caret_x = get_caretpos_x(hWnd); - calc_glyph_pos_cx(hWnd, sled, GLYPHSLEN, &glyphs_len_x); + calc_achar_pos_cx(hWnd, sled, ACHARSLEN, &achars_len_x); sleBackspaceText (hWnd, sled, del, TRUE, TRUE); - calc_glyph_pos_cx(hWnd, sled, sled->editPos, &del_rc.left); + calc_achar_pos_cx(hWnd, sled, sled->editPos, &del_rc.left); del_rc.left = del_rc.left - old_nContX; - del_rc.right = scroll_rc.left; + del_rc.right = scroll_rc.left; scroll_len = del_rc.left - scroll_rc.left; @@ -1784,36 +1784,36 @@ static void esleft_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) InvalidateRect(hWnd, NULL, TRUE); } else{ - if ((old_nContX > 0) && - ((glyphs_len_x - old_nContX) <= sled->rcVis.right)){ + if ((old_nContX > 0) && + ((achars_len_x - old_nContX) <= sled->rcVis.right)){ - cur_caret_x = get_caretpos_x(hWnd); + cur_caret_x = get_caretpos_x(hWnd); if (cur_caret_x != old_caret_x){ - scroll_len = cur_caret_x - old_caret_x; + scroll_len = cur_caret_x - old_caret_x; scroll_rc.left = sled->rcVis.left; scroll_rc.right = old_caret_x; ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); - + refresh_rc.left = old_caret_x; refresh_rc.right = cur_caret_x; InvalidateRect(hWnd, &refresh_rc, TRUE); } else if (sled->selStart != sled->selEnd) { - scroll_len = sel_start_x - sel_end_x; + scroll_len = sel_start_x - sel_end_x; scroll_rc.left = sled->rcVis.left; scroll_rc.right = old_caret_x; ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); - + refresh_rc.left = old_caret_x; refresh_rc.right = cur_caret_x; InvalidateRect(hWnd, &refresh_rc, TRUE); } else{ - InvalidateRect(hWnd, NULL, TRUE); + InvalidateRect(hWnd, NULL, TRUE); } } else{ @@ -1821,11 +1821,11 @@ static void esleft_del_refresh(HWND hWnd, PBIDISLEDITDATA sled, int del) InvalidateRect(hWnd, &del_rc, TRUE); ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); - calc_glyph_pos_cx(hWnd, sled, GLYPHSLEN, &rl); + calc_achar_pos_cx(hWnd, sled, ACHARSLEN, &rl); - if (((sled->nContW - sled->nContX) == sled->nVisW) && + if (((sled->nContW - sled->nContX) == sled->nVisW) && (old_nContX > 0)){ - InvalidateRect(hWnd, NULL, TRUE); + InvalidateRect(hWnd, NULL, TRUE); } else if (rl < sled->nVisW){ refresh_rc.left = rl; @@ -1874,7 +1874,7 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) return 0; } - + if (sled->selStart != sled->selEnd) { ShowCaret(hWnd); refresh = TRUE; @@ -1889,14 +1889,14 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) return 0; } - + case SCANCODE_END: { BOOL refresh = FALSE; - + if(lParam & KS_SHIFT) { sled->selStart = sled->editPos; - sled->selEnd = GLYPHSLEN; + sled->selEnd = ACHARSLEN; check_caret(); make_charpos_visible (hWnd, sled, sled->selEnd, NULL); InvalidateRect(hWnd, NULL, TRUE); @@ -1911,7 +1911,7 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) refresh = TRUE; } - sled->editPos = GLYPHSLEN; + sled->editPos = ACHARSLEN; sled->selStart = sled->selEnd = sled->editPos; if (!edtSetCaretPos (hWnd, sled) && refresh) @@ -1948,7 +1948,7 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) } if (sled->editPos > 0) { - sled->editPos--; + sled->editPos--; } if (sled->selStart != sled->selEnd) { @@ -1964,7 +1964,7 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) return 0; } - + case SCANCODE_CURSORBLOCKRIGHT: { BOOL refresh = FALSE; @@ -1973,13 +1973,13 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) if(sled->selStart == sled->selEnd) sled->selStart = sled->selEnd = sled->editPos; - if (sled->selStart == sled->selEnd || + if (sled->selStart == sled->selEnd || sled->selEnd > sled->editPos) { - if (sled->selEnd < GLYPHSLEN) - sled->selEnd++; + if (sled->selEnd < ACHARSLEN) + sled->selEnd++; } else { - sled->selStart++; + sled->selStart++; } check_caret (); @@ -1990,8 +1990,8 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) return 0; } - if (sled->editPos < GLYPHSLEN) { - sled->editPos++; + if (sled->editPos < ACHARSLEN) { + sled->editPos++; } if (sled->selStart != sled->selEnd) { @@ -2005,7 +2005,7 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) InvalidateRect (hWnd, NULL, TRUE); } return 0; - + case SCANCODE_REMOVE: { int del; @@ -2014,11 +2014,11 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) if ((dwStyle & ES_READONLY)) return 0; - if (sled->editPos == GLYPHSLEN && sled->selStart == sled->selEnd) + if (sled->editPos == ACHARSLEN && sled->selStart == sled->selEnd) return 0; - if (sled->selStart == sled->selEnd && sled->editPos < GLYPHSLEN) { - sled->editPos ++; + if (sled->selStart == sled->selEnd && sled->editPos < ACHARSLEN) { + sled->editPos ++; } del = sled->editPos - oldpos; @@ -2033,7 +2033,7 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) sled->changed = TRUE; NotifyParent (hWnd, GetDlgCtrlID(hWnd), EN_CHANGE); - } + } else if (dwStyle & ES_RIGHT) { esright_del_refresh(hWnd, sled, del); } @@ -2060,7 +2060,7 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) case SCANCODE_X: { if ((lParam & KS_CTRL) && (sled->selEnd - sled->selStart > 0)) { - SetClipBoardData (CBNAME_TEXT, TEXT + sled->selStart, + SetClipBoardData (CBNAME_TEXT, TEXT + sled->selStart, sled->selEnd - sled->selStart, CBOP_NORMAL); if (wParam == SCANCODE_X && !(GetWindowStyle(hWnd) & ES_READONLY)) { sleInsertText (hWnd, sled, NULL, 0, FALSE); @@ -2084,7 +2084,7 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) default: break; } //end switch - + if (bChange){ sled->changed = TRUE; NotifyParent (hWnd, pCtrl->id, EN_CHANGE); @@ -2092,8 +2092,8 @@ static int sleKeyDown (HWND hWnd, WPARAM wParam, LPARAM lParam) return 0; } -static void -esright_input_char_refresh (HWND hWnd, +static void +esright_input_char_refresh (HWND hWnd, PBIDISLEDITDATA sled, char *charBuffer, int chars) { RECT scroll_rc; @@ -2111,7 +2111,7 @@ esright_input_char_refresh (HWND hWnd, sleInsertText (hWnd, sled, (char* )charBuffer, chars,TRUE); calc_content_width(hWnd, sled, TEXTLEN, &cur_ncontw); - scroll_len = abs(old_ncontw- cur_ncontw); + scroll_len = abs(old_ncontw- cur_ncontw); cur_caret_x = get_caretpos_x(hWnd); scroll_rc.left = sled->rcVis.left; scroll_rc.right = cur_caret_x; @@ -2125,114 +2125,114 @@ esright_input_char_refresh (HWND hWnd, } } -static void -esleft_input_char_refresh (HWND hWnd, +static void +esleft_input_char_refresh (HWND hWnd, PBIDISLEDITDATA sled, char *charBuffer, int chars) { int old_caretpos_x; - int old_sel_start, old_sel_end; + int old_sel_start, old_sel_end; int old_sel_start_x, old_sel_end_x, cur_sel_start_x; RECT scroll_rc, refresh_rc; int scroll_len; int old_edit_pos_x, cur_edit_pos_x; int old_nContX; - //char_size is width of input chars; sel_size is width of the selected area + //char_size is width of input chars; sel_size is width of the selected area int char_size, sel_size; - int glyphs_len_x; + int achars_len_x; old_sel_start = sled->selStart; - old_sel_end = sled->selEnd; + old_sel_end = sled->selEnd; old_caretpos_x = get_caretpos_x(hWnd); - calc_glyph_pos_cx(hWnd, sled, sled->editPos, &old_edit_pos_x); - calc_glyph_pos_cx(hWnd, sled, GLYPHSLEN, &glyphs_len_x); + calc_achar_pos_cx(hWnd, sled, sled->editPos, &old_edit_pos_x); + calc_achar_pos_cx(hWnd, sled, ACHARSLEN, &achars_len_x); old_nContX= sled->nContX; - calc_glyph_pos_cx(hWnd, sled, old_sel_start, &old_sel_start_x); - calc_glyph_pos_cx(hWnd, sled, old_sel_end, &old_sel_end_x); + calc_achar_pos_cx(hWnd, sled, old_sel_start, &old_sel_start_x); + calc_achar_pos_cx(hWnd, sled, old_sel_end, &old_sel_end_x); old_sel_start_x = old_sel_start_x - sled->nContX; old_sel_end_x = old_sel_end_x - sled->nContX; sleInsertText (hWnd, sled, (char* )charBuffer, chars, TRUE); - calc_glyph_pos_cx(hWnd, sled, sled->editPos, &cur_edit_pos_x); - calc_glyph_pos_cx(hWnd, sled, old_sel_start, &cur_sel_start_x); + calc_achar_pos_cx(hWnd, sled, sled->editPos, &cur_edit_pos_x); + calc_achar_pos_cx(hWnd, sled, old_sel_start, &cur_sel_start_x); char_size = cur_edit_pos_x - cur_sel_start_x; sel_size = abs(old_sel_start_x - old_sel_end_x); - scroll_rc.top = sled->rcVis.top; - scroll_rc.bottom = sled->rcVis.bottom; + scroll_rc.top = sled->rcVis.top; + scroll_rc.bottom = sled->rcVis.bottom; refresh_rc.top = sled->rcVis.top; refresh_rc.bottom = sled->rcVis.bottom; if (char_size >= sled->nVisW){ - InvalidateRect(hWnd, NULL, TRUE); + InvalidateRect(hWnd, NULL, TRUE); } else{ if (old_sel_start != old_sel_end){ - if (sel_size >= sled->nVisW){ + if (sel_size >= sled->nVisW){ InvalidateRect(hWnd, NULL, TRUE); } else{ if (char_size < sel_size){ - //right scroll window - if ((old_nContX > 0) && - ((glyphs_len_x - old_nContX) <= sled->rcVis.right)) { - scroll_len = sel_size - char_size; - scroll_rc.left = sled->rcVis.left; + //right scroll window + if ((old_nContX > 0) && + ((achars_len_x - old_nContX) <= sled->rcVis.right)) { + scroll_len = sel_size - char_size; + scroll_rc.left = sled->rcVis.left; scroll_rc.right = old_sel_start_x < old_sel_end_x ? old_sel_start_x : old_sel_end_x; ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); refresh_rc.left = scroll_rc.right; - refresh_rc.right = refresh_rc.left + sel_size + + refresh_rc.right = refresh_rc.left + sel_size + scroll_len; InvalidateRect(hWnd, &refresh_rc, TRUE); - } - else{//left scroll window - scroll_len = -(sel_size - char_size); - scroll_rc.left = old_sel_start_x < old_sel_end_x - ? old_sel_end_x : old_sel_start_x; + } + else{//left scroll window + scroll_len = -(sel_size - char_size); + scroll_rc.left = old_sel_start_x < old_sel_end_x + ? old_sel_end_x : old_sel_start_x; scroll_rc.right = sled->rcVis.right; ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); - refresh_rc.left = scroll_rc.left - sel_size; - refresh_rc.right = scroll_rc.left; + refresh_rc.left = scroll_rc.left - sel_size; + refresh_rc.right = scroll_rc.left; InvalidateRect(hWnd, &refresh_rc, TRUE); } } - else{//when char_size > sel_size right scroll window - scroll_len = char_size - sel_size; - scroll_rc.left = old_sel_start_x < old_sel_end_x - ? old_sel_end_x : old_sel_start_x; - scroll_rc.right = sled->rcVis.right; + else{//when char_size > sel_size right scroll window + scroll_len = char_size - sel_size; + scroll_rc.left = old_sel_start_x < old_sel_end_x + ? old_sel_end_x : old_sel_start_x; + scroll_rc.right = sled->rcVis.right; ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); refresh_rc.left = scroll_rc.left - sel_size; - refresh_rc.right = refresh_rc.left + char_size + 1; + refresh_rc.right = refresh_rc.left + char_size + 1; InvalidateRect(hWnd, &refresh_rc, TRUE); } } } else{ - int right; - char_size = cur_edit_pos_x - old_edit_pos_x; + int right; + char_size = cur_edit_pos_x - old_edit_pos_x; - calc_glyph_pos_cx(hWnd, sled, GLYPHSLEN, &right); + calc_achar_pos_cx(hWnd, sled, ACHARSLEN, &right); - if (old_caretpos_x < sled->rcVis.right){//right scroll window - scroll_len = cur_edit_pos_x - old_edit_pos_x; + if (old_caretpos_x < sled->rcVis.right){//right scroll window + scroll_len = cur_edit_pos_x - old_edit_pos_x; if ((sled->rcVis.right - old_caretpos_x) < scroll_len){// - scroll_len = -(scroll_len - - (sled->rcVis.right- old_caretpos_x)); - scroll_rc.left = sled->rcVis.left; - scroll_rc.right = old_caretpos_x; + scroll_len = -(scroll_len - + (sled->rcVis.right- old_caretpos_x)); + scroll_rc.left = sled->rcVis.left; + scroll_rc.right = old_caretpos_x; ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); refresh_rc.left = sled->rcVis.right - char_size; @@ -2241,9 +2241,9 @@ esleft_input_char_refresh (HWND hWnd, InvalidateRect(hWnd, &refresh_rc, TRUE); } else{ - scroll_rc.left = old_caretpos_x; - scroll_rc.right = (right < sled->rcVis.right) - ? right+1 : sled->rcVis.right; + scroll_rc.left = old_caretpos_x; + scroll_rc.right = (right < sled->rcVis.right) + ? right+1 : sled->rcVis.right; ScrollWindow(hWnd, scroll_len, 0, &scroll_rc, NULL); refresh_rc.left = sled->rcVis.right - char_size; @@ -2252,19 +2252,19 @@ esleft_input_char_refresh (HWND hWnd, InvalidateRect(hWnd, &refresh_rc, TRUE); } } - else{//left scroll window - scroll_len = old_edit_pos_x - cur_edit_pos_x; + else{//left scroll window + scroll_len = old_edit_pos_x - cur_edit_pos_x; ScrollWindow(hWnd, scroll_len, 0, &sled->rcVis, NULL); refresh_rc.left = sled->rcVis.right - char_size; refresh_rc.right = sled->rcVis.right; - + InvalidateRect(hWnd, &refresh_rc, TRUE); } - if (((sled->nContW - sled->nContX) == sled->nVisW) + if (((sled->nContW - sled->nContX) == sled->nVisW) && (old_nContX > 0)){ - InvalidateRect(hWnd, NULL, TRUE); + InvalidateRect(hWnd, NULL, TRUE); } } } @@ -2273,7 +2273,7 @@ esleft_input_char_refresh (HWND hWnd, static void sledit_refresh_caret (HWND hWnd, PBIDISLEDITDATA sled, BOOL bInited) { DWORD dwStyle = GetWindowStyle(hWnd); - SIZE glyphs_size; + SIZE achars_size; int outchar; HDC hdc; @@ -2281,7 +2281,7 @@ static void sledit_refresh_caret (HWND hWnd, PBIDISLEDITDATA sled, BOOL bInited) return; hdc = GetClientDC (hWnd); - outchar = GetGlyphsExtentPoint (hdc, GLYPHS, GLYPHSLEN, 0, &glyphs_size); + outchar = GetGlyphsExtentPoint (hdc, ACHARS, ACHARSLEN, 0, &achars_size); ReleaseDC (hdc); if (bInited) { @@ -2319,9 +2319,9 @@ static int sledit_reset_text (HWND hWnd, PBIDISLEDITDATA sled, char* str) //TEXT = NULL; sled->str_content.buffsize = 0; TEXTLEN = 0; - sled->glyph_content.glyphs_buffsize = 0; - sled->glyph_content.glyphmap_buffsize = 0; - sled->glyph_content.glyphs_len = 0; + sled->achar_content.achars_buffsize = 0; + sled->achar_content.acharmap_buffsize = 0; + sled->achar_content.achars_len = 0; } sledit_settext (hWnd, sled, buffer); @@ -2340,7 +2340,7 @@ static int sledit_reset_text (HWND hWnd, PBIDISLEDITDATA sled, char* str) static LRESULT SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ +{ DWORD dwStyle; HDC hdc; PBIDISLEDITDATA sled = NULL; @@ -2383,7 +2383,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case MSG_FONTCHANGED: { - sled->starty = sled->topMargin + (sled->rcVis.bottom + sled->starty = sled->topMargin + (sled->rcVis.bottom - sled->rcVis.top - GetWindowFont(hWnd)->size - 1)/2; DestroyCaret (hWnd); @@ -2407,7 +2407,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) sled->status &= ~EST_FOCUSED; HideCaret (hWnd); - if ( sled->selStart != sled->selEnd + if ( sled->selStart != sled->selEnd || (dwStyle & ES_TIP && TEXTLEN <= 0)) { refresh = TRUE; } @@ -2425,11 +2425,11 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } } break; - + case MSG_SETFOCUS: if (sled->status & EST_FOCUSED) break; - + sled->status |= EST_FOCUSED; ActiveCaret (hWnd); @@ -2448,7 +2448,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) NotifyParent (hWnd, GetDlgCtrlID(hWnd), EN_SETFOCUS); break; - + case MSG_ENABLE: if ( (!(dwStyle & WS_DISABLED) && !wParam) || ((dwStyle & WS_DISABLED) && wParam) ) { @@ -2463,7 +2463,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case MSG_GETTEXTLENGTH: return TEXTLEN; - + case MSG_GETTEXT: { char* buffer = (char*)lParam; @@ -2520,7 +2520,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) charBuffer [0] = tolower (charBuffer[0]); } } - + if (chars == 1) { if (charBuffer [0] < 0x20 && charBuffer[0] != '\b') //FIXME return 0; @@ -2559,7 +2559,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } else if (dwStyle & ES_RIGHT) { esright_del_refresh(hWnd, sled, 0); - esright_input_char_refresh(hWnd, sled, (char*)charBuffer, + esright_input_char_refresh(hWnd, sled, (char*)charBuffer, chars); } else if (dwStyle & ES_CENTER) { @@ -2574,10 +2574,10 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } case MSG_LBUTTONDBLCLK: - sleSetSel (hWnd, sled, 0, GLYPHSLEN); + sleSetSel (hWnd, sled, 0, ACHARSLEN); NotifyParent (hWnd, GetDlgCtrlID(hWnd), EN_DBLCLK); break; - + case MSG_LBUTTONDOWN: { if ( sled->status & EST_TMP) { @@ -2585,7 +2585,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; } - if (HISWORD(lParam) < sled->rcVis.top + if (HISWORD(lParam) < sled->rcVis.top || HISWORD(lParam) > sled->rcVis.bottom) break; @@ -2599,7 +2599,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; } - + case MSG_NCLBUTTONUP: case MSG_LBUTTONUP: if (GetCapture() == hWnd) @@ -2617,7 +2617,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) sleMouseMove (hWnd, sled, lParam); return 0; } - + case MSG_GETDLGCODE: return DLGC_WANTCHARS| DLGC_HASSETSEL| DLGC_WANTARROWS| DLGC_WANTENTER; @@ -2628,7 +2628,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return IME_WINDOW_TYPE_PASSWORD; else return IME_WINDOW_TYPE_NOT_EDITABLE; - + case EM_GETCARETPOS: case EM_GETSELPOS: { @@ -2637,11 +2637,11 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) int* char_pos = (int *)lParam; if (message == EM_GETSELPOS) - pos = (sled->editPos == sled->selStart) + pos = (sled->editPos == sled->selStart) ? sled->selEnd : sled->selStart; else pos = sled->editPos; - nr_chars = GetTextMCharInfo (GetWindowFont (hWnd), + nr_chars = GetTextMCharInfo (GetWindowFont (hWnd), (const char* )(TEXT), pos, NULL); if (line_pos) *line_pos = 0; @@ -2653,28 +2653,28 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case EM_SETCARETPOS: case EM_SETSEL: { - int glyph_pos = (int)lParam; + int achar_pos = (int)lParam; - if (glyph_pos < 0) + if (achar_pos < 0) return -1; - if (glyph_pos > GLYPHSLEN) - glyph_pos = GLYPHSLEN; + if (achar_pos > ACHARSLEN) + achar_pos = ACHARSLEN; if (message == EM_SETCARETPOS) { - sled->editPos = glyph_pos; + sled->editPos = achar_pos; sled->selStart = sled->selEnd = 0; edtSetCaretPos (hWnd, sled); return sled->editPos; } else { int start, end; - if (sled->editPos < glyph_pos) { + if (sled->editPos < achar_pos) { start = sled->editPos; - end = glyph_pos; + end = achar_pos; } else { - start = glyph_pos; + start = achar_pos; end = sled->editPos; } return sleSetSel (hWnd, sled, start, end); @@ -2687,7 +2687,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) else ExcludeWindowStyle (hWnd, ES_READONLY); return 0; - + case EM_SETPASSWORDCHAR: if (sled->passwdChar != (int)wParam) { sled->passwdChar = (int)wParam; @@ -2696,14 +2696,14 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } } return 0; - + case EM_GETPASSWORDCHAR: { if (lParam) *((int*)lParam) = sled->passwdChar; return 0; } - + case EM_GETMAXLIMIT: return sled->hardLimit; @@ -2723,7 +2723,7 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } return -1; } - + case EM_GETTIPTEXT: { int len, tip_len; @@ -2781,8 +2781,8 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) else len = MIN(sled->selEnd - sled->selStart, (int)wParam); - strncpy (buffer, - (const char*)(TEXT + sled->selStart), len); + strncpy (buffer, + (const char*)(TEXT + sled->selStart), len); return len; } @@ -2799,10 +2799,10 @@ SLEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { #ifdef _MGHAVE_CLIPBOARD if (sled->selEnd - sled->selStart > 0) { - SetClipBoardData (CBNAME_TEXT, - TEXT + sled->selStart, + SetClipBoardData (CBNAME_TEXT, + TEXT + sled->selStart, sled->selEnd - sled->selStart, CBOP_NORMAL); - if (message == EM_CUTTOCB + if (message == EM_CUTTOCB && !(GetWindowStyle(hWnd) & ES_READONLY)) { sleInsertText (hWnd, sled, NULL, 0, FALSE); } diff --git a/src/control/bidiedit_impl.h b/src/control/bidiedit_impl.h index bf88ef44..1bdb73e1 100644 --- a/src/control/bidiedit_impl.h +++ b/src/control/bidiedit_impl.h @@ -44,20 +44,20 @@ extern "C" { #endif -typedef struct _GLYPHBUF +typedef struct _ACHARBUF { - GLYPHMAPINFO* glyph_map; /* glyph info array */ - Glyph32* glyphs; /* glyph array */ - int glyphs_len; /* glyph array len or buffer used size */ + ACHARMAPINFO* achar_map; /* achar info array */ + Achar32* achars; /* achar array */ + int achars_len; /* achar array len or buffer used size */ int blocksize; /* block size, a block is an allocate unit */ - int glyphs_buffsize; /* glyph string buffer size */ - int glyphmap_buffsize; /* glyph map buffer size */ -} GLYPHBUF; + int achars_buffsize; /* achar string buffer size */ + int acharmap_buffsize; /* achar map buffer size */ +} ACHARBUF; typedef struct tagBIDISLEDITDATA { StrBuffer str_content; // string text buffer - GLYPHBUF glyph_content; // glyph string buffer + ACHARBUF achar_content; // achar string buffer int editPos; // current edit position int selStart; // selection start position @@ -91,48 +91,48 @@ typedef struct tagBIDISLEDITDATA typedef BIDISLEDITDATA* PBIDISLEDITDATA; static inline void* -glyphbuf_alloc (GLYPHBUF* glyph_buff, int len, int block_size) +acharbuf_alloc (ACHARBUF* achar_buff, int len, int block_size) { - glyph_buff->glyphs_buffsize = (len + (block_size - len % block_size)) - * sizeof (Glyph32); - glyph_buff->glyphs = malloc (glyph_buff->glyphs_buffsize); + achar_buff->achars_buffsize = (len + (block_size - len % block_size)) + * sizeof (Achar32); + achar_buff->achars = malloc (achar_buff->achars_buffsize); - glyph_buff->glyphmap_buffsize = (len + (block_size - len % block_size)) - * sizeof (GLYPHMAPINFO); - glyph_buff->glyph_map = malloc (glyph_buff->glyphmap_buffsize); + achar_buff->acharmap_buffsize = (len + (block_size - len % block_size)) + * sizeof (ACHARMAPINFO); + achar_buff->achar_map = malloc (achar_buff->acharmap_buffsize); - glyph_buff->glyphs_len = len; - glyph_buff->blocksize = block_size; + achar_buff->achars_len = len; + achar_buff->blocksize = block_size; - return glyph_buff->glyphs; + return achar_buff->achars; } -static inline void glyphbuf_free (GLYPHBUF *glyph_buff) +static inline void acharbuf_free (ACHARBUF *achar_buff) { - if (glyph_buff) { - free (glyph_buff->glyphs); - free (glyph_buff->glyph_map); + if (achar_buff) { + free (achar_buff->achars); + free (achar_buff->achar_map); } } -static inline void* glyphbuf_realloc (GLYPHBUF *glyph_buff, int len) +static inline void* acharbuf_realloc (ACHARBUF *achar_buff, int len) { - if (len * sizeof(int) > glyph_buff->glyphs_buffsize || - len * sizeof(int) < glyph_buff->glyphs_buffsize - glyph_buff->blocksize) { - /* realloc glyph string mem */ - glyph_buff->glyphs_buffsize = (len + (glyph_buff->blocksize - - len % glyph_buff->blocksize))* sizeof(Glyph32); - glyph_buff->glyphs = realloc (glyph_buff->glyphs, - glyph_buff->glyphs_buffsize); + if (len * sizeof(int) > achar_buff->achars_buffsize || + len * sizeof(int) < achar_buff->achars_buffsize - achar_buff->blocksize) { + /* realloc achar string mem */ + achar_buff->achars_buffsize = (len + (achar_buff->blocksize - + len % achar_buff->blocksize))* sizeof(Achar32); + achar_buff->achars = realloc (achar_buff->achars, + achar_buff->achars_buffsize); - /* realloc glyph map mem */ - glyph_buff->glyphmap_buffsize = (len + (glyph_buff->blocksize - - len % glyph_buff->blocksize))* sizeof(GLYPHMAPINFO); - glyph_buff->glyph_map = realloc (glyph_buff->glyph_map, - glyph_buff->glyphmap_buffsize); + /* realloc achar map mem */ + achar_buff->acharmap_buffsize = (len + (achar_buff->blocksize - + len % achar_buff->blocksize))* sizeof(ACHARMAPINFO); + achar_buff->achar_map = realloc (achar_buff->achar_map, + achar_buff->acharmap_buffsize); } - return glyph_buff->glyphs; + return achar_buff->achars; } BOOL RegisterBIDISLEditControl (void); diff --git a/src/font/charset-arabic.c b/src/font/charset-arabic.c index 9074e3f4..7001ddc2 100644 --- a/src/font/charset-arabic.c +++ b/src/font/charset-arabic.c @@ -174,12 +174,12 @@ static unsigned short iso8859_68x_unicode_map [] = 0xFEF7, 0xFEF8, 0xFEF9, 0xFEFA, /*0x130~0x133*/ }; -static Uchar32 iso8859_6_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_6_conv_to_uc32 (Achar32 chv) { if (chv < 0x81) - return (Mchar32) (chv); + return (Achar32) (chv); else if (chv <= MAX_GLYPH_VALUE ) - return (Mchar32) iso8859_68x_unicode_map[chv - 0x81]; + return (Achar32) iso8859_68x_unicode_map[chv - 0x81]; else return 0xFFFF; } @@ -454,7 +454,7 @@ static int iso8859_6_len_first_char (const unsigned char* mstr, int len) #define ISARABIC_LIG_HALF(s) ((s == 0xa5) || (s == 0xa6)) -static unsigned int iso8859_6_char_type (Mchar32 chv) +static unsigned int iso8859_6_char_type (Achar32 chv) { unsigned int ch_type = MCHAR_TYPE_UNKNOWN; @@ -586,7 +586,7 @@ static Uint32 __mg_iso8859_68x_type[] = { BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, }; -static unsigned int iso8859_6_bidi_char_type (Mchar32 chv) +static unsigned int iso8859_6_bidi_char_type (Achar32 chv) { return __mg_iso8859_68x_type [chv]; } @@ -655,7 +655,7 @@ static int get_next_char(const unsigned char* mchar, int len) #ifndef _DEBUG static #endif -Mchar32 iso8859_6_get_char_value (const unsigned char* prev_mchar, +Achar32 iso8859_6_get_char_value (const unsigned char* prev_mchar, int prev_len, const unsigned char* mchar, int len) { BOOL next_affects_joining = FALSE, prev_affects_joining = FALSE; @@ -772,18 +772,18 @@ static const unsigned char* iso8859_6_get_next_word (const unsigned char* mstr, /*if cur_len>1, search ligature shape, * else search letter or phonetic symbol shape*/ -static Mchar32 iso8859_6_get_shaped_char_value (const unsigned char* cur_mchar, +static Achar32 iso8859_6_get_shaped_char_value (const unsigned char* cur_mchar, int cur_len, int shape_type) { - Mchar32 chv = -1; + Achar32 chv = -1; int ignore; int index; if (cur_len > 1) { - if (shape_type == GLYPH_ISOLATED) + if (shape_type == ACHAR_ISOLATED) chv = get_ligature (cur_mchar, cur_len, FALSE, &ignore); - else if (shape_type != GLYPH_INITIAL) { + else if (shape_type != ACHAR_INITIAL) { /* LAM+ALEF+HAMAZ+MADDA ligature. */ if (*cur_mchar == LAM) chv = fontset_68x_get_ligature_char(*(cur_mchar+1), TRUE, &ignore); @@ -800,16 +800,16 @@ static Mchar32 iso8859_6_get_shaped_char_value (const unsigned char* cur_mchar, if (index >=0) { switch (shape_type) { - case GLYPH_ISOLATED: + case ACHAR_ISOLATED: chv = shape_info[index].isolated; break; - case GLYPH_FINAL: + case ACHAR_FINAL: chv = shape_info[index].final; break; - case GLYPH_INITIAL: + case ACHAR_INITIAL: chv = shape_info[index].initial; break; - case GLYPH_MEDIAL: + case ACHAR_MEDIAL: chv = shape_info[index].medial; break; } @@ -839,7 +839,7 @@ static const BIDICHAR_MIRROR_MAP __mg_iso8859_68x_mirror_table [] = // {0x00BB, 0x00AB} }; -static BOOL iso8859_6_bidi_mirror_char (Mchar32 chv, Mchar32* mirrored) +static BOOL iso8859_6_bidi_mirror_char (Achar32 chv, Achar32* mirrored) { return get_mirror_char (__mg_iso8859_68x_mirror_table, TABLESIZE (__mg_iso8859_68x_mirror_table), chv, mirrored); @@ -868,7 +868,7 @@ static CHARSETOPS CharsetOps_iso8859_6 = { }; #ifdef _DEBUG -int iso8859_6_test_chv (int char_index, Mchar32 chv) +int iso8859_6_test_chv (int char_index, Achar32 chv) { int i = 0; for (i = 0; ibidi_char_type (glyphs[i])) != last->type){ + if ((type = charset_ops->bidi_char_type (achars[i])) != last->type){ link = calloc(1, sizeof(TYPERUN)); link->type = type; link->pos = i; @@ -473,7 +473,7 @@ static int bidi_resolveImplicit(TYPERUN **ptype_rl_list, int base_level) /* 6.Resolving Mirrored Char. */ static void -bidi_resolveMirrorChar (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, +bidi_resolveMirrorChar (const CHARSETOPS* charset_ops, Achar32* achars, int len, TYPERUN **ptype_rl_list, int base_level) { TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL; @@ -486,9 +486,9 @@ bidi_resolveMirrorChar (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, int i; for (i = POS (pp); i < POS (pp) + LEN (pp); i++) { - Glyph32 mirrored_ch; - if (charset_ops->bidi_mirror_char && charset_ops->bidi_mirror_char (glyphs[i], &mirrored_ch)) - glyphs[i] = mirrored_ch; + Achar32 mirrored_ch; + if (charset_ops->bidi_mirror_char && charset_ops->bidi_mirror_char (achars[i], &mirrored_ch)) + achars[i] = mirrored_ch; } } } @@ -497,7 +497,7 @@ bidi_resolveMirrorChar (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, } static void bidi_resolve_string (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, int pel, + Achar32* achars, int len, int pel, TYPERUN **ptype_rl_list, BYTE *pmax_level) { BYTE base_level = 0; @@ -505,7 +505,7 @@ static void bidi_resolve_string (const CHARSETOPS* charset_ops, TYPERUN *type_rl_list = NULL; /* split the text to some runs. */ - type_rl_list = get_runtype_link (charset_ops, glyphs, len); + type_rl_list = get_runtype_link (charset_ops, achars, len); /* 1.Find base level */ if (pel != 0 && pel != 1) { @@ -529,24 +529,24 @@ static void bidi_resolve_string (const CHARSETOPS* charset_ops, *pmax_level = bidi_resolveImplicit(&type_rl_list, base_level); /* 6.Resolving Mirrored Char. */ - bidi_resolveMirrorChar (charset_ops, glyphs, len, &type_rl_list, base_level); + bidi_resolveMirrorChar (charset_ops, achars, len, &type_rl_list, base_level); *ptype_rl_list = type_rl_list; } typedef struct _REORDER_CONTEXT { - Glyph32* glyphs; + Achar32* achars; void* extra; CB_REVERSE_EXTRA cb; } REORDER_CONTEXT; -static void bidi_reverse_glyphs (Glyph32* glyphs, int len, int pos) +static void bidi_reverse_achars (Achar32* achars, int len, int pos) { int i; - Glyph32* gs = glyphs + pos; + Achar32* gs = achars + pos; for (i = 0; i < len / 2; i++) { - Glyph32 tmp = gs[i]; + Achar32 tmp = gs[i]; gs[i] = gs[len - 1 - i]; gs[len - 1 - i] = tmp; } @@ -573,8 +573,8 @@ static void bidi_reorder (REORDER_CONTEXT* context, int len, } pp = pp1->prev; - if (context->glyphs) { - bidi_reverse_glyphs(context->glyphs, len, pos); + if (context->achars) { + bidi_reverse_achars(context->achars, len, pos); } if (context->extra && context->cb) { @@ -599,16 +599,16 @@ static void bidi_reverse_chars (void* context, int len, int pos) } void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, int pel, Uint8* embedding_levels, Uint8 type) + Achar32* achars, int len, int pel, Uint8* embedding_levels, Uint8 type) { int i = 0; BYTE max_level = 1; TYPERUN *type_rl_list = NULL, *pp; - print_hexstr(glyphs, len, FALSE); + print_hexstr(achars, len, FALSE); /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */ - bidi_resolve_string (charset_ops, glyphs, len, pel, &type_rl_list, + bidi_resolve_string (charset_ops, achars, len, pel, &type_rl_list, &max_level); /* type = 0, get the logical embedding level; else visual level.*/ @@ -621,7 +621,7 @@ void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, if (type) { REORDER_CONTEXT rc; - rc.glyphs = NULL; + rc.achars = NULL; rc.extra = embedding_levels; rc.cb = bidi_reverse_chars; bidi_reorder(&rc, len, &type_rl_list, max_level); @@ -630,7 +630,7 @@ void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, /* free typerun list.*/ free_typerun_list(type_rl_list); - print_hexstr(glyphs, len, TRUE); + print_hexstr(achars, len, TRUE); } #if 0 @@ -646,8 +646,8 @@ static void bidi_map_reverse (void* context, int len, int pos) } } -Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, GLYPHMAPINFO* map, int pel) +Achar32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, + Achar32* achars, int len, GLYPHMAPINFO* map, int pel) { BYTE max_level = 1; TYPERUN *type_rl_list = NULL; @@ -656,10 +656,10 @@ Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, int run_pos; int run_len; - print_hexstr(glyphs, len, FALSE); + print_hexstr(achars, len, FALSE); /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */ - bidi_resolve_string (charset_ops, glyphs, len, pel, &type_rl_list, &max_level); + bidi_resolve_string (charset_ops, achars, len, pel, &type_rl_list, &max_level); for (node_p=type_rl_list->next; node_p->next; node_p=node_p->next) { run_pos = node_p->pos; @@ -677,21 +677,21 @@ Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, /* free typerun list.*/ free_typerun_list(type_rl_list); - print_hexstr(glyphs, len, TRUE); + print_hexstr(achars, len, TRUE); - return glyphs; + return achars; } -Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, int* index_map, int pel) +Achar32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, + Achar32* achars, int len, int* index_map, int pel) { BYTE max_level = 1; TYPERUN *type_rl_list = NULL; - print_hexstr(glyphs, len, FALSE); + print_hexstr(achars, len, FALSE); /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */ - bidi_resolve_string (charset_ops, glyphs, len, pel, &type_rl_list, &max_level); + bidi_resolve_string (charset_ops, achars, len, pel, &type_rl_list, &max_level); bidi_reorder_cb(index_map, len, &type_rl_list, max_level, bidi_string_reverse); @@ -699,27 +699,27 @@ Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, /* free typerun list.*/ free_typerun_list(type_rl_list); - print_hexstr(glyphs, len, TRUE); + print_hexstr(achars, len, TRUE); - return glyphs; + return achars; } #endif -Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, int pel, +Achar32* __mg_charset_bidi_achars_reorder (const CHARSETOPS* charset_ops, + Achar32* achars, int len, int pel, void* extra, CB_REVERSE_EXTRA cb_reverse_extra) { BYTE max_level = 1; TYPERUN *type_rl_list = NULL; REORDER_CONTEXT rc; - print_hexstr(glyphs, len, FALSE); + print_hexstr(achars, len, FALSE); /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */ - bidi_resolve_string (charset_ops, glyphs, len, pel, &type_rl_list, + bidi_resolve_string (charset_ops, achars, len, pel, &type_rl_list, &max_level); - rc.glyphs = glyphs; + rc.achars = achars; rc.extra = extra; rc.cb = cb_reverse_extra; bidi_reorder (&rc, len, &type_rl_list, max_level); @@ -727,20 +727,20 @@ Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops, /* free typerun list.*/ free_typerun_list (type_rl_list); - print_hexstr (glyphs, len, TRUE); + print_hexstr (achars, len, TRUE); - return glyphs; + return achars; } Uint32 __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len) + Achar32* achars, int len) { BYTE base_level = 0; Uint32 base_dir = BIDI_TYPE_L; TYPERUN *type_rl_list = NULL; /* split the text to some runs. */ - type_rl_list = get_runtype_link (charset_ops, glyphs, len); + type_rl_list = get_runtype_link (charset_ops, achars, len); /* 1.Find base level */ bidi_resolveParagraphs(&type_rl_list, &base_dir, &base_level); @@ -751,16 +751,3 @@ Uint32 __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops, return base_dir; } -BOOL GetGlyphBIDIType (LOGFONT* log_font, Glyph32 glyph_value, - Uint32 *bidi_type) -{ - DEVFONT* devfont = SELECT_DEVFONT(log_font, glyph_value); - - if (devfont == NULL || - devfont->charset_ops->bidi_char_type == NULL) - return FALSE; - - *bidi_type = devfont->charset_ops->bidi_char_type (glyph_value); - return TRUE; -} - diff --git a/src/font/charset.c b/src/font/charset.c index 0d213471..58561b5c 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -57,13 +57,13 @@ static int sb_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 sb_get_char_value (const unsigned char* pre_mchar, int pre_len, +static Achar32 sb_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { - return (Mchar32)(*cur_mchar); + return (Achar32)(*cur_mchar); } -static unsigned int sb_char_type (Mchar32 chv) +static unsigned int sb_char_type (Achar32 chv) { unsigned int ch_type = MCHAR_TYPE_UNKNOWN; @@ -195,7 +195,7 @@ static int ascii_is_this_charset (const unsigned char* charset) } #ifdef _MGCHARSET_UNICODE -static Uchar32 ascii_conv_to_uc32 (Mchar32 chv) +static Uchar32 ascii_conv_to_uc32 (Achar32 chv) { if (chv < 128) return chv; @@ -261,7 +261,7 @@ static int iso8859_1_is_this_charset (const unsigned char* charset) } #ifdef _MGCHARSET_UNICODE -static Uchar32 iso8859_1_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_1_conv_to_uc32 (Achar32 chv) { return chv; } @@ -360,7 +360,7 @@ static unsigned short iso8859_2_unicode_map [] = 0x00FD, 0x0163, 0x02D9 }; -static Uchar32 iso8859_2_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_2_conv_to_uc32 (Achar32 chv) { if (chv < 0xA1) return chv; @@ -473,7 +473,7 @@ static unsigned short iso8859_3_unicode_map [] = 0x015D, 0x02D9 }; -static Uchar32 iso8859_3_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_3_conv_to_uc32 (Achar32 chv) { if (chv < 0xA1) return chv; @@ -585,7 +585,7 @@ static unsigned short iso8859_4_unicode_map [] = 0x016B, 0x02D9 }; -static Uchar32 iso8859_4_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_4_conv_to_uc32 (Achar32 chv) { if (chv < 0xA1) return chv; @@ -662,7 +662,7 @@ static int iso8859_5_is_this_charset (const unsigned char* charset) } #ifdef _MGCHARSET_UNICODE -static Uchar32 iso8859_5_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_5_conv_to_uc32 (Achar32 chv) { if (chv < 0xA1) return chv; @@ -735,7 +735,7 @@ static CHARSETOPS CharsetOps_iso8859_5 = { #include "bidi.h" -static BOOL get_mirror_char (const BIDICHAR_MIRROR_MAP* map, int n, Mchar32 chv, Mchar32* mirrored) +static BOOL get_mirror_char (const BIDICHAR_MIRROR_MAP* map, int n, Achar32 chv, Achar32* mirrored) { int pos, step; BOOL found = FALSE; @@ -743,7 +743,7 @@ static BOOL get_mirror_char (const BIDICHAR_MIRROR_MAP* map, int n, Mchar32 chv, pos = step = (n / 2) + 1; while (step > 1) { - Mchar32 cmp_char = map[pos].chv; + Achar32 cmp_char = map[pos].chv; step = (step + 1) / 2; if (cmp_char < chv) { @@ -815,7 +815,7 @@ static unsigned short iso8859_7_unicode_map [] = 0x038C, 0x00BD }; -static Uchar32 iso8859_7_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_7_conv_to_uc32 (Achar32 chv) { if (chv >= 0xBE && chv <= 0xFE) { return chv - 0xBE + 0x038E; @@ -1040,7 +1040,7 @@ static Uint32 __mg_iso8859_8_type[] = { BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, }; -static unsigned int iso8859_8_bidi_char_type (Mchar32 chv) +static unsigned int iso8859_8_bidi_char_type (Achar32 chv) { return __mg_iso8859_8_type [chv]; } @@ -1059,14 +1059,14 @@ static const BIDICHAR_MIRROR_MAP __mg_iso8859_8_mirror_table [] = // {0x00BB, 0x00AB} }; -static BOOL iso8859_8_bidi_mirror_char (Mchar32 chv, Mchar32* mirrored) +static BOOL iso8859_8_bidi_mirror_char (Achar32 chv, Achar32* mirrored) { return get_mirror_char (__mg_iso8859_8_mirror_table, TABLESIZE (__mg_iso8859_8_mirror_table), chv, mirrored); } #ifdef _MGCHARSET_UNICODE -static Uchar32 iso8859_8_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_8_conv_to_uc32 (Achar32 chv) { if (chv >= 0xE0 && chv <= 0xFA) { return chv - 0xE0 + 0x05D0; @@ -1169,7 +1169,7 @@ static int iso8859_9_is_this_charset (const unsigned char* charset) } #ifdef _MGCHARSET_UNICODE -static Uchar32 iso8859_9_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_9_conv_to_uc32 (Achar32 chv) { switch (chv) { case 0xD0: @@ -1306,7 +1306,7 @@ static unsigned short iso8859_10_unicode_map [] = 0x00FE, 0x0138 }; -static Uchar32 iso8859_10_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_10_conv_to_uc32 (Achar32 chv) { if (chv < 0xA1) return chv; @@ -1419,7 +1419,7 @@ static unsigned short iso8859_11_unicode_map [] = 0x00FE, 0x00FF }; -static Uchar32 iso8859_11_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_11_conv_to_uc32 (Achar32 chv) { if (chv < 0xA1) return chv; @@ -1531,7 +1531,7 @@ static unsigned short iso8859_13_unicode_map [] = 0x017E, 0x2019 }; -static Uchar32 iso8859_13_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_13_conv_to_uc32 (Achar32 chv) { if (chv < 0xA1) return chv; @@ -1643,7 +1643,7 @@ static unsigned short iso8859_14_unicode_map [] = 0x0177, 0x00FF }; -static Uchar32 iso8859_14_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_14_conv_to_uc32 (Achar32 chv) { if (chv < 0xA1) return chv; @@ -1719,7 +1719,7 @@ static int iso8859_15_is_this_charset (const unsigned char* charset) } #ifdef _MGCHARSET_UNICODE -static Uchar32 iso8859_15_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_15_conv_to_uc32 (Achar32 chv) { switch (chv) { case 0xA4: @@ -1829,7 +1829,7 @@ static int iso8859_16_is_this_charset (const unsigned char* charset) } #ifdef _MGCHARSET_UNICODE -static Uchar32 iso8859_16_conv_to_uc32 (Mchar32 chv) +static Uchar32 iso8859_16_conv_to_uc32 (Achar32 chv) { switch (chv) { case 0xA1: return 0x0104; @@ -1961,7 +1961,7 @@ static CHARSETOPS CharsetOps_iso8859_16 = { | defined(_MGCHARSET_SHIFTJIS) \ | defined(_MGCHARSET_UNICODE) -static unsigned int mb_char_type (Mchar32 chv) +static unsigned int mb_char_type (Achar32 chv) { /* TODO: get the subtype of the char */ return MCHAR_TYPE_GENERIC; @@ -2015,7 +2015,7 @@ static int gb2312_0_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 gb2312_0_get_char_value (const unsigned char* pre_mchar, +static Achar32 gb2312_0_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { int area = cur_mchar [0] - 0xA1; @@ -2102,7 +2102,7 @@ static int gb2312_0_pos_first_char (const unsigned char* mstr, int mstrlen) } #ifdef _MGCHARSET_UNICODE -static Uchar32 gb2312_0_conv_to_uc32 (Mchar32 chv) +static Uchar32 gb2312_0_conv_to_uc32 (Achar32 chv) { return (Uchar32)__mg_gbunicode_map [chv]; } @@ -2175,7 +2175,7 @@ static int gbk_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 gbk_get_char_value (const unsigned char* pre_mchar, int pre_len, +static Achar32 gbk_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { if (cur_mchar [1] > 0x7F) @@ -2260,7 +2260,7 @@ static int gbk_pos_first_char (const unsigned char* mstr, int mstrlen) } #ifdef _MGCHARSET_UNICODE -static Uchar32 gbk_conv_to_uc32 (Mchar32 chv) +static Uchar32 gbk_conv_to_uc32 (Achar32 chv) { return (Uchar32)__mg_gbkunicode_map[chv]; } @@ -2340,7 +2340,7 @@ static int gb18030_0_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 gb18030_0_get_char_value (const unsigned char* pre_mchar, +static Achar32 gb18030_0_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { unsigned char ch1; @@ -2504,7 +2504,7 @@ static const unsigned char* gb18030_0_get_next_word (const unsigned char* mstr, } #ifdef _MGCHARSET_UNICODE -static Uchar32 gb18030_0_conv_to_uc32 (Mchar32 chv) +static Uchar32 gb18030_0_conv_to_uc32 (Achar32 chv) { /* from 0x90308130 to 0xE3329A35 */ if (chv > 63611) { @@ -2597,7 +2597,7 @@ static int big5_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 big5_get_char_value (const unsigned char* pre_mchar, int pre_len, +static Achar32 big5_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { if (cur_mchar [1] & 0x80) @@ -2678,7 +2678,7 @@ static int big5_pos_first_char (const unsigned char* mstr, int mstrlen) } #ifdef _MGCHARSET_UNICODE -static Uchar32 big5_conv_to_uc32 (Mchar32 chv) +static Uchar32 big5_conv_to_uc32 (Achar32 chv) { unsigned short ucs_code = __mg_big5_unicode_map [chv]; @@ -2753,7 +2753,7 @@ static int ksc5601_0_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 ksc5601_0_get_char_value (const unsigned char* pre_mchar, +static Achar32 ksc5601_0_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { #if 1 @@ -2837,7 +2837,7 @@ static int ksc5601_0_pos_first_char (const unsigned char* mstr, int mstrlen) } #ifdef _MGCHARSET_UNICODE -static Uchar32 ksc5601_0_conv_to_uc32 (Mchar32 chv) +static Uchar32 ksc5601_0_conv_to_uc32 (Achar32 chv) { unsigned short ucs_code = __mg_ksc5601_0_unicode_map [chv]; @@ -2900,7 +2900,7 @@ static int jisx0201_0_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 jisx0201_0_get_char_value (const unsigned char* pre_mchar, +static Achar32 jisx0201_0_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { if (cur_mchar [0] == 0x8E) @@ -2958,7 +2958,7 @@ static int jisx0201_0_is_this_charset (const unsigned char* charset) #ifdef _MGCHARSET_UNICODE -static Uchar32 jisx0201_0_conv_to_uc32 (Mchar32 chv) +static Uchar32 jisx0201_0_conv_to_uc32 (Achar32 chv) { if (chv >= 0xA1 && chv <= 0xDF) return 0xFF61 + chv - 0xA1; @@ -3018,7 +3018,7 @@ static int jisx0208_0_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 jisx0208_0_get_char_value (const unsigned char* pre_mchar, +static Achar32 jisx0208_0_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { #if 1 @@ -3102,7 +3102,7 @@ static int jisx0208_0_pos_first_char (const unsigned char* mstr, int mstrlen) } #ifdef _MGCHARSET_UNICODE -static Uchar32 jisx0208_0_conv_to_uc32 (Mchar32 chv) +static Uchar32 jisx0208_0_conv_to_uc32 (Achar32 chv) { unsigned short ucs_code; @@ -3169,7 +3169,7 @@ static int jisx0201_1_is_this_charset (const unsigned char* charset) #ifdef _MGCHARSET_UNICODE -static Uchar32 jisx0201_1_conv_to_uc32 (Mchar32 chv) +static Uchar32 jisx0201_1_conv_to_uc32 (Achar32 chv) { if (chv >= 0xA1 && chv <= 0xDF) return 0xFF61 + chv - 0xA1; @@ -3247,7 +3247,7 @@ static int jisx0208_1_len_first_char (const unsigned char* mstr, int len) return 0; } -static Mchar32 jisx0208_1_get_char_value (const unsigned char* pre_mchar, +static Achar32 jisx0208_1_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { unsigned char ch1 = cur_mchar [0]; @@ -3358,7 +3358,7 @@ static int jisx0208_1_pos_first_char (const unsigned char* mstr, int mstrlen) } #ifdef _MGCHARSET_UNICODE -static Uchar32 jisx0208_1_conv_to_uc32 (Mchar32 chv) +static Uchar32 jisx0208_1_conv_to_uc32 (Achar32 chv) { unsigned short ucs_code; @@ -3432,7 +3432,7 @@ static int utf8_len_first_char (const unsigned char* mstr, int len) return 1; } -static Mchar32 utf8_get_char_value (const unsigned char* pre_mchar, int pre_len, +static Achar32 utf8_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { Uchar32 wc = *((unsigned char *)(cur_mchar++)); @@ -3528,7 +3528,7 @@ static Mchar32 utf8_get_char_value (const unsigned char* pre_mchar, int pre_len, ? TPROP_PART2 (((Char) - 0xe0000) >> 8, (Char) & 0xff) \ : UCHAR_BREAK_UNKNOWN)) -static unsigned int unicode_char_type (Mchar32 chv) +static unsigned int unicode_char_type (Achar32 chv) { unsigned int mchar_type = MCHAR_TYPE_UNKNOWN; unsigned int basic_type = 0, break_type = 0; @@ -3557,11 +3557,11 @@ static unsigned int unicode_char_type (Mchar32 chv) #include "unicode-bidi-tables.h" -static unsigned int unicode_bidi_char_type (Mchar32 chv) +static unsigned int unicode_bidi_char_type (Achar32 chv) { - Mchar32 chv_first = 0; - Mchar32 chv_last = (Mchar32)TABLESIZE (__mg_unicode_bidi_char_type_map); - Mchar32 chv_mid; + Achar32 chv_first = 0; + Achar32 chv_last = (Achar32)TABLESIZE (__mg_unicode_bidi_char_type_map); + Achar32 chv_mid; while (chv_last >= chv_first) { chv_mid = (chv_first + chv_last)/2; @@ -3585,7 +3585,7 @@ static unsigned int unicode_bidi_char_type (Mchar32 chv) return BIDI_TYPE_LTR; } -static BOOL unicode_bidi_mirror_char (Mchar32 chv, Mchar32* mirrored) +static BOOL unicode_bidi_mirror_char (Achar32 chv, Achar32* mirrored) { return get_mirror_char (__mg_unicode_mirror_table, TABLESIZE (__mg_unicode_mirror_table), chv, mirrored); @@ -3820,7 +3820,7 @@ static int utf16le_len_first_char (const unsigned char* mstr, int len) return 4; } -static Mchar32 utf16le_get_char_value (const unsigned char* pre_mchar, +static Achar32 utf16le_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { Uchar16 w1, w2; @@ -4046,7 +4046,7 @@ static int utf16be_len_first_char (const unsigned char* mstr, int len) return 4; } -static Mchar32 utf16be_get_char_value (const unsigned char* pre_mchar, +static Achar32 utf16be_get_char_value (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len) { Uchar16 w1, w2; diff --git a/src/include/bidi.h b/src/include/bidi.h index 85f6dbc6..71bca556 100644 --- a/src/include/bidi.h +++ b/src/include/bidi.h @@ -62,27 +62,27 @@ extern "C" { typedef struct _TYPERUN TYPERUN; typedef struct _BIDICHAR_MIRROR_MAP { - Mchar32 chv; - Mchar32 mirrored; + Achar32 chv; + Achar32 mirrored; } BIDICHAR_MIRROR_MAP; -Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, int pel, +Achar32* __mg_charset_bidi_achars_reorder (const CHARSETOPS* charset_ops, + Achar32* achars, int len, int pel, void* extra, CB_REVERSE_EXTRA cb_reverse_extra); /* -Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, GLYPHMAPINFO* map, int pel); +Achar32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, + Achar32* achars, int len, GLYPHMAPINFO* map, int pel); -Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, int* index_map, int pel); +Achar32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, + Achar32* achars, int len, int* index_map, int pel); */ void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len, int pel, Uint8* embedding_levels, Uint8 type); + Achar32* achars, int len, int pel, Uint8* embedding_levels, Uint8 type); Uint32 __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops, - Glyph32* glyphs, int len); + Achar32* achars, int len); #ifdef __cplusplus } diff --git a/src/include/devfont.h b/src/include/devfont.h index 0fa38861..63de1f03 100644 --- a/src/include/devfont.h +++ b/src/include/devfont.h @@ -40,6 +40,52 @@ #ifndef GUI_DEVFONT_H #define GUI_DEVFONT_H +#define ACHAR_MBC_FLAG 0x80000000 + +#define IS_MBCHV(chv) ((chv) & ACHAR_MBC_FLAG) +#define SET_MBCHV(chv) ((chv) | ACHAR_MBC_FLAG) +#define REAL_ACHAR(chv) ((chv) & ~ACHAR_MBC_FLAG) + +#define SELECT_DEVFONT_BY_ACHAR(logfont, chv) \ + IS_MBCHV(chv)?(logfont->devfonts[1]):(logfont->devfonts[0]) + +#define GLYPH_DEVFONT_INDEX_MASK 0xF0000000 +#define GLYPH_DEVFONT_INDEX_SHIFT 28 + +/** + * \def REAL_GLYPH(glyph) + * \brief Get the real (DEVFONT) glyph value from a LOGFONT glyph. + * + * \param glyph The LOGFONT glyph value + */ +#define REAL_GLYPH(glyph) ((glyph) & ~GLYPH_DEVFONT_INDEX_MASK) + +/** + * \def SELECT_DEVFONT_BY_GLYPH(logfont, glyph) + * \brief Select a DEVFONT according to the LOGFONT glyph value. + * + * \param logfont The pointer to a logical font. + * \param glyph The logical glyph value. + * + */ +#define SELECT_DEVFONT_BY_GLYPH(logfont, glyph) \ + (logfont)->devfonts[((glyph) >> GLYPH_DEVFONT_INDEX_SHIFT) & 0x07] + +#define DFI_IN_GLYPH(glyph) \ + (((glyph) >> GLYPH_DEVFONT_INDEX_SHIFT) & 0x07) + +/** + * \def IS_MBC_GLYPH(glyph) + * \brief Determine wether the glyph is multibyte glyph + * + * \param glyph The logfont glyph value + */ +#define IS_MBC_GLYPH(glyph) ((glyph) & GLYPH_DEVFONT_INDEX_MASK) + +#define SET_GLYPH_DFI(glyph, dfi) \ + (((glyph) & ~GLYPH_DEVFONT_INDEX_MASK) | \ + (((Glyph32)((dfi) & 0x07)) << GLYPH_DEVFONT_INDEX_SHIFT)) + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -133,11 +179,6 @@ static inline long get_opened_file_size (FILE* fp) return size; } -typedef unsigned int Mchar32; -#define IS_MBCHV(chv) ((chv) & 0x80000000) -#define SET_MBCHV(chv) ((chv) | 0x80000000) -#define REAL_CHV(chv) ((chv) & 0x7FFFFFFF) - /** The character set operation structure. */ struct _CHARSETOPS { @@ -151,21 +192,21 @@ struct _CHARSETOPS const char* name; /** Default character. */ - Mchar32 def_char_value; + Achar32 def_char_value; /** The method to get the length of the first character. */ int (*len_first_char) (const unsigned char* mstr, int mstrlen); /** The method to get the character index. */ - Mchar32 (*get_char_value) (const unsigned char* pre_mchar, int pre_len, + Achar32 (*get_char_value) (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len); /** The method to get the require shape type of a mchar. */ - Mchar32 (*get_shaped_char_value) (const unsigned char* cur_mchar, int cur_len, + Achar32 (*get_shaped_char_value) (const unsigned char* cur_mchar, int cur_len, int shape_type); /** The method to get the type of one character. */ - unsigned int (*char_type) (Mchar32 chv); + unsigned int (*char_type) (Achar32 chv); /** The method to get character number in the string function. */ int (*nr_chars_in_str) (const unsigned char* mstr, int mstrlen); @@ -186,14 +227,14 @@ struct _CHARSETOPS int (*pos_first_char) (const unsigned char* mstr, int mstrlen); /** The method to get the BIDI type of one character. */ - unsigned int (*bidi_char_type) (Mchar32 chv); + unsigned int (*bidi_char_type) (Achar32 chv); /** Get mirrored character */ - BOOL (*bidi_mirror_char) (Mchar32 chv, Mchar32* mirrored); + BOOL (*bidi_mirror_char) (Achar32 chv, Achar32* mirrored); #ifdef _MGCHARSET_UNICODE /** The method to convert a mchar32 value to 32 bit UNICODE function. */ - Uchar32 (*conv_to_uc32) (Mchar32 chv); + Uchar32 (*conv_to_uc32) (Achar32 chv); /** The method to convert \a wc to multily byte character function. */ int (*conv_from_uc32) (Uchar32 wc, unsigned char* mchar); @@ -283,7 +324,7 @@ struct _FONTOPS * * Since 3.4.0. */ - Glyph32 (*get_glyph_value) (LOGFONT* logfont, DEVFONT* devfont, Mchar32 chv); + Glyph32 (*get_glyph_value) (LOGFONT* logfont, DEVFONT* devfont, Achar32 chv); }; typedef struct { diff --git a/src/include/glyph.h b/src/include/glyph.h index b31d86f9..fab933da 100644 --- a/src/include/glyph.h +++ b/src/include/glyph.h @@ -45,9 +45,6 @@ extern "C" { #endif /* __cplusplus */ -Glyph32 _gdi_select_glyph_dfi(LOGFONT* lf, Glyph32 gv); -Glyph32 _gdi_get_glyph_value(LOGFONT* lf, Mchar32 chv); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/newgdi/Makefile.am b/src/newgdi/Makefile.am index d6b810da..446d68a0 100644 --- a/src/newgdi/Makefile.am +++ b/src/newgdi/Makefile.am @@ -13,7 +13,7 @@ SRC_FILES = gdi.c attr.c clip.c map.c coor.c rect.c \ region.c generators.c polygon.c flood.c \ advapi.c midash.c mispans.c miwideline.c \ mifillarc.c mifpolycon.c miarc.c rotatebmp.c \ - text.c glyph.c bidi.c glyph-unicode.c \ + text.c achar.c glyph.c bidi.c glyph-unicode.c \ textout.c tabbedtextout.c drawtext.c endif diff --git a/src/newgdi/achar.c b/src/newgdi/achar.c new file mode 100644 index 00000000..3ca9bf4f --- /dev/null +++ b/src/newgdi/achar.c @@ -0,0 +1,198 @@ +/* + * This file is part of MiniGUI, a mature cross-platform windowing + * and Graphics User Interface (GUI) support system for embedded systems + * and smart IoT devices. + * + * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 1998~2002, WEI Yongming + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Or, + * + * As this program is a library, any link to this program must follow + * GNU General Public License version 3 (GPLv3). If you cannot accept + * GPLv3, you need to be licensed from FMSoft. + * + * If you have got a commercial license of this program, please use it + * under the terms and conditions of the commercial license. + * + * For more information about the commercial license, please refer to + * . + */ +/* +** achar.c: API implementation for abstract character. +** +** Create date: 2019/03/05 +*/ + +#include +#include +#include + +#include "common.h" +#include "minigui.h" +#include "gdi.h" +#include "window.h" +#include "devfont.h" + +Achar32 GUIAPI GetACharValue (LOGFONT* logfont, const char* mchar, + int mchar_len, const char* pre_mchar, int pre_len) +{ + int len_cur_char; + Achar32 chv = INV_ACHAR_VALUE; + DEVFONT* sbc_devfont = logfont->devfonts[0]; + DEVFONT* mbc_devfont = logfont->devfonts[1]; + + if (mbc_devfont) { + len_cur_char = mbc_devfont->charset_ops->len_first_char + ((const unsigned char*)mchar, mchar_len); + + if (len_cur_char > 0) { + chv = mbc_devfont->charset_ops->get_char_value + ((Uint8*)pre_mchar, pre_len, (Uint8*)mchar, mchar_len); + + return SET_MBCHV(chv); + } + } + + len_cur_char = sbc_devfont->charset_ops->len_first_char + ((const unsigned char*)mchar, mchar_len); + + if (len_cur_char > 0) { + chv = sbc_devfont->charset_ops->get_char_value + (NULL, 0, (Uint8*)mchar, mchar_len); + } + + return chv; +} + +Achar32 GUIAPI GetShapedAChar (LOGFONT* logfont, const char* mchar, + int mchar_len, ACHARSHAPETYPE shape_type) +{ + int len_cur_char; + + Achar32 chv = INV_ACHAR_VALUE; + DEVFONT* sbc_devfont = logfont->devfonts[0]; + DEVFONT* mbc_devfont = logfont->devfonts[1]; + + if (mbc_devfont) { + len_cur_char = mbc_devfont->charset_ops->len_first_char ( + (const unsigned char*)mchar, mchar_len); + + if (len_cur_char > 0) { + if (mbc_devfont->charset_ops->get_shaped_char_value) + chv = mbc_devfont->charset_ops->get_shaped_char_value( + (const unsigned char*)mchar, mchar_len, shape_type); + else + chv = mbc_devfont->charset_ops->get_char_value + (NULL, 0, (Uint8*)mchar, len_cur_char); + + return SET_MBCHV(chv); + } + } + + len_cur_char = sbc_devfont->charset_ops->len_first_char + ((const unsigned char*)mchar, mchar_len); + + if (len_cur_char > 0) { + if (sbc_devfont->charset_ops->get_shaped_char_value) + chv = sbc_devfont->charset_ops->get_shaped_char_value( + (const unsigned char*)mchar, mchar_len, shape_type); + else + chv = sbc_devfont->charset_ops->get_char_value + (NULL, 0, (Uint8*)mchar, len_cur_char); + + } + + return chv; +} + +BOOL GUIAPI GetMirrorAChar (LOGFONT* logfont, Achar32 chv, Achar32* mirrored) +{ + DEVFONT* devfont = SELECT_DEVFONT_BY_ACHAR(logfont, chv); + + *mirrored = INV_ACHAR_VALUE; + if (devfont->charset_ops->bidi_mirror_char) { + return devfont->charset_ops->bidi_mirror_char(REAL_ACHAR(chv), + mirrored); + } + + return FALSE; +} + +Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv) +{ + DEVFONT* devfont = SELECT_DEVFONT_BY_ACHAR(logfont, chv); + return devfont->charset_ops->char_type (REAL_ACHAR (chv)); +} + +Uint32 GetGlyphBIDIType (LOGFONT* log_font, Achar32 chv) +{ + DEVFONT* devfont = SELECT_DEVFONT_BY_ACHAR(log_font, chv); + + if (devfont == NULL || + devfont->charset_ops->bidi_char_type == NULL) + return BIDI_TYPE_INVALID; + + return devfont->charset_ops->bidi_char_type (REAL_ACHAR (chv)); +} + +#ifdef _MGCHARSET_UNICODE + +Uchar32 GUIAPI Achar2UChar(LOGFONT* logfont, Achar32 chv) +{ + Uchar32 uc; + DEVFONT* devfont = SELECT_DEVFONT_BY_ACHAR(logfont, chv); + + if (devfont) { + chv = REAL_ACHAR(chv); + if (devfont->charset_ops->conv_to_uc32) + uc = devfont->charset_ops->conv_to_uc32(chv); + else + uc = chv; + + return uc; + } + + return 0; +} + +int GUIAPI AChars2UChars(LOGFONT* logfont, const Achar32* chs, + Uchar32* ucs, int n) +{ + int i; + Uchar32 uc; + DEVFONT* devfont; + + for (i = 0; i < n; i++) { + Achar32 chv = chs[i]; + devfont = SELECT_DEVFONT_BY_ACHAR(logfont, chv); + if (devfont) { + chv = REAL_ACHAR(chv); + if (devfont->charset_ops->conv_to_uc32) + uc = devfont->charset_ops->conv_to_uc32(chv); + else + uc = chv; + + ucs[i] = uc; + } + else + return i + 1; + } + + return TRUE; +} + +#endif /* _MGCHARSET_UNICODE */ diff --git a/src/newgdi/bidi.c b/src/newgdi/bidi.c index 3f425a26..8879705c 100644 --- a/src/newgdi/bidi.c +++ b/src/newgdi/bidi.c @@ -57,33 +57,32 @@ #include "bidi.h" #include "cursor.h" -static Glyph32* _gdi_get_glyphs_string(PDC pdc, const unsigned char* text, - int text_len, int* nr_glyphs) +static Achar32* _gdi_get_achs_string(PDC pdc, const unsigned char* text, + int text_len, int* nr_achs) { int i = 0; int len_cur_char; int left_bytes = text_len; unsigned int char_type; - Glyph32 glyph_value; + Achar32 chv; DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; - Glyph32 *logical_glyphs = NULL; + Achar32 *logical_achs = NULL; if (mbc_devfont) { int prev_len = 0; const unsigned char* prev_mchar = NULL; - logical_glyphs = malloc(text_len * sizeof (Glyph32)); + logical_achs = malloc(text_len * sizeof (Achar32)); while (left_bytes > 0) { len_cur_char = mbc_devfont->charset_ops->len_first_char ((const unsigned char*)text, left_bytes); if (len_cur_char > 0) { - glyph_value = mbc_devfont->charset_ops->get_char_value + chv = mbc_devfont->charset_ops->get_char_value (prev_mchar, prev_len, text, left_bytes); - logical_glyphs[i++] - = _gdi_select_glyph_dfi(pdc->pLogFont, glyph_value); + logical_achs[i++] = SET_MBCHV(chv); char_type = (*mbc_devfont->charset_ops->char_type) - (glyph_value); + (chv); if (!(char_type & MCHAR_TYPE_NOSPACING_MARK)){ prev_mchar = text; prev_len = len_cur_char; @@ -101,9 +100,9 @@ static Glyph32* _gdi_get_glyphs_string(PDC pdc, const unsigned char* text, ((const unsigned char*)text, left_bytes); if (len_cur_char > 0) { - glyph_value = sbc_devfont->charset_ops->get_char_value + chv = sbc_devfont->charset_ops->get_char_value (NULL, 0, text, left_bytes); - logical_glyphs[i++] = glyph_value; + logical_achs[i++] = chv; text += len_cur_char; left_bytes -= len_cur_char; } @@ -111,54 +110,54 @@ static Glyph32* _gdi_get_glyphs_string(PDC pdc, const unsigned char* text, break; } - if (nr_glyphs) - *nr_glyphs = i; + if (nr_achs) + *nr_achs = i; } - return logical_glyphs; + return logical_achs; } -static unsigned int inline get_char_type(LOGFONT* logfont, Glyph32 glyph_value) +static unsigned int inline get_char_type(LOGFONT* logfont, Achar32 chv) { - if (IS_MBC_GLYPH (glyph_value)) - return logfont->devfonts[1]->charset_ops->char_type(glyph_value); + if (IS_MBC_GLYPH (chv)) + return logfont->devfonts[1]->charset_ops->char_type(chv); else - return logfont->devfonts[0]->charset_ops->char_type(glyph_value); + return logfont->devfonts[0]->charset_ops->char_type(chv); } -static int inline get_glyph_advance_in_dc (PDC pdc, Glyph32 glyph_value) +static int inline get_glyph_advance_in_dc (PDC pdc, Achar32 chv) { - return _gdi_get_glyph_advance(pdc, glyph_value, TRUE, 0, 0, NULL, NULL, NULL); + return _gdi_get_glyph_advance(pdc, chv, TRUE, 0, 0, NULL, NULL, NULL); } -static int jump_vowels_ltr (PDC pdc, Glyph32* glyphs, int glyph_num, Glyph32* biggest_vowel) +static int jump_vowels_ltr (PDC pdc, Achar32* achs, int glyph_num, Glyph32* biggest_vowel) { int i = 0; int max_advance = 0; int cur_advance = 0; for (i=0; ipLogFont, glyphs[i]))) + if (!check_vowel(get_char_type (pdc->pLogFont, achs[i]))) return i; - cur_advance = get_glyph_advance_in_dc (pdc, glyphs[i]); + cur_advance = get_glyph_advance_in_dc (pdc, achs[i]); if (cur_advance > max_advance) { max_advance = cur_advance; - *biggest_vowel = glyphs [i]; + *biggest_vowel = achs [i]; } } return glyph_num; } -static int output_visual_glyphs_ltr (PDC pdc, Glyph32* visual_glyphs, - int nr_glyphs, CB_ONE_GLYPH cb_one_glyph, void* context) +static int output_visual_achs_ltr (PDC pdc, Achar32* visual_achs, + int nr_achs, CB_ONE_GLYPH cb_one_glyph, void* context) { int i = 0; int j = 0; unsigned int char_type; - Glyph32 glyph_value; - Glyph32 biggest_vowel = 0; + Achar32 chv; + Achar32 biggest_vowel = 0; int vowel_num; int outed_num = 0; @@ -166,21 +165,21 @@ static int output_visual_glyphs_ltr (PDC pdc, Glyph32* visual_glyphs, int old_text_align = pdc->ta_flags; int bkmode = pdc->bkmode; - while (i < nr_glyphs) { + while (i < nr_achs) { /*jump vowels*/ - vowel_num = jump_vowels_ltr (pdc, visual_glyphs, - nr_glyphs-i, &biggest_vowel); + vowel_num = jump_vowels_ltr (pdc, visual_achs, + nr_achs-i, &biggest_vowel); - visual_glyphs += vowel_num; + visual_achs += vowel_num; /*output the letter after vowels, * the letter is the owner of jumped vowels * if there is a letter on the vowel's right*/ - if (vowel_num < nr_glyphs - i) + if (vowel_num < nr_achs - i) { - glyph_value = *(visual_glyphs); - char_type = get_char_type (pdc->pLogFont, glyph_value); - if (!cb_one_glyph (context, glyph_value, char_type)){ + chv = *(visual_achs); + char_type = get_char_type (pdc->pLogFont, chv); + if (!cb_one_glyph (context, chv, char_type)){ goto end; } outed_num++; @@ -202,14 +201,14 @@ static int output_visual_glyphs_ltr (PDC pdc, Glyph32* visual_glyphs, pdc->bkmode = BM_TRANSPARENT; } - /*output other vowels from visual_glyphs[i]*/ + /*output other vowels from visual_achs[i]*/ for (j = 1; j<=vowel_num; j++) { - glyph_value = *(visual_glyphs - j); - if (glyph_value != biggest_vowel) + chv = *(visual_achs - j); + if (chv != biggest_vowel) { - char_type = get_char_type (pdc->pLogFont, glyph_value); - if (!cb_one_glyph (context, glyph_value, char_type)){ + char_type = get_char_type (pdc->pLogFont, chv); + if (!cb_one_glyph (context, chv, char_type)){ goto end; } outed_num++; @@ -220,7 +219,7 @@ static int output_visual_glyphs_ltr (PDC pdc, Glyph32* visual_glyphs, pdc->bkmode = bkmode; i += vowel_num + 1; - visual_glyphs ++; + visual_achs ++; } end: @@ -228,11 +227,11 @@ end: return outed_num; } -static int output_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, +static int output_vowels_rtl (PDC pdc, Achar32* end_glyph, int left_num, CB_ONE_GLYPH cb_one_glyph, void* context, int* outed_num) { int i = 0; - Glyph32 glyph_value; + Achar32 chv; unsigned int char_type; int old_text_align = pdc->ta_flags; int old_bkmode = pdc->bkmode; @@ -241,11 +240,11 @@ static int output_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, pdc->bkmode = BM_TRANSPARENT; *outed_num = 0; for (i=0; ipLogFont, glyph_value); + chv = *end_glyph--; + char_type = get_char_type (pdc->pLogFont, chv); if (check_vowel(char_type)) { - if (cb_one_glyph(context, glyph_value, char_type)) { + if (cb_one_glyph(context, chv, char_type)) { (*outed_num) ++; } } @@ -257,12 +256,12 @@ static int output_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, return i; } -static int output_unowned_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, +static int output_unowned_vowels_rtl (PDC pdc, Achar32* end_glyph, int left_num, CB_ONE_GLYPH cb_one_glyph, void* context, int* outed_num) { int i = 0; - Glyph32 glyph_value = INV_GLYPH_VALUE; - Glyph32 biggest_vowel = INV_GLYPH_VALUE; + Achar32 chv = INV_GLYPH_VALUE; + Achar32 biggest_vowel = INV_GLYPH_VALUE; unsigned int char_type; int cur_advance = 0; int max_advance = 0; @@ -276,17 +275,17 @@ static int output_unowned_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, pdc->ta_flags = (old_text_align & ~TA_RIGHT) | TA_LEFT; for (i=0; ipLogFont, glyph_value); + chv = end_glyph [-i]; + char_type = get_char_type (pdc->pLogFont, chv); if (!check_vowel(char_type)) break; - cur_advance = get_glyph_advance_in_dc (pdc, glyph_value); + cur_advance = get_glyph_advance_in_dc (pdc, chv); if (cur_advance > max_advance) { max_advance = cur_advance; - biggest_vowel = glyph_value; + biggest_vowel = chv; } } @@ -303,11 +302,11 @@ static int output_unowned_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, left_num = i; for (i=0; ipLogFont, glyph_value); - if (cb_one_glyph(context, glyph_value, char_type)) + char_type = get_char_type (pdc->pLogFont, chv); + if (cb_one_glyph(context, chv, char_type)) { (*outed_num) ++; } @@ -318,18 +317,18 @@ static int output_unowned_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, return left_num; } -static int output_visual_glyphs_rtl (PDC pdc, Glyph32* visual_glyphs, - int nr_glyphs, CB_ONE_GLYPH cb_one_glyph, void* context) +static int output_visual_achs_rtl (PDC pdc, Achar32* visual_achs, + int nr_achs, CB_ONE_GLYPH cb_one_glyph, void* context) { - int cur = nr_glyphs - 1; + int cur = nr_achs - 1; unsigned int char_type; - Glyph32 glyph_value; + Achar32 chv; int vowel_num; int outed_vowel_num; int outed_glyph_num = 0; /*out the vowels on the rightest*/ - vowel_num = output_unowned_vowels_rtl (pdc, visual_glyphs+cur, cur+1, + vowel_num = output_unowned_vowels_rtl (pdc, visual_achs+cur, cur+1, cb_one_glyph, context, &outed_vowel_num); if (outed_vowel_num < vowel_num) return outed_vowel_num; @@ -338,17 +337,17 @@ static int output_visual_glyphs_rtl (PDC pdc, Glyph32* visual_glyphs, outed_glyph_num = outed_vowel_num; while (cur >= 0) { - glyph_value = visual_glyphs[cur]; - char_type = get_char_type (pdc->pLogFont, glyph_value); + chv = visual_achs[cur]; + char_type = get_char_type (pdc->pLogFont, chv); /*output the letter*/ - if (!cb_one_glyph(context, glyph_value, char_type)){ + if (!cb_one_glyph(context, chv, char_type)){ return outed_glyph_num; } outed_glyph_num ++; /*output the vowels of current letter, align with the letter's left*/ - vowel_num = output_vowels_rtl (pdc, visual_glyphs+cur-1, cur, + vowel_num = output_vowels_rtl (pdc, visual_achs+cur-1, cur, cb_one_glyph, context, &outed_vowel_num); outed_glyph_num += outed_vowel_num; @@ -361,27 +360,27 @@ static int output_visual_glyphs_rtl (PDC pdc, Glyph32* visual_glyphs, return outed_glyph_num; } -int _gdi_output_visual_glyphs(PDC pdc, Glyph32* visual_glyphs, - int nr_glyphs, BOOL direction, CB_ONE_GLYPH cb_one_glyph, void* context) +int _gdi_output_visual_achs(PDC pdc, Achar32* visual_achs, + int nr_achs, BOOL direction, CB_ONE_GLYPH cb_one_glyph, void* context) { /* call cb_one_glyph to show text. */ if (!direction) { /* right to left.*/ - return output_visual_glyphs_rtl (pdc, visual_glyphs, - nr_glyphs, cb_one_glyph, context); + return output_visual_achs_rtl (pdc, visual_achs, + nr_achs, cb_one_glyph, context); } else { - return output_visual_glyphs_ltr (pdc, visual_glyphs, - nr_glyphs, cb_one_glyph, context); + return output_visual_achs_ltr (pdc, visual_achs, + nr_achs, cb_one_glyph, context); } } -static int _gdi_output_glyphs_direct(PDC pdc, const unsigned char* text, +static int _gdi_output_achs_direct(PDC pdc, const unsigned char* text, int text_len, CB_ONE_GLYPH cb_one_glyph, void* context, BOOL if_break, BOOL if_draw) { unsigned int char_type; - Glyph32 glyph_value; + Achar32 chv; DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; int len_cur_char = 0; @@ -404,10 +403,10 @@ static int _gdi_output_glyphs_direct(PDC pdc, const unsigned char* text, len_cur_char = mbc_devfont->charset_ops->len_first_char ((const unsigned char*)text, left_bytes); if (len_cur_char > 0) { - glyph_value = mbc_devfont->charset_ops->get_char_value + chv = mbc_devfont->charset_ops->get_char_value (prev_mchar, prev_len, text, left_bytes); - glyph_value = _gdi_select_glyph_dfi(pdc->pLogFont, glyph_value); + chv = SET_MBCHV(chv); goto do_glyph; } } @@ -416,16 +415,16 @@ static int _gdi_output_glyphs_direct(PDC pdc, const unsigned char* text, ((const unsigned char*)text, left_bytes); if (len_cur_char > 0) { - glyph_value = sbc_devfont->charset_ops->get_char_value + chv = sbc_devfont->charset_ops->get_char_value (NULL, 0, text, left_bytes); } else break; do_glyph: - if (IS_MBC_GLYPH (glyph_value)) - char_type = mbc_devfont->charset_ops->char_type (glyph_value); + if (IS_MBC_GLYPH (chv)) + char_type = mbc_devfont->charset_ops->char_type (chv); else - char_type = sbc_devfont->charset_ops->char_type (glyph_value); + char_type = sbc_devfont->charset_ops->char_type (chv); if(if_break){ DRAWTEXTEX2_CTXT _txt; @@ -436,7 +435,7 @@ do_glyph: _txt.nFormat = ctxt->nFormat; _txt.only_extent = TRUE; _txt.tab_width = ctxt->tab_width; - if (!cb_one_glyph(&_txt, glyph_value, char_type)){ + if (!cb_one_glyph(&_txt, chv, char_type)){ break; } line_width += _txt.advance; @@ -446,7 +445,7 @@ do_glyph: } if(if_draw) { - if (!cb_one_glyph(ctxt, glyph_value, char_type)){ + if (!cb_one_glyph(ctxt, chv, char_type)){ break; } } @@ -462,20 +461,20 @@ do_glyph: } -Glyph32* _gdi_bidi_reorder (PDC pdc, const unsigned char* text, int text_len, - int* nr_glyphs) +Achar32* _gdi_bidi_reorder (PDC pdc, const unsigned char* text, int text_len, + int* nr_achs) { DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; - Glyph32 *logical_glyphs = NULL; + Achar32 *logical_achs = NULL; if (mbc_devfont && mbc_devfont->charset_ops->bidi_char_type) { - logical_glyphs = _gdi_get_glyphs_string (pdc, text, text_len, nr_glyphs); - if (*nr_glyphs > 0) - __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, - logical_glyphs, *nr_glyphs, -1, NULL, NULL); + logical_achs = _gdi_get_achs_string (pdc, text, text_len, nr_achs); + if (*nr_achs > 0) + __mg_charset_bidi_achars_reorder (mbc_devfont->charset_ops, + logical_achs, *nr_achs, -1, NULL, NULL); } - return logical_glyphs; + return logical_achs; } int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, @@ -483,67 +482,67 @@ int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, { int i = 0; unsigned int char_type; - Glyph32 glyph_value; + Achar32 chv; DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; if (mbc_devfont) { - int nr_glyphs = 0; - Glyph32 *logical_glyphs = NULL; + int nr_achs = 0; + Achar32 *logical_achs = NULL; if (mbc_devfont->charset_ops->bidi_char_type) { - logical_glyphs = _gdi_bidi_reorder (pdc, text, text_len, &nr_glyphs); - if (!logical_glyphs || nr_glyphs <= 0) + logical_achs = _gdi_bidi_reorder (pdc, text, text_len, &nr_achs); + if (!logical_achs || nr_achs <= 0) return 0; - i = _gdi_output_visual_glyphs (pdc, logical_glyphs, nr_glyphs, + i = _gdi_output_visual_achs (pdc, logical_achs, nr_achs, direction, cb_one_glyph, context); } else if (!direction) { - /* not need reorder glyphs, right to left, should alloc - * glyphs range. */ - logical_glyphs = _gdi_get_glyphs_string(pdc, text, text_len, - &nr_glyphs); - if(!logical_glyphs || nr_glyphs <= 0) return 0; + /* not need reorder achs, right to left, should alloc + * achs range. */ + logical_achs = _gdi_get_achs_string(pdc, text, text_len, + &nr_achs); + if(!logical_achs || nr_achs <= 0) return 0; - i = _gdi_output_visual_glyphs(pdc, logical_glyphs, nr_glyphs, + i = _gdi_output_visual_achs(pdc, logical_achs, nr_achs, direction, cb_one_glyph, context); } else{ - /* not need reorder glyphs, output left to right.*/ - i = _gdi_output_glyphs_direct(pdc, text, text_len, + /* not need reorder achs, output left to right.*/ + i = _gdi_output_achs_direct(pdc, text, text_len, cb_one_glyph, context, FALSE, TRUE); } - if (logical_glyphs) { - free(logical_glyphs); + if (logical_achs) { + free(logical_achs); } } else { if (!direction) { /* right to left, reverse text.*/ for (i = text_len - 1; i >= 0; i--) { - if (!(glyph_value = sbc_devfont->charset_ops->get_char_value + if (!(chv = sbc_devfont->charset_ops->get_char_value (NULL, 0, text + i, 1))) return (text_len-i-1); char_type = sbc_devfont->charset_ops->char_type - (glyph_value); + (chv); - if (!cb_one_glyph (context, glyph_value, char_type)) + if (!cb_one_glyph (context, chv, char_type)) break; } } else { for (i = 0; i < text_len; i++) { - if (!(glyph_value = sbc_devfont->charset_ops->get_char_value + if (!(chv = sbc_devfont->charset_ops->get_char_value (NULL, 0, text + i, 1))) return i; char_type = sbc_devfont->charset_ops->char_type - (glyph_value); + (chv); - if(!cb_one_glyph (context, glyph_value, char_type)) + if(!cb_one_glyph (context, chv, char_type)) break; } } @@ -551,18 +550,18 @@ int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, return i; } -static Glyph32* -_gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, - int text_len, int* nr_glyphs, void* context) +static Achar32* +_gdi_get_achs_string_charbreak(PDC pdc, const unsigned char* text, + int text_len, int* nr_achs, void* context) { int i = 0; int len_cur_char; int left_bytes = text_len; unsigned int char_type; - Glyph32 glyph_value; + Achar32 chv; DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; - Glyph32 *logical_glyphs = NULL; + Achar32 *logical_achs = NULL; DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; int line_width = 0; @@ -571,7 +570,7 @@ _gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, int prev_len = 0; const unsigned char* prev_mchar = NULL; - logical_glyphs = malloc(text_len * sizeof (Glyph32)); + logical_achs = malloc(text_len * sizeof (Achar32)); while (left_bytes > 0){ if (mbc_devfont) { @@ -581,15 +580,15 @@ _gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, else len_cur_char = 0; if (len_cur_char > 0) { - glyph_value = mbc_devfont->charset_ops->get_char_value + chv = mbc_devfont->charset_ops->get_char_value (prev_mchar, prev_len, text, left_bytes); prev_mchar = text; prev_len = len_cur_char; - logical_glyphs[i++] = _gdi_select_glyph_dfi(pdc->pLogFont, glyph_value); + logical_achs[i++] = SET_MBCHV(chv); char_type = (*mbc_devfont->charset_ops->char_type) - (glyph_value); + (chv); if (!(char_type & MCHAR_TYPE_NOSPACING_MARK)){ prev_mchar = text; } @@ -597,7 +596,7 @@ _gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, prev_len += len_cur_char; } - line_width += _gdi_get_glyph_advance (pdc, logical_glyphs[i-1], + line_width += _gdi_get_glyph_advance (pdc, logical_achs[i-1], TRUE, 0, 0, NULL, NULL, &bbox); left_bytes -= len_cur_char; text += len_cur_char; @@ -607,10 +606,10 @@ _gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, ((const unsigned char*)text, left_bytes); if (len_cur_char > 0) { - glyph_value = sbc_devfont->charset_ops->get_char_value + chv = sbc_devfont->charset_ops->get_char_value (NULL, 0, text, left_bytes); - logical_glyphs[i++] = glyph_value; - line_width += _gdi_get_glyph_advance (pdc, logical_glyphs[i-1], + logical_achs[i++] = chv; + line_width += _gdi_get_glyph_advance (pdc, logical_achs[i-1], TRUE, 0, 0, NULL, NULL, &bbox); left_bytes -= len_cur_char; text += len_cur_char; @@ -624,9 +623,9 @@ _gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, } ctxt->nCount = text_len - left_bytes; } - if(nr_glyphs) *nr_glyphs = i; + if(nr_achs) *nr_achs = i; - return logical_glyphs; + return logical_achs; } @@ -675,8 +674,8 @@ static int _gdi_get_nextword_width (PDC pdc, const unsigned char* pText, } static void -_gdi_get_glyphs_string_pos_wordbreak(PDC pdc, const unsigned char* text, - int text_len, int* nr_glyphs, void* context) +_gdi_get_achs_string_pos_wordbreak(PDC pdc, const unsigned char* text, + int text_len, int* nr_achs, void* context) { int len_cur_char = 0; int left_bytes = text_len; @@ -690,10 +689,10 @@ _gdi_get_glyphs_string_pos_wordbreak(PDC pdc, const unsigned char* text, &wordLen, context); if(line_width > ctxt->max_extent){ if(ctxt->nCount == 0){ - Glyph32* logical_glyphs = - _gdi_get_glyphs_string_charbreak(pdc, text, - text_len, nr_glyphs, ctxt); - if(logical_glyphs) free(logical_glyphs); + Achar32* logical_achs = + _gdi_get_achs_string_charbreak(pdc, text, + text_len, nr_achs, ctxt); + if(logical_achs) free(logical_achs); } break; } @@ -725,61 +724,61 @@ _gdi_get_glyphs_string_pos_wordbreak(PDC pdc, const unsigned char* text, } } -static Glyph32* -_gdi_get_glyphs_string_wordbreak(PDC pdc, const unsigned char* text, - int text_len, int* nr_glyphs, void* context) +static Achar32* +_gdi_get_achs_string_wordbreak(PDC pdc, const unsigned char* text, + int text_len, int* nr_achs, void* context) { DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; - Glyph32 *logical_glyphs = NULL; + Achar32 *logical_achs = NULL; if (mbc_devfont) { - _gdi_get_glyphs_string_pos_wordbreak(pdc, text, - text_len, nr_glyphs, context); - logical_glyphs = _gdi_get_glyphs_string(pdc, text, ctxt->nCount, - nr_glyphs); + _gdi_get_achs_string_pos_wordbreak(pdc, text, + text_len, nr_achs, context); + logical_achs = _gdi_get_achs_string(pdc, text, ctxt->nCount, + nr_achs); } - return logical_glyphs; + return logical_achs; } -static Glyph32* _gdi_get_glyphs_string_break(PDC pdc, const unsigned char* text, - int text_len, int* nr_glyphs, void* context) +static Achar32* _gdi_get_achs_string_break(PDC pdc, const unsigned char* text, + int text_len, int* nr_achs, void* context) { DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; if((ctxt->nFormat & DT_CHARBREAK) || (ctxt->nFormat & DT_SINGLELINE)){ - return _gdi_get_glyphs_string_charbreak(pdc, text, - text_len, nr_glyphs, ctxt); + return _gdi_get_achs_string_charbreak(pdc, text, + text_len, nr_achs, ctxt); } //else if(ctxt->nFormat & DT_WORDBREAK){ else { - return _gdi_get_glyphs_string_wordbreak(pdc, text, - text_len, nr_glyphs, ctxt); + return _gdi_get_achs_string_wordbreak(pdc, text, + text_len, nr_achs, ctxt); } } static int -_gdi_output_glyphs_direct_break(PDC pdc, const unsigned char* text, +_gdi_output_achs_direct_break(PDC pdc, const unsigned char* text, int text_len, CB_ONE_GLYPH cb_one_glyph, void* context) { DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; - int nr_glyphs = 0; + int nr_achs = 0; if(ctxt->nFormat & DT_WORDBREAK){ - _gdi_get_glyphs_string_pos_wordbreak(pdc, text, - text_len, &nr_glyphs, context); + _gdi_get_achs_string_pos_wordbreak(pdc, text, + text_len, &nr_achs, context); - return _gdi_output_glyphs_direct(pdc, text, ctxt->nCount, + return _gdi_output_achs_direct(pdc, text, ctxt->nCount, cb_one_glyph, ctxt, FALSE, TRUE); } else { - return _gdi_output_glyphs_direct(pdc, text, text_len, + return _gdi_output_achs_direct(pdc, text, text_len, cb_one_glyph, ctxt, TRUE, TRUE); } } -static void _gdi_get_glyphs_string_sbc_rtol_wordbreak(PDC pdc, - const unsigned char* text, int text_len, int* nr_glyphs, void* context) +static void _gdi_get_achs_string_sbc_rtol_wordbreak(PDC pdc, + const unsigned char* text, int text_len, int* nr_achs, void* context) { int len_cur_char = 0; int left_bytes = text_len; @@ -819,26 +818,26 @@ static void _gdi_get_glyphs_string_sbc_rtol_wordbreak(PDC pdc, } static int -_gdi_output_glyphs_direct_sbc_rtol_break(PDC pdc, const unsigned char* text, +_gdi_output_achs_direct_sbc_rtol_break(PDC pdc, const unsigned char* text, int text_len, CB_ONE_GLYPH cb_one_glyph, void* context) { DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; - int nr_glyphs = 0; + int nr_achs = 0; int i = 0; unsigned int char_type; - Glyph32 glyph_value; + Achar32 chv; DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; if(ctxt->nFormat & DT_WORDBREAK){ - _gdi_get_glyphs_string_sbc_rtol_wordbreak(pdc, - text, text_len, &nr_glyphs, ctxt); + _gdi_get_achs_string_sbc_rtol_wordbreak(pdc, + text, text_len, &nr_achs, ctxt); } else { /* get break char's pos, only count no draw chars out. */ - _gdi_output_glyphs_direct(pdc, text, text_len, + _gdi_output_achs_direct(pdc, text, text_len, cb_one_glyph, ctxt, TRUE, FALSE); /* - return _gdi_output_glyphs_direct(pdc, text, ctxt->nCount, + return _gdi_output_achs_direct(pdc, text, ctxt->nCount, cb_one_glyph, ctxt, TRUE, TRUE); */ } @@ -846,16 +845,16 @@ _gdi_output_glyphs_direct_sbc_rtol_break(PDC pdc, const unsigned char* text, if(ctxt->nCount <= 0) return 0; for (i = ctxt->nCount - 1; i >= 0; i--) { - glyph_value = sbc_devfont->charset_ops->get_char_value + chv = sbc_devfont->charset_ops->get_char_value (NULL, 0, text + i, 1); char_type = sbc_devfont->charset_ops->char_type - (glyph_value); + (chv); - if(!cb_one_glyph (context, glyph_value, char_type)) + if(!cb_one_glyph (context, chv, char_type)) break; } - return nr_glyphs; + return nr_achs; } int _gdi_reorder_text_break (PDC pdc, const unsigned char* text, @@ -865,111 +864,111 @@ int _gdi_reorder_text_break (PDC pdc, const unsigned char* text, DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; if (mbc_devfont) { - int nr_glyphs = text_len; - Glyph32 *logical_glyphs = NULL; + int nr_achs = text_len; + Achar32 *logical_achs = NULL; if (mbc_devfont->charset_ops->bidi_char_type){ - logical_glyphs = _gdi_get_glyphs_string_break(pdc, text, text_len, - &nr_glyphs, context); - __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, - logical_glyphs, nr_glyphs, -1, NULL, NULL); + logical_achs = _gdi_get_achs_string_break(pdc, text, text_len, + &nr_achs, context); + __mg_charset_bidi_achars_reorder (mbc_devfont->charset_ops, + logical_achs, nr_achs, -1, NULL, NULL); - if(!logical_glyphs) + if(!logical_achs) return 0; - i = _gdi_output_visual_glyphs(pdc, logical_glyphs, nr_glyphs, + i = _gdi_output_visual_achs(pdc, logical_achs, nr_achs, direction, cb_one_glyph, context); } - /* not need reorder glyphs, right to left, should - * alloc glyphs range. */ + /* not need reorder achs, right to left, should + * alloc achs range. */ else if(!direction){ - logical_glyphs = _gdi_get_glyphs_string_break(pdc, text, text_len, - &nr_glyphs, context); - if(!logical_glyphs) return 0; - i = _gdi_output_visual_glyphs(pdc, logical_glyphs, nr_glyphs, + logical_achs = _gdi_get_achs_string_break(pdc, text, text_len, + &nr_achs, context); + if(!logical_achs) return 0; + i = _gdi_output_visual_achs(pdc, logical_achs, nr_achs, direction, cb_one_glyph, context); } - /* not need reorder glyphs, output left to right.*/ + /* not need reorder achs, output left to right.*/ else { - i = _gdi_output_glyphs_direct_break(pdc, text, text_len, + i = _gdi_output_achs_direct_break(pdc, text, text_len, cb_one_glyph, context); } - if (logical_glyphs) { - free(logical_glyphs); + if (logical_achs) { + free(logical_achs); } } else{ /* note: follow sbc_devfont surpport not need to - * alloc mem for glyphs.*/ + * alloc mem for achs.*/ if (!direction) { /* right to left, reverse text.*/ - i = _gdi_output_glyphs_direct_sbc_rtol_break(pdc, text, + i = _gdi_output_achs_direct_sbc_rtol_break(pdc, text, text_len, cb_one_glyph, context); } else { - i = _gdi_output_glyphs_direct_break(pdc, text, text_len, + i = _gdi_output_achs_direct_break(pdc, text, text_len, cb_one_glyph, context); } } return i; } -/* \bref: Get the logical glyph string and the glyphs map table, if - * caller not malloc space for glyphs or glyphs_map, it will malloc +/* \bref: Get the logical glyph string and the achs map table, if + * caller not malloc space for achs or achs_map, it will malloc * space inner. * * \param LOGFONT* log_font: The logical font. * \param unsigned char* text: Input logical string, input. * \param int text_len: Input logical string len, input. - * \param Glyph32** glyphs: logical glyph string, input/output. - * \param GLYPHMAPINFO* glyph_map: position mapping from Logical - * glyphs strin to logical text, output. + * \param Achar32** achs: logical glyph string, input/output. + * \param ACHARMAPINFO* glyph_map: position mapping from Logical + * achs strin to logical text, output. * * \param int : return logical glyph string len, output. */ -int GUIAPI BIDIGetTextLogicalGlyphs( +int GUIAPI BIDIGetTextLogicalAChars( LOGFONT* log_font, const char* text, int text_len, - Glyph32** glyphs, - GLYPHMAPINFO** glyphs_map) + Achar32** achs, + ACHARMAPINFO** achs_map) { int i = 0; int left_bytes = text_len; int nr_chars; int prev_len = 0, len_cur_char = 0; const char* prev_mchar = NULL; - Glyph32 glyph_value = INV_GLYPH_VALUE; - Glyph32* glyph_string = NULL; - GLYPHMAPINFO* map = NULL; + Achar32 chv = INV_GLYPH_VALUE; + Achar32* achar_str = NULL; + ACHARMAPINFO* map = NULL; /* use the actual characters count for optimized memory usage. */ nr_chars = GetTextMCharInfo (log_font, text, text_len, NULL); - if (glyphs && *glyphs == NULL){ - *glyphs = malloc (nr_chars * sizeof (Glyph32)); - memset (*glyphs, 0, nr_chars * sizeof(Glyph32)); + if (achs && *achs == NULL){ + *achs = malloc (nr_chars * sizeof (Achar32)); + memset (*achs, 0, nr_chars * sizeof(Achar32)); } - if(glyphs_map && *glyphs_map == NULL){ - *glyphs_map = malloc (nr_chars * sizeof (GLYPHMAPINFO)); - memset (*glyphs_map, 0, nr_chars * sizeof(GLYPHMAPINFO)); + if(achs_map && *achs_map == NULL){ + *achs_map = malloc (nr_chars * sizeof (ACHARMAPINFO)); + memset (*achs_map, 0, nr_chars * sizeof(ACHARMAPINFO)); } - if (glyphs) glyph_string = *glyphs; - if (glyphs_map) map = *glyphs_map; - if (!map && !glyph_string) + if (achs) achar_str = *achs; + if (achs_map) map = *achs_map; + if (!map && !achar_str) return 0; while (left_bytes > 0){ len_cur_char = GetFirstMCharLen(log_font, text, left_bytes); - glyph_value = GetGlyphValue(log_font, text, left_bytes, + chv = GetACharValue(log_font, text, left_bytes, prev_mchar, prev_len); - if(glyph_string) glyph_string[i] = glyph_value; + if(achar_str) achar_str[i] = chv; /* set the glyph map info. */ if(map) { map[i].char_len = len_cur_char; @@ -987,108 +986,6 @@ int GUIAPI BIDIGetTextLogicalGlyphs( return i; } -/* - * \param HDC* hdc: The device context. - * \param Glyph32* glyph: Input glyph string, input. - * \param int nr_glyphs: Input glyph string len, input. - * \param int max_extent: Input glyph string extent value, input. - * \param int size: Ouput the fit glyph's visual extent value, Output. - * - * \param return int return the fit glyph's visual_glyph_index. - */ -int GUIAPI GetGlyphsExtentPoint( - HDC hdc, - Glyph32* glyphs, - int nr_glyphs, - int max_extent, - SIZE* size) -{ - int i = 0; - int advance = 0; - int adv_x, adv_y; - PDC pdc = dc_HDC2PDC(hdc); - PLOGFONT log_font = pdc->pLogFont; - DEVFONT* devfont = NULL; - unsigned int char_type = 0; - - size->cx = 0; - size->cy = 0; - - while(i < nr_glyphs){ - devfont = SELECT_DEVFONT(log_font, glyphs[i]); - char_type = devfont->charset_ops->char_type(glyphs[i]); - - if (check_zero_width (char_type)) { - adv_x = adv_y = 0; - } - else { - advance += _gdi_get_glyph_advance (pdc, glyphs[i], - (pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - 0, 0, &adv_x, &adv_y, NULL); - } - - if (max_extent > 0 && advance > max_extent) - break; - - size->cx += adv_x; - size->cy += adv_y; - i ++; - } - - _gdi_calc_glyphs_size_from_two_points (pdc, 0, 0, - size->cx, size->cy, size); - - return i; -} - -/* - * \param HDC* hdc: The device context. - * \param Glyph32* glyphs: Input glyph string, input. - * \param int nr_glyphs: Input glyph string len, input. - * \param SIZE size: Ouput the fit glyph's extent value, Output. - * - * \return int: return the nr_glyphs glyph_string extent. - */ -int GUIAPI GetGlyphsExtent( - HDC hdc, - Glyph32* glyphs, - int nr_glyphs, - SIZE* size) -{ - int i = 0; - int advance = 0; - int adv_x, adv_y; - unsigned int char_type; - Glyph32 glyph_value = INV_GLYPH_VALUE; - PDC pdc = dc_HDC2PDC(hdc); - PLOGFONT log_font = pdc->pLogFont; - DEVFONT* devfont = SELECT_DEVFONT(log_font, glyph_value); - - size->cx = 0; - size->cy = 0; - while (i < nr_glyphs) { - devfont = SELECT_DEVFONT(log_font, glyphs[i]); - char_type = devfont->charset_ops->char_type(glyphs[i]); - - if (check_zero_width (char_type)) { - adv_x = adv_y = 0; - } - else { - advance += _gdi_get_glyph_advance (pdc, glyphs[i], - (pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - 0, 0, &adv_x, &adv_y, NULL); - } - size->cx += adv_x; - size->cy += adv_y; - i ++; - } - - _gdi_calc_glyphs_size_from_two_points (pdc, 0, 0, - size->cx, size->cy, size); - - return advance; -} - typedef struct _RANGEINFO{ int start; int end; @@ -1098,7 +995,7 @@ typedef struct _RANGEINFO{ extern int GUIAPI GetLastMCharLen (PLOGFONT log_font, const char* mstr, int len); -static BOOL check_sel_range (PLOGFONT log_font, const char* text, +static BOOL check_sel_range (PLOGFONT log_font, const char* text, int text_len, int* start_index, int* end_index) { BOOL ret = TRUE; @@ -1125,18 +1022,18 @@ static BOOL check_sel_range (PLOGFONT log_font, const char* text, #define DEF_RANGES 8 -static int* generate_ranges(PLOGFONT log_font, Glyph32* log_glyphs, - int nr_glyphs, GLYPHMAPINFO* l_map, +static int* generate_ranges(PLOGFONT log_font, Achar32* log_achs, + int nr_achs, ACHARMAPINFO* l_map, int l_start_index, int l_end_index, int* nr_ranges) { int m = 0, i = 0, j = 0; int* p = NULL; int max_ranges = DEF_RANGES * 2; - GLYPHMAPINFO* v_map = NULL; + ACHARMAPINFO* v_map = NULL; Uint8* embedding_levels = NULL; - BIDIGetLogicalEmbeddLevels(log_font, log_glyphs, - nr_glyphs, &embedding_levels); + BIDIGetLogicalEmbeddLevels(log_font, log_achs, + nr_achs, &embedding_levels); /* get all the logical ranges in the same language. * default malloc DEF_RANGES ranges.*/ @@ -1164,13 +1061,13 @@ static int* generate_ranges(PLOGFONT log_font, Glyph32* log_glyphs, } v_map = l_map; - BIDILogGlyphs2VisGlyphs (log_font, log_glyphs, nr_glyphs, v_map); + BIDILogAChars2VisAChars (log_font, log_achs, nr_achs, v_map); *nr_ranges = m; /* translate the logical bytes index to visual glyph index. */ for(j = 0; j < *nr_ranges; j++){ - for(i = 0; i < nr_glyphs; i++) { + for(i = 0; i < nr_achs; i++) { if(p[j] == v_map[i].byte_index){ p[j] = i; break; @@ -1183,12 +1080,12 @@ static int* generate_ranges(PLOGFONT log_font, Glyph32* log_glyphs, } -static BOOL check_range_edge(int index, int nr_glyphs, GLYPHMAPINFO* v_map) +static BOOL check_range_edge(int index, int nr_achs, ACHARMAPINFO* v_map) { - if (index < 0 || index > nr_glyphs) + if (index < 0 || index > nr_achs) return FALSE; - if(index >= nr_glyphs-1 || index == 0){ + if(index >= nr_achs-1 || index == 0){ return TRUE; } @@ -1211,7 +1108,7 @@ static void computer_ranges(int* p, int* nr_ranges) int j = 0; int m = *nr_ranges; - /* set the visual glyphs range start_index < end_index.*/ + /* set the visual achs range start_index < end_index.*/ for(j = 0; j < m; j+=2){ if((j+1) < m && p[j] > p[j+1]){ int tmp = p[j]; @@ -1254,7 +1151,6 @@ static void computer_ranges(int* p, int* nr_ranges) *nr_ranges = (j+1); } } - } void GUIAPI GetTextRangesLog2VisTest( @@ -1268,10 +1164,10 @@ void GUIAPI GetTextRangesLog2VisTest( { int m = 0, i = 0; int* p = NULL; - Glyph32* l_glyphs = NULL; - GLYPHMAPINFO* v_map = NULL; - GLYPHMAPINFO* l_map = NULL; - int nr_glyphs = 0; + Achar32* l_achs = NULL; + ACHARMAPINFO* v_map = NULL; + ACHARMAPINFO* l_map = NULL; + int nr_achs = 0; *nr_ranges = 0; @@ -1280,11 +1176,11 @@ void GUIAPI GetTextRangesLog2VisTest( return; } - nr_glyphs = BIDIGetTextLogicalGlyphs(log_font, text, text_len, - &l_glyphs, &l_map); + nr_achs = BIDIGetTextLogicalAChars(log_font, text, text_len, + &l_achs, &l_map); v_map = l_map; - BIDILogGlyphs2VisGlyphs (log_font, l_glyphs, nr_glyphs, v_map); + BIDILogAChars2VisAChars (log_font, l_achs, nr_achs, v_map); /* get all the logical ranges in the same language. * default malloc 5 ranges.*/ @@ -1297,7 +1193,7 @@ void GUIAPI GetTextRangesLog2VisTest( start_index = end_index; end_index = a; } - for(i = 0; i < nr_glyphs; i++){ + for(i = 0; i < nr_achs; i++){ /* deal the start_index and end_index.*/ if(v_map[i].byte_index <= start_index && (v_map[i].byte_index+v_map[i].char_len) > start_index){ @@ -1308,7 +1204,7 @@ void GUIAPI GetTextRangesLog2VisTest( p[m++] = i; } - if((i+1) >= nr_glyphs){ + if((i+1) >= nr_achs){ if(v_map[i].byte_index > start_index && v_map[i].byte_index < end_index){ p[m++] = i+1; @@ -1330,7 +1226,7 @@ void GUIAPI GetTextRangesLog2VisTest( *nr_ranges /= 2; free(l_map); - free(l_glyphs); + free(l_achs); } /* @@ -1353,10 +1249,10 @@ void GUIAPI BIDIGetTextRangesLog2Vis(LOGFONT* log_font, { int i = 0; int* p = NULL; - Glyph32* l_glyphs = NULL; - GLYPHMAPINFO* l_map = NULL; + Achar32* l_achs = NULL; + ACHARMAPINFO* l_map = NULL; int l_start_index = start_index, l_end_index = end_index; - int nr_glyphs = 0; + int nr_achs = 0; *nr_ranges = 0; /* it is not bidi string. */ @@ -1388,10 +1284,10 @@ void GUIAPI BIDIGetTextRangesLog2Vis(LOGFONT* log_font, return; } - nr_glyphs = BIDIGetTextLogicalGlyphs(log_font, text, text_len, - &l_glyphs, &l_map); + nr_achs = BIDIGetTextLogicalAChars(log_font, text, text_len, + &l_achs, &l_map); - for(i = 0; i < nr_glyphs; i++) { + for(i = 0; i < nr_achs; i++) { int len = l_map[i].char_len; if(l_map[i].byte_index <= start_index && start_index <= (l_map[i].byte_index + len)){ @@ -1410,7 +1306,7 @@ void GUIAPI BIDIGetTextRangesLog2Vis(LOGFONT* log_font, l_end_index = tmp; } - p = generate_ranges(log_font, l_glyphs, nr_glyphs, l_map, + p = generate_ranges(log_font, l_achs, nr_achs, l_map, l_start_index, l_end_index, nr_ranges); computer_ranges(p, nr_ranges); @@ -1418,7 +1314,7 @@ void GUIAPI BIDIGetTextRangesLog2Vis(LOGFONT* log_font, /* check the ranges edges, +1 when edges. * after generate_ranges, l_map is translate to v_map*/ for(i = 1; i < *nr_ranges; i+=2){ - if(p[i] != 0 && check_range_edge(p[i], nr_glyphs, l_map)){ + if(p[i] != 0 && check_range_edge(p[i], nr_achs, l_map)){ p[i] += 1; } } @@ -1427,73 +1323,72 @@ void GUIAPI BIDIGetTextRangesLog2Vis(LOGFONT* log_font, *nr_ranges /= 2; free(l_map); - free(l_glyphs); + free(l_achs); } static void bidi_reverse_map (void* context, int len, int pos) { - GLYPHMAPINFO* str = (GLYPHMAPINFO*)context + pos; + ACHARMAPINFO* str = (ACHARMAPINFO*)context + pos; int i; for (i = 0; i < len / 2; i++) { - GLYPHMAPINFO tmp = str[i]; + ACHARMAPINFO tmp = str[i]; str[i] = str[len - 1 - i]; str[len - 1 - i] = tmp; } } -int GUIAPI BIDIGetTextVisualGlyphs(LOGFONT* log_font, +int GUIAPI BIDIGetTextVisualAChars(LOGFONT* log_font, const char* text, int text_len, - Glyph32** glyphs, - GLYPHMAPINFO** glyphs_map) + Achar32** achs, + ACHARMAPINFO** achs_map) { - int nr_glyphs = 0; + int nr_achs = 0; DEVFONT* mbc_devfont = log_font->devfonts[1]; - if (glyphs == NULL || glyphs_map == NULL) - return nr_glyphs; + if (achs == NULL || achs_map == NULL) + return nr_achs; - nr_glyphs = BIDIGetTextLogicalGlyphs(log_font, text, text_len, - glyphs, glyphs_map); + nr_achs = BIDIGetTextLogicalAChars(log_font, text, text_len, + achs, achs_map); - if (nr_glyphs > 0 && mbc_devfont + if (nr_achs > 0 && mbc_devfont && mbc_devfont->charset_ops->bidi_char_type) { - __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, - *glyphs, nr_glyphs, -1, - *glyphs_map, bidi_reverse_map); + __mg_charset_bidi_achars_reorder (mbc_devfont->charset_ops, + *achs, nr_achs, -1, + *achs_map, bidi_reverse_map); } - return nr_glyphs; + return nr_achs; } -Glyph32* GUIAPI BIDILogGlyphs2VisGlyphs(LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyphs_map) +Achar32* GUIAPI BIDILogAChars2VisAChars(LOGFONT* log_font, + Achar32* achs, int nr_achs, ACHARMAPINFO* achs_map) { DEVFONT* mbc_devfont = log_font->devfonts[1]; - if (nr_glyphs > 0 && mbc_devfont + if (nr_achs > 0 && mbc_devfont && mbc_devfont->charset_ops->bidi_char_type) { - __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, - glyphs, nr_glyphs, -1, - glyphs_map, bidi_reverse_map); + __mg_charset_bidi_achars_reorder (mbc_devfont->charset_ops, + achs, nr_achs, -1, + achs_map, bidi_reverse_map); - return glyphs; + return achs; } return NULL; } -BOOL GUIAPI BIDILogGlyphs2VisGlyphsEx(LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, int pel, +BOOL GUIAPI BIDILogAChars2VisACharsEx(LOGFONT* log_font, + Achar32* achs, int nr_achs, int pel, void* extra, CB_REVERSE_EXTRA cb_reorder_extra) { DEVFONT* mbc_devfont = log_font->devfonts[1]; - if (nr_glyphs > 0 && mbc_devfont + if (nr_achs > 0 && mbc_devfont && mbc_devfont->charset_ops->bidi_char_type) { - __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, - glyphs, nr_glyphs, pel, - extra, cb_reorder_extra); + __mg_charset_bidi_achars_reorder (mbc_devfont->charset_ops, + achs, nr_achs, pel, extra, cb_reorder_extra); return TRUE; } @@ -1502,38 +1397,38 @@ BOOL GUIAPI BIDILogGlyphs2VisGlyphsEx(LOGFONT* log_font, } void GUIAPI BIDIGetLogicalEmbedLevelsEx(LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, int pel, + Achar32* achs, int nr_achs, int pel, Uint8** embedding_levels) { DEVFONT* mbc_devfont = log_font->devfonts[1]; if (*embedding_levels == NULL) - *embedding_levels = malloc(nr_glyphs * sizeof (Uint8)); + *embedding_levels = malloc(nr_achs * sizeof (Uint8)); if (mbc_devfont && mbc_devfont->charset_ops->bidi_char_type) { __mg_charset_bidi_get_embeddlevels (mbc_devfont->charset_ops, - glyphs, nr_glyphs, pel, *embedding_levels, 0); + achs, nr_achs, pel, *embedding_levels, 0); } else { - memset (*embedding_levels, 0, sizeof(Uint8) * nr_glyphs); + memset (*embedding_levels, 0, sizeof(Uint8) * nr_achs); } } void GUIAPI BIDIGetVisualEmbedLevelsEx(LOGFONT* log_font, - Glyph32* glyphs, int nr_glyphs, int pel, + Achar32* achs, int nr_achs, int pel, Uint8** embedding_levels) { DEVFONT* mbc_devfont = log_font->devfonts[1]; if (*embedding_levels == NULL) - *embedding_levels = malloc(nr_glyphs * sizeof (Uint8)); + *embedding_levels = malloc(nr_achs * sizeof (Uint8)); if (mbc_devfont && mbc_devfont->charset_ops->bidi_char_type) { __mg_charset_bidi_get_embeddlevels (mbc_devfont->charset_ops, - glyphs, nr_glyphs, pel, *embedding_levels, 1); + achs, nr_achs, pel, *embedding_levels, 1); } else { - memset (*embedding_levels, 0, sizeof(Uint8) * nr_glyphs); + memset (*embedding_levels, 0, sizeof(Uint8) * nr_achs); } } diff --git a/src/newgdi/drawtext.h b/src/newgdi/drawtext.h index f190d8bf..c2728ba0 100644 --- a/src/newgdi/drawtext.h +++ b/src/newgdi/drawtext.h @@ -69,7 +69,7 @@ static inline int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value, BOOL direction, int x, int y, int* adv_x, int* adv_y, BBOX* bbox) { LOGFONT* logfont = pdc->pLogFont; - DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value); + DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(logfont, glyph_value); glyph_value = REAL_GLYPH (glyph_value); return _font_get_glyph_advance (logfont, devfont, glyph_value, diff --git a/src/newgdi/glyph-unicode.c b/src/newgdi/glyph-unicode.c index a08d4a1d..47ae577b 100644 --- a/src/newgdi/glyph-unicode.c +++ b/src/newgdi/glyph-unicode.c @@ -160,7 +160,6 @@ struct glyph_break_ctxt { LOGFONT* lf; DEVFONT* mbc_devfont; DEVFONT* sbc_devfont; - Glyph32* gvs; Uchar32* ucs; Uint8* bts; Uint16* bos; @@ -204,9 +203,6 @@ struct glyph_break_ctxt { Uint8 is_grapheme_boundary:1; Uint8 is_word_boundary:1; Uint8 is_sentence_boundary:1; - - // internal use - Uint8 need_ucs:1; }; static BOOL gbctxt_change_lbo_last(struct glyph_break_ctxt* gbctxt, @@ -303,8 +299,8 @@ static BOOL gbctxt_change_lbo_before_last_sp(struct glyph_break_ctxt* gbctxt, } #endif -static int get_next_glyph(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32* uc) +static int get_next_uchar(struct glyph_break_ctxt* gbctxt, + const char* mstr, int mstr_len, Uchar32* uc) { int mclen = 0; @@ -316,7 +312,7 @@ static int get_next_glyph(struct glyph_break_ctxt* gbctxt, ((const unsigned char*)mstr, mstr_len); if (mclen > 0) { - Mchar32 chv = gbctxt->mbc_devfont->charset_ops->get_char_value + Achar32 chv = gbctxt->mbc_devfont->charset_ops->get_char_value (NULL, 0, (Uint8*)mstr, mclen); if (gbctxt->mbc_devfont->charset_ops->conv_to_uc32) @@ -325,24 +321,21 @@ static int get_next_glyph(struct glyph_break_ctxt* gbctxt, *uc = chv; chv = SET_MBCHV(chv); - *gv = _gdi_get_glyph_value(gbctxt->lf, chv); } } - if (*gv == INV_GLYPH_VALUE) { + if (mclen == 0) { mclen = gbctxt->sbc_devfont->charset_ops->len_first_char ((const unsigned char*)mstr, mstr_len); if (mclen > 0) { - Mchar32 chv = gbctxt->sbc_devfont->charset_ops->get_char_value + Achar32 chv = gbctxt->sbc_devfont->charset_ops->get_char_value (NULL, 0, (Uint8*)mstr, mclen); if (gbctxt->sbc_devfont->charset_ops->conv_to_uc32) *uc = gbctxt->sbc_devfont->charset_ops->conv_to_uc32(chv); else *uc = chv; - - *gv = _gdi_get_glyph_value(gbctxt->lf, chv); } } @@ -1371,13 +1364,7 @@ static void dbg_dump_gbctxt(struct glyph_break_ctxt* gbctxt, #define dbg_dump_gbctxt(gbctxt, func, uc, gwsbo) #endif -static inline Glyph32 uc2gv(Glyph32 gv, Uchar32 uc) -{ - Glyph32 dfi_mask = (gv & GLYPH_DEVFONT_INDEX_MASK); - return ((Glyph32)uc) | dfi_mask; -} - -static inline BOOL is_glyph_letter(Uchar32 uc, +static inline BOOL is_uchar_letter(Uchar32 uc, UCharGeneralCategory gc, UCharBreakType bt) { if ((gc >= UCHAR_CATEGORY_LOWERCASE_LETTER @@ -1402,31 +1389,25 @@ static int gbctxt_init_spaces(struct glyph_break_ctxt* gbctxt, int size) if (gbctxt->len_buff < MIN_LEN_GLYPHS) gbctxt->len_buff = MIN_LEN_GLYPHS; - gbctxt->gvs = (Glyph32*)malloc(sizeof(Glyph32) * gbctxt->len_buff); - if (gbctxt->need_ucs) - gbctxt->ucs = (Uchar32*)malloc(sizeof(Uchar32) * gbctxt->len_buff); + gbctxt->ucs = (Uchar32*)malloc(sizeof(Uchar32) * gbctxt->len_buff); gbctxt->bts = (Uint8*)malloc(sizeof(Uint8) * gbctxt->len_buff); gbctxt->bos = (Uint16*)malloc(sizeof(Uint16) * gbctxt->len_buff); gbctxt->ods = (Uint8*)malloc(sizeof(Uint8) * gbctxt->len_buff); - if (gbctxt->gvs == NULL || gbctxt->bts == NULL || - gbctxt->bos == NULL || gbctxt->ods == NULL || - (gbctxt->need_ucs && gbctxt->ucs == NULL)) + if (gbctxt->bts == NULL || gbctxt->bos == NULL || + gbctxt->ods == NULL || gbctxt->ucs == NULL) return 0; return gbctxt->len_buff; } static int gbctxt_push_back(struct glyph_break_ctxt* gbctxt, - Glyph32 gv, Uchar32 uc, UCharBreakType bt, Uint16 lbo) + Uchar32 uc, UCharBreakType bt, Uint16 lbo) { /* realloc buffers if it needs */ if ((gbctxt->n + 2) >= gbctxt->len_buff) { gbctxt->len_buff += INC_LEN_GLYPHS; - gbctxt->gvs = (Glyph32*)realloc(gbctxt->gvs, - sizeof(Glyph32) * gbctxt->len_buff); - if (gbctxt->need_ucs) - gbctxt->ucs = (Uchar32*)realloc(gbctxt->ucs, - sizeof(Uchar32) * gbctxt->len_buff); + gbctxt->ucs = (Uchar32*)realloc(gbctxt->ucs, + sizeof(Uchar32) * gbctxt->len_buff); gbctxt->bts = (Uint8*)realloc(gbctxt->bts, sizeof(Uint8) * gbctxt->len_buff); gbctxt->bos = (Uint16*)realloc(gbctxt->bos, @@ -1434,9 +1415,8 @@ static int gbctxt_push_back(struct glyph_break_ctxt* gbctxt, gbctxt->ods = (Uint8*)realloc(gbctxt->ods, sizeof(Uint8) * gbctxt->len_buff); - if (gbctxt->gvs == NULL || gbctxt->bts == NULL || - gbctxt->bos == NULL || gbctxt->ods == NULL || - (gbctxt->need_ucs && gbctxt->ucs == NULL)) + if (gbctxt->bts == NULL || gbctxt->bos == NULL || + gbctxt->ods == NULL ||gbctxt->ucs == NULL) return 0; } @@ -1451,9 +1431,7 @@ static int gbctxt_push_back(struct glyph_break_ctxt* gbctxt, Uint16 gwsbo = 0; // set the after line break opportunity - gbctxt->gvs[gbctxt->n - 1] = gv; - if (gbctxt->need_ucs) - gbctxt->ucs[gbctxt->n - 1] = uc; + gbctxt->ucs[gbctxt->n - 1] = uc; gbctxt->bts[gbctxt->n - 1] = bt; gbctxt->bos[gbctxt->n] = lbo; if (lbo == BOV_UNKNOWN) @@ -1494,7 +1472,7 @@ static int gbctxt_push_back(struct glyph_break_ctxt* gbctxt, // Character Transformation // NOTE: Assume character transformation will not affect the breaks - if (gbctxt->ctr && (is_glyph_letter(uc, gc, bt) || uc == 0x0020)) { + if (gbctxt->ctr && (is_uchar_letter(uc, gc, bt) || uc == 0x0020)) { Uchar32 new_uc = uc; switch(gbctxt->ctr & CTR_CASE_MASK) { @@ -1519,10 +1497,6 @@ static int gbctxt_push_back(struct glyph_break_ctxt* gbctxt, if (gbctxt->ctr & CTR_FULL_SIZE_KANA) { new_uc = UCharToFullSizeKana(new_uc); } - - if (new_uc != uc) { - gbctxt->gvs[gbctxt->n - 1] = uc2gv(gv, new_uc); - } } gbctxt->prev_uc = uc; @@ -1548,9 +1522,8 @@ static int collapse_space(struct glyph_break_ctxt* gbctxt, do { int mclen; - Glyph32 gv; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, &uc); if (mclen == 0) break; @@ -1573,10 +1546,9 @@ static int check_glyphs_following_zw(struct glyph_break_ctxt* gbctxt, do { int mclen; - Glyph32 gv; Uchar32 uc; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, &uc); if (mclen > 0) { mstr += mclen; mstr_len -= mclen; @@ -1584,7 +1556,7 @@ static int check_glyphs_following_zw(struct glyph_break_ctxt* gbctxt, if (resolve_lbc(gbctxt, uc) == UCHAR_BREAK_SPACE) { cosumed += mclen; gbctxt_change_lbo_last(gbctxt, BOV_LB_NOTALLOWED); - gbctxt_push_back(gbctxt, gv, uc, UCHAR_BREAK_SPACE, + gbctxt_push_back(gbctxt, uc, UCHAR_BREAK_SPACE, BOV_LB_NOTALLOWED); } else { @@ -1600,12 +1572,12 @@ static int check_glyphs_following_zw(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_bt(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32* uc, + const char* mstr, int mstr_len, Uchar32* uc, UCharBreakType bt) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0 && resolve_lbc(gbctxt, *uc) == bt) return mclen; @@ -1613,16 +1585,16 @@ static int is_next_glyph_bt(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_letter(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32* uc, + const char* mstr, int mstr_len, Uchar32* uc, UCharBreakType* pbt) { int mclen; UCharBreakType bt; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { bt = resolve_lbc(gbctxt, *uc); - if (is_glyph_letter(*uc, gbctxt->curr_gc, bt)) { + if (is_uchar_letter(*uc, gbctxt->curr_gc, bt)) { if (pbt) *pbt = bt; return mclen; } @@ -1632,96 +1604,96 @@ static int is_next_glyph_letter(struct glyph_break_ctxt* gbctxt, } static inline int is_next_glyph_lf(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32* uc) + const char* mstr, int mstr_len, Uchar32* uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_LINE_FEED); } static inline int is_next_glyph_sp(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32* uc) + const char* mstr, int mstr_len, Uchar32* uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_SPACE); } static inline int is_next_glyph_gl(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32* uc) + const char* mstr, int mstr_len, Uchar32* uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_NON_BREAKING_GLUE); } static inline int is_next_glyph_hl(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_HEBREW_LETTER); } static inline int is_next_glyph_in(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_INSEPARABLE); } static inline int is_next_glyph_nu(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_NUMERIC); } static inline int is_next_glyph_po(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_POSTFIX); } static inline int is_next_glyph_pr(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_PREFIX); } static inline int is_next_glyph_op(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_OPEN_PUNCTUATION); } static inline int is_next_glyph_jt(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_HANGUL_T_JAMO); } static inline int is_next_glyph_ri(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_REGIONAL_INDICATOR); } static inline int is_next_glyph_em(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { - return is_next_glyph_bt(gbctxt, mstr, mstr_len, gv, uc, + return is_next_glyph_bt(gbctxt, mstr, mstr_len, uc, UCHAR_BREAK_EMOJI_MODIFIER); } static int is_next_glyph_cm_zwj(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32* uc, + const char* mstr, int mstr_len, Uchar32* uc, UCharBreakType* pbt) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = UCharGetBreakType(*uc); if (bt == UCHAR_BREAK_COMBINING_MARK @@ -1735,12 +1707,12 @@ static int is_next_glyph_cm_zwj(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_hy_ba(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc, + const char* mstr, int mstr_len, Uchar32 *uc, UCharBreakType* pbt) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_HYPHEN @@ -1754,10 +1726,10 @@ static int is_next_glyph_hy_ba(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_al_hl(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_HEBREW_LETTER || bt == UCHAR_BREAK_ALPHABETIC) @@ -1768,10 +1740,10 @@ static int is_next_glyph_al_hl(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_pr_po(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_PREFIX || bt == UCHAR_BREAK_POSTFIX) @@ -1782,10 +1754,10 @@ static int is_next_glyph_pr_po(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_id_eb_em(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_IDEOGRAPHIC @@ -1798,11 +1770,11 @@ static int is_next_glyph_id_eb_em(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_jl_jv_jt_h2_h3(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc, + const char* mstr, int mstr_len, Uchar32 *uc, UCharBreakType* pbt) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_HANGUL_L_JAMO @@ -1819,11 +1791,10 @@ static int is_next_glyph_jl_jv_jt_h2_h3(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_jl_jv_h2_h3(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc, - UCharBreakType* pbt) + const char* mstr, int mstr_len, Uchar32 *uc, UCharBreakType* pbt) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_HANGUL_L_JAMO @@ -1839,11 +1810,11 @@ static int is_next_glyph_jl_jv_h2_h3(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_jv_jt(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc, + const char* mstr, int mstr_len, Uchar32 *uc, UCharBreakType* pbt) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_HANGUL_V_JAMO @@ -1857,10 +1828,10 @@ static int is_next_glyph_jv_jt(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_al_hl_nu(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_HEBREW_LETTER @@ -1873,10 +1844,10 @@ static int is_next_glyph_al_hl_nu(struct glyph_break_ctxt* gbctxt, } static int is_next_glyph_cl_cp_is_sy(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_CLOSE_PUNCTUATION @@ -1891,14 +1862,13 @@ static int is_next_glyph_cl_cp_is_sy(struct glyph_break_ctxt* gbctxt, static int is_next_glyph_nu_OR_op_hy_followed_nu( struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { int mclen; int next_mclen; - Glyph32 next_gv; Uchar32 next_uc; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_NUMERIC) { @@ -1907,7 +1877,7 @@ static int is_next_glyph_nu_OR_op_hy_followed_nu( else if ((bt == UCHAR_BREAK_OPEN_PUNCTUATION || bt == UCHAR_BREAK_HYPHEN) && (next_mclen = is_next_glyph_nu(gbctxt, - mstr + mclen, mstr_len - mclen, &next_gv, &next_uc)) > 0) { + mstr + mclen, mstr_len - mclen, &next_uc)) > 0) { return mclen + next_mclen; } } @@ -1916,10 +1886,10 @@ static int is_next_glyph_nu_OR_op_hy_followed_nu( } static int is_next_glyph_nu_sy_is(struct glyph_break_ctxt* gbctxt, - const char* mstr, int mstr_len, Glyph32* gv, Uchar32 *uc) + const char* mstr, int mstr_len, Uchar32 *uc) { int mclen; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, gv, uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, *uc); if (bt == UCHAR_BREAK_NUMERIC @@ -1991,10 +1961,9 @@ static BOOL is_next_glyph_zw(struct glyph_break_ctxt* gbctxt, const char* mstr, int mstr_len) { int mclen; - Glyph32 gv; Uchar32 uc; - mclen = get_next_glyph(gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, &uc); if (mclen > 0 && resolve_lbc(gbctxt, uc) == UCHAR_BREAK_ZERO_WIDTH_SPACE) return TRUE; @@ -2008,16 +1977,15 @@ static int check_subsequent_cm_zwj(struct glyph_break_ctxt* gbctxt, { int cosumed = 0; int mclen; - Glyph32 gv; Uchar32 uc; UCharBreakType bt; while ((mclen = is_next_glyph_cm_zwj(gbctxt, mstr, mstr_len, - &gv, &uc, &bt)) > 0) { + &uc, &bt)) > 0) { // CM/ZWJ should have the same break class as // its base character. - gbctxt_push_back(gbctxt, gv, uc, gbctxt->base_bt, BOV_LB_NOTALLOWED); + gbctxt_push_back(gbctxt, uc, gbctxt->base_bt, BOV_LB_NOTALLOWED); mstr += mclen; mstr_len -= mclen; @@ -2032,11 +2000,10 @@ static int check_subsequent_sp(struct glyph_break_ctxt* gbctxt, { int cosumed = 0; int mclen; - Glyph32 gv; Uchar32 uc; - while ((mclen = is_next_glyph_sp(gbctxt, mstr, mstr_len, &gv, &uc)) > 0) { - gbctxt_push_back(gbctxt, gv, uc, UCHAR_BREAK_SPACE, BOV_LB_NOTALLOWED); + while ((mclen = is_next_glyph_sp(gbctxt, mstr, mstr_len, &uc)) > 0) { + gbctxt_push_back(gbctxt, uc, UCHAR_BREAK_SPACE, BOV_LB_NOTALLOWED); mstr += mclen; mstr_len -= mclen; cosumed += mclen; @@ -2048,12 +2015,11 @@ static int check_subsequent_sp(struct glyph_break_ctxt* gbctxt, static int is_subsequent_sps_and_end_bt(struct glyph_break_ctxt* gbctxt, const char* mstr, int mstr_len, UCharBreakType end_bt) { - Glyph32 gv; Uchar32 uc; int mclen; while (mstr_len > 0 && *mstr != '\0') { - mclen = get_next_glyph(gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, &uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, uc); if (bt == UCHAR_BREAK_SPACE) { @@ -2077,11 +2043,10 @@ static int check_subsequent_sps_and_end_bt(struct glyph_break_ctxt* gbctxt, { int cosumed = 0; int mclen; - Glyph32 gv; Uchar32 uc; while (mstr_len > 0 && *mstr != '\0') { - mclen = get_next_glyph(gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, &uc); if (mclen > 0) { UCharBreakType bt = resolve_lbc(gbctxt, uc); _DBG_PRINTF("%s: %04X (%d)\n", __FUNCTION__, uc, bt); @@ -2090,7 +2055,7 @@ static int check_subsequent_sps_and_end_bt(struct glyph_break_ctxt* gbctxt, mstr_len -= mclen; cosumed += mclen; if (!col_sp) - gbctxt_push_back(gbctxt, gv, uc, bt, BOV_LB_NOTALLOWED); + gbctxt_push_back(gbctxt, uc, bt, BOV_LB_NOTALLOWED); continue; } else if (bt == end_bt) { @@ -2110,11 +2075,10 @@ static BOOL is_odd_nubmer_of_subsequent_ri(struct glyph_break_ctxt* gbctxt, { int nr = 0; int mclen; - Glyph32 gv; Uchar32 uc; while (mstr_len > 0 && *mstr != '\0') { - mclen = get_next_glyph(gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, &uc); mstr += mclen; mstr_len -= mclen; @@ -2139,11 +2103,10 @@ static BOOL is_even_nubmer_of_subsequent_ri(struct glyph_break_ctxt* gbctxt, { int nr = 0; int mclen; - Glyph32 gv; Uchar32 uc; while (mstr_len > 0 && *mstr != '\0') { - mclen = get_next_glyph(gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, &uc); mstr += mclen; mstr_len -= mclen; @@ -2167,18 +2130,17 @@ static int check_subsequent_ri(struct glyph_break_ctxt* gbctxt, { int cosumed = 0; int mclen; - Glyph32 gv; Uchar32 uc; while (mstr_len > 0 && *mstr != '\0') { - mclen = get_next_glyph(gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(gbctxt, mstr, mstr_len, &uc); if (mclen > 0 && resolve_lbc(gbctxt, uc) == UCHAR_BREAK_REGIONAL_INDICATOR) { mstr += mclen; mstr_len -= mclen; cosumed += mclen; - gbctxt_push_back(gbctxt, gv, uc, + gbctxt_push_back(gbctxt, uc, UCHAR_BREAK_REGIONAL_INDICATOR, BOV_LB_NOTALLOWED); continue; } @@ -2189,11 +2151,10 @@ static int check_subsequent_ri(struct glyph_break_ctxt* gbctxt, return cosumed; } -int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, +int GUIAPI GetUCharsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, LanguageCode content_language, UCharScriptType writing_system, Uint8 wsr, Uint8 ctr, Uint8 wbr, Uint8 lbp, - Glyph32** glyphs, Uchar32** uchars, Uint16** break_oppos, - int* nr_glyphs) + Uchar32** uchars, Uint16** break_oppos, int* nr_ucs) { struct glyph_break_ctxt gbctxt; int cosumed = 0; @@ -2212,7 +2173,6 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, gbctxt.mbc_devfont = logfont->devfonts[1]; gbctxt.sbc_devfont = logfont->devfonts[0]; #if 0 - gbctxt.gvs = NULL; gbctxt.ucs = NULL; gbctxt.bts = NULL; gbctxt.bos = NULL; @@ -2256,13 +2216,9 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, gbctxt.is_extended_pictographic = 0; #endif - *glyphs = NULL; - if (uchars) { - *uchars = NULL; - gbctxt.need_ucs = 1; - } + *uchars = NULL; *break_oppos = NULL; - *nr_glyphs = 0; + *nr_ucs = 0; if (mstr_len == 0) return 0; @@ -2272,7 +2228,6 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, } while (TRUE) { - Glyph32 gv; Uchar32 uc; int mclen = 0; UCharBreakType bt; @@ -2280,13 +2235,12 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // line break opportunity Uint16 lbo; - Glyph32 next_gv; Uchar32 next_uc; UCharBreakType next_bt; int next_mclen; int cosumed_one_loop = 0; - mclen = get_next_glyph(&gbctxt, mstr, mstr_len, &gv, &uc); + mclen = get_next_uchar(&gbctxt, mstr, mstr_len, &uc); if (mclen == 0) { // badly encoded or end of text break; @@ -2304,7 +2258,6 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // Every tab is converted to a space (U+0020). _DBG_PRINTF ("CSS: Every tab is converted to a space (U+0020)\n"); uc = UCHAR_SPACE; - gv = uc2gv(gv, uc); } /* @@ -2321,7 +2274,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, if (gbctxt.n == 0) { _DBG_PRINTF ("LB2 Never break at the start of text\n"); gbctxt.curr_od = LB2; - if (gbctxt_push_back(&gbctxt, 0, 0, 0, BOV_LB_NOTALLOWED) == 0) + if (gbctxt_push_back(&gbctxt, 0, 0, BOV_LB_NOTALLOWED) == 0) goto error; } @@ -2338,11 +2291,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, } // Set default break opportunity of the current glyph - if (gbctxt_push_back(&gbctxt, gv, uc, bt, lbo) == 0) + if (gbctxt_push_back(&gbctxt, uc, bt, lbo) == 0) goto error; // LB3 Always break at the end of text. - if (get_next_glyph(&gbctxt, mstr, mstr_len, &next_gv, &next_uc) == 0) { + if (get_next_uchar(&gbctxt, mstr, mstr_len, &next_uc) == 0) { _DBG_PRINTF ("LB3 Always break at the end of text\n"); gbctxt.curr_od = LB3; gbctxt_change_lbo_last(&gbctxt, BOV_LB_MANDATORY); @@ -2364,7 +2317,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // LB6 Do not break before hard line breaks. else if (bt == UCHAR_BREAK_CARRIAGE_RETURN && (next_mclen = is_next_glyph_lf(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc)) > 0) { + mstr, mstr_len, &next_uc)) > 0) { cosumed_one_loop += next_mclen; _DBG_PRINTF ("LB5 Treat CR followed by LF, as well as CR, LF, and NL as hard line breaks.\n"); @@ -2379,7 +2332,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, lbo = BOV_LB_NOTALLOWED; else lbo = BOV_LB_MANDATORY; - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, + if (gbctxt_push_back(&gbctxt, next_uc, UCHAR_BREAK_LINE_FEED, lbo) == 0) goto error; } @@ -2448,7 +2401,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // emoji base or emoji modifier. if (bt == UCHAR_BREAK_ZERO_WIDTH_JOINER && is_next_glyph_id_eb_em(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB8a Do not break between a zero width joiner and ID, EB, EM\n"); gbctxt.curr_od = LB8a; @@ -2469,7 +2422,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, && bt != UCHAR_BREAK_SPACE && bt != UCHAR_BREAK_ZERO_WIDTH_SPACE && is_next_glyph_cm_zwj(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc, NULL) > 0) { + mstr, mstr_len, &next_uc, NULL) > 0) { _DBG_PRINTF ("LB9 Do not break a combining character sequence\n"); gbctxt.curr_od = LB9; @@ -2531,13 +2484,13 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, * line-break settings other than anywhere) except where opportunities * exist due to dictionary-based breaking. */ - if (wbr == WBR_KEEP_ALL && is_glyph_letter(uc, gc, bt) + if (wbr == WBR_KEEP_ALL && is_uchar_letter(uc, gc, bt) && (next_mclen = is_next_glyph_letter(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc, &next_bt)) > 0) { + mstr, mstr_len, &next_uc, &next_bt)) > 0) { _DBG_PRINTF ("WBR_KEEP_ALL.\n"); gbctxt.curr_od = LB12a; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, next_bt, + if (gbctxt_push_back(&gbctxt, next_uc, next_bt, BOV_UNKNOWN) == 0) goto error; @@ -2556,7 +2509,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, && bt != UCHAR_BREAK_AFTER && bt != UCHAR_BREAK_HYPHEN && is_next_glyph_gl(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB12a Do not break before NBSP and related characters, except after SP and HY\n"); gbctxt.curr_od = LB12a; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2575,7 +2528,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // LB13 for LBP_NORMAL if (bt != UCHAR_BREAK_NUMERIC && is_next_glyph_cl_cp_is_sy(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB13 for LBP_NORMAL: Do not break between non-number and ‘]’ or ‘;’ or ‘/’.\n"); gbctxt.curr_od = LB13; @@ -2705,13 +2658,13 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // LB21a Don't break after Hebrew + Hyphen. else if (bt == UCHAR_BREAK_HEBREW_LETTER && (next_mclen = is_next_glyph_hy_ba(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc, &next_bt)) > 0) { + mstr, mstr_len, &next_uc, &next_bt)) > 0) { _DBG_PRINTF ("LB21a Don't break after Hebrew + Hyphen\n"); gbctxt.curr_od = LB21a; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); if (gbctxt_push_back(&gbctxt, - next_gv, next_uc, next_bt, BOV_LB_NOTALLOWED) == 0) + next_uc, next_bt, BOV_LB_NOTALLOWED) == 0) goto error; cosumed_one_loop += next_mclen; @@ -2719,7 +2672,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // LB21b Don’t break between Solidus and Hebrew letters. else if (bt == UCHAR_BREAK_SYMBOL && is_next_glyph_hl(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB21b Don’t break between Solidus and Hebrew letters\n"); gbctxt.curr_od = LB21b; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2735,7 +2688,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, || bt == UCHAR_BREAK_INSEPARABLE || bt == UCHAR_BREAK_NUMERIC) && is_next_glyph_in(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB22 Do not break between two ellipses, or between letters...\n"); gbctxt.curr_od = LB22; @@ -2748,14 +2701,14 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, if ((bt == UCHAR_BREAK_HEBREW_LETTER || bt == UCHAR_BREAK_ALPHABETIC) && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB23 Do not break between digits and letters\n"); gbctxt.curr_od = LB23; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_NUMERIC && is_next_glyph_al_hl(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB23 Do not break between digits and letters\n"); gbctxt.curr_od = LB23; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2764,7 +2717,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // or between ideographs and numeric postfixes. else if (bt == UCHAR_BREAK_PREFIX && is_next_glyph_id_eb_em(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB23a.1 Do not break between numeric prefixes and ID...\n"); gbctxt.curr_od = LB23a; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2773,7 +2726,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, || bt == UCHAR_BREAK_EMOJI_BASE || bt == UCHAR_BREAK_EMOJI_MODIFIER) && is_next_glyph_po(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB23a.2 Do not break between numeric prefixes and ID...\n"); gbctxt.curr_od = LB23a; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2783,7 +2736,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, else if ((bt == UCHAR_BREAK_PREFIX || bt == UCHAR_BREAK_POSTFIX) && is_next_glyph_al_hl(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB24 Do not break between numeric prefix/postfix and letters\n"); gbctxt.curr_od = LB24; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2791,7 +2744,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, else if ((bt == UCHAR_BREAK_ALPHABETIC || bt == UCHAR_BREAK_HEBREW_LETTER) && is_next_glyph_pr_po(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB24 Do not break between numeric prefix/postfix and letters\n"); gbctxt.curr_od = LB24; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2803,42 +2756,42 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, if (lbp == LBP_LOOSE) { if (bt == UCHAR_BREAK_NUMERIC && is_next_glyph_po(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.5 for LBP_LOOSE: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_NUMERIC && is_next_glyph_pr(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.6 for LBP_LOOSE: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_POSTFIX && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { gbctxt.curr_od = LB25; _DBG_PRINTF ("LB25.8 for LBP_LOOSE: Do not break between the certain pairs of classes\n"); gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_PREFIX && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.a for LBP_LOOSE: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_HYPHEN && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.b for LBP_LOOSE: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_NUMERIC && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.d for LBP_LOOSE: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2847,7 +2800,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, else if (lbp == LBP_NORMAL) { if ((bt == UCHAR_BREAK_PREFIX || bt == UCHAR_BREAK_POSTFIX) && is_next_glyph_nu_OR_op_hy_followed_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.1 for LBP_NORMAL: (PR | PO) × ( OP | HY )? NU.\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2855,14 +2808,14 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, else if ((bt == UCHAR_BREAK_OPEN_PUNCTUATION || bt == UCHAR_BREAK_HYPHEN) && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.2 for LBP_NORMAL: ( OP | HY ) × NU.\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_NUMERIC && is_next_glyph_nu_sy_is(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.3 for LBP_NORMAL: NU × (NU | SY | IS).\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2888,97 +2841,97 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, else { if (bt == UCHAR_BREAK_CLOSE_PUNCTUATION && is_next_glyph_po(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.1 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_CLOSE_PUNCTUATION && is_next_glyph_pr(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.2 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_CLOSE_PARANTHESIS && is_next_glyph_po(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { gbctxt.curr_od = LB25; _DBG_PRINTF ("LB25.3 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_CLOSE_PARANTHESIS && is_next_glyph_pr(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.4 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_NUMERIC && is_next_glyph_po(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.5 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_NUMERIC && is_next_glyph_pr(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.6 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_POSTFIX && is_next_glyph_op(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { gbctxt.curr_od = LB25; _DBG_PRINTF ("LB25.7 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_POSTFIX && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { gbctxt.curr_od = LB25; _DBG_PRINTF ("LB25.8 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_PREFIX && is_next_glyph_op(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { gbctxt.curr_od = LB25; _DBG_PRINTF ("LB25.9 for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_PREFIX && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.a for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_HYPHEN && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.b for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_INFIX_SEPARATOR && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.c for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_NUMERIC && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.d for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_SYMBOL && is_next_glyph_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB25.e for LBP_STRICT: Do not break between the certain pairs of classes\n"); gbctxt.curr_od = LB25; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -2989,11 +2942,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // LB26 Do not break a Korean syllable. if (bt == UCHAR_BREAK_HANGUL_L_JAMO && (next_mclen = is_next_glyph_jl_jv_h2_h3(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc, &next_bt)) > 0) { + mstr, mstr_len, &next_uc, &next_bt)) > 0) { _DBG_PRINTF ("LB26.1 Do not break a Korean syllable.\n"); gbctxt.curr_od = LB26; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, next_bt, + if (gbctxt_push_back(&gbctxt, next_uc, next_bt, BOV_UNKNOWN) == 0) goto error; @@ -3002,11 +2955,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, else if ((bt == UCHAR_BREAK_HANGUL_V_JAMO || bt == UCHAR_BREAK_HANGUL_LV_SYLLABLE) && (next_mclen = is_next_glyph_jv_jt(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc, &next_bt)) > 0) { + mstr, mstr_len, &next_uc, &next_bt)) > 0) { _DBG_PRINTF ("LB26.2 Do not break a Korean syllable.\n"); gbctxt.curr_od = LB26; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, next_bt, + if (gbctxt_push_back(&gbctxt, next_uc, next_bt, BOV_UNKNOWN) == 0) goto error; @@ -3015,11 +2968,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, else if ((bt == UCHAR_BREAK_HANGUL_T_JAMO || bt == UCHAR_BREAK_HANGUL_LVT_SYLLABLE) && (next_mclen = is_next_glyph_jt(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc)) > 0) { + mstr, mstr_len, &next_uc)) > 0) { _DBG_PRINTF ("LB26.3 Do not break a Korean syllable.\n"); gbctxt.curr_od = LB26; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, + if (gbctxt_push_back(&gbctxt, next_uc, UCHAR_BREAK_HANGUL_T_JAMO, BOV_UNKNOWN) == 0) goto error; @@ -3032,11 +2985,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, || bt == UCHAR_BREAK_HANGUL_LV_SYLLABLE || bt == UCHAR_BREAK_HANGUL_LVT_SYLLABLE) && (next_mclen = is_next_glyph_in(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc)) > 0) { + mstr, mstr_len, &next_uc)) > 0) { _DBG_PRINTF ("LB27.1 Treat a Korean Syllable Block the same as ID.\n"); gbctxt.curr_od = LB27; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, + if (gbctxt_push_back(&gbctxt, next_uc, UCHAR_BREAK_INSEPARABLE, BOV_UNKNOWN) == 0) goto error; @@ -3048,11 +3001,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, || bt == UCHAR_BREAK_HANGUL_LV_SYLLABLE || bt == UCHAR_BREAK_HANGUL_LVT_SYLLABLE) && (next_mclen = is_next_glyph_po(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc)) > 0) { + mstr, mstr_len, &next_uc)) > 0) { _DBG_PRINTF ("LB27.2 Treat a Korean Syllable Block the same as ID.\n"); gbctxt.curr_od = LB27; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, + if (gbctxt_push_back(&gbctxt, next_uc, UCHAR_BREAK_POSTFIX, BOV_UNKNOWN) == 0) goto error; @@ -3060,11 +3013,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, } else if (bt == UCHAR_BREAK_PREFIX && (next_mclen = is_next_glyph_jl_jv_jt_h2_h3(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc, &next_bt)) > 0) { + mstr, mstr_len, &next_uc, &next_bt)) > 0) { _DBG_PRINTF ("LB27.3 Treat a Korean Syllable Block the same as ID.\n"); gbctxt.curr_od = LB27; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, + if (gbctxt_push_back(&gbctxt, next_uc, next_bt, BOV_UNKNOWN) == 0) goto error; @@ -3078,7 +3031,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, else if ((bt == UCHAR_BREAK_HEBREW_LETTER || bt == UCHAR_BREAK_ALPHABETIC) && is_next_glyph_al_hl(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB28 Do not break between alphabetics (“at”)\n"); gbctxt.curr_od = LB28; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -3088,7 +3041,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // and alphabetics (“e.g.”). else if (bt == UCHAR_BREAK_INFIX_SEPARATOR && is_next_glyph_al_hl(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB29 Do not break between numeric punctuation\n"); gbctxt.curr_od = LB29; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -3100,14 +3053,14 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, || bt == UCHAR_BREAK_ALPHABETIC || bt == UCHAR_BREAK_NUMERIC) && is_next_glyph_op(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB30.1 Do not break between letters, numbers...\n"); gbctxt.curr_od = LB30; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); } else if (bt == UCHAR_BREAK_CLOSE_PARANTHESIS && is_next_glyph_al_hl_nu(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc) > 0) { + mstr, mstr_len, &next_uc) > 0) { _DBG_PRINTF ("LB30.2 Do not break between letters, numbers...\n"); gbctxt.curr_od = LB30; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); @@ -3118,11 +3071,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // position of the break. else if (bt == UCHAR_BREAK_REGIONAL_INDICATOR && (next_mclen = is_next_glyph_ri(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc)) > 0) { + mstr, mstr_len, &next_uc)) > 0) { _DBG_PRINTF ("LB30a.1 Break between two regional indicator symbols...\n"); gbctxt.curr_od = LB30a; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, + if (gbctxt_push_back(&gbctxt, next_uc, UCHAR_BREAK_REGIONAL_INDICATOR, BOV_UNKNOWN) == 0) goto error; cosumed_one_loop += next_mclen; @@ -3144,11 +3097,11 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // LB30b Do not break between an emoji base and an emoji modifier. else if (bt == UCHAR_BREAK_EMOJI_BASE && (next_mclen = is_next_glyph_em(&gbctxt, - mstr, mstr_len, &next_gv, &next_uc)) > 0) { + mstr, mstr_len, &next_uc)) > 0) { _DBG_PRINTF ("LB30b Do not break between an emoji base and an emoji modifier\n"); gbctxt.curr_od = LB30b; gbctxt_change_lbo_last(&gbctxt, BOV_LB_NOTALLOWED); - if (gbctxt_push_back(&gbctxt, next_gv, next_uc, + if (gbctxt_push_back(&gbctxt, next_uc, UCHAR_BREAK_EMOJI_MODIFIER, BOV_UNKNOWN) == 0) goto error; @@ -3192,11 +3145,10 @@ next_glyph: } } - *glyphs = gbctxt.gvs; *break_oppos = gbctxt.bos; if (uchars) *uchars = gbctxt.ucs; - *nr_glyphs = gbctxt.n - 1; + *nr_ucs = gbctxt.n - 1; } else goto error; @@ -3207,7 +3159,6 @@ next_glyph: return cosumed; error: - if (gbctxt.gvs) free(gbctxt.gvs); if (gbctxt.ucs) free(gbctxt.ucs); if (gbctxt.bts) free(gbctxt.bts); if (gbctxt.bos) free(gbctxt.bos); @@ -3300,7 +3251,7 @@ static int font_get_glyph_metrics(LOGFONT* logfont, int bbox_w = 0, bbox_h = 0; int gbt; - DEVFONT* devfont = SELECT_DEVFONT(logfont, gv); + DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(logfont, gv); gbt = devfont->font_ops->get_glyph_bmptype (logfont, devfont) & DEVFONTGLYPHTYPE_MASK_BMPTYPE; @@ -3986,7 +3937,7 @@ static inline BOOL is_stop_or_common(const MYGLYPHINFO* gi) static void init_glyph_info(MYGLYPHARGS* args, int i, MYGLYPHINFO* gi) { - DEVFONT* devfont = SELECT_DEVFONT(args->lfur, args->gvs[i]); + DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(args->lfur, args->gvs[i]); if (devfont->charset_ops->conv_to_uc32) gi->uc = devfont->charset_ops->conv_to_uc32(args->gvs[i]); else @@ -4459,19 +4410,6 @@ error: return 0; } -Uchar32 GUIAPI Glyph2UChar(LOGFONT* logfont, Glyph32 gv) -{ - Uchar32 uc; - DEVFONT* devfont = SELECT_DEVFONT(logfont, gv); - - if (devfont->charset_ops->conv_to_uc32) - uc = devfont->charset_ops->conv_to_uc32(gv); - else - uc = REAL_GLYPH(gv); - - return uc; -} - #endif /* _MGCHARSET_UNICODE */ int GUIAPI DrawGlyphStringEx(HDC hdc, diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index ec5e6419..9d0ccc5e 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -71,184 +71,66 @@ int ft2IsFreeTypeDevfont (DEVFONT* devfont); #define FS_WEIGHT_AUTOBOLD 29 -Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, const char* mchar, - int mchar_len, const char* pre_mchar, int pre_len) +Glyph32 GetGlyphValue(LOGFONT* lf, Achar32 chv) { - int len_cur_char; - Glyph32 gv = INV_GLYPH_VALUE; - DEVFONT* sbc_devfont = logfont->devfonts[0]; - DEVFONT* mbc_devfont = logfont->devfonts[1]; + Glyph32 gv = INV_GLYPH_VALUE; + int i, dfi = 0; + DEVFONT* df; - if (mbc_devfont) { - int i, dfi; - DEVFONT* df; + if (IS_MBCHV(chv)) { + chv = REAL_ACHAR(chv); + for (i = 1; i < MAXNR_DEVFONTS; i++) { + if ((df = lf->devfonts[i])) { + if (df->font_ops->get_glyph_value) + gv = df->font_ops->get_glyph_value(lf, df, chv); + else + gv = chv; - len_cur_char = mbc_devfont->charset_ops->len_first_char - ((const unsigned char*)mchar, mchar_len); - - if (len_cur_char > 0) { - gv = mbc_devfont->charset_ops->get_char_value - ((Uint8*)pre_mchar, pre_len, (Uint8*)mchar, mchar_len); - - dfi = 1; - for (i = 1; i < MAXNR_DEVFONTS; i++) { - if ((df = logfont->devfonts[i])) { - if (df->font_ops->is_glyph_existed(logfont, df, gv)) { - dfi = i; - break; - } + if (df->font_ops->is_glyph_existed(lf, df, gv)) { + dfi = i; + break; } } - - // return the first devfont as the default - return SET_GLYPH_DFI(gv, dfi); } - } - len_cur_char = sbc_devfont->charset_ops->len_first_char - ((const unsigned char*)mchar, mchar_len); - - if (len_cur_char > 0) { - gv = sbc_devfont->charset_ops->get_char_value - (NULL, 0, (Uint8*)mchar, mchar_len); - } - - return gv; -} - -Glyph32 GUIAPI GetShapedGlyph (LOGFONT* logfont, const char* mchar, - int mchar_len, GLYPHSHAPETYPE shape_type) -{ - int len_cur_char; - - Glyph32 glyph_value = INV_GLYPH_VALUE; - DEVFONT* sbc_devfont = logfont->devfonts[0]; - DEVFONT* mbc_devfont = logfont->devfonts[1]; - - if (mbc_devfont) { - len_cur_char = mbc_devfont->charset_ops->len_first_char ( - (const unsigned char*)mchar, mchar_len); - - if (len_cur_char > 0) { - int i, dfi; - DEVFONT* df; - - if (mbc_devfont->charset_ops->get_shaped_char_value) - glyph_value = mbc_devfont->charset_ops->get_shaped_char_value( - (const unsigned char*)mchar, mchar_len, shape_type); + if (dfi == 0) { + if ((df = lf->devfonts[1])) { + dfi = 1; + if (df->font_ops->get_glyph_value) + gv = df->font_ops->get_glyph_value(lf, df, chv); + else + gv = chv; + } else - glyph_value = mbc_devfont->charset_ops->get_char_value - (NULL, 0, (Uint8*)mchar, len_cur_char); - - dfi = 1; - for (i = 1; i < MAXNR_DEVFONTS; i++) { - if ((df = logfont->devfonts[i])) { - if (df->font_ops->is_glyph_existed(logfont, df, glyph_value)) { - dfi = i; - break; - } - } - } - - return SET_GLYPH_DFI(glyph_value, dfi); + goto error; } } - - len_cur_char = sbc_devfont->charset_ops->len_first_char - ((const unsigned char*)mchar, mchar_len); - - if (len_cur_char > 0) { - if (sbc_devfont->charset_ops->get_shaped_char_value) - glyph_value = sbc_devfont->charset_ops->get_shaped_char_value( - (const unsigned char*)mchar, mchar_len, shape_type); - else - glyph_value = sbc_devfont->charset_ops->get_char_value - (NULL, 0, (Uint8*)mchar, len_cur_char); - - } - - return glyph_value; -} - -BOOL GUIAPI GetMirrorGlyph (LOGFONT* logfont, Glyph32 gv, - Glyph32* mirrored) -{ - *mirrored = INV_GLYPH_VALUE; - - DEVFONT* devfont = SELECT_DEVFONT(logfont, gv); - if (devfont->charset_ops->bidi_mirror_char) { - return devfont->charset_ops->bidi_mirror_char(gv, mirrored); - } - - return FALSE; -} - -int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, - int* adv_x, int* adv_y) -{ - int advance; - int char_type; - - PDC pdc = dc_HDC2PDC(hdc); - DEVFONT* devfont = SELECT_DEVFONT(pdc->pLogFont, glyph_value); - - /* Transfer logical to device to screen here. */ - coor_LP2SP (pdc, &x, &y); - pdc->rc_output = pdc->DevRC; - - char_type = devfont->charset_ops->char_type (glyph_value); - if (check_zero_width(char_type)) { - if (adv_x) *adv_x = 0; - if (adv_y) *adv_y = 0; - advance = 0; - } else { - int my_adv_x, my_adv_y; - /* convert to the start point on baseline. */ - _gdi_get_baseline_point (pdc, &x, &y); - - advance = _gdi_draw_one_glyph (pdc, glyph_value, - (pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - x, y, &my_adv_x, &my_adv_y); - - if (adv_x) *adv_x = my_adv_x; - if (adv_y) *adv_y = my_adv_y; + dfi = 0; + if ((df = lf->devfonts[0])) { + if (df->font_ops->get_glyph_value) + gv = df->font_ops->get_glyph_value(lf, df, chv); + else + gv = chv; + } + else + goto error; } - return advance; -} + return SET_GLYPH_DFI(gv, dfi); -unsigned int GUIAPI GetGlyphType (LOGFONT* logfont, Glyph32 glyph_value) -{ - /* get the relative device font */ - DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value); - glyph_value = REAL_GLYPH (glyph_value); - return devfont->charset_ops->char_type (glyph_value); +error: + return INV_GLYPH_VALUE; } int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, GLYPHINFO* glyph_info) { /* get the relative device font */ - DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value); + DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(logfont, glyph_value); glyph_value = REAL_GLYPH (glyph_value); SIZE sz; - /* get glyph type */ - if (glyph_info->mask & GLYPH_INFO_TYPE) - glyph_info->char_type = devfont->charset_ops->char_type (glyph_value); - - /* get glyph type */ - if (glyph_info->mask & GLYPH_INFO_BIDI_TYPE) { - if (devfont->charset_ops->bidi_char_type) { - glyph_info->bidi_char_type - = devfont->charset_ops->bidi_char_type (glyph_value); - } - else { - glyph_info->bidi_char_type = BIDI_TYPE_INVALID; - } - } - /* get metrics of the glyph */ if ((glyph_info->mask & GLYPH_INFO_METRICS) || (glyph_info->mask & GLYPH_INFO_BMP)) { @@ -274,29 +156,18 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, case GLYPHBMP_TYPE_MONO: glyph_info->bits = devfont->font_ops->get_glyph_monobitmap ( logfont, devfont, glyph_value, &sz, &glyph_info->bmp_pitch, NULL); - glyph_info->bbox_w = sz.cx; - glyph_info->bbox_h = sz.cy; - glyph_info->bmp_size = glyph_info->bmp_pitch * glyph_info->bbox_h; break; case GLYPHBMP_TYPE_GREY: glyph_info->bits = devfont->font_ops->get_glyph_greybitmap ( logfont, devfont, glyph_value, &sz, &glyph_info->bmp_pitch, NULL); - glyph_info->bbox_w = sz.cx; - glyph_info->bbox_h = sz.cy; - glyph_info->bmp_size = - glyph_info->bmp_pitch * glyph_info->bbox_h; break; case GLYPHBMP_TYPE_SUBPIXEL: glyph_info->bits = devfont->font_ops->get_glyph_greybitmap ( logfont, devfont, glyph_value, &sz, &glyph_info->bmp_pitch, NULL); - glyph_info->bbox_w = sz.cx; - glyph_info->bbox_h = sz.cy; - glyph_info->bmp_size = - glyph_info->bmp_pitch * glyph_info->bbox_h; break; case GLYPHBMP_TYPE_PRERENDER: @@ -306,26 +177,44 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, } } + glyph_info->bmp_width = sz.cx; + glyph_info->bmp_height = sz.cy; return 0; } -void GUIAPI GetGlyphBitmap (LOGFONT* logfont, const char* mchar, - int mchar_len, GLYPHBITMAP* glyph_bitmap) +int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, + int* adv_x, int* adv_y) { - GLYPHINFO glyph_info; - Glyph32 glyph_value = INV_GLYPH_VALUE; + int advance; + int char_type; - memset(&glyph_info, 0, sizeof(GLYPHINFO)); - glyph_value = GetGlyphValue(logfont, (const char*)mchar, - mchar_len, NULL, 0); + PDC pdc = dc_HDC2PDC(hdc); + DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(pdc->pLogFont, glyph_value); - glyph_info.mask = GLYPH_INFO_METRICS | GLYPH_INFO_BMP; - glyph_info.bmp_type = GLYPHBMP_TYPE_MONO; + /* Transfer logical to device to screen here. */ + coor_LP2SP (pdc, &x, &y); + pdc->rc_output = pdc->DevRC; - if (glyph_value != INV_GLYPH_VALUE) - GetGlyphInfo(logfont, glyph_value, &glyph_info); + char_type = devfont->charset_ops->char_type (glyph_value); + if (check_zero_width(char_type)) { + if (adv_x) *adv_x = 0; + if (adv_y) *adv_y = 0; + advance = 0; + } + else { + int my_adv_x, my_adv_y; + /* convert to the start point on baseline. */ + _gdi_get_baseline_point (pdc, &x, &y); - memcpy(glyph_bitmap, &glyph_info.bbox_x, sizeof(GLYPHBITMAP)); + advance = _gdi_draw_one_glyph (pdc, glyph_value, + (pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + x, y, &my_adv_x, &my_adv_y); + + if (adv_x) *adv_x = my_adv_x; + if (adv_y) *adv_y = my_adv_y; + } + + return advance; } static int mult (fixed op1, fixed op2) @@ -2011,7 +1900,7 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value, unsigned short scale = 1; BYTE* data = NULL; PLOGFONT logfont = pdc->pLogFont; - DEVFONT* devfont = SELECT_DEVFONT(pdc->pLogFont, glyph_value); + DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(pdc->pLogFont, glyph_value); glyph_value = REAL_GLYPH(glyph_value); DWORD bmptype = devfont->font_ops->get_glyph_bmptype (logfont, devfont); @@ -2813,7 +2702,7 @@ int _gdi_draw_one_glyph (PDC pdc, Glyph32 glyph_value, BOOL direction, x, y, adv_x, adv_y, &bbox); logfont = pdc->pLogFont; - devfont = SELECT_DEVFONT (logfont, glyph_value); + devfont = SELECT_DEVFONT_BY_GLYPH (logfont, glyph_value); glyph_bmptype = devfont->font_ops->get_glyph_bmptype (logfont, devfont) & DEVFONTGLYPHTYPE_MASK_BMPTYPE; @@ -2938,59 +2827,80 @@ void _gdi_start_new_line (PDC pdc) } } -Glyph32 _gdi_select_glyph_dfi(LOGFONT* lf, Glyph32 gv) +int GUIAPI GetGlyphsExtentPoint(HDC hdc, Glyph32* glyphs, int nr_glyphs, + int max_extent, SIZE* size) { - int i, dfi = 0; - DEVFONT* df; + int i = 0; + int advance = 0; + int adv_x, adv_y; + PDC pdc = dc_HDC2PDC(hdc); + PLOGFONT log_font = pdc->pLogFont; + DEVFONT* devfont = NULL; + unsigned int char_type = 0; - for (i = 1; i < MAXNR_DEVFONTS; i++) { - if ((df = lf->devfonts[i])) { - if (df->font_ops->is_glyph_existed(lf, df, gv)) { - dfi = i; - break; - } + size->cx = 0; + size->cy = 0; + + while(i < nr_glyphs){ + devfont = SELECT_DEVFONT_BY_GLYPH(log_font, glyphs[i]); + char_type = devfont->charset_ops->char_type(glyphs[i]); + + if (check_zero_width (char_type)) { + adv_x = adv_y = 0; } + else { + advance += _gdi_get_glyph_advance (pdc, glyphs[i], + (pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + 0, 0, &adv_x, &adv_y, NULL); + } + + if (max_extent > 0 && advance > max_extent) + break; + + size->cx += adv_x; + size->cy += adv_y; + i ++; } - if (dfi == 0) { - if (REAL_GLYPH(gv) < 0x80) - dfi = 0; - else - dfi = 1; - } + _gdi_calc_glyphs_size_from_two_points (pdc, 0, 0, + size->cx, size->cy, size); - return SET_GLYPH_DFI(gv, dfi); + return i; } -Glyph32 _gdi_get_glyph_value(LOGFONT* lf, Mchar32 chv) +int GUIAPI GetGlyphsExtent(HDC hdc, Glyph32* glyphs, int nr_glyphs, SIZE* size) { - Glyph32 gv = INV_GLYPH_VALUE; - int i, dfi = 0; - DEVFONT* df; + int i = 0; + int advance = 0; + int adv_x, adv_y; + unsigned int char_type; + Glyph32 glyph_value = INV_GLYPH_VALUE; + PDC pdc = dc_HDC2PDC(hdc); + PLOGFONT log_font = pdc->pLogFont; + DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(log_font, glyph_value); - if (IS_MBCHV(chv)) { - for (i = 1; i < MAXNR_DEVFONTS; i++) { - if ((df = lf->devfonts[i])) { - if (df->font_ops->get_glyph_value) - gv = df->font_ops->get_glyph_value(lf, df, chv); - else - gv = REAL_CHV(chv); + size->cx = 0; + size->cy = 0; + while (i < nr_glyphs) { + devfont = SELECT_DEVFONT_BY_GLYPH(log_font, glyphs[i]); + char_type = devfont->charset_ops->char_type(glyphs[i]); - if (df->font_ops->is_glyph_existed(lf, df, gv)) { - dfi = i; - break; - } - } + if (check_zero_width (char_type)) { + adv_x = adv_y = 0; } + else { + advance += _gdi_get_glyph_advance (pdc, glyphs[i], + (pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + 0, 0, &adv_x, &adv_y, NULL); + } + size->cx += adv_x; + size->cy += adv_y; + i ++; } - if (dfi == 0) { - if (REAL_CHV(chv) < 0x80) - dfi = 0; - else - dfi = 1; - } + _gdi_calc_glyphs_size_from_two_points (pdc, 0, 0, + size->cx, size->cy, size); - return SET_GLYPH_DFI(gv, dfi); + return advance; }