@@ -5551,6 +5551,78 @@ atom.declare( 'LibCanvas.Plugins.SpriteFont.Lexer', {
55515551} ) ;
55525552
55535553
5554+ /** @class SpriteFont.MorphemesFinder */
5555+ atom . declare ( 'LibCanvas.Plugins.SpriteFont.MorphemesFinder' , {
5556+ vowels : 'AEIOUYaeiouyАОУЮИЫЕЭЯЁаоуюиыеэяёьЄІЇЎєіїў' ,
5557+
5558+ initialize : function ( ) {
5559+ } ,
5560+
5561+ isLetter : function ( str ) {
5562+ return ( str >= 'a' && str <= 'z' ) || ( str >= 'A' && str <= 'я' ) ||
5563+ ( str >= 'A' && str <= 'Z' ) || ( str >= '\u00c0' && str <= '\u02a8' ) ||
5564+ ( str >= '0' && str <= '9' ) || ( str >= '\u0386' && str <= '\u04ff' ) ;
5565+ } ,
5566+
5567+ isVowel : function ( str ) {
5568+ return str && str . length == 1 && this . vowels . indexOf ( str ) > - 1 ;
5569+ } ,
5570+
5571+ isMorpheme : function ( str ) {
5572+ if ( ! str || str . length <= 1 ) return false ;
5573+
5574+ for ( var i = str . length ; i -- ; ) if ( this . isVowel ( str [ i ] ) ) return true ;
5575+
5576+ return false ;
5577+ } ,
5578+
5579+ findMorphemes : function ( line ) {
5580+ var i = 0 , c , morphemes = [ ] , lastStr = '' , last = [ ] , prev ;
5581+
5582+ var pushLast = function ( ) {
5583+ prev = morphemes [ morphemes . length - 1 ] ;
5584+ if ( Array . isArray ( prev ) ) {
5585+ atom . array . append ( prev , last ) ;
5586+ } else {
5587+ morphemes . push ( last ) ;
5588+ }
5589+ last = [ ] ;
5590+ lastStr = '' ;
5591+
5592+ if ( ! this . isLetter ( c ) ) {
5593+ morphemes . push ( line [ i ] ) ;
5594+ }
5595+ } . bind ( this ) ;
5596+
5597+ for ( ; i < line . length ; i ++ ) {
5598+ c = line [ i ] . content ;
5599+
5600+ if ( line [ i ] . type == 'icon' ) {
5601+ morphemes . push ( last ) ;
5602+ last = [ ] ;
5603+ lastStr = '' ;
5604+ morphemes . push ( line [ i ] ) ;
5605+ } else if ( line [ i ] . type == 'symbol' && this . isLetter ( c ) ) {
5606+ lastStr += c ;
5607+ last . push ( line [ i ] ) ;
5608+ if ( this . isMorpheme ( lastStr ) ) {
5609+ morphemes . push ( last ) ;
5610+ last = [ ] ;
5611+ lastStr = '' ;
5612+ }
5613+ } else if ( lastStr ) {
5614+ pushLast ( ) ;
5615+ } else {
5616+ morphemes . push ( line [ i ] ) ;
5617+ }
5618+ }
5619+
5620+ if ( lastStr ) pushLast ( ) ;
5621+
5622+ return morphemes ;
5623+ }
5624+ } ) ;
5625+
55545626/** @class SpriteFont.LinesEnRu */
55555627atom . declare ( 'LibCanvas.Plugins.SpriteFont.LinesEnRu' , {
55565628 setConfig : function ( font , noWrap , forceSplit ) {
0 commit comments