Skip to content

Commit

Permalink
optional forced font loading
Browse files Browse the repository at this point in the history
  • Loading branch information
wissenbach committed May 11, 2017
1 parent 215be2b commit c27fc3d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
32 changes: 18 additions & 14 deletions svg_rendering/page/debug.html
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset='utf-8'>
<link rel="stylesheet" href="css/webfonts.css">
<link rel="stylesheet" href="css/webfonts.css">
<link rel="stylesheet" href="css/document-text.css">
<link rel="stylesheet" href="css/document-transcript.css">
<link rel="stylesheet" href="css/document-transcript-highlight-hands.css">
Expand Down Expand Up @@ -96,30 +96,34 @@ <h1>Transcript Generation Debugging</h1>
var fontError = false;
var webFontConfig = {
custom: {
families: ['Ubuntu', 'Ubuntu Monospace', 'Gentium Plus']
// we don not need to specify urls as they are specified in the css files
families: ['Ubuntu', 'Ubuntu Monospace', 'Gentium Plus'],
// we don not need to specify urls as they are specified in the css files
urls: ['/css/webfonts.css']
},
// do not time out if font can't be loaded
timeout: Number.MAX_VALUE,
timeout: 10, //Number.MAX_VALUE,
active: function() {
// if we made it this far without 'fontinactive' occurring, then all
// fonts have been loaded
if (!fontError) {
if (!Faust.TranscriptConfiguration.forceFontLoading || !fontError) {
Faust.io(json, transcriptGeneration.createDiplomaticSvg);
} else {}
} else {
// do not try to render page
}

},
fontinactive: function(familyName, fvd) {
// font could not be loaded, abort
fontError = true;
var message = "Error: web font could not be loaded: " + familyName + " " + fvd;

var htmlMessage = document.createElement('div');
htmlMessage.innerHTML = message;
document.body.append(htmlMessage);
throw(message);
if (Faust.TranscriptConfiguration.forceFontLoading) {
fontError = true;
var message = "Error: web font could not be loaded: " + familyName + " " + fvd;
var htmlMessage = document.createElement('div');
htmlMessage.innerHTML = message;
document.body.append(htmlMessage);
throw(message);
}
}
};
};

WebFont.load(webFontConfig);
</script>
Expand Down
3 changes: 2 additions & 1 deletion svg_rendering/page/js-gen/transcript-configuration-faust.js
Expand Up @@ -58,7 +58,8 @@ if(window.Faust === undefined) {
initialize : function (layoutState) {
layoutState.idMap = {};
},
names: {
forceFontLoading: false,
names: {
'anchor': {
vc: function(node, text, layoutState) {
//use empty text element as an anchor
Expand Down

0 comments on commit c27fc3d

Please sign in to comment.