@@ -32,27 +32,33 @@ sanitizers.half = function (glyph) {
3232 glyph . advanceWidth = targetW ;
3333 return glyph ;
3434} ;
35- sanitizers . halfLeft = function ( glyph , gid ) {
35+ sanitizers . halfLeft = function ( glyph , gid , isGothic ) {
3636 const g1 = sanitizers . half . call ( this , this . find . glyph$ ( this . find . gname . subst ( "pwid" , gid ) ) ) ;
3737 Object . assign ( glyph , g1 ) ;
3838 deleteGPOS ( this . font , gid ) ;
39+ if ( isGothic ) glyph . advanceWidth = this . em ;
3940 return glyph ;
4041} ;
41- sanitizers . halfRight = function ( glyph , gid ) {
42+ sanitizers . halfRight = function ( glyph , gid , isGothic ) {
4243 const g1 = sanitizers . half . call ( this , this . find . glyph$ ( this . find . gname . subst ( "pwid" , gid ) ) ) ;
4344 Object . assign ( glyph , g1 ) ;
4445 deleteGPOS ( this . font , gid ) ;
46+ if ( isGothic ) {
47+ glyph . advanceWidth = this . em ;
48+ for ( let c of glyph . contours ) for ( let z of c ) z . x += this . em / 2 ;
49+ }
4550 return glyph ;
4651} ;
4752
4853function HalfCompN ( n , forceFullWidth , forceHalfWidth ) {
49- return function ( glyph , gid , isType = false ) {
54+ return function ( glyph , gid , isGothic , isType ) {
5055 const g1 = this . find . glyph$ ( this . find . gname . subst ( "fwid" , gid ) ) ;
5156 Object . assign ( glyph , g1 ) ;
5257 const targetW = Math . min (
5358 this . em * n ,
5459 Math . ceil ( glyph . advanceWidth / this . em ) *
55- ( this . em * ( forceHalfWidth ? 1 / 2 : isType || forceFullWidth ? 1 : 1 / 2 ) )
60+ ( this . em *
61+ ( forceHalfWidth ? 1 / 2 : isGothic || isType || forceFullWidth ? 1 : 1 / 2 ) )
5662 ) ;
5763 if ( glyph . contours ) {
5864 for ( let c of glyph . contours ) for ( let z of c ) z . x *= targetW / glyph . advanceWidth ;
@@ -83,7 +89,7 @@ const sanitizerTypes = {
8389 "\u2e3b" : "halfComp3"
8490} ;
8591
86- exports . sanitizeSymbols = async function sanitizeSymbols ( isType ) {
92+ exports . sanitizeSymbols = async function sanitizeSymbols ( isGothic , isType ) {
8793 let san = new Map ( ) ;
8894 for ( let c in this . font . cmap ) {
8995 if ( ! this . font . cmap [ c ] ) continue ;
@@ -94,7 +100,7 @@ exports.sanitizeSymbols = async function sanitizeSymbols(isType) {
94100 let sanitizer = sanitizers [ san . has ( g ) ? san . get ( g ) : "auto" ] ;
95101 const glyph = this . font . glyf [ g ] ;
96102 if ( ! glyph ) continue ;
97- sanitizer . call ( this , glyph , g , isType ) ;
103+ sanitizer . call ( this , glyph , g , isGothic , isType ) ;
98104 }
99105} ;
100106
0 commit comments