@@ -326,22 +326,35 @@ export class WatermarkAction extends BaseImageAction {
326
326
}
327
327
328
328
calculateTextSize ( text : string , fontSize : number ) : WatermarkTextOpts {
329
+ // any better way?
329
330
let cWidth = 0 ;
330
331
for ( let v of text ) {
331
332
const charCode = v . charCodeAt ( 0 ) ;
332
333
if ( charCode > 256 ) {
333
334
cWidth += fontSize ;
334
335
} else if ( charCode > 97 ) {
335
- cWidth += fontSize * 0.55 ;
336
- } else if ( charCode === 87 ) {
337
- // char W is bigger than others
338
- cWidth += fontSize * 0.95 ;
339
- } else if ( charCode === 77 ) {
340
- // char M is bigger than others
341
- cWidth += fontSize * 0.85 ;
342
-
336
+ // i, j,l
337
+ if ( charCode === 105 || charCode === 106 || charCode === 108 ) {
338
+ cWidth += fontSize * 0.22 ;
339
+ } else if ( charCode === 102 ) {
340
+ // f
341
+ cWidth += fontSize * 0.28 ;
342
+ } else {
343
+ cWidth += fontSize * 0.55 ;
344
+ }
343
345
} else if ( charCode > 59 && charCode < 91 ) {
344
- cWidth += fontSize * 0.75 ;
346
+ if ( charCode === 87 ) {
347
+ // char W is bigger than others
348
+ cWidth += fontSize * 0.95 ;
349
+ } else if ( charCode === 77 ) {
350
+ // char M is bigger than others
351
+ cWidth += fontSize * 0.85 ;
352
+ } else if ( charCode === 73 || charCode === 74 ) {
353
+ // I,J
354
+ cWidth += fontSize * 0.6 ;
355
+ } else {
356
+ cWidth += fontSize * 0.75 ;
357
+ }
345
358
} else if ( charCode > 47 && charCode < 58 ) {
346
359
// number
347
360
cWidth += fontSize * 0.55 ;
0 commit comments