different font families for people with dyslexia

This commit is contained in:
John McLear 2015-03-25 12:24:20 +00:00
parent 5761e998de
commit b72127c327
4 changed files with 106 additions and 17 deletions

View file

@ -576,9 +576,18 @@ var pad = {
if(padcookie.getPref("rtlIsTrue") == true){
pad.changeViewOption('rtlIsTrue', true);
}
if(padcookie.getPref("useMonospaceFont") == true){
pad.changeViewOption('useMonospaceFont', true);
}
var fonts = ['useMonospaceFont', 'useComicSansFont', 'useCourierNewFont', 'useGeorgiaFont', 'useImpactFont',
'useLucidaFont', 'useLucidaSansFont', 'usePalatinoFont', 'useTahomaFont', 'useTimesNewRomanFont',
'useTrebuchetFont', 'useVerdanaFont', 'useSymbolFont', 'useWebdingsFont', 'useWingDingsFont', 'useSansSerifFont',
'useSerifFont'];
$.each(fonts, function(i, font){
if(padcookie.getPref(font) == true){
pad.changeViewOption(font, true);
}
})
hooks.aCallAll("postAceInit", {ace: padeditor.ace, pad: pad});
}
},
@ -629,6 +638,7 @@ var pad = {
for (var k in opts.view)
{
pad.padOptions.view[k] = opts.view[k];
console.log("setpref", k, opts.view[k]);
padcookie.setPref(k, opts.view[k]);
}
padeditor.setViewOptions(pad.padOptions.view);

View file

@ -28,6 +28,13 @@ var padeditor = (function()
var Ace2Editor = undefined;
var pad = undefined;
var settings = undefined;
// Array of available fonts
var fonts = ['useMonospaceFont', 'useComicSansFont', 'useCourierNewFont', 'useGeorgiaFont', 'useImpactFont',
'useLucidaFont', 'useLucidaSansFont', 'usePalatinoFont', 'useTahomaFont', 'useTimesNewRomanFont',
'useTrebuchetFont', 'useVerdanaFont', 'useSymbolFont', 'useWebdingsFont', 'useWingDingsFont', 'useSansSerifFont',
'useSerifFont'];
var self = {
ace: null,
// this is accessed directly from other files
@ -85,10 +92,15 @@ var padeditor = (function()
padutils.setCheckbox($("#options-rtlcheck"), ('rtl' == html10n.getDirection()));
})
// font face
// font family change
$("#viewfontmenu").change(function()
{
pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
$.each(fonts, function(i, font){
var sfont = font.replace("use","");
sfont = sfont.replace("Font","");
sfont = sfont.toLowerCase();
pad.changeViewOption(font, $("#viewfontmenu").val() == sfont);
});
});
// Language
@ -98,12 +110,12 @@ var padeditor = (function()
// this does not interfere with html10n's normal value-setting because html10n just ingores <input>s
// also, a value which has been set by the user will be not overwritten since a user-edited <input>
// does *not* have the editempty-class
$('input[data-l10n-id]').each(function(key, input)
{
input = $(input);
if(input.hasClass("editempty"))
input.val(html10n.get(input.attr("data-l10n-id")));
});
$('input[data-l10n-id]').each(function(key, input){
input = $(input);
if(input.hasClass("editempty")){
input.val(html10n.get(input.attr("data-l10n-id")));
}
});
})
$("#languagemenu").val(html10n.getLanguage());
$("#languagemenu").change(function() {
@ -136,13 +148,49 @@ var padeditor = (function()
v = getOption('showAuthorColors', true);
self.ace.setProperty("showsauthorcolors", v);
padutils.setCheckbox($("#options-colorscheck"), v);
// Override from parameters if true
if (settings.noColors !== false)
self.ace.setProperty("showsauthorcolors", !settings.noColors);
v = getOption('useMonospaceFont', false);
self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif"));
$("#viewfontmenu").val(v ? "monospace" : "normal");
// Override from parameters if true
if (settings.noColors !== false){
self.ace.setProperty("showsauthorcolors", !settings.noColors);
}
var normalFont = true;
// Go through each font and see if the option is set..
$.each(fonts, function(i, font){
var isEnabled = getOption(font, false);
if(isEnabled){
font = font.replace("use","");
font = font.replace("Font","");
font = font.toLowerCase();
if(font === "monospace") self.ace.setProperty("textface", "Courier new");
if(font === "comicsans") self.ace.setProperty("textface", "Comic Sans MS");
if(font === "georgia") self.ace.setProperty("textface", "Georgia");
if(font === "impact") self.ace.setProperty("textface", "Impact");
if(font === "lucida") self.ace.setProperty("textface", "Lucida");
if(font === "lucidasans") self.ace.setProperty("textface", "Lucida Sans Unicode");
if(font === "palatino") self.ace.setProperty("textface", "Palatino Linotype");
if(font === "tahoma") self.ace.setProperty("textface", "Tahoma");
if(font === "timesnewroman") self.ace.setProperty("textface", "Times New Roman");
if(font === "trebuchet") self.ace.setProperty("textface", "Trebuchet MS");
if(font === "verdana") self.ace.setProperty("textface", "Verdana");
if(font === "symbol") self.ace.setProperty("textface", "Symbol");
if(font === "webdings") self.ace.setProperty("textface", "Webdings");
if(font === "wingdings") self.ace.setProperty("textface", "Wingdings");
if(font === "sansserif") self.ace.setProperty("textface", "MS Sans Serif");
if(font === "serif") self.ace.setProperty("textface", "MS Serif");
// $("#viewfontmenu").val(font);
normalFont = false;
}
});
// No font has been previously selected so use the Normal font
if(normalFont){
console.log("Enabling a normal font");
self.ace.setProperty("textface", "Arial, sans-serif");
// $("#viewfontmenu").val("normal");
}
},
dispose: function()
{