@@ -87,4 +87,38 @@ describe('SymbolTextSpec', function () {
8787 // expect(geometry.getTextDesc().size.width).to.be.eql(0);
8888 expect ( geometry . getTextDesc ( ) . size . height ) . to . be . eql ( textSize ) ;
8989 } ) ;
90+
91+ it ( '#2093 text symbol TextDesc rows when textName Is multi line text ' , function ( ) {
92+ function líneasNuevas ( s ) {
93+ return s . split ( '' ) . join ( '\n' ) . replace ( / ( [ \ud800 - \udfff ] ) \n ( [ \ud800 - \udfff ] ) / g, '$1$2' ) ;
94+ }
95+ const textNames = [ '甲子' , '乙丑' , '丙寅' , '丁卯' , '戊辰' , '己巳' ] . map ( name => {
96+ return líneasNuevas ( name + '行都司' ) ;
97+ } ) ;
98+ textNames . push ( '大家好' ) ;
99+ textNames . push ( 'Hello\nWorld' ) ;
100+ const randomName = Math . ceil ( Math . random ( ) * 100000 ) + '' ;
101+ textNames . push ( líneasNuevas ( randomName ) ) ;
102+
103+ var v = new maptalks . VectorLayer ( 'v' , { 'drawImmediate' : true } ) . addTo ( map ) ;
104+ textNames . forEach ( textName => {
105+ v . clear ( ) ;
106+ const lineRows = textName . split ( '\n' ) ;
107+ var geometry = new maptalks . Marker ( center . copy ( ) , {
108+ symbol : {
109+ 'textName' : textName ,
110+ "textFaceName" : "楷体" ,
111+ "textSize" : { "stops" : [ [ 8 , 14 ] , [ 20 , 32 ] ] } ,
112+ "textFill" : "#000" ,
113+ "textOpacity" : 1 ,
114+ "textHaloFill" : [ 1 , 1 , 1 , 0.9 ] ,
115+ "textHaloRadius" : 1 ,
116+ "textHorizontalAlignment" : "middle" ,
117+ "textVerticalAlignment" : "middle"
118+ }
119+ } ) ;
120+ v . addGeometry ( geometry ) ;
121+ expect ( geometry . getTextDesc ( ) . rows . length ) . to . be . eql ( lineRows . length ) ;
122+ } ) ;
123+ } ) ;
90124} ) ;
0 commit comments