@@ -25,7 +25,9 @@ function inRange(v, min, max) {
2525 */
2626function checkRange ( name , type , v , min , max ) {
2727 if ( ! inRange ( v , min , max ) )
28- throw Error ( `${ type } "${ name } " has value ${ v } which is not in range of ${ min } to ${ max } ` ) ;
28+ throw Error (
29+ `${ type } "${ name } " has value ${ v } which is not in range of ${ min } to ${ max } ` ,
30+ ) ;
2931 return v ;
3032}
3133
@@ -53,7 +55,9 @@ function Table(name, value) {
5355Object . defineProperties ( Table . prototype , {
5456 size : {
5557 get ( ) {
56- return this . value . length === 0 ? 0 : this . value . map ( ( v ) => v . size ) . reduce ( ( a , b ) => a + b ) ;
58+ return this . value . length === 0
59+ ? 0
60+ : this . value . map ( ( v ) => v . size ) . reduce ( ( a , b ) => a + b ) ;
5761 } ,
5862 } ,
5963 encode : {
@@ -258,7 +262,13 @@ Object.defineProperties(LongDateTime.prototype, {
258262 size : { value : 8 } ,
259263 encode : {
260264 value ( ) {
261- return [ 0 , 0 , 0 , 0 , ...intToBytes ( Math . round ( this . value . getTime ( ) / 1000 ) + 0x7c25b080 , 4 ) ] ;
265+ return [
266+ 0 ,
267+ 0 ,
268+ 0 ,
269+ 0 ,
270+ ...intToBytes ( Math . round ( this . value . getTime ( ) / 1000 ) + 0x7c25b080 , 4 ) ,
271+ ] ;
262272 } ,
263273 } ,
264274} ) ;
@@ -353,7 +363,9 @@ Object.defineProperties(CffIndex.prototype, {
353363 }
354364 if ( offSize ) break ;
355365 }
356- const offsetType = { 1 : uint8 , 2 : uint16 , 3 : uint24 , 4 : uint32 } [ offSize ] ;
366+ const offsetType = { 1 : uint8 , 2 : uint16 , 3 : uint24 , 4 : uint32 } [
367+ offSize
368+ ] ;
357369 return Table ( this . name , [
358370 uint32 ( 'count' , this . value . length ) ,
359371 uint8 ( 'offSize' , offSize ) ,
@@ -420,7 +432,14 @@ Object.defineProperties(CffNum.prototype, {
420432 * @param {glyphBounds } props.glyphBounds
421433 * @returns {Table }
422434 */
423- const genHead = ( { majorVersion, minorVersion, checksumAdjustment, flags, date, glyphBounds } ) =>
435+ const genHead = ( {
436+ majorVersion,
437+ minorVersion,
438+ checksumAdjustment,
439+ flags,
440+ date,
441+ glyphBounds,
442+ } ) =>
424443 Table ( 'head' , [
425444 uint16 ( 'majorVersion' , 1 ) ,
426445 uint16 ( 'minorVersion' , 0 ) ,
@@ -476,7 +495,8 @@ const genHhea = ({ glyphBounds, width }) =>
476495 * https://docs.microsoft.com/en-us/typography/opentype/spec/maxp
477496 * @returns {Table }
478497 */
479- const genMaxp = ( ) => Table ( 'maxp' , [ uint32 ( 'version' , 0x00005000 ) , uint16 ( 'numGlyphs' , 2 ) ] ) ;
498+ const genMaxp = ( ) =>
499+ Table ( 'maxp' , [ uint32 ( 'version' , 0x00005000 ) , uint16 ( 'numGlyphs' , 2 ) ] ) ;
480500
481501/**
482502 * https://docs.microsoft.com/en-us/typography/opentype/spec/os2
@@ -546,7 +566,7 @@ const genOS2 = ({ width, glyphBounds }) =>
546566 */
547567const genName = ( { name, version } ) => {
548568 const nameData = Table ( 'data' , [
549- String16 ( 'copyright' , 'github.com/jwr12135 /fallback-font' ) ,
569+ String16 ( 'copyright' , 'github.com/jwr1 /fallback-font' ) ,
550570 String16 ( 'fontFamily' , name ) ,
551571 String16 ( 'fontSubfamily' , 'Regular' ) ,
552572 String16 ( 'uniqueID' , `${ name . replace ( / / g, '' ) } -${ version } ` ) ,
@@ -730,13 +750,23 @@ const genCff2 = (path) =>
730750 ] ) ,
731751 CffIndex ( 'globalSubrIndex' , [ ] ) ,
732752 CffIndex ( 'charStringsIndex' , [
733- Table ( 'glyph0' , [ Table ( 'callsubr' , [ CffNum ( 'offset' , - 107 ) , uint8 ( 'op' , 10 ) ] ) ] ) ,
734- Table ( 'glyph1' , [ Table ( 'callsubr' , [ CffNum ( 'offset' , - 107 ) , uint8 ( 'op' , 10 ) ] ) ] ) ,
753+ Table ( 'glyph0' , [
754+ Table ( 'callsubr' , [ CffNum ( 'offset' , - 107 ) , uint8 ( 'op' , 10 ) ] ) ,
755+ ] ) ,
756+ Table ( 'glyph1' , [
757+ Table ( 'callsubr' , [ CffNum ( 'offset' , - 107 ) , uint8 ( 'op' , 10 ) ] ) ,
758+ ] ) ,
735759 ] ) ,
736760 CffIndex ( 'fontDictIndex' , [
737- Table ( 'Private' , [ CffNum ( 'size' , 2 ) , CffNum ( 'offset' , 36 ) , uint8 ( 'op' , 18 ) ] ) ,
761+ Table ( 'Private' , [
762+ CffNum ( 'size' , 2 ) ,
763+ CffNum ( 'offset' , 36 ) ,
764+ uint8 ( 'op' , 18 ) ,
765+ ] ) ,
766+ ] ) ,
767+ Table ( 'privateDict0' , [
768+ Table ( 'Subrs' , [ CffNum ( 'num' , 2 ) , uint8 ( 'op' , 19 ) ] ) ,
738769 ] ) ,
739- Table ( 'privateDict0' , [ Table ( 'Subrs' , [ CffNum ( 'num' , 2 ) , uint8 ( 'op' , 19 ) ] ) ] ) ,
740770 CffIndex ( 'localSubrIndex' , [ Table ( 'localSubrIndex0' , path . cffPath ) ] ) ,
741771 ] ) ;
742772
@@ -749,8 +779,14 @@ const genCff2 = (path) =>
749779 */
750780const genHmtx = ( { width, glyphBounds } ) =>
751781 Table ( 'hmtx' , [
752- Table ( 'glyph0' , [ uint16 ( 'advanceWidth' , width ) , int16 ( 'lsb' , glyphBounds . xMin ) ] ) ,
753- Table ( 'glyph1' , [ uint16 ( 'advanceWidth' , width ) , int16 ( 'lsb' , glyphBounds . xMin ) ] ) ,
782+ Table ( 'glyph0' , [
783+ uint16 ( 'advanceWidth' , width ) ,
784+ int16 ( 'lsb' , glyphBounds . xMin ) ,
785+ ] ) ,
786+ Table ( 'glyph1' , [
787+ uint16 ( 'advanceWidth' , width ) ,
788+ int16 ( 'lsb' , glyphBounds . xMin ) ,
789+ ] ) ,
754790 ] ) ;
755791
756792/**
@@ -763,7 +799,11 @@ const calcChecksum = (data) => {
763799
764800 let sum = 0 ;
765801 for ( let i = 0 ; i < bytes . length ; i += 4 ) {
766- const val = ( bytes [ i ] << 24 ) + ( bytes [ i + 1 ] << 16 ) + ( bytes [ i + 2 ] << 8 ) + bytes [ i + 3 ] ;
802+ const val =
803+ ( bytes [ i ] << 24 ) +
804+ ( bytes [ i + 1 ] << 16 ) +
805+ ( bytes [ i + 2 ] << 8 ) +
806+ bytes [ i + 3 ] ;
767807 sum += val < 0 ? val + 0x100000000 : val ;
768808 }
769809
@@ -782,7 +822,9 @@ module.exports = {
782822 */
783823 genFont ( { name, version, path, width, date = new Date ( ) } ) {
784824 const fileName = name . toLowerCase ( ) . replace ( / / g, '-' ) ;
785- const [ majorVersion , minorVersion ] = version . split ( '.' ) . map ( ( v ) => parseInt ( v , 10 ) ) ;
825+ const [ majorVersion , minorVersion ] = version
826+ . split ( '.' )
827+ . map ( ( v ) => parseInt ( v , 10 ) ) ;
786828 const glyphBounds = {
787829 xMin : path . xMin ,
788830 yMin : path . yMin ,
@@ -839,7 +881,9 @@ module.exports = {
839881 ] ) ;
840882 const newChecksumAdjustment = 0xb1b0afba - calcChecksum ( otfFile . encode ( ) ) ;
841883 checksumAdjustment . value =
842- newChecksumAdjustment < 0 ? newChecksumAdjustment + 0x100000000 : newChecksumAdjustment ;
884+ newChecksumAdjustment < 0
885+ ? newChecksumAdjustment + 0x100000000
886+ : newChecksumAdjustment ;
843887 writeFileSync ( `./dist/${ fileName } .otf` , new Uint8Array ( otfFile . encode ( ) ) ) ;
844888
845889 spawn ( './woff2/woff2_compress' , [ `./dist/${ fileName } .otf` ] ) ;
0 commit comments