-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
68 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.js] | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/* | ||
node_modules/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: ['scratch', 'scratch/node', 'scratch/es6'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['scratch', 'scratch/es6'], | ||
env: { | ||
browser: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
// Synchronously load TTF fonts. | ||
// First, have Webpack load their data as Base 64 strings. | ||
let FONTS; | ||
|
||
const getFonts = function () { | ||
if (FONTS) return FONTS; | ||
/* eslint-disable global-require */ | ||
FONTS = { | ||
'Sans Serif': require('base64-loader!./NotoSans-Medium.ttf'), | ||
'Serif': require('base64-loader!./SourceSerifPro-Regular.otf'), | ||
'Handwriting': require('base64-loader!./handlee-regular.ttf'), | ||
'Marker': require('base64-loader!./Knewave.ttf'), | ||
'Curly': require('base64-loader!./Griffy-Regular.ttf'), | ||
'Pixel': require('base64-loader!./Grand9K-Pixel.ttf'), | ||
'Scratch': require('base64-loader!./Scratch.ttf') | ||
}; | ||
/* eslint-enable global-require */ | ||
|
||
// For each Base 64 string, | ||
// 1. Replace each with a usable @font-face tag that points to a Data URI. | ||
// 2. Inject the font into a style on `document.body`, so measurements | ||
// can be accurately taken in SvgRenderer._transformMeasurements. | ||
for (const fontName in FONTS) { | ||
const fontData = FONTS[fontName]; | ||
FONTS[fontName] = '@font-face {' + | ||
`font-family: "${fontName}";src: url("data:application/x-font-ttf;charset=utf-8;base64,${fontData}");}`; | ||
} | ||
|
||
if (!document.getElementById('scratch-font-styles')) { | ||
const documentStyleTag = document.createElement('style'); | ||
documentStyleTag.id = 'scratch-font-styles'; | ||
for (const fontName in FONTS) { | ||
documentStyleTag.textContent += FONTS[fontName]; | ||
} | ||
document.body.insertBefore(documentStyleTag, document.body.firstChild); | ||
} | ||
|
||
return FONTS; | ||
} | ||
|
||
module.exports = getFonts; | ||
// Synchronously load TTF fonts. | ||
// First, have Webpack load their data as Base 64 strings. | ||
let FONTS; | ||
|
||
const getFonts = function () { | ||
if (FONTS) return FONTS; | ||
/* eslint-disable global-require */ | ||
FONTS = { | ||
'Sans Serif': require('base64-loader!./NotoSans-Medium.ttf'), | ||
'Serif': require('base64-loader!./SourceSerifPro-Regular.otf'), | ||
'Handwriting': require('base64-loader!./handlee-regular.ttf'), | ||
'Marker': require('base64-loader!./Knewave.ttf'), | ||
'Curly': require('base64-loader!./Griffy-Regular.ttf'), | ||
'Pixel': require('base64-loader!./Grand9K-Pixel.ttf'), | ||
'Scratch': require('base64-loader!./Scratch.ttf') | ||
}; | ||
/* eslint-enable global-require */ | ||
|
||
// For each Base 64 string, | ||
// 1. Replace each with a usable @font-face tag that points to a Data URI. | ||
// 2. Inject the font into a style on `document.body`, so measurements | ||
// can be accurately taken in SvgRenderer._transformMeasurements. | ||
for (const fontName in FONTS) { | ||
const fontData = FONTS[fontName]; | ||
FONTS[fontName] = '@font-face {' + | ||
`font-family: "${fontName}";src: url("data:application/x-font-ttf;charset=utf-8;base64,${fontData}");}`; | ||
} | ||
|
||
if (!document.getElementById('scratch-font-styles')) { | ||
const documentStyleTag = document.createElement('style'); | ||
documentStyleTag.id = 'scratch-font-styles'; | ||
for (const fontName in FONTS) { | ||
documentStyleTag.textContent += FONTS[fontName]; | ||
} | ||
document.body.insertBefore(documentStyleTag, document.body.firstChild); | ||
} | ||
|
||
return FONTS; | ||
}; | ||
|
||
module.exports = getFonts; |