Skip to content

Commit c901b28

Browse files
authored
Merge pull request #3450 from ntrrgc/text-wrapping
Text wrapping support for more languages
2 parents 353c5b5 + fa3d2fa commit c901b28

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,25 @@ cc.LabelTTF._textBaseline = ["top", "middle", "bottom"];
2424
//check the first character
2525
cc.LabelTTF.wrapInspection = true;
2626

27-
//Support: English French German
28-
//Other as Oriental Language
29-
cc.LabelTTF._wordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)/;
30-
cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>]/;
31-
cc.LabelTTF._lastWordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)$/;
32-
cc.LabelTTF._lastEnglish = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+$/;
33-
cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
27+
// These regular expressions consider a word any sequence of characters
28+
// from these Unicode (sub)blocks:
29+
// - Basic Latin (letters and numbers, plus the hypen-minus '-')
30+
// - Latin-1 Supplement (accentuated letters and ¿¡ only)
31+
// - Latin Extended-A (complete)
32+
// - Latin Extended-B (complete)
33+
// - IPA Extensions (complete)
34+
// - Spacing Modifier Letters (complete)
35+
// - Combining Diacritical Marks (Combining Grapheme Joiner excluded)
36+
// - Greek and Coptic (complete, including reserved code points)
37+
// - Cyrillic (complete)
38+
// - Cyrillic Supplement (complete)
39+
// - General Punctuation (Non-Breaking Hyphen* [U+2011] and quotation marks)
40+
// * Note that Hyphen [U+2010] is considered a word boundary.
41+
cc.LabelTTF._wordRex = /([a-zA-Z0-9\-¿¡«À-ÖØ-öø-ʯ\u0300-\u034e\u0350-\u036FͰ-ԯ\u2011-]+|\S)/;
42+
cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>»\u2010--]/;
43+
cc.LabelTTF._lastWordRex = /([a-zA-Z0-9\-¿¡«À-ÖØ-öø-ʯ\u0300-\u034e\u0350-\u036FͰ-ԯ\u2011-]+|\S)$/;
44+
cc.LabelTTF._lastEnglish = /[a-zA-Z0-9\-¿¡«À-ÖØ-öø-ʯ\u0300-\u034e\u0350-\u036FͰ-ԯ\u2011-]+$/;
45+
cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9\-¿¡«À-ÖØ-öø-ʯ\u0300-\u034e\u0350-\u036FͰ-ԯ\u2011-]/;
3446

3547
(function () {
3648
cc.LabelTTF.RenderCmd = function () {

0 commit comments

Comments
 (0)