@@ -30,6 +30,8 @@ import {
3030 SvgDelimiterData ,
3131 SvgFontData ,
3232 SvgFontDataClass ,
33+ VFUZZ ,
34+ HFUZZ ,
3335} from '../FontData.js' ;
3436import {
3537 CommonMo ,
@@ -41,11 +43,6 @@ import { MmlMo } from '../../../core/MmlTree/MmlNodes/mo.js';
4143import { BBox } from '../../../util/BBox.js' ;
4244import { DIRECTION , SvgCharData } from '../FontData.js' ;
4345
44- /*****************************************************************/
45-
46- const VFUZZ = 0.1 ; // overlap for vertical stretchy glyphs
47- const HFUZZ = 0.1 ; // overlap for horizontal stretchy glyphs
48-
4946/*****************************************************************/
5047/**
5148 * The SvgMo interface for the SVG Mo wrapper
@@ -269,7 +266,7 @@ export const SvgMo = (function <N, T, D>(): SvgMoClass<N, T, D> {
269266 /**
270267 * @param {number } n The number of the character to look up
271268 * @param {string } variant The variant for the character to look up
272- * @returns {SvgCharData } The full CharData object, with CharOptions guaranteed to be defined
269+ * @returns {SvgCharData } The full CharData object, with CharOptions guaranteed to be defined
273270 */
274271 protected getChar ( n : number , variant : string ) : SvgCharData {
275272 const char = this . font . getChar ( variant , n ) || [ 0 , 0 , 0 , null ] ;
@@ -287,7 +284,7 @@ export const SvgMo = (function <N, T, D>(): SvgMoClass<N, T, D> {
287284 * @param {number } x The x position of the glyph
288285 * @param {number } y The y position of the glyph
289286 * @param {N } parent The container for the glyph
290- * @returns {number } The width of the character placed
287+ * @returns {number } The width of the character placed
291288 */
292289 protected addGlyph (
293290 n : number ,
@@ -315,7 +312,7 @@ export const SvgMo = (function <N, T, D>(): SvgMoClass<N, T, D> {
315312 * @param {string } v The variant for the top glyph
316313 * @param {number } H The height of the stretched delimiter
317314 * @param {number } W The width of the stretched delimiter
318- * @returns {number } The total height of the top glyph
315+ * @returns {number } The total height of the top glyph
319316 */
320317 protected addTop ( n : number , v : string , H : number , W : number ) : number {
321318 if ( ! n ) return 0 ;
@@ -333,27 +330,40 @@ export const SvgMo = (function <N, T, D>(): SvgMoClass<N, T, D> {
333330 * @param {number } B The height of the bottom glyph in the delimiter
334331 * @param {number } W The width of the stretched delimiter
335332 */
336- /* prettier-ignore */
337- protected addExtV ( n : number , v : string , H : number , D : number , T : number , B : number , W : number ) {
333+ protected addExtV (
334+ n : number ,
335+ v : string ,
336+ H : number ,
337+ D : number ,
338+ T : number ,
339+ B : number ,
340+ W : number
341+ ) {
338342 if ( ! n ) return ;
339- T = Math . max ( 0 , T - VFUZZ ) ; // A little overlap on top
340- B = Math . max ( 0 , B - VFUZZ ) ; // A little overlap on bottom
343+ T = Math . max ( 0 , T - VFUZZ ) ; // A little overlap on top
344+ B = Math . max ( 0 , B - VFUZZ ) ; // A little overlap on bottom
341345 const adaptor = this . adaptor ;
342346 const [ h , d , w ] = this . getChar ( n , v ) ;
343- const Y = H + D - T - B ; // The height of the extender
344- const s = 1.5 * Y / ( h + d ) ; // Scale height by 1.5 to avoid bad ends
345- // (glyphs with rounded or anti-aliased ends don't stretch well,
346- // so this makes for sharper ends)
347- const y = ( s * ( h - d ) - Y ) / 2 ; // The bottom point to clip the extender
347+ const Y = H + D - T - B ; // The height of the extender
348+ const s = ( 1.5 * Y ) / ( h + d ) ; // Scale height by 1.5 to avoid bad ends
349+ // (glyphs with rounded or anti-aliased ends don't stretch well,
350+ // so this makes for sharper ends)
351+ const y = ( s * ( h - d ) - Y ) / 2 ; // The bottom point to clip the extender
348352 if ( Y <= 0 ) return ;
349353 const svg = this . svg ( 'svg' , {
350- width : this . fixed ( w ) , height : this . fixed ( Y ) ,
351- y : this . fixed ( B - D ) , x : this . fixed ( ( W - w ) / 2 ) ,
352- viewBox : [ 0 , y , w , Y ] . map ( x => this . fixed ( x ) ) . join ( ' ' )
354+ width : this . fixed ( w ) ,
355+ height : this . fixed ( Y ) ,
356+ y : this . fixed ( B - D ) ,
357+ x : this . fixed ( ( W - w ) / 2 ) ,
358+ viewBox : [ 0 , y , w , Y ] . map ( ( x ) => this . fixed ( x ) ) . join ( ' ' ) ,
353359 } ) ;
354360 this . addGlyph ( n , v , 0 , 0 , svg ) ;
355361 const glyph = adaptor . lastChild ( svg ) ;
356- adaptor . setAttribute ( glyph as N , 'transform' , `scale(1,${ this . jax . fixed ( s ) } )` ) ;
362+ adaptor . setAttribute (
363+ glyph as N ,
364+ 'transform' ,
365+ `scale(1,${ this . jax . fixed ( s ) } )`
366+ ) ;
357367 if ( this . dom [ 0 ] ) {
358368 adaptor . append ( this . dom [ 0 ] , svg ) ;
359369 }
@@ -367,7 +377,7 @@ export const SvgMo = (function <N, T, D>(): SvgMoClass<N, T, D> {
367377 * @param {string } v The variant for the bottom glyph
368378 * @param {number } D The depth of the stretched delimiter
369379 * @param {number } W The width of the stretched delimiter
370- * @returns {number } The total height of the bottom glyph
380+ * @returns {number } The total height of the bottom glyph
371381 */
372382 protected addBot ( n : number , v : string , D : number , W : number ) : number {
373383 if ( ! n ) return 0 ;
@@ -395,7 +405,7 @@ export const SvgMo = (function <N, T, D>(): SvgMoClass<N, T, D> {
395405 /**
396406 * @param {number } n The character number for the left glyph of the stretchy character
397407 * @param {string } v The variant for the left glyph
398- * @returns {number } The width of the left glyph
408+ * @returns {number } The width of the left glyph
399409 */
400410 protected addLeft ( n : number , v : string ) : number {
401411 return n ? this . addGlyph ( n , v , 0 , 0 ) : 0 ;
@@ -418,14 +428,14 @@ export const SvgMo = (function <N, T, D>(): SvgMoClass<N, T, D> {
418428 x : number = 0
419429 ) {
420430 if ( ! n ) return ;
421- R = Math . max ( 0 , R - HFUZZ ) ; // A little less than the width of the right glyph
422- L = Math . max ( 0 , L - HFUZZ ) ; // A little less than the width of the left glyph
431+ R = Math . max ( 0 , R - HFUZZ ) ; // A little less than the width of the right glyph
432+ L = Math . max ( 0 , L - HFUZZ ) ; // A little less than the width of the left glyph
423433 const adaptor = this . adaptor ;
424434 const [ h , d , w ] = this . getChar ( n , v ) ;
425- const X = W - L - R ; // The width of the extender
426- const Y = h + d + 2 * VFUZZ ; // The height (plus some fuzz) of the extender
427- const s = 1.5 * ( X / w ) ; // Scale the width so that left- and right-bearing won't hurt us
428- const D = - ( d + VFUZZ ) ; // The bottom position of the glyph
435+ const X = W - L - R ; // The width of the extender
436+ const Y = h + d + 2 * VFUZZ ; // The height (plus some fuzz) of the extender
437+ const s = 1.5 * ( X / w ) ; // Scale the width so that left- and right-bearing won't hurt us
438+ const D = - ( d + VFUZZ ) ; // The bottom position of the glyph
429439 if ( X <= 0 ) return ;
430440 const svg = this . svg ( 'svg' , {
431441 width : this . fixed ( X ) ,
@@ -453,7 +463,7 @@ export const SvgMo = (function <N, T, D>(): SvgMoClass<N, T, D> {
453463 * @param {number } n The character number for the right glyph of the stretchy character
454464 * @param {string } v The variant for the right glyph
455465 * @param {number } W The width of the stretched character
456- * @returns {number } The width of the right glyph
466+ * @returns {number } The width of the right glyph
457467 */
458468 protected addRight ( n : number , v : string , W : number ) : number {
459469 if ( ! n ) return 0 ;
0 commit comments