Commit f9d4f918 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

Add handling of locale fonts. Add a dyslexic font and a cursive one (used by...

Add handling of locale fonts. Add a dyslexic font and a cursive one (used by default). Add a font loader singleton
parent cb22c76b
......@@ -52,7 +52,7 @@
#include <QDebug>
#define GC_DEFAULT_LOCALE "en_US.UTF-8"
#define GC_DEFAULT_FONT "Sans Serif"
#define GC_DEFAULT_FONT "Andika-R.ttf"
static const QString GENERAL_GROUP_KEY = "General";
static const QString ADMIN_GROUP_KEY = "Admin";
......@@ -64,6 +64,7 @@ static const QString ENABLE_AUDIO_EFFECTS_KEY = "enableAudioEffects";
static const QString VIRTUALKEYBOARD_KEY = "virtualKeyboard";
static const QString LOCALE_KEY = "locale";
static const QString FONT_KEY = "font";
static const QString IS_CURRENT_FONT_EMBEDDED = "isCurrentFontEmbedded";
static const QString ENABLE_AUTOMATIC_DOWNLOADS = "enableAutomaticDownloads";
static const QString DOWNLOAD_SERVER_URL_KEY = "downloadServerUrl";
......@@ -91,6 +92,7 @@ ApplicationSettings::ApplicationSettings(QObject *parent): QObject(parent),
m_locale = m_config.value(LOCALE_KEY,
QLocale::system() == QLocale::c() ? GC_DEFAULT_LOCALE : QString(QLocale::system().name() + ".UTF-8")).toString();
m_font = m_config.value(FONT_KEY, GC_DEFAULT_FONT).toString();
m_isEmbeddedFont = m_config.value(IS_CURRENT_FONT_EMBEDDED, true).toBool();
m_isAutomaticDownloadsEnabled = m_config.value(ENABLE_AUTOMATIC_DOWNLOADS,
!ApplicationInfo::getInstance()->isMobile()).toBool();
......@@ -130,6 +132,7 @@ ApplicationSettings::~ApplicationSettings()
m_config.setValue(ENABLE_AUDIO_VOICES_KEY, m_isAudioVoicesEnabled);
m_config.setValue(LOCALE_KEY, m_locale);
m_config.setValue(FONT_KEY, m_font);
m_config.setValue(IS_CURRENT_FONT_EMBEDDED, m_isEmbeddedFont);
m_config.setValue(FULLSCREEN_KEY, m_isFullscreen);
m_config.setValue(VIRTUALKEYBOARD_KEY, m_isVirtualKeyboard);
m_config.setValue(ENABLE_AUTOMATIC_DOWNLOADS, m_isAutomaticDownloadsEnabled);
......@@ -176,6 +179,12 @@ void ApplicationSettings::notifyFontChanged()
qDebug() << "new font: " << m_font;
}
void ApplicationSettings::notifyEmbeddedFontChanged()
{
updateValueInConfig(GENERAL_GROUP_KEY, IS_CURRENT_FONT_EMBEDDED, m_isEmbeddedFont);
qDebug() << "new font is embedded: " << m_isEmbeddedFont;
}
void ApplicationSettings::notifyFullscreenChanged()
{
updateValueInConfig(GENERAL_GROUP_KEY, FULLSCREEN_KEY, m_isFullscreen);
......
......@@ -60,6 +60,7 @@ class ApplicationSettings : public QObject
Q_PROPERTY(bool isVirtualKeyboard READ isVirtualKeyboard WRITE setVirtualKeyboard NOTIFY virtualKeyboardChanged)
Q_PROPERTY(QString locale READ locale WRITE setLocale NOTIFY localeChanged)
Q_PROPERTY(QString font READ font WRITE setFont NOTIFY fontChanged)
Q_PROPERTY(bool isEmbeddedFont READ isEmbeddedFont WRITE setIsEmbeddedFont NOTIFY embeddedFontChanged)
Q_PROPERTY(bool isAutomaticDownloadsEnabled READ isAutomaticDownloadsEnabled WRITE setIsAutomaticDownloadsEnabled NOTIFY automaticDownloadsEnabledChanged)
Q_PROPERTY(quint32 filterLevelMin READ filterLevelMin WRITE setFilterLevelMin NOTIFY filterLevelMinChanged)
Q_PROPERTY(quint32 filterLevelMax READ filterLevelMax WRITE setFilterLevelMax NOTIFY filterLevelMaxChanged)
......@@ -123,6 +124,12 @@ public:
emit fontChanged();
}
bool isEmbeddedFont() const { return m_isEmbeddedFont; }
void setIsEmbeddedFont(const bool newIsEmbeddedFont) {
m_isEmbeddedFont = newIsEmbeddedFont;
emit embeddedFontChanged();
}
bool isAutomaticDownloadsEnabled() const { return m_isAutomaticDownloadsEnabled; }
void setIsAutomaticDownloadsEnabled(const bool newIsAutomaticDownloadsEnabled) {
m_isAutomaticDownloadsEnabled = newIsAutomaticDownloadsEnabled;
......@@ -160,6 +167,7 @@ protected slots:
Q_INVOKABLE void notifyVirtualKeyboardChanged();
Q_INVOKABLE void notifyLocaleChanged();
Q_INVOKABLE void notifyFontChanged();
Q_INVOKABLE void notifyEmbeddedFontChanged();
Q_INVOKABLE void notifyAutomaticDownloadsEnabledChanged();
Q_INVOKABLE void notifyFilterLevelMinChanged();
Q_INVOKABLE void notifyFilterLevelMaxChanged();
......@@ -177,6 +185,7 @@ signals:
void virtualKeyboardChanged();
void localeChanged();
void fontChanged();
void embeddedFontChanged();
void automaticDownloadsEnabledChanged();
void filterLevelMinChanged();
void filterLevelMaxChanged();
......@@ -197,6 +206,7 @@ private:
bool m_isFullscreen;
bool m_isVirtualKeyboard;
bool m_isAutomaticDownloadsEnabled;
bool m_isEmbeddedFont;
quint32 m_filterLevelMin;
quint32 m_filterLevelMax;
QString m_locale;
......
......@@ -57,7 +57,7 @@ endif()
target_link_libraries(GCompris ${QT_LIBRARIES})
GCOMPRIS_ADD_RCC(core *.qml *.js resource/*.* resource/bonus/* resource/sounds/*)
GCOMPRIS_ADD_RCC(core *.qml *.js resource/*.* resource/bonus/* resource/sounds/* resource/fonts/* qmldir)
# Installation
# ============
......
......@@ -186,7 +186,7 @@ Rectangle {
var language = languages.get(languageBox.currentIndex).text;
voicesText.text = language + " " + qsTr("sounds");
voicesRow.haveLocalResource = DownloadManager.haveLocalResource(
DownloadManager.getVoicesResourceForLocale(localeShort));
DownloadManager.getVoicesResourceForLocale(localeShort));
}
Connections {
......@@ -211,7 +211,7 @@ Rectangle {
id: voicesImage
sourceSize.height: 30 * ApplicationInfo.ratio
source: voicesRow.haveLocalResource ? "qrc:/gcompris/src/core/resource/apply.svgz" :
"qrc:/gcompris/src/core/resource/cancel.svgz"
"qrc:/gcompris/src/core/resource/cancel.svgz"
}
Button {
......@@ -219,13 +219,13 @@ Rectangle {
height: parent.height * ApplicationInfo.ratio
anchors.verticalCenter: parent.verticalCenter
text: voicesRow.haveLocalResource ? qsTr("Check for updates") :
qsTr("Download")
qsTr("Download")
style: GCButtonStyle {}
onClicked: {
if (DownloadManager.downloadResource(
DownloadManager.getVoicesResourceForLocale(
languages.get(languageBox.currentIndex).locale.substr(0, 2))))
DownloadManager.getVoicesResourceForLocale(
languages.get(languageBox.currentIndex).locale.substr(0, 2))))
{
var downloadDialog = Core.showDownloadDialog(dialogConfig, {});
}
......@@ -446,12 +446,13 @@ Rectangle {
ApplicationSettings.isVirtualKeyboard = isVirtualKeyboard
ApplicationSettings.isAutomaticDownloadsEnabled = isAutomaticDownloadsEnabled
ApplicationSettings.isEmbeddedFont = fonts.get(fontBox.currentIndex).isLocalResource;
ApplicationSettings.font = fonts.get(fontBox.currentIndex).text
if (ApplicationSettings.locale != languages.get(languageBox.currentIndex).locale) {
ApplicationSettings.locale = languages.get(languageBox.currentIndex).locale
if (!DownloadManager.haveLocalResource(
DownloadManager.getVoicesResourceForLocale(
DownloadManager.getVoicesResourceForLocale(
ApplicationInfo.localeShort)))
{
// ask for downloading new voices
......@@ -461,16 +462,16 @@ Rectangle {
buttonHandler[StandardButton.Yes] = function() {
// yes -> start download
if (DownloadManager.downloadResource(
DownloadManager.getVoicesResourceForLocale(ApplicationInfo.localeShort)))
DownloadManager.getVoicesResourceForLocale(ApplicationInfo.localeShort)))
var downloadDialog = Core.showDownloadDialog(main, {});
};
dialog = Core.showMessageDialog(dialogConfig,
qsTr("You selected a new locale"),
qsTr("Do you want to download the corresponding sound files now?"),
"",
StandardIcon.Question,
buttonHandler
);
qsTr("You selected a new locale"),
qsTr("Do you want to download the corresponding sound files now?"),
"",
StandardIcon.Question,
buttonHandler
);
} else // check for udpates or/and register new voices
DownloadManager.updateResource(DownloadManager.getVoicesResourceForLocale(ApplicationInfo.localeShort))
}
......@@ -525,18 +526,23 @@ Rectangle {
isExcluded = true;
break;
}
// TODO Remove all *symbol* and *ding*
}
if(!isExcluded) {
fonts.append({ "text": systemFonts[i], "isLocalResource": false });
}
}
// Append fonts from resources
fonts.append({ "text": "Andika-R.ttf", "isLocalResource": true });
fonts.append({ "text": "OpenDyslexic-Regular.otf", "isLocalResource": true });
}
}
function hasConfigChanged() {
return (ApplicationSettings.locale != languages.get(languageBox.currentIndex).locale ||
(ApplicationSettings.font != fonts.get(fontBox.currentIndex).text) ||
(ApplicationSettings.isEmbeddedFont != fonts.get(fontBox.currentIndex).isLocalResource) ||
(ApplicationSettings.isAudioVoicesEnabled != isAudioVoicesEnabled) ||
(ApplicationSettings.isAudioEffectsEnabled != isAudioEffectsEnabled) ||
(ApplicationSettings.isFullscreen != isFullscreen) ||
......
/* GCompris - GCSingletonFontLoader.qml
*
* Copyright (C) 2014 Johnny Jazeix
*
* Authors:
* Johnny Jazeix <jazeix@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
pragma Singleton
import QtQuick 2.0
import GCompris 1.0
import "."
QtObject {
property QtObject fontLoader: ApplicationSettings.isEmbeddedFont ? sourceLoader : nameLoader
property QtObject fontSourceLoader: FontLoader {
id: sourceLoader
source: ApplicationSettings.isEmbeddedFont ? "resource/fonts/"+ApplicationSettings.font : ""
}
property QtObject fontNameLoader: FontLoader {
id: nameLoader
name: ApplicationSettings.font
}
}
......@@ -21,6 +21,10 @@
import QtQuick 2.0
import GCompris 1.0
// QTBUG-34418, singletons require explicit import to load qmldir file
// https://qt-project.org/wiki/QmlStyling#6b81104b320e452a59cc3bf6857115ab
import "."
Text {
font.family: ApplicationSettings.font
font.family: GCSingletonFontLoader.fontLoader.name
}
......@@ -35,7 +35,7 @@ Window {
title: "GCompris"
onClosing: Core.quit()
GCAudio {
id: audioVoices
source: "qrc:/gcompris/src/core/resource/intro.ogg"
......
singleton GCSingletonFontLoader GCSingletonFontLoader.qml
\ No newline at end of file
Copyright (c) 2011, Ana Sanfelippo (www.anasanfelippo.com.ar),
Copyright (c) 2011, Ang�lica D�az Rivera (www.typereview.wordpress.com),
Copyright (c) 2011, Meme Hern�ndez (http://issuu.com/memepeca/docs/memehernandez_portafolio),
with Reserved Font Name "Ruluko"
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
README
Andika
=========================================
Thank you for your interest in Andika ("Write!" in Swahili), a
Unicode-compliant sans serif font designed by SIL International
primarily for literacy use.
Andika supports a wide range of Latin and Cyrillic characters.
Documentation for the font is available on Andika website
(http://scripts.sil.org/andika), including details on what ranges are
supported.
Andika is released under the SIL Open Font License.
See the OFL and OFL-FAQ for details of the SIL Open Font License.
See the FONTLOG for information on this and previous releases.
See the website (http://scripts.sil.org/andika) for further documentation.
Andika FAQ (http://scripts.sil.org/Andika_FAQ-KI) for frequently
asked questions and their answers.
See the SIL Unicode Roman FAQ (http://scripts.sil.org/ComplexRomanFontFAQ)
for frequently asked questions and their answers regarding SIL's Roman fonts.
TIPS
====
As this font is distributed at no cost, we are unable to provide a
commercial level of personal technical support. The font has, however,
been through some testing on various platforms to be sure it works in most
situations. In particular, it has been tested and shown to work on Windows
XP, Windows Vista and Windows 7. Graphite capabilities have been tested
on Graphite-supported platforms.
If you do find a problem, please do report it to andika@sil.org.
We can't guarantee any direct response, but will try to fix reported bugs in
future versions. Make sure you read through the
SIL Unicode Roman FAQ (http://scripts.sil.org/ComplexRomanFontFAQ).
Many problems can be solved, or at least explained, through an understanding
of the encoding and use of the fonts. Here are some basic hints:
Encoding:
The fonts are encoded according to Unicode, so your application must support
Unicode text in order to access letters other than the standard alphabet.
Most Windows applications provide basic Unicode support. You will, however,
need some way of entering Unicode text into your document.
Keyboarding:
Andika does not include any keyboarding helps or utilities. It uses the
built-in keyboards of the operating system. You will need to install the
appropriate keyboard and input method for the characters of the language you
wish to use. If you want to enter characters that are not supported by any
system keyboard, the Keyman program (www.tavultesoft.com) can be helpful
on Windows systems. Also available for Windows is MSKLC
(http://www.microsoft.com/globaldev/tools/msklc.mspx).
For other platforms, KMFL (http://kmfl.sourceforge.net/),
XKB (http://www.x.org/wiki/XKB) or Ukelele (http://scripts.sil.org/ukelele)
can be helpful.
If you want to enter characters that are not supported by any system
keyboard, and to access the full Unicode range, we suggest you use
gucharmap, kcharselect on Ubuntu or similar software.
Another method of entering some symbols is provided by a few applications such
as Adobe InDesign or OpenOffice.org. They can display a glyph palette or input
dialog that shows all the glyphs (symbols) in a font and allow you to enter
them by clicking on the glyph you want.
Rendering:
This font is designed to work with Graphite or Opentype advanced font
technologies. To take advantage of the advanced typographic
capabilities of this font, you must be using applications that provide an
adequate level of support for Graphite or OpenType. See "Applications
that provide an adequate level of support for SIL Unicode Roman fonts"
(http://scripts.sil.org/Complex_AdLvSup).
CONTACT
========
For more information please visit the Andika page on SIL International's
Computers and Writing systems website:
http://scripts.sil.org/andika
Or send an email to andika@sil.org
README
======
Places I've officially uploaded the latest stable versions to are [dafont.com](http://dafont.com/open-dyslexic.font) and [opendyslexic.org](http://opendyslexic.org)
The latest version may not always be the best version. If you want a stable version, check [github](https://github.com/antijingoist/open-dyslexic/tags) for the latest stable or working beta including otf's and ttf's, or [DaFont](http://dafont.com/open-dyslexic.font) for a stable otf.
If you are upgrading your copy of this font, you may want to remove previous version first.
Typeface/font to help readability, and help readability for some of the symptoms of dyslexia.
Your brain can sometimes do funny things to letters. OpenDyslexic tries to help prevent some of these things from happening. Letters have heavy weighted bottoms to provide an indication of orientation to make it more difficult to confuse with other similar letters. Consistently weighted bottoms can also help reenforce the line of text. The unique shapes of each letter can help prevent flipping and swapping.
The italic style for OpenDyslexic has been crafted still be able to be used for emphasis while still being readable.
Install:
========
Windows: Copy .OTF files to C:\Windows\Fonts
MacOSX: Drag font files to Font Book, and click install
Thanks to everyone that donated during the Glyphs.app fundraising:
- Cheryl Marshall
- Anonymous (MG). <-- look at that, anonymous supports this. :D
- Eric Bailey
- Steven V James
- @nguarracino
- Plow Software, LLC
You guys are super cool! Thanks!
Also, thanks to:
- @glyphsapp for helping me learn Glyphs properly.
- Rob Carpenter of Oak Grove College in England for the Alta style
- The awesome folk @ TEDxGateway that still have yet to release the OpenDyslexic TEDx talk.
It is based on Bitstream Vera Sans because of the nice license it has.
OpenDyslexic is not packaged by me as an .exe file. It is packaged as a zip file, with no installer, so you know what you are getting.
If you were compelled to pay for this font, ask for a refund. This font is provided at no charge. Donations are cool, but optional. :)
License
-------
The license for this font is:
♡ Copying is an act of love. Please copy.
OpenDyslexic(open-dyslexic) by Abelardo Gonzalez is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at dyslexicfonts.com.
Permissions beyond the scope of this license may be available at [http://opendyslexic.org/legal/](http://opendyslexic.org/legal/).
Original Bitstream License:
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license (“Fonts”) and associated documentation files (the “Font Software”), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words “Bitstream” or the word “Vera”.
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the “Bitstream Vera” names.
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org.
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment