[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 267f6c103b12f71a056148eda4433f6c5a2d15a4
Eugeniy Meshcheryakov
eugen at debian.org
Sun Sep 9 20:11:52 UTC 2007
The branch, master has been updated
via 267f6c103b12f71a056148eda4433f6c5a2d15a4 (commit)
from 7cb1cd93c5395c22bd2588db4136d23c5cd1c6fe (commit)
- Shortlog ------------------------------------------------------------
267f6c1 Make tooltips more useable
Summary of changes:
.gitignore | 1 +
Makefile.am | 5 ++-
configure.ac | 2 +
gui/glyphsmodel.cxx | 7 +++-
gui/unicodeproxymodel.cxx | 11 +++++-
nongui/nongui.rules | 27 ++++++++-----
nongui/unicodenameslist.awk | 86 +++++++++++++++++++++++++++++++++++++++++++
nongui/unicodenameslist.cxx | 52 ++++++++++++++++++++++++++
nongui/unicodenameslist.h | 41 ++++++++++++++++++++
9 files changed, 219 insertions(+), 13 deletions(-)
-----------------------------------------------------------------------
Details of changes:
commit 267f6c103b12f71a056148eda4433f6c5a2d15a4
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Sun Sep 9 22:11:36 2007 +0200
Make tooltips more useable
diff --git a/.gitignore b/.gitignore
index b4eb069..4b126f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ src/ufondue
# generated sources
*.tbl.cxx
*.moc.cxx
+*.awked.cxx
# various autotools stuff
.deps
diff --git a/Makefile.am b/Makefile.am
index 6f3e84f..f0191e4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
AM_CXXFLAGS = -Wall -Wextra -pedantic -Wno-long-long -Wwrite-strings
AM_LDFLAGS = -Wl,--as-needed
-SUFFIXES = .moc.cxx .tbl.cxx .xsl
+SUFFIXES = .moc.cxx .tbl.cxx .xsl .awked.cxx .awk
bin_PROGRAMS =
noinst_LIBRARIES =
@@ -22,4 +22,7 @@ EXTRA_DIST += data/instructions.xml
.xsl.tbl.cxx:
$(XSLTPROC) -o $@ $< $(DATAFILE)
+.awk.awked.cxx:
+ $(AWK) -f $< $(DATAFILE) > $@
+
INCLUDES = -I$(srcdir)/src -I$(srcdir)/ruby -I$(srcdir)/gui -I$(srcdir)/nongui
diff --git a/configure.ac b/configure.ac
index 61c4c81..41aed3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,8 @@ AC_PROG_CXX
AC_PROG_RANLIB
AC_LANG([C++])
+AC_PROG_AWK
+
AC_ARG_ENABLE([ruby],
AS_HELP_STRING([--enable-ruby], [compile with ruby support (default is YES)]),
[case "${enableval}" in
diff --git a/gui/glyphsmodel.cxx b/gui/glyphsmodel.cxx
index 6eec886..e3105de 100644
--- a/gui/glyphsmodel.cxx
+++ b/gui/glyphsmodel.cxx
@@ -23,6 +23,7 @@
#include "contour.h"
#include "glyphpoint.h"
#include <QDebug>
+#include "unicodenameslist.h"
QVariant GlyphsModel::data(const QModelIndex &index, int role) const
{
@@ -41,8 +42,12 @@ QVariant GlyphsModel::data(const QModelIndex &index, int role) const
switch (index.column()) {
case GlyphColumn:
- if (role == Qt::DisplayRole || role == Qt::ToolTipRole)
+ if (role == Qt::DisplayRole)
return glyph->objectName();
+ if (role == Qt::ToolTipRole) {
+ int unicode = glyph->unicode();
+ return UnicodeNamesList::makeDescription(unicode, glyph->objectName());
+ }
else if (role == Qt::DecorationRole) {
QVariant var;
if (glyph->hasHorizAdvX() || glyph->content.size()) {
diff --git a/gui/unicodeproxymodel.cxx b/gui/unicodeproxymodel.cxx
index c4fd18f..0ddc312 100644
--- a/gui/unicodeproxymodel.cxx
+++ b/gui/unicodeproxymodel.cxx
@@ -1,6 +1,7 @@
#include "unicodeproxymodel.h"
#include "glyphsmodel.h"
#include <QDebug>
+#include "unicodenameslist.h"
UnicodeProxyModel::UnicodeProxyModel(QObject *parent) : QAbstractProxyModel(parent),
unencodedGlyphs(0)
@@ -133,7 +134,7 @@ QVariant UnicodeProxyModel::data(const QModelIndex &index, int role) const
switch (index.column()) {
case GlyphsModel::GlyphColumn:
- if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
+ if (role == Qt::DisplayRole) {
QString name;
if (index.row() < 0x10000)
name.sprintf("uni%04X", index.row());
@@ -141,6 +142,14 @@ QVariant UnicodeProxyModel::data(const QModelIndex &index, int role) const
name.sprintf("u%X", index.row());
return name;
}
+ else if (role == Qt::ToolTipRole) {
+ QString name;
+ if (index.row() < 0x10000)
+ name.sprintf("uni%04X", index.row());
+ else
+ name.sprintf("u%X", index.row());
+ return UnicodeNamesList::makeDescription(index.row(), name);
+ }
break;
case GlyphsModel::NameColumn:
if (role == Qt::DisplayRole || role == Qt::EditRole) {
diff --git a/nongui/nongui.rules b/nongui/nongui.rules
index 2a3dfcd..6fb33a2 100644
--- a/nongui/nongui.rules
+++ b/nongui/nongui.rules
@@ -9,13 +9,15 @@ libfonduenongui_a_SOURCES = \
nongui/cvtmodel.cxx \
nongui/ttfwriter.cxx \
nongui/glyph.cxx \
- nongui/maxpmodel.cxx
+ nongui/maxpmodel.cxx \
+ nongui/unicodenameslist.cxx
-nodist_libfonduenongui_a_SOURCES = \
- nongui/decodertable.tbl.cxx \
- nongui/glyph.moc.cxx \
- nongui/fontdocument.moc.cxx \
- nongui/encodertable.tbl.cxx
+nodist_libfonduenongui_a_SOURCES = \
+ nongui/decodertable.tbl.cxx \
+ nongui/glyph.moc.cxx \
+ nongui/fontdocument.moc.cxx \
+ nongui/encodertable.tbl.cxx \
+ nongui/unicodenameslist.awked.cxx
nongui/decodertable.tbl.cxx: data/instructions.xml
nongui/decodertable.tbl.cxx: DATAFILE=$(srcdir)/data/instructions.xml
@@ -23,9 +25,13 @@ nongui/decodertable.tbl.cxx: DATAFILE=$(srcdir)/data/instructions.xml
nongui/encodertable.tbl.cxx: data/instructions.xml
nongui/encodertable.tbl.cxx: DATAFILE=$(srcdir)/data/instructions.xml
+## TODO: this should be configurable
+nongui/unicodenameslist.awked.cxx: /usr/share/unicode/NamesList.txt
+nongui/unicodenameslist.awked.cxx: DATAFILE=/usr/share/unicode/NamesList.txt
+
libfonduenongui_a_CPPFLAGS = $(QtCore_CFLAGS) $(QtXml_CFLAGS)
-CLEANFILES += nongui/*.tbl.cxx nongui/*.moc.cxx
+CLEANFILES += nongui/*.tbl.cxx nongui/*.moc.cxx nongui/*.awked.cxx
noinst_HEADERS += \
nongui/ttfdecode.h \
@@ -44,8 +50,9 @@ noinst_HEADERS += \
nongui/ttfwriter.h \
nongui/maxpmodel.h
-EXTRA_DIST += \
- nongui/decodertable.xsl \
- nongui/encodertable.xsl
+EXTRA_DIST += \
+ nongui/decodertable.xsl \
+ nongui/encodertable.xsl \
+ nongui/unicodenameslist.awk
## vim:ft=automake
diff --git a/nongui/unicodenameslist.awk b/nongui/unicodenameslist.awk
new file mode 100644
index 0000000..42e2e48
--- /dev/null
+++ b/nongui/unicodenameslist.awk
@@ -0,0 +1,86 @@
+# Copyright (C) 2007 ÐвгенÑй ÐеÑеÑÑков <eugen at debian.org>
+#
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+BEGIN {
+ FS="\t"
+ in_desc = 0;
+ has_extra_desc = 0;
+ print "#include \"unicodenameslist.h\""
+ print ""
+ print "const UnicodeNamesList::UnicodeName UnicodeNamesList::UnicodeNames[] = {"
+}
+
+# escape C and HTML special scharacters
+function escape(s) {
+ tmp = gensub(/\\/, "\\\\\\\\", "g", s)
+ tmp = gensub(/"/, "\\\\\"", "g", tmp)
+ tmp = gensub(/\&/, "\\&", "g", tmp)
+ tmp = gensub(/</, "\\<", "g", tmp)
+ tmp = gensub(/>/, "\\>", "g", tmp)
+ return tmp
+}
+
+function replace_special(s) {
+ sub(/^\*/, "\\•", s) # * -> â¢
+ sub(/^#/, "\\≈", s) # # -> â
+ sub(/^:/, "\\≡", s) # : -> â¡
+ s = gensub(/^x \(([^)]*)\)$/, "\\→ \\1", 1, s) # x -> â
+ return s
+}
+
+function close_record() {
+ if (in_desc) {
+ if (has_extra_desc) {
+ printf "\""
+ }
+ else {
+ printf "0"
+ }
+ printf "},\n"
+ }
+ has_extra_desc = 0
+ in_desc = 0
+}
+
+/^[0123456789ABCDEF]+/ {
+ close_record()
+ in_desc = 1
+ has_extra_desc = 0
+ printf " {0x%s, \"%s\", ", $1, escape($2)
+}
+
+/^\t/ {
+ if (in_desc) {
+ if (has_extra_desc) {
+ printf "<br/>"
+ }
+ else {
+ has_extra_desc = 1
+ printf "\""
+ }
+ printf "%s", replace_special(escape($2))
+ }
+}
+
+/^[^0123456789ABCDEF\t]/ {
+ close_record()
+}
+
+END {
+ close_record()
+ print " {0, 0, 0},"
+ printf "};\n"
+}
diff --git a/nongui/unicodenameslist.cxx b/nongui/unicodenameslist.cxx
new file mode 100644
index 0000000..0081579
--- /dev/null
+++ b/nongui/unicodenameslist.cxx
@@ -0,0 +1,52 @@
+/* Copyright (C) 2007 ÐвгенÑй ÐеÑеÑÑков <eugen at debian.org>
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "unicodenameslist.h"
+
+const UnicodeNamesList UnicodeNamesList::unicodeNamesList;
+
+UnicodeNamesList::UnicodeNamesList()
+{
+ for (const UnicodeName *name = UnicodeNames; name->description; name++) {
+ descriptions[name->code] = name->description;
+ if (name->extra)
+ extras[name->code] = name->extra;
+ }
+}
+
+QString UnicodeNamesList::makeDescription(int c, const QString &name)
+{
+ QString desc;
+ QString unicode;
+
+ if (c != -1)
+ unicode.sprintf(" (U+%04X)", c);
+
+ if (hasChar(c)) {
+ desc = QString("<b>%1 — %2%3</b><br/>")
+ .arg(name)
+ .arg(QString::fromUtf8(unicodeNamesList.descriptions[c]))
+ .arg(unicode);
+ desc.replace(QChar(0x0020), QChar(0x00A0), Qt::CaseInsensitive); // space -> nbsp
+ if (unicodeNamesList.extras.contains(c))
+ desc += QString::fromUtf8(unicodeNamesList.extras[c]);
+ }
+ else {
+ desc = QString("<b>%1%2</b>").arg(name).arg(unicode);
+ desc.replace(QChar(0x0020), QChar(0x00A0), Qt::CaseInsensitive); // space -> nbsp
+ }
+ return desc;
+}
diff --git a/nongui/glyphref.h b/nongui/unicodenameslist.h
similarity index 60%
copy from nongui/glyphref.h
copy to nongui/unicodenameslist.h
index 7e76e3c..f152e4d 100644
--- a/nongui/glyphref.h
+++ b/nongui/unicodenameslist.h
@@ -14,25 +14,28 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef GLYPHREF_H
-#define GLYPHREF_H
+#ifndef UNICODENAMESLIST_H
+#define UNICODENAMESLIST_H
+#include <QHash>
#include <QString>
-#include <QPointF>
-#include <QMetaType>
-class GlyphRef {
+class UnicodeNamesList {
+ // Constructor is intentionaly private
+ UnicodeNamesList();
public:
- GlyphRef(const QString &name = 0, const QPointF &off = QPointF(0, 0)) : m_name(name), m_off(off) {}
- GlyphRef(const GlyphRef &other) {m_name = other.m_name; m_off = other.m_off;}
- const QPointF &offset() const {return m_off;}
- void setOffset(const QPointF &off) {m_off = off;}
- const QString &glyphName() const {return m_name;}
- void setGlyphName(const QString &name) {m_name = name;}
+ static bool hasChar(int c) {return unicodeNamesList.descriptions.contains(c);}
+ static QString makeDescription(int c, const QString &name = QString());
private:
- QString m_name;
- QPointF m_off;
+ QHash<int, const char *> descriptions;
+ QHash<int, const char *> extras;
+ struct UnicodeName {
+ int code;
+ const char *description;
+ const char *extra;
+ };
+ static const UnicodeName UnicodeNames[];
+ static const UnicodeNamesList unicodeNamesList;
};
-Q_DECLARE_METATYPE(GlyphRef)
#endif
--
Fondue Font Editor
More information about the fondue-commits
mailing list