diff -Nru fontmatrix-0.6.0+svn20100107/cmake/modules/FindICU.cmake fontmatrix-0.6.0+svn20110930/cmake/modules/FindICU.cmake --- fontmatrix-0.6.0+svn20100107/cmake/modules/FindICU.cmake 2008-05-19 16:53:25.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/cmake/modules/FindICU.cmake 2010-12-05 19:12:11.000000000 +0000 @@ -32,10 +32,24 @@ DOC "Libraries to link against for the common parts of ICU") mark_as_advanced(ICU_LIBRARY) +# Look for the library. Again +find_library( + ICUX_LIBRARY + NAMES iculx + DOC "Libraries to link against for the common parts of ICU X") +mark_as_advanced(ICUX_LIBRARY) + +# Look for the library. Again +find_library( + ICUUC_LIBRARY + NAMES icuuc + DOC "Libraries to link against for the common parts of ICU X") +mark_as_advanced(ICUUC_LIBRARY) + # Copy the results to the output variables. -if(ICU_INCLUDE_DIR AND ICU_LIBRARY) +if(ICU_INCLUDE_DIR AND ICU_LIBRARY AND ICUX_LIBRARY AND ICUUC_LIBRARY) set(ICU_FOUND 1) - set(ICU_LIBRARIES ${ICU_LIBRARY}) + set(ICU_LIBRARIES ${ICU_LIBRARY} ${ICUX_LIBRARY} ${ICUUC_LIBRARY}) set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR}) # Look for the ICU internationalization libraries @@ -57,5 +71,5 @@ set(ICU_LIBRARIES) set(ICU_I18N_LIBRARIES) set(ICU_INCLUDE_DIRS) -endif(ICU_INCLUDE_DIR AND ICU_LIBRARY) +endif(ICU_INCLUDE_DIR AND ICU_LIBRARY AND ICUX_LIBRARY AND ICUUC_LIBRARY) diff -Nru fontmatrix-0.6.0+svn20100107/CMakeLists.txt fontmatrix-0.6.0+svn20110930/CMakeLists.txt --- fontmatrix-0.6.0+svn20100107/CMakeLists.txt 2009-07-03 15:20:04.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/CMakeLists.txt 2010-10-01 13:17:27.000000000 +0000 @@ -4,7 +4,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) SET (VERSION_MAJOR "0") -SET (VERSION_MINOR "6") +SET (VERSION_MINOR "9") SET (VERSION_PATCH "99") SET (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) ADD_DEFINITIONS(-DFONTMATRIX_VERSION_MAJOR=${VERSION_MAJOR} -DFONTMATRIX_VERSION_MINOR=${VERSION_MINOR} -DFONTMATRIX_VERSION_PATCH=${VERSION_PATCH}) diff -Nru fontmatrix-0.6.0+svn20100107/debian/changelog fontmatrix-0.6.0+svn20110930/debian/changelog --- fontmatrix-0.6.0+svn20100107/debian/changelog 2011-11-21 17:13:05.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/changelog 2011-11-13 18:51:42.000000000 +0000 @@ -1,41 +1,19 @@ -fontmatrix (0.6.0+svn20100107-2ubuntu5) precise; urgency=low +fontmatrix (0.6.0+svn20110930-1.1) unstable; urgency=low - * Rebuild for libicu48. + * Non-maintainer upload. + * Fix type mismatch between qreal and double on ARM EABI (closes: #644250). - -- Colin Watson Mon, 21 Nov 2011 17:13:05 +0000 + -- Jakub Wilk Sun, 13 Nov 2011 19:51:41 +0100 -fontmatrix (0.6.0+svn20100107-2ubuntu4) natty; urgency=low +fontmatrix (0.6.0+svn20110930-1) unstable; urgency=low - * Add debian/patches/no-indirect-linking - - Add cmake/modules/FindICUUC.cmake and adjust CMakeLists.txt so the - linker can find libicuuc - - -- Scott Kitterman Sat, 18 Dec 2010 18:27:43 -0500 - -fontmatrix (0.6.0+svn20100107-2ubuntu3) natty; urgency=low - - * Rebuild with python 2.7 as the python default. - - -- Matthias Klose Thu, 09 Dec 2010 16:46:38 +0000 - -fontmatrix (0.6.0+svn20100107-2ubuntu2) maverick; urgency=low - - * rebuild on libqtwebkit-dev for qtwebkit transition - - -- Jonathan Riddell Wed, 21 Jul 2010 10:05:31 +0100 - -fontmatrix (0.6.0+svn20100107-2ubuntu1) maverick; urgency=low - - * Add build-dep on libqt4-webkit-dev. - - -- Felix Geyer Sun, 23 May 2010 19:05:10 +0200 - -fontmatrix (0.6.0+svn20100107-2) unstable; urgency=low - - * debian/patches/fminfodisplay.cpp: Created a new patch to fix FTBFS on - armel as Michael's patch was incomplete (Closes: #563972). + * Upstream svn snapshot (Closes: #554407, #628304). + * debian/control: + - Updated Standards-Version to 3.9.2. + - Added build-depends on libqt4-opengl-dev and libqtwebkit-dev to prevent + a ftbfs. - -- Oleksandr Moskalenko Sat, 09 Jan 2010 03:09:57 -0600 + -- Oleksandr Moskalenko Fri, 30 Sep 2011 17:00:54 -0500 fontmatrix (0.6.0+svn20100107-1) unstable; urgency=low diff -Nru fontmatrix-0.6.0+svn20100107/debian/control fontmatrix-0.6.0+svn20110930/debian/control --- fontmatrix-0.6.0+svn20100107/debian/control 2010-07-21 09:05:24.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/control 2011-10-03 20:46:39.000000000 +0000 @@ -1,11 +1,10 @@ Source: fontmatrix Section: graphics Priority: optional -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Oleksandr Moskalenko +Maintainer: Oleksandr Moskalenko Uploaders: Gürkan Sengün , Debian Fonts Task Force -Build-Depends: debhelper (>= 5), libfreetype6-dev, libqt4-dev (>= 4.3), libqtwebkit-dev, cmake, libfontconfig1-dev, libm17n-dev, libicu-dev, python-all-dev, libpuzzle-dev, python-qt4 -Standards-Version: 3.8.3 +Build-Depends: debhelper (>= 5), libfreetype6-dev, libqt4-dev (>= 4.3), cmake, libfontconfig1-dev, libm17n-dev, libicu-dev, python-all-dev, libpuzzle-dev, python-qt4, libqtwebkit-dev, libqt4-opengl-dev +Standards-Version: 3.9.2 Homepage: http://www.fontmatrix.net/ Package: fontmatrix diff -Nru fontmatrix-0.6.0+svn20100107/debian/patches/01_fminfodisplay.cpp.patch fontmatrix-0.6.0+svn20110930/debian/patches/01_fminfodisplay.cpp.patch --- fontmatrix-0.6.0+svn20100107/debian/patches/01_fminfodisplay.cpp.patch 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/patches/01_fminfodisplay.cpp.patch 2010-01-07 17:19:36.000000000 +0000 @@ -0,0 +1,16 @@ +From: Michael Casadevall +Subject: Fix FTBFS on armel +Bug-Debian: http://bugs.debian.org/563972 +Index: fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp +=================================================================== +--- fontmatrix-0.6.0+svn20100107.orig/src/fminfodisplay.cpp 2010-01-07 11:16:21.000000000 -0600 ++++ fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp 2010-01-07 11:16:50.000000000 -0600 +@@ -151,7 +151,7 @@ + GlyphToSVGHelper gtsh ( gpi->path(), tf ); + svg += gtsh.getSVGPath() + "\n"; + horOffset += gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor; +- maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); ++ maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); + tf.translate( gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor,0 ); + delete gpi; + } diff -Nru fontmatrix-0.6.0+svn20100107/debian/patches/debian-changes-0.6.0+svn20100107-1 fontmatrix-0.6.0+svn20110930/debian/patches/debian-changes-0.6.0+svn20100107-1 --- fontmatrix-0.6.0+svn20100107/debian/patches/debian-changes-0.6.0+svn20100107-1 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/patches/debian-changes-0.6.0+svn20100107-1 2010-01-07 18:28:29.000000000 +0000 @@ -0,0 +1,39 @@ +Description: Upstream changes introduced in version 0.6.0+svn20100107-1 + This patch has been created by dpkg-source during the package build. + Here's the last changelog entry, hopefully it gives details on why + those changes were made: + . + fontmatrix (0.6.0+svn20100107-1) unstable; urgency=low + . + * Upstream svn snapshot. + * debian/source/format: Switched to dpkg-source 3.0 (quilt) format. + * debian/control: Updated Standards-Version to 3.8.3. + * debian/patches/01_fminfodisplay.cpp.patch: fixes FTBFS on arm. Thanks to + Michael Casadevall . + . + The person named in the Author field signed this changelog entry. +Author: Oleksandr Moskalenko + +--- +The information above should follow the Patch Tagging Guidelines, please +checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here +are templates for supplementary fields that you might want to add: + +Origin: , +Bug: +Bug-Debian: http://bugs.debian.org/ +Forwarded: +Reviewed-By: +Last-Update: + +--- fontmatrix-0.6.0+svn20100107.orig/src/fminfodisplay.cpp ++++ fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp +@@ -151,7 +151,7 @@ QString FMInfoDisplay::writeSVGPreview(F + GlyphToSVGHelper gtsh ( gpi->path(), tf ); + svg += gtsh.getSVGPath() + "\n"; + horOffset += gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor; +- maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); ++ maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); + tf.translate( gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor,0 ); + delete gpi; + } diff -Nru fontmatrix-0.6.0+svn20100107/debian/patches/debian-changes-0.6.0+svn20100107-2 fontmatrix-0.6.0+svn20110930/debian/patches/debian-changes-0.6.0+svn20100107-2 --- fontmatrix-0.6.0+svn20100107/debian/patches/debian-changes-0.6.0+svn20100107-2 2010-01-09 09:27:34.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/patches/debian-changes-0.6.0+svn20100107-2 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -Description: Upstream changes introduced in version 0.6.0+svn20100107-2 - This patch has been created by dpkg-source during the package build. - Here's the last changelog entry, hopefully it gives details on why - those changes were made: - . - fontmatrix (0.6.0+svn20100107-2) unstable; urgency=low - . - * debian/patches/fminfodisplay.cpp: Created a new patch to fix FTBFS on - armel as Michael's patch was incomplete (Closes: #563972). - . - The person named in the Author field signed this changelog entry. -Author: Oleksandr Moskalenko -Bug-Debian: http://bugs.debian.org/563972 - ---- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -are templates for supplementary fields that you might want to add: - -Origin: , -Bug: -Bug-Debian: http://bugs.debian.org/ -Forwarded: -Reviewed-By: -Last-Update: - ---- /dev/null -+++ fontmatrix-0.6.0+svn20100107/patches/series -@@ -0,0 +1 @@ -+fminfodisplay.cpp ---- /dev/null -+++ fontmatrix-0.6.0+svn20100107/patches/fminfodisplay.cpp -@@ -0,0 +1,22 @@ -+Index: fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp -+=================================================================== -+--- fontmatrix-0.6.0+svn20100107.orig/src/fminfodisplay.cpp 2010-01-09 03:07:33.000000000 -0600 -++++ fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp 2010-01-09 03:07:45.000000000 -0600 -+@@ -137,7 +137,7 @@ -+ QTransform tf; -+ double pifs ( typotek::getInstance()->getPreviewInfoFontSize() ); -+ double scaleFactor( pifs / font->getUnitPerEm() ); -+- double maxHeight ( 0 ); -++ qreal maxHeight ( 0 ); -+ double vertOffset ( pifs ); -+ double horOffset ( 0 ); -+ tf.translate ( horOffset , vertOffset ); -+@@ -151,7 +151,7 @@ -+ GlyphToSVGHelper gtsh ( gpi->path(), tf ); -+ svg += gtsh.getSVGPath() + "\n"; -+ horOffset += gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor; -+- maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); -++ maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); -+ tf.translate( gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor,0 ); -+ delete gpi; -+ } ---- /dev/null -+++ fontmatrix-0.6.0+svn20100107/patches/01_fminfodisplay.cpp.patch -@@ -0,0 +1,13 @@ -+Index: fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp -+=================================================================== -+--- fontmatrix-0.6.0+svn20100107.orig/src/fminfodisplay.cpp 2009-08-03 05:27:37.000000000 -0500 -++++ fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp 2010-01-09 03:03:13.000000000 -0600 -+@@ -151,7 +151,7 @@ -+ GlyphToSVGHelper gtsh ( gpi->path(), tf ); -+ svg += gtsh.getSVGPath() + "\n"; -+ horOffset += gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor; -+- maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); -++ maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); -+ tf.translate( gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor,0 ); -+ delete gpi; -+ } diff -Nru fontmatrix-0.6.0+svn20100107/debian/patches/fminfodisplay.cpp fontmatrix-0.6.0+svn20110930/debian/patches/fminfodisplay.cpp --- fontmatrix-0.6.0+svn20100107/debian/patches/fminfodisplay.cpp 2010-01-09 09:17:52.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/patches/fminfodisplay.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -Index: fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp -=================================================================== ---- fontmatrix-0.6.0+svn20100107.orig/src/fminfodisplay.cpp 2010-01-09 03:17:37.000000000 -0600 -+++ fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp 2010-01-09 03:17:48.000000000 -0600 -@@ -137,7 +137,7 @@ - QTransform tf; - double pifs ( typotek::getInstance()->getPreviewInfoFontSize() ); - double scaleFactor( pifs / font->getUnitPerEm() ); -- double maxHeight ( 0 ); -+ qreal maxHeight ( 0 ); - double vertOffset ( pifs ); - double horOffset ( 0 ); - tf.translate ( horOffset , vertOffset ); -@@ -151,7 +151,7 @@ - GlyphToSVGHelper gtsh ( gpi->path(), tf ); - svg += gtsh.getSVGPath() + "\n"; - horOffset += gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor; -- maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); -+ maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); - tf.translate( gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor,0 ); - delete gpi; - } diff -Nru fontmatrix-0.6.0+svn20100107/debian/patches/no-indirect-linking fontmatrix-0.6.0+svn20110930/debian/patches/no-indirect-linking --- fontmatrix-0.6.0+svn20100107/debian/patches/no-indirect-linking 2010-12-19 00:00:53.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/patches/no-indirect-linking 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -Description: Upstream changes introduced in version 0.6.0+svn20100107-2ubuntu4 - This patch has been created by dpkg-source during the package build. - Here's the last changelog entry, hopefully it gives details on why - those changes were made: - . - fontmatrix (0.6.0+svn20100107-2ubuntu4) lucid; urgency=low - . - * Add cmake/modules/FindICUUC.cmake and adjust CMakeLists.txt so the linker - can find libicuuc - . - The person named in the Author field signed this changelog entry. -Author: Scott Kitterman - ---- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -are templates for supplementary fields that you might want to add: - -Origin: Ubuntu -Bug-Debian: http://bugs.debian.org/607148 -Forwarded: no -Last-Update: <2010-12-18> - ---- fontmatrix-0.6.0+svn20100107.orig/CMakeLists.txt -+++ fontmatrix-0.6.0+svn20100107/CMakeLists.txt -@@ -64,6 +64,14 @@ IF(WANT_ICU) - ELSE(ICU_FOUND) - MESSAGE(FATAL_ERROR "ICU Not Found ARGH") - ENDIF(ICU_FOUND) -+ # Need to link more than what CMake finds on it's own. -+ FIND_PACKAGE(ICUUC) -+ if(ICUU_FOUND) -+ MESSAGE(STATUS "ICUUC Found OK") -+ LINK_LIBRARIES(${ICUU_LIBRARIES}) -+ ELSE(ICUU_FOUND) -+ MESSAGE(FATAL_ERROR "ICUUC Not Found ARGH") -+ ENDIF(ICUU_FOUND) - ENDIF(WANT_ICU) - - #>> ICU ---- /dev/null -+++ fontmatrix-0.6.0+svn20100107/cmake/modules/FindICUUC.cmake -@@ -0,0 +1,23 @@ -+# Finds additional components for Unicode (ICU) Library -+# -+# ICUU_FOUND - True if ICUUUC found. -+# ICUU_LIBRARIES - Additional libraries to link against for the common ICU -+ -+# Look for the additional library. -+find_library( -+ ICUU_LIBRARY -+ NAMES icuuc -+ PATHS /usr/lib /usr/local/lib /lib -+ MESSAGE(STATUS "Found ICUUC library: ${ICUU_LIBRARY}")) -+mark_as_advanced(ICUU_LIBRARY) -+ -+# Copy the results to the output variables. -+if(ICUU_LIBRARY) -+ MESSAGE(STATUS "Found ICUUC: ${ICUU_LIBRARY}") -+ set(ICUU_FOUND 1) -+ set(ICUU_LIBRARIES ${ICUU_LIBRARY}) -+else(ICUU_LIBRARY) -+ set(ICUU_FOUND 0) -+ set(ICUU_LIBRARIES) -+endif(ICUU_LIBRARY) -+ diff -Nru fontmatrix-0.6.0+svn20100107/debian/patches/qreal.diff fontmatrix-0.6.0+svn20110930/debian/patches/qreal.diff --- fontmatrix-0.6.0+svn20100107/debian/patches/qreal.diff 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/patches/qreal.diff 2011-11-13 18:51:03.000000000 +0000 @@ -0,0 +1,17 @@ +Description: Fix type mismatch between qreal and double on ARM EABI. +Author: Jakub Wilk +Bug-Debian: http://bugs.debian.org/644250 +Forwarded: no +Last-Update: 2011-11-13 + +--- a/src/fminfodisplay.cpp ++++ b/src/fminfodisplay.cpp +@@ -151,7 +151,7 @@ + GlyphToSVGHelper gtsh ( gpi->path(), tf ); + svg += gtsh.getSVGPath() + "\n"; + horOffset += gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor; +- maxHeight = qMax ( gtsh.getRect().height(), maxHeight ); ++ maxHeight = qMax ( (double)gtsh.getRect().height(), maxHeight ); + tf.translate( gpi->data(GLYPH_DATA_HADVANCE).toDouble() * scaleFactor,0 ); + delete gpi; + } diff -Nru fontmatrix-0.6.0+svn20100107/debian/patches/series fontmatrix-0.6.0+svn20110930/debian/patches/series --- fontmatrix-0.6.0+svn20100107/debian/patches/series 2010-12-18 23:55:51.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/patches/series 2011-11-13 01:22:05.000000000 +0000 @@ -1,3 +1,3 @@ -fminfodisplay.cpp -debian-changes-0.6.0+svn20100107-2 -no-indirect-linking +01_fminfodisplay.cpp.patch +debian-changes-0.6.0+svn20100107-1 +qreal.diff diff -Nru fontmatrix-0.6.0+svn20100107/debian/.pc/.version fontmatrix-0.6.0+svn20110930/debian/.pc/.version --- fontmatrix-0.6.0+svn20100107/debian/.pc/.version 2010-01-09 09:05:57.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/.pc/.version 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -2 diff -Nru fontmatrix-0.6.0+svn20100107/debian/rules fontmatrix-0.6.0+svn20110930/debian/rules --- fontmatrix-0.6.0+svn20100107/debian/rules 2010-01-07 17:49:39.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/debian/rules 2011-10-03 17:13:08.000000000 +0000 @@ -62,6 +62,11 @@ # cp bin/fontmatrix DESTDIR=$(CURDIR)/debian/fontmatrix/usr/bin/ +# Build architecture-dependent files here. +#build %: +# dh $@ +# dh_installman -pfontmatrix fontmatrix.1 + # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. @@ -87,8 +92,9 @@ dh_md5sums dh_builddeb + upstream: find . -name ".svn*" -exec rm -rf {} \; binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure +.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install configure diff -Nru fontmatrix-0.6.0+svn20100107/help/en/news.html fontmatrix-0.6.0+svn20110930/help/en/news.html --- fontmatrix-0.6.0+svn20100107/help/en/news.html 2009-07-02 15:23:39.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/help/en/news.html 2010-08-12 23:35:05.000000000 +0000 @@ -2,28 +2,20 @@ -Fontmatrix User Manual — What's new +Fontmatrix User Manual — What's New -

What's new

+

What's New

The version you are looking at contains a number of improvements over the previous one, such as:

diff -Nru fontmatrix-0.6.0+svn20100107/OSX-package/linktools/ingest.py fontmatrix-0.6.0+svn20110930/OSX-package/linktools/ingest.py --- fontmatrix-0.6.0+svn20100107/OSX-package/linktools/ingest.py 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/OSX-package/linktools/ingest.py 2010-07-16 13:07:26.000000000 +0000 @@ -0,0 +1,72 @@ +#!/usr/bin/python + +import os +import sys +import osxtools + +def usage(): + print """ + Usage: ingest.py bundle [-x lib] [-s fw] + + Copies all dependent libraries and frameworks into the app bundle. + System libraries (/usr/lib*, /System/Library) are not copied. + Fixes the dependencies in all executabels contained in bundle. + + bundle: the path to the *.app bundle + -x lib: dont move lib into the bundle. + -s fw: only move the referenced libarry file from framework fw + into the bundle, not the complete framework + """ + + +if len(sys.argv) <= 1 or sys.argv[1] == "-?" : + usage() + sys.exit(0) + + + +exceptions = [] +strippedfws = [] +bundle = None + +argp = 1 + +while argp < len(sys.argv) : + if sys.argv[argp] == '-x' : + exceptions.append(sys.argv[argp + 1]) + argp = argp + 2 + elif sys.argv[argp][0:2] == '-x' : + exceptions.append(sys.argv[argp][2:]) + argp = argp + 1 + elif sys.argv[argp] == '-s' : + strippedfws.append(sys.argv[argp + 1]) + argp = argp + 2 + elif sys.argv[argp][0:2] == '-s' : + strippedfws.append(sys.argv[argp][2:]) + argp = argp + 1 + elif sys.argv[argp][0:1] == '-' : + print "Error: unknown option: " + sys.argv[argp] + usage() + sys.exit(1) + elif bundle == None: + bundle = sys.argv[argp] + argp = argp + 1 + else: + print "Error: more than one bundle path specified!" + usage() + sys.exit(1) + +if bundle == None: + print "Error: no bundle path specified!" + usage() + sys.exit(1) + +if not os.path.isabs(bundle): + bundle = os.path.join(os.getenv("PWD"), bundle) + +if not os.path.isdir(bundle): + print "Error: '" + bundle + "' is no bundle path!" + usage() + sys.exit(1) + +osxtools.ingest(bundle, exceptions, strippedfws) diff -Nru fontmatrix-0.6.0+svn20100107/OSX-package/linktools/MachO.py fontmatrix-0.6.0+svn20110930/OSX-package/linktools/MachO.py --- fontmatrix-0.6.0+svn20100107/OSX-package/linktools/MachO.py 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/OSX-package/linktools/MachO.py 2010-07-16 13:07:26.000000000 +0000 @@ -0,0 +1,215 @@ +import os +import re +import shutil + + +def findFramework(path, name = None): + "find the framework folder for FW name" + if path == "" or path == "@executable_path" or path == "/": + return None + elif name == None: + return findFramework(os.path.dirname(path), + os.path.basename(path)) + elif os.path.basename(path) == name + ".framework": + return path + elif len(os.path.dirname(path)) >= len(path): + print "MachO.findFramework: Oops '" + path + "', '" + name + "'" + return None + else: + return findFramework(os.path.dirname(path), name) + + + +def stripPrefix(prefix, path): + "Returns the relative path r such that os.path.join(prefix, r) == path" + prefix = os.path.normpath(prefix) + prefixLen = len(prefix) + path = os.path.normpath(path) + if path[0 : prefixLen] == prefix: + if path[prefixLen] == os.sep: + return path[prefixLen+1 : ] + else: + return path[prefixLen : ] + else: + return path + + +class Executable: + "Represents an Mach-O executable." + + def __init__(self, path, kind): + self.Location = path + self.Kind = kind + + + def __repr__(self): + return self.Location + " (" + self.Kind + ")" + + + def getDependencies(self): + "Return a list of MachO.Fixes describing the dependencies." + "Uses otool -L" + f = os.popen("otool -L " + self.Location, "r") + result = [] + pat = re.compile("\s*([^(]*)\s\((.+)\)") + for line in f: + m = pat.match(line) + if m != None: + result.append(Fix(m.group(1), m.group(2))) + status = f.close() + return result + + def applyFixes(self, changes, log): + "Uses install_name_tool to change the links to dependencies." + "changes is a dictionary mapping links (as strings) to Fixes." + args = "" + for dep in self.getDependencies(): + if dep.Link in changes: + args = args + changes[dep.Link].getChange() + log.append(">> " + "install_name_tool " + args + self.Location) + if len(args) > 0: + os.system("install_name_tool " + args + self.Location) + pat = re.compile("(library)|(universal binary)") + if pat.search(self.Kind): + relName = os.path.basename(self.Location) # FIXME: rel to fw + log.append(">> " + "install_name_tool -id " + relName + + " " + self.Location) + os.system("install_name_tool -id " + relName + + " " + self.Location) + + +def findExecutables(bundleDir): + "Return a list of MachO.Executables found in bundleDir" + result = [] + pat = re.compile("Mach-O (.+)") + for root, dirs, files in os.walk(bundleDir): + for n in files: + p = os.path.join(root, n) + f = os.popen("file -b " + p, "r") + m = pat.match(f.readline()) + if m != None: + result.append(Executable(p, m.group(1))) + print "found " + m.group(1) + ": " + n + f.close() + return result + + + +class Fix: + "Represents a fix for a library link." + + def __init__(self, dependency, versionString="?"): + self.Link = dependency + self.Location = dependency + self.NewLink = dependency + self.NewLocation = dependency + self.versionString = versionString # not used yet + self.fwPath = None + self.relPath = None + + def __repr__(self): + return (self.Link + " (" + self.versionString + ")") + + def isAbsolute(self): + return os.path.isabs(self.Link) + + def isBundleRelative(self): + return self.Link[0:17] == "@executable_path/" + + def isSystem(self): + return (self.Location[0:8] == "/usr/lib" # also matches libexec + or self.Location[0:8] == "/usr/X11" # also matches X11R6 + or self.Location[0:8] == "/System/") + + def getChange(self): + "Returns argument for install_name_tool." + if self.Link == self.NewLink: + return "" + else: + return "-change " + self.Link + " " + self.NewLink + " " + + def findLocation(self, exePath=None): + if self.isBundleRelative(): + if exePath != None: + self.Location = os.path.normpath( + os.path.join(exePath, self.Link[17:])) + else: + self.Location = self.Link[17:] + else: + self.Location = self.Link + + # check if done + if (os.path.isabs(self.Location) and + os.path.isfile(self.Location)): + self.NewLocation = self.Location + return True + + # search for frameworks in /System/Library and /Library + fwPath = findFramework(self.Location) + if fwPath: + fwdir = os.path.dirname(fwPath) + self.relPath = stripPrefix(fwdir, self.Location) + for d in ["/Library/Frameworks", + "/System/Library/Frameworks"]: + if os.path.isfile(os.path.join(d, self.relPath)): +# self.Location = os.path.join(d, self.relPath) + self.Location = os.path.join(d, self.relPath) + self.NewLocation = self.Location + self.fwPath = os.path.join(d, os.path.basename(fwPath)) + self.relPath = stripPrefix(self.fwPath, self.Location) + return True + + # ok, try libs + lib = os.path.basename(self.Location) + self.relPath = None + for d in ["/usr/local/lib", "/opt/local/lib", + "/usr/lib", "/opt/lib"]: + if os.path.isfile(os.path.join(d, lib)): + self.Location = os.path.join(d, lib) + self.NewLocation = self.Location + return True + + # not found + return False + + + def moveLibrary(self, destBundlePath, stripFW, log): + "Copies the library or fw to destBundlePath." + "Also sets NewLink and NewLocation properties" + "Returns a list of copied executables" + + # dont do this if we are already inside the bundle: + if stripPrefix(destBundlePath, self.Location) != self.Location: + log.append("-- ignoring " + self.Location) + return [] + + if self.relPath != None and not stripFW: + # copy framework + newFwPath = os.path.join(destBundlePath, + "Contents/Frameworks", + os.path.basename(self.fwPath)) + log.append(">> " + self.fwPath + " ===> " + newFwPath) + if (os.path.exists(destBundlePath) and + not os.path.exists(newFwPath)): + shutil.copytree(self.fwPath, newFwPath, True) + self.NewLocation = os.path.join(newFwPath, self.relPath) + self.NewLink = ("@executable_path/" + + os.path.join("../Frameworks", + os.path.basename(self.fwPath), + self.relPath)) + return findExecutables(newFwPath) + else: + # copy lib to bundle.app/Contents/Frameworks/ + self.NewLocation = os.path.join(destBundlePath, + "Contents/Frameworks", + os.path.basename(self.Location)) + self.NewLink = ("@executable_path/" + + os.path.join("../Frameworks", + os.path.basename(self.Location))) + log.append(">> " + self.Location + " ---> " + self.NewLocation) + if (os.path.exists(destBundlePath) and + not os.path.exists(self.NewLocation)): + shutil.copy(self.Location, self.NewLocation) + return [Executable(self.NewLocation, "lib")] + + \ No newline at end of file diff -Nru fontmatrix-0.6.0+svn20100107/OSX-package/linktools/mkappbundle.py fontmatrix-0.6.0+svn20110930/OSX-package/linktools/mkappbundle.py --- fontmatrix-0.6.0+svn20100107/OSX-package/linktools/mkappbundle.py 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/OSX-package/linktools/mkappbundle.py 2010-07-16 13:07:26.000000000 +0000 @@ -0,0 +1,87 @@ +#!/usr/bin/python + +import os +import sys +import shutil +import osxtools + +def usage(): + print """ + Usage: mkappbundle.py bundle [-b binary] [-i infofile|-v version] + + Creates the directory structure for an application bundle. + If binary is given, it will be used as the binaries executable, + otherwise the binary will just be an empty shell. + + bundle: the path to the *.app bundle + -b binary: copy lib into the bundle. + -i infofile: use "ver" as the version instead of the standard 'A' + """ + + +if len(sys.argv) <= 1 or sys.argv[1] == "-?" : + usage() + sys.exit(0) + + + +infofile = None +binfile = None +bundle = None + +argp = 1 + +while argp < len(sys.argv) : + if sys.argv[argp] == '-b' : + binfile = (sys.argv[argp + 1]) + argp = argp + 2 + elif sys.argv[argp][0:2] == '-b' : + binfile = (sys.argv[argp][2:]) + argp = argp + 1 + elif sys.argv[argp] == '-i' : + infofile = (sys.argv[argp + 1]) + argp = argp + 2 + elif sys.argv[argp][0:2] == '-i' : + infofile = (sys.argv[argp][2:]) + argp = argp + 1 + elif sys.argv[argp][0:1] == '-' : + print "Error: unknown option: " + sys.argv[argp] + usage() + sys.exit(1) + elif bundle == None: + bundle = sys.argv[argp] + argp = argp + 1 + else: + print "Error: more than one bundle path specified!" + usage() + sys.exit(1) + +if bundle == None: + print "Error: no bundle path specified!" + usage() + sys.exit(1) + +if not os.path.isabs(bundle): + bundle = os.path.join(os.getenv("PWD"), bundle) + +if bundle[-4 : ] != ".app": + bundle = bundle + ".app" +appName = os.path.basename(bundle)[0: -4] + +if not os.path.exists(bundle): + os.makedirs(bundle, 0755) +elif not os.path.isdir(bundle): + print "Error: '" + bundle + "' is no bundle path!" + usage() + sys.exit(1) + +binPath = os.path.join(bundle, "Contents/MacOS") + +if not os.path.exists(binPath): + os.makedirs(binPath, 0755) + +if binfile != None: + shutil.copy(binfile, os.path.join(binPath, appName)) + +shutil.copy(infofile, os.path.join(bundle, "Contents/Info.plist") + diff -Nru fontmatrix-0.6.0+svn20100107/OSX-package/linktools/mkframework.py fontmatrix-0.6.0+svn20110930/OSX-package/linktools/mkframework.py --- fontmatrix-0.6.0+svn20100107/OSX-package/linktools/mkframework.py 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/OSX-package/linktools/mkframework.py 2010-07-16 13:07:26.000000000 +0000 @@ -0,0 +1,111 @@ +#!/usr/bin/python + +import os +import sys +import shutil +import osxtools + +def usage(): + print """ + Usage: mkframework.py bundle [-l libfile] [-v version] + + Creates the directory structure for a framework. + If libfile is given, it will be used as the frameworks executable, + otherwise the framework will just be an empty shell. + + bundle: the path to the *.framework bundle + -l lib: copy lib into the bundle. + -v ver: use "ver" as the version instead of the standard 'A' + -f: overwrite existing files if version exists + """ + + +if len(sys.argv) <= 1 or sys.argv[1] == "-?" : + usage() + sys.exit(0) + + + +version = "A" +overwrite = False +libfile = None +bundle = None + +argp = 1 + +while argp < len(sys.argv) : + if sys.argv[argp] == '-f': + overwrite = True; + argp = argp + 1 + elif sys.argv[argp] == '-l' : + libfile = (sys.argv[argp + 1]) + argp = argp + 2 + elif sys.argv[argp][0:2] == '-l' : + libfile = (sys.argv[argp][2:]) + argp = argp + 1 + elif sys.argv[argp] == '-v' : + version = (sys.argv[argp + 1]) + argp = argp + 2 + elif sys.argv[argp][0:2] == '-v' : + version = (sys.argv[argp][2:]) + argp = argp + 1 + elif sys.argv[argp][0:1] == '-' : + print "Error: unknown option: " + sys.argv[argp] + usage() + sys.exit(1) + elif bundle == None: + bundle = sys.argv[argp] + argp = argp + 1 + else: + print "Error: more than one bundle path specified!" + usage() + sys.exit(1) + +if bundle == None: + print "Error: no bundle path specified!" + usage() + sys.exit(1) + +if not os.path.isabs(bundle): + bundle = os.path.join(os.getenv("PWD"), bundle) + +if bundle[-10 : ] != ".framework": + bundle = bundle + ".framework" +fwName = os.path.basename(bundle)[0: -10] + +if not os.path.exists(bundle): + os.makedirs(bundle, 0755) +elif not os.path.isdir(bundle): + print "Error: '" + bundle + "' is no bundle path!" + usage() + sys.exit(1) + +versionPath = os.path.join(bundle, "Versions", version) + +if os.path.exists(versionPath): + if overwrite: + shutil.removetree(versionPath) + else: + print "Error: '" + versionPath + "' already exists!" + usage() + sys.exit(1) + +os.makedirs(versionPath, 0755) + +if libfile != None: + shutil.copy(libfile, os.path.join(versionPath, fwName)) + os.system("install_name_tool -id @executable_path/" + + os.path.join("../Frameworks", + fwName + ".framework", + "Versions", + version, + fwName) + + " " + + os.path.join(versionPath, fwName)) + +osxtools.createSymlinks(bundle, [ + ("Versions/Current", version), + (fwName, os.path.join("Versions/Current", fwName)), + ("Headers", "Versions/Current/Headers") +]) + diff -Nru fontmatrix-0.6.0+svn20100107/OSX-package/linktools/osxtools.py fontmatrix-0.6.0+svn20110930/OSX-package/linktools/osxtools.py --- fontmatrix-0.6.0+svn20100107/OSX-package/linktools/osxtools.py 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/OSX-package/linktools/osxtools.py 2010-07-16 13:07:26.000000000 +0000 @@ -0,0 +1,114 @@ +import os +import re +import MachO +from distutils.dir_util import copy_tree +from datetime import datetime + + +def findDependencies(exeFiles, exePath): + "Return a dictionary of MachO.Fixes of all recursive dependencies" + result = {} + + # allow some sloppyness: + if isinstance(exeFiles, str): + exeFiles = [MachO.Executable(exeFiles, "executable")] + elif isinstance(exeFiles, MachO.Executable): + exeFiles = [exeFiles] + + # go through executables and store Fixes + todo = [x for x in exeFiles] + done = [x.Location for x in exeFiles] + while len(todo) > 0: + current = todo.pop() + print "getting dependencies for " + current.Location + for dep in current.getDependencies(): + if dep.Link not in result: + if dep.findLocation(exePath): + result[dep.Link] = dep + # check if we need to traverse the referenced lib + if not dep.isSystem() and dep.Location not in done: + print "- adding " + dep.Location + done.append(dep.Location) + todo.append(MachO.Executable(dep.Location, "lib")) + else: + print ("couldn't find " + dep.Link + + " -> " + dep.Location) + + # forget any system dependencies + for k,fix in result.items(): + if fix.isSystem(): + del result[k] + + return result + + +def ingest(bundle, exceptions=[], strippedFrameworks=[]): + "Moves all needed non-System libraries inside the bundle and fixes links" + # step 1: find all executables + executables = MachO.findExecutables(bundle) + # find the bundle executable + pat = re.compile("executable") + exePath = "" + for exe in executables: + if pat.match(exe.Kind): + exePath = os.path.dirname(exe.Location) + print "using @executable_path=" + exePath + break + # step 2: find all dependencies + fixes = findDependencies(executables, exePath) + # step 3: move all libraries which are not excepted + log = [] + frameworks = os.path.join(bundle, "Contents/Frameworks") + if not os.path.exists(frameworks): + log.append(">> mkdir " + frameworks) + os.makedirs(frameworks, 0755) + for k,fix in fixes.items(): + if fix.Location in exceptions or fix.Link in exceptions: + del fixes[k] + else: + stripFW = fix.Location in strippedFrameworks + executables.extend(fix.moveLibrary(bundle, stripFW, log)) + + # step 3.5: copy aspell dictionaries, hacked for aspell via macports for now, #7371 + aspellsrcpath = "/opt/local/share/aspell" + if os.path.exists(aspellsrcpath): + aspelldestpath = os.path.join(bundle, "Contents/share/aspell") + if not os.path.exists(aspelldestpath): + log.append(">> mkdir " + aspelldestpath) + os.makedirs(aspelldestpath, 0755) + if os.path.exists(aspelldestpath): + log.append(">> copying aspell dictionaries") + print "copying aspell dictionaries" + copy_tree(aspellsrcpath, aspelldestpath) + + # step 4: fix all executables + for exe in executables: + exe.applyFixes(fixes, log) + # step 5: write log + logfile = file(os.path.join(bundle, "Contents/osxtools.log"), "a") + logfile.write("ingest at " + datetime.now().isoformat(" ") + "\n") + for e in log: + logfile.write(e + "\n") + logfile.close() + + +def createSymlinks(bundle, links): + currDir = os.getcwd() + for lnk,tar in links: + print "chdir to " + os.path.join(bundle, os.path.dirname(lnk)) + os.chdir(os.path.join(bundle, os.path.dirname(lnk))) + print "symlink " + os.path.basename(lnk) + " -> " + tar + os.symlink(tar, os.path.basename(lnk)) + os.chdir(currDir) + + +def relinkOld(FILE, LIBDIR, INSTALLDIR): + #LIBS=`otool -L $FILE | sed 's/\([^(]*\)(.*)/\1/g'` + #for LIB in $LIBS ; do + # LNAM=`basename $LIB` + # if [ $FILE -ef $LIBDIR/$LNAM ] ; then + # install_name_tool -id $INSTALLDIR$LNAM $FILE + # elif [ -e $LIBDIR/$LNAM ] ; then + # install_name_tool -change $LIB $INSTALLDIR$LNAM $FILE + pass + diff -Nru fontmatrix-0.6.0+svn20100107/src/activationwidget.cpp fontmatrix-0.6.0+svn20110930/src/activationwidget.cpp --- fontmatrix-0.6.0+svn20100107/src/activationwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/activationwidget.cpp 2010-08-14 08:00:49.000000000 +0000 @@ -0,0 +1,97 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "activationwidget.h" +#include "ui_activationwidget.h" + +#include "fmfontdb.h" +#include "fmactivate.h" +#include "fmactivationreport.h" +#include "fontitem.h" +#include "activationwidgetitem.h" +#include "fmvariants.h" + + +const QString ActivationWidget::Name = QObject::tr("Activation"); + +ActivationWidget::ActivationWidget(const QString& familyName, QWidget *parent) : + FloatingWidget(familyName, Name, parent), + family(familyName), + ui(new Ui::ActivationWidget) +{ + ui->setupUi(this); + QList fl(FMVariants::Order(FMFontDb::DB()->FamilySet(family))); + foreach(FontItem* f, fl) + { + ActivationWidgetItem * i(new ActivationWidgetItem(f->path(), this)); + ui->listLayout->addWidget(i); + items.append(i); + + connect(i, SIGNAL(fontStateChanged()), this, SIGNAL(familyStateChanged())); + } + + connect(ui->activateAll, SIGNAL(clicked()), this, SLOT(slotActivate())); + connect(ui->deactivateAll, SIGNAL(clicked()), this, SLOT(slotDeactivate())); +} + +ActivationWidget::~ActivationWidget() +{ + delete ui; +} + +void ActivationWidget::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void ActivationWidget::slotActivate() +{ + activateAll(true); +} + +void ActivationWidget::slotDeactivate() +{ + activateAll(false); +} + +void ActivationWidget::activateAll(bool c) +{ + FMActivate::getInstance()->errors(); + FMActivate::getInstance()->activate(FMFontDb::DB()->FamilySet(family), c); + QMap actErr(FMActivate::getInstance()->errors()); + if(actErr.count() > 0) + { + FMActivationReport ar(this, actErr); + ar.exec(); + } + foreach(ActivationWidgetItem *i, items) + { + i->changeState(c); + } + + emit familyStateChanged(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/activationwidget.h fontmatrix-0.6.0+svn20110930/src/activationwidget.h --- fontmatrix-0.6.0+svn20100107/src/activationwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/activationwidget.h 2010-08-14 08:00:49.000000000 +0000 @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef ACTIVATIONWIDGET_H +#define ACTIVATIONWIDGET_H + +#include "floatingwidget.h" + +namespace Ui { + class ActivationWidget; +} + +class ActivationWidgetItem; + +class ActivationWidget : public FloatingWidget +{ + Q_OBJECT + +public: + static const QString Name; + explicit ActivationWidget(const QString& familyName, QWidget *parent = 0); + ~ActivationWidget(); + +protected: + void changeEvent(QEvent *e); + +private: + const QString family; + Ui::ActivationWidget *ui; + + QList items; + void activateAll(bool c); + +private slots: + void slotActivate(); + void slotDeactivate(); + +signals: + void familyStateChanged(); +}; + +#endif // ACTIVATIONWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/activationwidgetitem.cpp fontmatrix-0.6.0+svn20110930/src/activationwidgetitem.cpp --- fontmatrix-0.6.0+svn20100107/src/activationwidgetitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/activationwidgetitem.cpp 2010-08-14 08:00:49.000000000 +0000 @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "activationwidgetitem.h" +#include "ui_activationwidgetitem.h" + +#include "fmfontdb.h" +#include "fontitem.h" +#include "fmactivate.h" +#include "fmactivationreport.h" + +ActivationWidgetItem::ActivationWidgetItem(const QString& fontID, QWidget *parent) : + QWidget(parent), + fileName(fontID), + ui(new Ui::ActivationWidgetItem) +{ + ui->setupUi(this); + FontItem * f(FMFontDb::DB()->Font(fileName)); + ui->styleName->setText(f->variant()); + ui->activatedStatus->setText(fileName); + ui->activatedStatus->setChecked(f->isActivated()); + + connect(ui->activatedStatus, SIGNAL(toggled(bool)), this, SLOT(activate(bool))); +} + +ActivationWidgetItem::~ActivationWidgetItem() +{ + delete ui; +} + +void ActivationWidgetItem::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + + +void ActivationWidgetItem::activate(bool a) +{ + FontItem * f(FMFontDb::DB()->Font(fileName)); + if(f == 0) + return; + if(a != f->isActivated()) + { + QList fl; + fl.clear(); + fl.append(f); + FMActivate::getInstance()->errors(); + FMActivate::getInstance()->activate(fl, a); + QMap actErr(FMActivate::getInstance()->errors()); + if(actErr.count() > 0) + { + FMActivationReport ar(this, actErr); + ar.exec(); + } + emit fontStateChanged(); + } +} + +void ActivationWidgetItem::changeState(bool s) +{ + ui->activatedStatus->setChecked(s); +} + diff -Nru fontmatrix-0.6.0+svn20100107/src/activationwidgetitem.h fontmatrix-0.6.0+svn20110930/src/activationwidgetitem.h --- fontmatrix-0.6.0+svn20100107/src/activationwidgetitem.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/activationwidgetitem.h 2010-08-14 08:00:49.000000000 +0000 @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef ACTIVATIONWIDGETITEM_H +#define ACTIVATIONWIDGETITEM_H + +#include + +namespace Ui { + class ActivationWidgetItem; +} + +class ActivationWidgetItem : public QWidget +{ + Q_OBJECT + +public: + explicit ActivationWidgetItem(const QString& fontID, QWidget *parent = 0); + ~ActivationWidgetItem(); + + void changeState(bool s); + +protected: + void changeEvent(QEvent *e); + +private: + const QString fileName; + Ui::ActivationWidgetItem *ui; + +private slots: + void activate(bool a); + +signals: + void fontStateChanged(); +}; + +#endif // ACTIVATIONWIDGETITEM_H diff -Nru fontmatrix-0.6.0+svn20100107/src/activationwidgetitem.ui fontmatrix-0.6.0+svn20110930/src/activationwidgetitem.ui --- fontmatrix-0.6.0+svn20100107/src/activationwidgetitem.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/activationwidgetitem.ui 2010-08-14 08:00:49.000000000 +0000 @@ -0,0 +1,62 @@ + + + ActivationWidgetItem + + + + 0 + 0 + 458 + 66 + + + + Form + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 2 + + + 0 + + + + + + 75 + true + + + + StyleName + + + + + + + Activated + + + + + + + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/activationwidget.ui fontmatrix-0.6.0+svn20110930/src/activationwidget.ui --- fontmatrix-0.6.0+svn20100107/src/activationwidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/activationwidget.ui 2010-08-14 08:00:49.000000000 +0000 @@ -0,0 +1,95 @@ + + + ActivationWidget + + + + 0 + 0 + 465 + 364 + + + + Form + + + + + + Activate All + + + + + + + Deactivate All + + + + + + + Qt::Horizontal + + + + 147 + 20 + + + + + + + + true + + + + + 0 + 0 + 451 + 320 + + + + + + + 0 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + FloatingWidget + QWidget +
floatingwidget.h
+ 1 +
+
+ + +
diff -Nru fontmatrix-0.6.0+svn20100107/src/application.qrc fontmatrix-0.6.0+svn20110930/src/application.qrc --- fontmatrix-0.6.0+svn20100107/src/application.qrc 2009-06-17 05:23:22.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/application.qrc 2011-02-08 14:43:38.000000000 +0000 @@ -1,66 +1,59 @@ - - icons/action-copy-char-24.png - graphic-resources/welcome.png - icons/application-fontmatrix_128.png - icons/fontmatrix-systray.png - icons/icon_warning-32.png - graphic-resources/splashscreen.png - graphic-resources/font-info.png - graphic-resources/font-glyph.png - graphic-resources/font-playground.png - graphic-resources/font-tag.png - graphic-resources/font-compare.png - graphic-resources/fontmatrix-tag-graphic.png - graphic-resources/fontmatrix-zoom.png - graphic-resources/font-class.png - graphic-resources/fontmatrix-AA.png - graphic-resources/fontmatrix-tagseteditor.png - graphic-resources/fontmatrix-tagseteditor-icon.png - graphic-resources/fontmatrix-fontbookexport-icon.png - graphic-resources/fontmatrix-import-icon.png - icons/font_truetype16.png - icons/font_type116.png - graphic-resources/font-sampletext2.png - icons/font_otf16.png - icons/action-empty-128.png - - - icons/help/document-print.png - icons/help/exit.png - icons/help/go-bottom.png - icons/help/go-down.png - icons/help/go-first.png - icons/help/go-home.png - icons/help/go-last.png - icons/help/go-next.png - icons/help/go-previous.png - icons/help/go-top.png - icons/help/go-up.png - icons/help/help-browser.png - - - messages/about.html - messages/about_people.html - - - messages/about_de.html - - - messages/about_fi.html - - - messages/about_fr.html - - - messages/about_uk.html - - - langs/latn.dict - langs/latn.match - - - langs/deva.dict - langs/deva.match - + + icons/action-copy-char-24.png + graphic-resources/welcome.png + icons/application-fontmatrix_128.png + icons/fontmatrix-systray.png + icons/icon_warning-32.png + graphic-resources/splashscreen.png + graphic-resources/font-info.png + graphic-resources/font-glyph.png + graphic-resources/font-playground.png + graphic-resources/font-tag.png + graphic-resources/font-compare.png + graphic-resources/fontmatrix-tag-graphic.png + graphic-resources/fontmatrix-zoom.png + graphic-resources/font-class.png + graphic-resources/fontmatrix-AA.png + graphic-resources/fontmatrix-tagseteditor.png + graphic-resources/fontmatrix-tagseteditor-icon.png + graphic-resources/fontmatrix-fontbookexport-icon.png + graphic-resources/fontmatrix-import-icon.png + icons/font_truetype16.png + icons/font_type116.png + graphic-resources/font-sampletext2.png + icons/font_otf16.png + icons/action-empty-128.png + graphic-resources/filter-and.png + graphic-resources/filter-remove.png + graphic-resources/filter.png + + + icons/help/document-print.png + icons/help/exit.png + icons/help/go-bottom.png + icons/help/go-down.png + icons/help/go-first.png + icons/help/go-home.png + icons/help/go-last.png + icons/help/go-next.png + icons/help/go-previous.png + icons/help/go-top.png + icons/help/go-up.png + icons/help/help-browser.png + + + messages/about.html + messages/about_people.html + messages/about_de.html + messages/about_fi.html + messages/about_fr.html + messages/about_uk.html + + + langs/latn.dict + langs/latn.match + langs/deva.dict + langs/deva.match + diff -Nru fontmatrix-0.6.0+svn20100107/src/browserwidget.cpp fontmatrix-0.6.0+svn20110930/src/browserwidget.cpp --- fontmatrix-0.6.0+svn20100107/src/browserwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/browserwidget.cpp 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,392 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "browserwidget.h" +#include "ui_browserwidget.h" + +#include "fmfontdb.h" +#include "fontitem.h" +#include "fminfodisplay.h" +#include "floatingwidgetsregister.h" +#include "samplewidget.h" +#include "chartwidget.h" +#include "typotek.h" + +#include +#include +#include +#include +#include + +BrowserWidget::BrowserWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::BrowserWidget) +{ + ui->setupUi(this); + + ui->infoButton->setEnabled(false); + ui->sampleButton->setEnabled(false); + ui->chartButton->setEnabled(false); + + folderViewContextMenu = 0; + currentPage = BROWSER_VIEW_SAMPLE; + sample = chart = 0; + ffilter << "*.otf" << "*.ttf" << "*.pfb"; + theDirModel = new QDirModel(ffilter, QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot, QDir::DirsFirst | QDir::Name); + theDirModel->setLazyChildCount(true); + ui->browserView->setModel(theDirModel); + ui->browserView->hideColumn(1); + ui->browserView->hideColumn(2); + ui->browserView->hideColumn(3); + ui->browserView->setContextMenuPolicy(Qt::CustomContextMenu); + + QSettings settings; + QString lastUsedDir = settings.value("Places/LastUsedFolder", QDir::homePath()).toString(); + QDir d(lastUsedDir); + if (!d.exists()) + lastUsedDir = QDir::homePath(); + QModelIndex luIdx(theDirModel->index(lastUsedDir, 0)); + ui->browserView->setCurrentIndex(luIdx); + QModelIndexList hierarchy; + while(luIdx.isValid()) + { + hierarchy.prepend(luIdx); + luIdx = luIdx.parent(); + } + foreach(QModelIndex idx, hierarchy) + ui->browserView->expand(idx); + + dirWatcher = new QFileSystemWatcher(this); + initWatcher(theDirModel->index(0,0)); + + connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(slotShowInfo())); + connect(ui->sampleButton, SIGNAL(clicked()), this, SLOT(slotShowSample())); + connect(ui->chartButton, SIGNAL(clicked()), this, SLOT(slotShowChart())); + + connect(ui->importButton, SIGNAL(clicked()), this, SLOT(slotImport())); + + connect(ui->browserView, SIGNAL(activated( const QModelIndex& )), this, SLOT(slotFolderItemclicked(QModelIndex))); + connect(ui->browserView, SIGNAL(clicked( const QModelIndex& )), this, SLOT(slotFolderItemclicked(QModelIndex))); + connect(ui->browserView,SIGNAL(pressed( const QModelIndex& )),this,SLOT(slotFolderPressed(QModelIndex))); + + connect(ui->browserView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotFolderViewContextMenu(const QPoint &))); + + connect(dirWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(slotFolderRefresh(QString))); + +} + +BrowserWidget::~BrowserWidget() +{ + delete ui; +} + +void BrowserWidget::initWatcher(QModelIndex parent) +{ + // qDebug()<<"initWatcher"<filePath(parent); + for(int fIdx(0); fIdx < theDirModel->rowCount(parent); ++fIdx) + { + QModelIndex mIdx(theDirModel->index(fIdx,0, parent)); + // qDebug()<<"\t"<filePath(mIdx)<isExpanded(mIdx); + if(ui->browserView->isExpanded(mIdx)) + { + QString fp(theDirModel->filePath(mIdx)); + dirWatcher->addPath(fp); + qDebug()<<"***Watch"<filePath(mIdx); + dirWatcher->addPath(theDirModel->filePath(mIdx)); +} + +void BrowserWidget::slotFolderItemclicked(QModelIndex mIdx) +{ + if(curVariant.isEmpty()) + { + ui->infoButton->setEnabled(true); + ui->sampleButton->setEnabled(true); + ui->chartButton->setEnabled(true); + } + QString path(theDirModel->data(mIdx,QDirModel::FilePathRole).toString()); + QFileInfo pf(path); + if(!pf.isDir()) + { + if(FMFontDb::DB()->insertTemporaryFont(path)) + { +// emit folderSelectFont(pf.absoluteFilePath()); + QString fid(pf.absoluteFilePath()); + if(fid != curVariant) + { + if(chart != 0) + uniBlock = reinterpret_cast(chart)->currentBlock(); + delete sample; + delete chart; + sample = chart = 0; + curVariant = fid; +// currentIndex = index.row(); + switch(currentPage) + { + case BROWSER_VIEW_INFO: slotShowInfo(); + break; + case BROWSER_VIEW_SAMPLE: slotShowSample(); + break; + case BROWSER_VIEW_CHART: slotShowChart(); + break; + default: + break; + } + +// emit fontSelected(curVariant); + } + } + } + settingsDir(path); +} + +void BrowserWidget::slotFolderPressed(QModelIndex mIdx) +{ + currentFIndex = mIdx; +} + +void BrowserWidget::slotFolderRefresh(const QString &dirPath) +{ + if(ui->browserView->isVisible()) + { + qDebug()<<"Refresh"<refresh(theDirModel->index(dirPath, 0 )); + } +} + +void BrowserWidget::slotFolderRemoveFromWatcher(QModelIndex mIdx) +{ + qDebug()<<"Remove from watcher"<filePath(mIdx); + dirWatcher->removePath(theDirModel->filePath(mIdx)); +} + +void BrowserWidget::settingsDir(const QString &path) +{ + static QString s; + if (s == path) + return; + + QFileInfo fi(path); + QString dirPath = fi.absoluteFilePath(); + if (fi.isFile()) + dirPath = fi.absoluteDir().absolutePath(); + + QSettings settings; + settings.setValue("Places/LastUsedFolder", dirPath); + + s = path; +} + + +void BrowserWidget::slotShowInfo() +{ + FMInfoDisplay fid(FMFontDb::DB()->Font(curVariant)); + ui->webView->setContent(fid.getHtml().toUtf8(), "application/xhtml+xml"); + ui->displayStack->setCurrentIndex(BROWSER_VIEW_INFO); + currentPage = BROWSER_VIEW_INFO; + updateButtons(); +} + +void BrowserWidget::slotShowChart() +{ + FloatingWidget * fw(FloatingWidgetsRegister::Widget(curVariant, ChartWidget::Name)); + if(fw == 0) + { + if(0 == chart) + { + ChartWidget *cw(new ChartWidget(curVariant, uniBlock, ui->pageChart)); + ui->displayStack->insertWidget(BROWSER_VIEW_CHART, cw); + chart = cw; + connect(chart, SIGNAL(detached()), this, SLOT(slotDetachChart())); + } + ui->displayStack->setCurrentWidget(chart); + } + else + { + fw->show(); + } + currentPage = BROWSER_VIEW_CHART; + updateButtons(); +} + + +void BrowserWidget::slotShowSample() +{ + FloatingWidget * fw(FloatingWidgetsRegister::Widget(curVariant, SampleWidget::Name)); + if(fw == 0) + { + if(0 == sample) + { + SampleWidget *sw(new SampleWidget(curVariant, ui->pageSample)); + ui->displayStack->insertWidget(BROWSER_VIEW_SAMPLE, sw); + sample = sw; + connect(sample, SIGNAL(detached()), this, SLOT(slotDetachSample())); + } + ui->displayStack->setCurrentWidget(sample); + } + else + { + fw->show(); + } + currentPage = BROWSER_VIEW_SAMPLE; + updateButtons(); +} + +void BrowserWidget::slotDetachChart() +{ + disconnect(chart, SIGNAL(detached()), this, SLOT(slotDetachChart())); + chart = 0; + slotShowInfo(); +} + +void BrowserWidget::slotDetachSample() +{ + disconnect(sample, SIGNAL(detached()), this, SLOT(slotDetachSample())); + sample = 0; + slotShowInfo(); +} + +void BrowserWidget::slotFolderViewContextMenu(const QPoint &p) +{ + qDebug()<<"P"<(ui->browserView->model()); + if (!dm) + return; + + QModelIndex mi = ui->browserView->currentIndex(); + if (!mi.isValid()) + return; + + slotFolderItemclicked(mi); // make sure the font in question is loaded + // with a direct right click it would crash without this + + if (!folderViewContextMenu) + folderViewContextMenu = new FolderViewMenu(); + + folderViewContextMenu->exec(dm->fileInfo(mi), mapToGlobal(p)); +} + +void BrowserWidget::updateButtons() +{ + static QList buttons; + if(buttons.isEmpty()) + { + buttons << ui->sampleButton + << ui->infoButton + << ui->chartButton; + foreach(QToolButton * b, buttons) + { + b->setCheckable(true); + } + } + foreach(QToolButton * b, buttons) + { + b->setChecked(false); + } + switch(currentPage) + { + case BROWSER_VIEW_SAMPLE: ui->sampleButton->setChecked(true); + break; + case BROWSER_VIEW_CHART: ui->chartButton->setChecked(true); + break; + case BROWSER_VIEW_INFO : ui->infoButton->setChecked(true); + break; + default:break; + } +} + +void BrowserWidget::slotImport() +{ + if(!curVariant.isEmpty()) + typotek::getInstance()->open(curVariant, false, true); +} + +FolderViewMenu::FolderViewMenu() : QMenu() +{ + dirAction = new QAction(tr("Import Directory"), 0); + dirRecursiveAction = new QAction(tr("Import recursively"), 0); + fileAction = new QAction(tr("Import File"), 0); + + addAction(dirAction); + addAction(dirRecursiveAction); + addAction(fileAction); + + connect(dirAction, SIGNAL(triggered()), this, SLOT(slotImportDir())); + connect(dirRecursiveAction, SIGNAL(triggered()), this, SLOT(slotImportDirRecursively())); + connect(fileAction, SIGNAL(triggered()), this, SLOT(slotImportFile())); +} + +void FolderViewMenu::exec(const QFileInfo &fi, const QPoint &p) +{ + if (fi.isDir()) { + dirAction->setEnabled(true); + dirRecursiveAction->setEnabled(true); + fileAction->setEnabled(false); + } else if (fi.isFile()) { + dirAction->setEnabled(false); + dirRecursiveAction->setEnabled(false); + fileAction->setEnabled(true); + } else + return; // not a file or a directory + + selectedFileOrDir = fi; + + QMenu::exec(p); +} + + +void FolderViewMenu::slotImportDir() +{ +// QDir dir(selectedFileOrDir.absoluteFilePath()); +// QStringList ffilter; +// ffilter << "*.otf" << "*.ttf" << "*.pfb"; +// QStringList fontList = dir.entryList(ffilter); +// if (fontList.count() < 1) +// return; +// QString lastItem = fontList.at(fontList.count() - 1); +// fontList.removeAt(fontList.count() - 1); +// foreach(QString tmpFontPath, fontList) { +// QString absPath = dir.absolutePath() + "/" + tmpFontPath; +// typotek::getInstance()->open(absPath, false, true); +// } + typotek::getInstance()->open(selectedFileOrDir.absoluteFilePath(),false, true); // import the last font with the announce flag set to true +} + +void FolderViewMenu::slotImportDirRecursively() +{ + typotek::getInstance()->open(selectedFileOrDir.absoluteFilePath()); +} + +void FolderViewMenu::slotImportFile() +{ + typotek::getInstance()->open(selectedFileOrDir.absoluteFilePath()); +} + +FolderViewMenu::~FolderViewMenu() +{ + +} diff -Nru fontmatrix-0.6.0+svn20100107/src/browserwidget.h fontmatrix-0.6.0+svn20110930/src/browserwidget.h --- fontmatrix-0.6.0+svn20100107/src/browserwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/browserwidget.h 2010-09-17 13:49:00.000000000 +0000 @@ -0,0 +1,123 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef BROWSERWIDGET_H +#define BROWSERWIDGET_H + +#include +#include +#include +#include +#include +#include + +#define BROWSER_VIEW_INFO 0 +#define BROWSER_VIEW_SAMPLE 1 +#define BROWSER_VIEW_CHART 2 + +class QDirModel; +class QFileSystemWatcher; +class FloatingWidget; +class FolderViewMenu; + +namespace Ui { + class BrowserWidget; +} + +class BrowserWidget : public QWidget +{ + Q_OBJECT + +public: + explicit BrowserWidget(QWidget *parent = 0); + ~BrowserWidget(); + +private: + Ui::BrowserWidget *ui; + + QString curVariant; + + FloatingWidget *sample; + FloatingWidget *chart; + FloatingWidget *activation; + + unsigned int currentIndex; + unsigned int currentPage; + QString uniBlock; + + QDirModel *theDirModel; + QStringList ffilter; + QFileSystemWatcher *dirWatcher; + QModelIndex currentFIndex; + + FolderViewMenu *folderViewContextMenu; + + void initWatcher(QModelIndex parent); + void settingsDir(const QString& path); + + void updateButtons(); + +private slots: + void slotFolderItemclicked(QModelIndex mIdx); + void slotFolderPressed(QModelIndex mIdx); + void slotFolderAddToWatcher(QModelIndex mIdx); + void slotFolderRemoveFromWatcher(QModelIndex mIdx); + void slotFolderRefresh(const QString& dirPath); + + void slotShowInfo(); + void slotShowSample(); + void slotShowChart(); + + void slotImport(); + + void slotDetachChart(); + void slotDetachSample(); + + void slotFolderViewContextMenu(const QPoint&); + +signals: + void folderSelectFont(QString); +}; + +class FolderViewMenu : public QMenu +{ + Q_OBJECT +public: + FolderViewMenu(); + ~FolderViewMenu(); + + void exec(const QFileInfo &fi, const QPoint &p); + +private: + QAction *dirAction; + QAction *dirRecursiveAction; + QAction *fileAction; + + QFileInfo selectedFileOrDir; + +private slots: + void slotImportDir(); + void slotImportDirRecursively(); + void slotImportFile(); + +}; + + +#endif // BROWSERWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/browserwidget.ui fontmatrix-0.6.0+svn20110930/src/browserwidget.ui --- fontmatrix-0.6.0+svn20100107/src/browserwidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/browserwidget.ui 2010-09-17 10:57:10.000000000 +0000 @@ -0,0 +1,144 @@ + + + BrowserWidget + + + + 0 + 0 + 668 + 603 + + + + Form + + + + + + Qt::Horizontal + + + + + 0 + 0 + + + + + + + 2 + 0 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Info + + + true + + + + + + + Import + + + false + + + + + + + Chart + + + true + + + + + + + Sample + + + true + + + + + + + + + + + + 0 + + + + + + about:blank + + + + + + + + + + + + + + + + + + + QWebView + QWidget +
QtWebKit/QWebView
+ 1 +
+
+ + +
diff -Nru fontmatrix-0.6.0+svn20100107/src/chartwidget.cpp fontmatrix-0.6.0+svn20110930/src/chartwidget.cpp --- fontmatrix-0.6.0+svn20100107/src/chartwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/chartwidget.cpp 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,558 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "chartwidget.h" +#include "ui_chartwidget.h" + +#include "fmglyphhighlight.h" +#include "fontitem.h" +#include "fmfontdb.h" +#include "fmuniblocks.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const QString ChartWidget::Name = QObject::tr("Chart"); + +ChartWidget::ChartWidget(const QString& fid, const QString& block, QWidget *parent) : + FloatingWidget(fid, Name, parent), + ui(new Ui::ChartWidget), + fontIdentifier(fid) +{ + FontItem * theVeryFont(FMFontDb::DB()->Font(fontIdentifier)); + ui->setupUi(this); + ui->uniLine->setEnabled(false); + abcScene = new QGraphicsScene; + ui->abcView->setScene ( abcScene ); + ui->abcView->setRenderHint ( QPainter::Antialiasing, true ); + QStringListModel* cslModel(new QStringListModel); + cslModel->setStringList(theVeryFont->getNames()); + QCompleter* cslCompleter(new QCompleter(ui->charSearchLine)); + cslCompleter->setModel(cslModel); + ui->charSearchLine->setCompleter(cslCompleter); + unMapGlyphName = tr("Un-Mapped Glyphs"); + allMappedGlyphName = tr("View all mapped glyphs"); + uRangeIsNotEmpty = false; + fillUniPlanesCombo(theVeryFont); + curGlyph = 0; + fancyGlyphInUse = -1; + + if(!block.isEmpty()) + selectBlock(block); + + createConnections(); +} + +ChartWidget::~ChartWidget() +{ + // As we're about to delete the scene, we must tell FontItem to clear its cache + FMFontDb::DB()->Font(fontIdentifier)->deRenderAll(); + removeConnections(); + delete ui; + delete abcScene; + delete curGlyph; +} + +void ChartWidget::createConnections() +{ + connect ( ui->abcView,SIGNAL ( pleaseShowSelected() ),this,SLOT ( slotShowOneGlyph() ) ); + connect ( ui->abcView,SIGNAL ( pleaseShowAll() ),this,SLOT ( slotShowAllGlyph() ) ); + connect ( ui->abcView,SIGNAL ( refit ( int ) ),this,SLOT ( slotAdjustGlyphView ( int ) ) ); + connect ( ui->abcView, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateGView())); + connect ( ui->abcView, SIGNAL(pleaseUpdateSingle()), this, SLOT(slotUpdateGViewSingle())); + connect ( ui->uniPlaneCombo,SIGNAL ( activated ( int ) ),this,SLOT ( slotPlaneSelected ( int ) ) ); + connect ( ui->clipboardCheck, SIGNAL (toggled ( bool )),this,SLOT(slotShowULine(bool))); + connect ( ui->charSearchLine, SIGNAL(returnPressed()), this, SLOT(slotSearchCharName())); + + connect(ui->toolbar, SIGNAL(Close()), this, SLOT(close())); + connect(ui->toolbar, SIGNAL(Hide()), this, SLOT(hide())); + connect(ui->toolbar, SIGNAL(Print()), this, SLOT(slotPrint())); + connect(ui->toolbar, SIGNAL(Detach()), this, SLOT(ddetach())); +} + +void ChartWidget::removeConnections() +{ + disconnect ( ui->abcView,SIGNAL ( pleaseShowSelected() ),this,SLOT ( slotShowOneGlyph() ) ); + disconnect ( ui->abcView,SIGNAL ( pleaseShowAll() ),this,SLOT ( slotShowAllGlyph() ) ); + disconnect ( ui->abcView,SIGNAL ( refit ( int ) ),this,SLOT ( slotAdjustGlyphView ( int ) ) ); + disconnect ( ui->abcView, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateGView())); + disconnect ( ui->abcView, SIGNAL(pleaseUpdateSingle()), this, SLOT(slotUpdateGViewSingle())); + disconnect ( ui->uniPlaneCombo,SIGNAL ( activated ( int ) ),this,SLOT ( slotPlaneSelected ( int ) ) ); + disconnect ( ui->clipboardCheck, SIGNAL (toggled ( bool )),this,SLOT(slotShowULine(bool))); + disconnect ( ui->charSearchLine, SIGNAL(returnPressed()), this, SLOT(slotSearchCharName())); + + disconnect(ui->toolbar, SIGNAL(Close()), this, SLOT(close())); + disconnect(ui->toolbar, SIGNAL(Hide()), this, SLOT(hide())); + disconnect(ui->toolbar, SIGNAL(Print()), this, SLOT(slotPrint())); +} + +void ChartWidget::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +QString ChartWidget::currentBlock() +{ + return ui->uniPlaneCombo->currentText(); +} + +bool ChartWidget::selectBlock(const QString &uname) +{ + int idx(ui->uniPlaneCombo->findText(uname)); + if(idx < 0) + idx = 0; + ui->uniPlaneCombo->setCurrentIndex(idx); + FontItem * theVeryFont(FMFontDb::DB()->Font(fontIdentifier)); + if(theVeryFont && ui->abcView->lock()) + { + QPair uniPair; + if(uname == unMapGlyphName) + uniPair = qMakePair(-1,100); + else if(uname == allMappedGlyphName) + uniPair = qMakePair(0, 0x10FFFF); + else + uniPair = FMUniBlocks::interval( uname ); + + int coverage = theVeryFont->countCoverage ( uniPair.first, uniPair.second ); + int interval = uniPair.second - uniPair.first; + coverage = coverage * 100 / ( interval + 1 );// against /0 exception + + QString statstring(tr("Block (%1):").arg( QString::number ( coverage ) + "\%")); + ui->unicodeCoverageStat->setText ( statstring ); + + theVeryFont->renderAll ( abcScene , uniPair.first, uniPair.second ); + ui->abcView->unlock(); + } +} + +void ChartWidget::slotShowOneGlyph() +{ + // qDebug() <<"slotShowOneGlyph()"<selectedItems().count(); + if ( abcScene->selectedItems().isEmpty() ) + return; + if ( ui->abcView->lock() ) + { + QGraphicsRectItem* curGlyph = reinterpret_cast ( abcScene->selectedItems().first() ); + curGlyph->setSelected ( false ); + if ( fancyGlyphInUse < 0 ) + { + if ( curGlyph->data ( 3 ).toInt() > 0 ) // Is a codepoint + { + fancyGlyphData = curGlyph->data ( 3 ).toInt(); + if(ui->clipboardCheck->isChecked()) + { + new FMGlyphHighlight(abcScene, curGlyph->rect()); + QString simpleC; + simpleC += QChar(fancyGlyphData); + QApplication::clipboard()->setText(simpleC, QClipboard::Clipboard); + ui->uniLine->setText(ui->uniLine->text() + simpleC); + } + else + fancyGlyphInUse = FMFontDb::DB()->Font(fontIdentifier)->showFancyGlyph ( ui->abcView, fancyGlyphData ); + } + else // Is a glyph index + { + fancyGlyphData = curGlyph->data ( 2 ).toInt(); + fancyGlyphInUse = FMFontDb::DB()->Font(fontIdentifier)->showFancyGlyph ( ui->abcView, fancyGlyphData , true ); + } + if ( fancyGlyphInUse < 0 ) + { + ui->abcView->unlock(); + return; + } + ui->abcView->setState ( FMGlyphsView::SingleView ); + } + ui->abcView->unlock(); + } + else + qDebug("cannot lock ABCview"); +} + + +void ChartWidget::slotShowAllGlyph() +{ + // qDebug() <<"slotShowAllGlyph()"; + if ( fancyGlyphInUse < 0 ) + return; + if ( ui->abcView->lock() ) + { + // qDebug()<<"View Locked"; + FMFontDb::DB()->Font(fontIdentifier)->hideFancyGlyph ( fancyGlyphInUse ); + fancyGlyphInUse = -1; + ui->abcView->setState ( FMGlyphsView::AllView ); + + ui->abcView->unlock(); + } + // qDebug() <<"ENDOF slotShowAllGlyph()"; +} + +void ChartWidget::slotUpdateGView() +{ + FontItem * theVeryFont(FMFontDb::DB()->Font(fontIdentifier)); + if(theVeryFont && ui->abcView->lock()) + { + QPair uniPair; + QString curBlockText(ui->uniPlaneCombo->currentText()); + if(curBlockText == unMapGlyphName) + uniPair = qMakePair(-1,100); + else if(curBlockText == allMappedGlyphName) + uniPair = qMakePair(0, 0x10FFFF); + else + uniPair = FMUniBlocks::interval( curBlockText ); + + int coverage = theVeryFont->countCoverage ( uniPair.first, uniPair.second ); + int interval = uniPair.second - uniPair.first; + coverage = coverage * 100 / ( interval + 1 );// against /0 exception + + QString statstring(tr("Block (%1):").arg( QString::number ( coverage ) + "\%")); + ui->unicodeCoverageStat->setText ( statstring ); + + theVeryFont->renderAll ( abcScene , uniPair.first, uniPair.second ); + ui->abcView->unlock(); + } +} + + +void ChartWidget::slotAdjustGlyphView ( int width ) +{ +// if ( !theVeryFont ) +// return; + + // theVeryFont->adjustGlyphsPerRow ( width ); + // slotView ( true ); +} + + + + +void ChartWidget::slotUpdateGViewSingle() +{ + FontItem * theVeryFont(FMFontDb::DB()->Font(fontIdentifier)); + if ( theVeryFont && ui->abcView->lock()) + { + // qDebug() <<"1.FGI"<hideFancyGlyph ( fancyGlyphInUse ); + if ( fancyGlyphData > 0 ) // Is a codepoint + { + fancyGlyphInUse = theVeryFont->showFancyGlyph ( ui->abcView, fancyGlyphData ); + // qDebug() <<"2.FGI"<showFancyGlyph ( ui->abcView, fancyGlyphData , true ); + // qDebug() <<"3.FGI"<abcView->unlock(); + + } + +} + + +void ChartWidget::slotPlaneSelected ( int i ) +{ + // qDebug()<<"slotPlaneSelected"<currentIndex(); + FontItem * theVeryFont(FMFontDb::DB()->Font(fontIdentifier)); + if(i != ui->uniPlaneCombo->currentIndex()) + ui->uniPlaneCombo->setCurrentIndex(i); + + bool stickState = uRangeIsNotEmpty; + uRangeIsNotEmpty = true; + slotShowAllGlyph(); + slotUpdateGView(); + if( (stickState == false) && theVeryFont) + { + fillUniPlanesCombo(theVeryFont); + } + ui->abcView->verticalScrollBar()->setValue ( 0 ); +} + +void ChartWidget::slotShowULine(bool checked) +{ + if(checked) + { + ui->uniLine->setText(""); + ui->uniLine->setEnabled(true); + } + else + { + ui->uniLine->setEnabled(false); + } +} + +void ChartWidget::slotSearchCharName() +{ + FontItem * theVeryFont(FMFontDb::DB()->Font(fontIdentifier)); + if(!theVeryFont) + return; + QString name(ui->charSearchLine->text()); + unsigned short cc(0); + bool searchCodepoint(false); + if(name.startsWith("U+") + || name.startsWith("u+") + || name.startsWith("+")) + { + QString vString(name.mid(name.indexOf("+"))); + bool ok(false); + cc = vString.toInt(&ok, 16); + if(!ok) + cc = 0; + searchCodepoint = true; + } + else + cc = theVeryFont->getNamedChar(name); + // qDebug()<<"CS"<clear(); + return; + } + + foreach(const QString& key, FMUniBlocks::blocks() ) + { + QPair p(FMUniBlocks::interval(key)); + if((cc >= p.first) + && (cc <= p.second)) + { + int idx(ui->uniPlaneCombo->findText(key)); + slotPlaneSelected(idx); + int sv(0); + bool first(true); + do{ + if(first) + first = false; + else + { + ui->abcView->verticalScrollBar()->setValue(sv + ui->abcView->height()); + sv = ui->abcView->verticalScrollBar()->value(); + } + foreach(QGraphicsItem* sit, abcScene->items()) + { + if((sit->data(1).toString() == "select") + && (sit->data(3).toInt() == cc)) + { + QGraphicsRectItem* ms(reinterpret_cast (sit)); + if(ms) + { + QRectF rf(ms->rect()); + new FMGlyphHighlight(abcScene, rf, 2000, 160); + } + else + qDebug()<<"ERROR: An select item not being a QRect?"; + return; + + } + } + }while(sv < ui->abcView->verticalScrollBar()->maximum()); + return; + } + } + + // if user was looking for a name and we did not find it in + // Unicode blocks, it must be unmapped. + if(!searchCodepoint) + { + int idx(ui->uniPlaneCombo->findText(unMapGlyphName)); + slotPlaneSelected(idx); + int sv(0); + bool first(true); + do{ + if(first) + first = false; + else + { + ui->abcView->verticalScrollBar()->setValue(sv + ui->abcView->height()); + sv = ui->abcView->verticalScrollBar()->value(); + } + foreach(QGraphicsItem* sit, abcScene->items()) + { + if((sit->data(1).toString() == "select") + && (sit->data(3).toInt() == cc)) + { + QGraphicsRectItem* ms(reinterpret_cast (sit)); + if(ms) + { + QRectF rf(ms->rect()); + new FMGlyphHighlight(abcScene, rf, 2000, 160); + } + else + qDebug()<<"ERROR: An select item not being a QRect?"; + return; + + } + } + }while(sv < ui->abcView->verticalScrollBar()->maximum()); + return; + } + +} + + +void ChartWidget::fillUniPlanesCombo ( FontItem* item ) +{ + QString stickyRange(ui->uniPlaneCombo->currentText()); + // qDebug()<<"STiCKyRaNGe :: "<uniPlaneCombo->clear(); + + int begin(0); + int end(0); + QString lastBlock(FMUniBlocks::lastBlock(begin, end)); + QString block(FMUniBlocks::firstBlock( begin, end )); + bool first(true); + do + { + if(first) + first = false; + else + block = FMUniBlocks::nextBlock(begin, end); + + int codecount ( item->countCoverage ( begin , end ) ); + if ( codecount > 0 ) + { + // qDebug() << p << codecount; + ui->uniPlaneCombo->addItem ( block ); + if(block == stickyRange) + { + stickyIndex = ui->uniPlaneCombo->count() - 1; + uRangeIsNotEmpty = true; + } + } + else + { + if(block == stickyRange) + { + stickyIndex = ui->uniPlaneCombo->count() - 1; + uRangeIsNotEmpty = true; + } + } + + } while(lastBlock != block); + if(item->countCoverage ( -1 , 100 ) > 0) + { + ui->uniPlaneCombo->addItem( unMapGlyphName ); + if(unMapGlyphName == stickyRange) + { + stickyIndex = ui->uniPlaneCombo->count() - 1; + uRangeIsNotEmpty = true; + } + } + ui->uniPlaneCombo->addItem( allMappedGlyphName ); + if(allMappedGlyphName == stickyRange) + { + stickyIndex = ui->uniPlaneCombo->count() - 1; + uRangeIsNotEmpty = true; + } + + ui->uniPlaneCombo->setCurrentIndex ( stickyIndex ); + +} + +void ChartWidget::slotPrint() +{ + FontItem *font(FMFontDb::DB()->Font(fontIdentifier)); + if(font == 0) + return; + + if(printer == 0) + printer = new QPrinter(QPrinter::HighResolution); + if(printDialog == 0) + printDialog = new QPrintDialog(printer, this); + + printDialog->setWindowTitle("Fontmatrix - " + tr("Print Chart") +" - " + font->fancyName() ); + + + printDialog->open(this, SLOT(slotDoPrinting())); + +} + +void ChartWidget::slotDoPrinting() +{ + FontItem *font(FMFontDb::DB()->Font(fontIdentifier)); + printer->setFullPage ( true ); + QPainter aPainter ( printer ); + + + double pWidth(printer->paperRect().width()); + double pHeight(printer->paperRect().height()); + double pFactor(printer->resolution() ); + + qDebug()<<"Paper :"<"< lgit(pScene.items()); + foreach(QGraphicsItem* git, lgit) + { + pScene.removeItem(git); + delete git; + } + + int controlN(maxCharcode - beginCharcode); + int stopAtCode( font->renderChart(&pScene, beginCharcode, maxCharcode, sourceR.width(),sourceR.height() ) ); + qDebug()<< "Control"<newPage(); + } + aPainter.drawText(targetR.bottomLeft(), font->fancyName()+"[U"+QString::number(beginCharcode ,16).toUpper()+", U"+QString::number(stopAtCode ,16).toUpper()+"]"); + pScene.render(&aPainter,targetR, sourceR, Qt::KeepAspectRatio); + + beginCharcode = stopAtCode; + } + +} diff -Nru fontmatrix-0.6.0+svn20100107/src/chartwidget.h fontmatrix-0.6.0+svn20110930/src/chartwidget.h --- fontmatrix-0.6.0+svn20100107/src/chartwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/chartwidget.h 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef CHARTWIDGET_H +#define CHARTWIDGET_H + +#include "floatingwidget.h" + +class QGraphicsScene; +class FontItem; +class QGraphicsRectItem; + +namespace Ui { + class ChartWidget; +} + +class ChartWidget : public FloatingWidget +{ + Q_OBJECT + +public: + static const QString Name; + explicit ChartWidget(const QString& fid, const QString& block, QWidget *parent = 0); + ~ChartWidget(); + + QString currentBlock(); + bool selectBlock(const QString& uname); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::ChartWidget *ui; + const QString fontIdentifier; + + QGraphicsScene *abcScene; + int fancyGlyphInUse; + int fancyGlyphData; + QString unMapGlyphName; + QString allMappedGlyphName; + bool uRangeIsNotEmpty; + QGraphicsRectItem *curGlyph; + + + void createConnections(); + void removeConnections(); + void fillUniPlanesCombo(FontItem* item); + +private slots: + void slotShowOneGlyph(); + void slotShowAllGlyph(); + void slotAdjustGlyphView(int width); + void slotUpdateGView(); + void slotUpdateGViewSingle(); + void slotPlaneSelected(int); + void slotShowULine(bool); + void slotSearchCharName(); + + void slotPrint(); + void slotDoPrinting(); + +}; + +#endif // CHARTWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/chartwidget.ui fontmatrix-0.6.0+svn20110930/src/chartwidget.ui --- fontmatrix-0.6.0+svn20100107/src/chartwidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/chartwidget.ui 2010-06-25 09:14:56.000000000 +0000 @@ -0,0 +1,189 @@ + + + ChartWidget + + + + 0 + 0 + 704 + 587 + + + + Form + + + + 4 + + + 2 + + + + + + + + 0 + 0 + + + + Coverage of Unicode Interval + + + Block: + + + 2 + + + uniPlaneCombo + + + + + + + + 0 + 0 + + + + true + + + QComboBox::AdjustToContents + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Search: + + + charSearchLine + + + + + + + Search a character by its codepoint (expressed in hexadecimal +and prefixed with "U+", "u+" or "+") or a glyph by its name. +Press enter after editing to run the search. + + + + + + + + + + + + + + + + 0 + 2 + + + + Qt::NoFocus + + + Clicking on a glyph will show details about it + + + QFrame::NoFrame + + + Qt::IntersectsItemBoundingRect + + + + + + + + + + 0 + 0 + + + + Set Mode "Copy Character to Clipboard" + + + Copy Mode + + + + :/action-copy-char:/action-copy-char + + + true + + + Qt::ToolButtonTextOnly + + + true + + + + + + + + + + + + + + + + FloatingWidget + QWidget +
floatingwidget.h
+ 1 +
+ + FloatingWidgetToolBar + QWidget +
floatingwidgettoolbar.h
+ 1 +
+ + FMGlyphsView + QGraphicsView +
fmglyphsview.h
+
+
+ + + + +
diff -Nru fontmatrix-0.6.0+svn20100107/src/CMakeLists.txt fontmatrix-0.6.0+svn20110930/src/CMakeLists.txt --- fontmatrix-0.6.0+svn20100107/src/CMakeLists.txt 2009-11-20 14:59:52.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/CMakeLists.txt 2011-01-12 15:05:44.000000000 +0000 @@ -2,9 +2,25 @@ set(fontmatrix_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/aboutwidget.cpp +${CMAKE_CURRENT_SOURCE_DIR}/activationwidget.cpp +${CMAKE_CURRENT_SOURCE_DIR}/activationwidgetitem.cpp +${CMAKE_CURRENT_SOURCE_DIR}/browserwidget.cpp +${CMAKE_CURRENT_SOURCE_DIR}/chartwidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dataexport.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dataloader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dumpdialog.cpp +${CMAKE_CURRENT_SOURCE_DIR}/familywidget.cpp +${CMAKE_CURRENT_SOURCE_DIR}/filterbar.cpp +${CMAKE_CURRENT_SOURCE_DIR}/filterdata.cpp +${CMAKE_CURRENT_SOURCE_DIR}/filtersdialog.cpp +${CMAKE_CURRENT_SOURCE_DIR}/filtersdialogitem.cpp +${CMAKE_CURRENT_SOURCE_DIR}/filteritem.cpp +${CMAKE_CURRENT_SOURCE_DIR}/filtermeta.cpp +${CMAKE_CURRENT_SOURCE_DIR}/filterpanose.cpp +${CMAKE_CURRENT_SOURCE_DIR}/filtertag.cpp +${CMAKE_CURRENT_SOURCE_DIR}/floatingwidget.cpp +${CMAKE_CURRENT_SOURCE_DIR}/floatingwidgetsregister.cpp +${CMAKE_CURRENT_SOURCE_DIR}/floatingwidgettoolbar.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmactivate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmactivationreport.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmaltcontext.cpp @@ -17,6 +33,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/fmfontdb.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmfontextract.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmfontstrings.cpp +${CMAKE_CURRENT_SOURCE_DIR}/fmfreetypelib.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmglyphhighlight.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmglyphsview.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fminfodisplay.cpp @@ -36,6 +53,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/fmshaper_own.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmuniblocks.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmutils.cpp +${CMAKE_CURRENT_SOURCE_DIR}/fmvariants.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fmverticalbutton.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fontbook.cpp ${CMAKE_CURRENT_SOURCE_DIR}/fontbookdialog.cpp @@ -51,24 +69,31 @@ ${CMAKE_CURRENT_SOURCE_DIR}/QHexView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/parallelcoor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/puzzleviewimp.cpp -${CMAKE_CURRENT_SOURCE_DIR}/listdockwidget.cpp +#${CMAKE_CURRENT_SOURCE_DIR}/listdockwidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mainviewwidget.cpp +${CMAKE_CURRENT_SOURCE_DIR}/metawidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/modeltext.cpp +${CMAKE_CURRENT_SOURCE_DIR}/openclosearrow.cpp ${CMAKE_CURRENT_SOURCE_DIR}/panosedialog.cpp ${CMAKE_CURRENT_SOURCE_DIR}/panosematch.cpp ${CMAKE_CURRENT_SOURCE_DIR}/panosemodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/panosewidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/pangoshaper.cpp +${CMAKE_CURRENT_SOURCE_DIR}/playwidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/prefspaneldialog.cpp +${CMAKE_CURRENT_SOURCE_DIR}/progressbarduo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/remotedir.cpp #${CMAKE_CURRENT_SOURCE_DIR}/savedata.cpp +${CMAKE_CURRENT_SOURCE_DIR}/sampletoolbar.cpp +${CMAKE_CURRENT_SOURCE_DIR}/samplewidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/schelptreemodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sctextbrowser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shortcuts.cpp ${CMAKE_CURRENT_SOURCE_DIR}/systray.cpp # ${CMAKE_CURRENT_SOURCE_DIR}/tagseteditor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tagswidget.cpp +${CMAKE_CURRENT_SOURCE_DIR}/tagswidget_listmodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/textprogression.cpp ${CMAKE_CURRENT_SOURCE_DIR}/treeitem.cpp ${CMAKE_CURRENT_SOURCE_DIR}/treemodel.cpp @@ -127,7 +152,20 @@ SET(fontmatrix_MOC_HDRS aboutwidget.h +browserwidget.h +activationwidget.h +activationwidgetitem.h +chartwidget.h +dataexport.h dumpdialog.h +familywidget.h +filterbar.h +filterdata.h +filtersdialog.h +filtersdialogitem.h +filteritem.h +floatingwidget.h +floatingwidgettoolbar.h fmactivate.h fmaltcontext.h fmaltselector.h @@ -136,6 +174,7 @@ fmfontdb.h fmfontextract.h fmfontstrings.h +fmfreetypelib.h fmglyphhighlight.h fmglyphsview.h fmlayoptwidget.h @@ -154,20 +193,27 @@ importtags.h iview.h QHexView.h -listdockwidget.h +#listdockwidget.h mainviewwidget.h +metawidget.h modeltext.h +openclosearrow.h panosedialog.h panosewidget.h parallelcoor.h +playwidget.h prefspaneldialog.h +progressbarduo.h remotedir.h +sampletoolbar.h +samplewidget.h sctextbrowser.h shortcuts.h systray.h # tagseteditor.h tagswidget.h -textprogression.h +tagswidget_listmodel.h +#textprogression.h tttableview.h typotek.h ) @@ -179,23 +225,39 @@ SET(fontmatrix_UIS ${CMAKE_CURRENT_SOURCE_DIR}/about.ui ${CMAKE_CURRENT_SOURCE_DIR}/activationreportdialog.ui +${CMAKE_CURRENT_SOURCE_DIR}/activationwidget.ui +${CMAKE_CURRENT_SOURCE_DIR}/activationwidgetitem.ui ${CMAKE_CURRENT_SOURCE_DIR}/altselectorwidget.ui ${CMAKE_CURRENT_SOURCE_DIR}/bookexport.ui +${CMAKE_CURRENT_SOURCE_DIR}/browserwidget.ui +${CMAKE_CURRENT_SOURCE_DIR}/chartwidget.ui ${CMAKE_CURRENT_SOURCE_DIR}/comparewidget.ui +${CMAKE_CURRENT_SOURCE_DIR}/dataexport.ui ${CMAKE_CURRENT_SOURCE_DIR}/dumpdialog.ui +${CMAKE_CURRENT_SOURCE_DIR}/familywidget.ui +${CMAKE_CURRENT_SOURCE_DIR}/filterbar.ui +${CMAKE_CURRENT_SOURCE_DIR}/filtersdialog.ui +${CMAKE_CURRENT_SOURCE_DIR}/filtersdialogitem.ui +${CMAKE_CURRENT_SOURCE_DIR}/filteritem.ui +${CMAKE_CURRENT_SOURCE_DIR}/floatingwidgettoolbar.ui ${CMAKE_CURRENT_SOURCE_DIR}/fontextractordialog.ui ${CMAKE_CURRENT_SOURCE_DIR}/importedfonts.ui ${CMAKE_CURRENT_SOURCE_DIR}/importtags.ui # ${CMAKE_CURRENT_SOURCE_DIR}/help.ui ${CMAKE_CURRENT_SOURCE_DIR}/helpbrowser.ui ${CMAKE_CURRENT_SOURCE_DIR}/layoutoptions.ui -${CMAKE_CURRENT_SOURCE_DIR}/listsdock.ui +#${CMAKE_CURRENT_SOURCE_DIR}/listsdock.ui ${CMAKE_CURRENT_SOURCE_DIR}/mainview.ui +${CMAKE_CURRENT_SOURCE_DIR}/metawidget.ui ${CMAKE_CURRENT_SOURCE_DIR}/matchraster.ui ${CMAKE_CURRENT_SOURCE_DIR}/panosedialog.ui ${CMAKE_CURRENT_SOURCE_DIR}/panosewidget.ui +${CMAKE_CURRENT_SOURCE_DIR}/playwidget.ui ${CMAKE_CURRENT_SOURCE_DIR}/prefs_panel.ui +${CMAKE_CURRENT_SOURCE_DIR}/progressbarduo.ui ${CMAKE_CURRENT_SOURCE_DIR}/repair.ui +${CMAKE_CURRENT_SOURCE_DIR}/sampletoolbar.ui +${CMAKE_CURRENT_SOURCE_DIR}/samplewidget.ui # ${CMAKE_CURRENT_SOURCE_DIR}/tagset.ui ${CMAKE_CURRENT_SOURCE_DIR}/tagswidget.ui ${CMAKE_CURRENT_SOURCE_DIR}/textprogression.ui @@ -305,6 +367,7 @@ ${SHAPERS_LIBRARIES} ${PYTHON_LIBRARIES} ${LIBPODOFO_LIBRARY} + "-framework ApplicationServices" ) # here we’ll poupulate the bundle in order to make it @@ -343,9 +406,28 @@ COMMAND cp ARGS ${fontmatrix_QMS} ${BUNDLE_LOCALES_DIR} ) # bundles libs - ADD_CUSTOM_COMMAND(TARGET ${PROGNAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} ARGS -Dinput_file=${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/MacOS/${PROGNAME} -P ${CMAKE_MODULE_PATH}/OwnIngestOSXBundleLibraries.cmake - ) +# ADD_CUSTOM_COMMAND(TARGET ${PROGNAME} POST_BUILD +# COMMAND ${CMAKE_COMMAND} ARGS -Dinput_file=${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/MacOS/${PROGNAME} -P ${CMAKE_MODULE_PATH}/OwnIngestOSXBundleLibraries.cmake +# ) + +INSTALL(TARGETS ${PROGNAME} + BUNDLE DESTINATION . COMPONENT Runtime + ) + +SET(APPLE_LIBS + ${PYTHONQT_LIB} + ${QT_LIBRARIES} + ${FREETYPE_LIBRARIES} + ${SHAPERS_LIBRARIES} + ${PYTHON_LIBRARIES} + ${LIBPODOFO_LIBRARY} +) +SET(APPLE_DIRS "${QT_PLUGINS_DIR}/sqldrivers") +SET(APPLE_APPS "\${CMAKE_INSTALL_PREFIX}/fontmatrix.app") +INSTALL(CODE " + include(BundleUtilities) + fixup_bundle(\"${APPLE_APPS}\" \"${APPLE_LIBS}\" \"${APPLE_DIRS}\") + " COMPONENT Runtime) ENDIF(APPLE) diff -Nru fontmatrix-0.6.0+svn20100107/src/dataexport.cpp fontmatrix-0.6.0+svn20110930/src/dataexport.cpp --- fontmatrix-0.6.0+svn20100107/src/dataexport.cpp 2009-08-09 18:03:55.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/dataexport.cpp 2010-09-14 16:10:56.000000000 +0000 @@ -9,7 +9,9 @@ // Copyright: See COPYING file that comes with this distribution // // + #include "dataexport.h" +#include "ui_dataexport.h" #include "typotek.h" #include "fontitem.h" @@ -20,61 +22,91 @@ #include #include #include +#include +#include -DataExport::DataExport(const QString &dirPath, const QString &filterTag) +//DataExport::DataExport(const QString &dirPath, const QString &filterTag) +//{ +// exDir.setPath(dirPath); +// filter = filterTag; +// fonts = FMFontDb::DB()->Fonts(filter,FMFontDb::Tags); +//} + +DataExport::DataExport(QWidget* parent): + QWidget(parent,Qt::Window), + ui(new Ui::DataExport) { - exDir.setPath(dirPath); - filter = filterTag; - typotek *typ = typotek::getInstance(); -// fonts = typ->getFonts(filter,"tag"); - fonts = FMFontDb::DB()->Fonts(filter,FMFontDb::Tags); - typ->resetFilter(); -} + setAttribute(Qt::WA_DeleteOnClose, true); + ui->setupUi(this); + fonts = FMFontDb::DB()->getFilteredFonts(); + foreach(FontItem* f, fonts) + { + QListWidgetItem *it(new QListWidgetItem(f->path())); + it->setCheckState(Qt::Checked); + ui->listWidget->addItem(it); + } + show(); + connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close())); + connect(ui->continueButton, SIGNAL(clicked()), this, SLOT(doExport())); +} DataExport::~DataExport() { + } +void DataExport::doExport() +{ + QString dir( QDir::homePath() ); + dir = QFileDialog::getExistingDirectory ( this, tr ( "Choose Directory" ), dir , QFileDialog::ShowDirsOnly ); + if ( dir.isEmpty() ) + return ; + exDir = QDir(dir); + + copyFiles(); + buildHtml(); + close(); +} + + int DataExport::copyFiles() { - QProgressDialog progress ( QObject::tr ( "Copying files" ), QObject::tr ( "cancel" ), 0, fonts.count(), typotek::getInstance() ); + QProgressDialog progress ( QObject::tr ( "Copying files" ), QObject::tr ( "cancel" ), 0, fonts.count(), this ); progress.setWindowModality ( Qt::WindowModal ); int progressindex(0); - - - int copyCounter(0); QList toRemove; for(int fidx( 0 ); fidx < fonts.count() ; ++fidx) { if ( progress.wasCanceled() ) break; - QString preview(typotek::getInstance()->word(fonts[fidx])); - progress.setLabelText ( fonts[fidx]->fancyName() ); progress.setValue ( ++progressindex ); QFile ffile(fonts[fidx]->path()); QFileInfo ifile(ffile); -// qDebug()<< exDir.absolutePath() + exDir.separator() + ifile.fileName(); if(ffile.copy(exDir.absolutePath() + exDir.separator() + ifile.fileName()) ) { - ++copyCounter; - QImage itImage(fonts[fidx]->oneLinePreviewPixmap(preview, Qt::black , Qt::white).toImage()); - if(!itImage.save(exDir.absolutePath() + exDir.separator() + ifile.fileName() + ".png")) - qDebug()<<"Unable to save "<< exDir.absolutePath() + exDir.separator() + ifile.fileName() + ".png"; + if ( !fonts[fidx]->afm().isEmpty() ) + { + if ( !QFile::copy( fonts[fidx]->afm(), exDir.absolutePath() + exDir.separator() + fonts[fidx]->activationAFMName() ) ) + { + qDebug() << "unable to copy " << fonts[fidx]->afm(); + } + else + { + qDebug() << fonts[fidx]->afm() << "copied"; + } + } } else - { - typotek::getInstance()->showStatusMessage(QObject::tr("Unable to copy")+" "+fonts[fidx]->path()); toRemove << fidx; - } } for(int i(toRemove.count() - 1); i >= 0;--i) fonts.removeAt(toRemove[i]); - return copyCounter; + return 0; } int DataExport::buildIndex() @@ -111,8 +143,8 @@ xmlStream.writeCharacters( fid.getHtml() ); xmlStream.writeEndElement(); QStringList tl = fitem->tags(); -// tl.removeAll("Activated_On"); -// tl.removeAll("Activated_Off"); + // tl.removeAll("Activated_On"); + // tl.removeAll("Activated_Off"); foreach(QString tag, tl) { xmlStream.writeStartElement("tag"); @@ -129,18 +161,6 @@ return fonts.count(); } -int DataExport::doExport() -{ - int bd (buildIndex()); - if( bd == 0 ) - return 0; - - int cp (copyFiles()); - - buildHtml(); - - return cp; -} int DataExport::buildHtml() { @@ -186,17 +206,17 @@ xmlStream.writeEndElement();// div.namebox - xmlStream.writeStartElement("img"); - xmlStream.writeAttribute("class", "imgbox"); - xmlStream.writeAttribute("src", ffile.fileName() + ".png"); - xmlStream.writeEndElement();// img.imgbox + // xmlStream.writeStartElement("img"); + // xmlStream.writeAttribute("class", "imgbox"); + // xmlStream.writeAttribute("src", ffile.fileName() + ".png"); + // xmlStream.writeEndElement();// img.imgbox xmlStream.writeStartElement("div"); xmlStream.writeAttribute("class", "infobox"); QStringList tl = fitem->tags(); -// tl.removeAll("Activated_On"); -// tl.removeAll("Activated_Off"); + // tl.removeAll("Activated_On"); + // tl.removeAll("Activated_Off"); foreach(QString tag, tl) { xmlStream.writeStartElement("div"); diff -Nru fontmatrix-0.6.0+svn20100107/src/dataexport.h fontmatrix-0.6.0+svn20110930/src/dataexport.h --- fontmatrix-0.6.0+svn20100107/src/dataexport.h 2008-05-23 07:17:53.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/dataexport.h 2010-09-14 16:10:56.000000000 +0000 @@ -14,33 +14,43 @@ #include #include +#include class FontItem; +namespace Ui { + class DataExport; +} + /** @author Pierre Marchand This class is supposed to export a set of fonts in a directory and build a usefull index of the exported font files. */ -class DataExport +class DataExport : public QWidget { - public: - DataExport(const QString &dirPath, const QString &filterTag); - ~DataExport(); - - int doExport(); - - private: - //data - QDir exDir; - QString filter; - QList fonts; - //methods - int copyFiles(); - int buildIndex(); - int buildHtml(); - int buildTemplate(const QString& templateDirPath); + Q_OBJECT +public: + explicit DataExport(QWidget* parent); +// DataExport(const QString &dirPath, const QString &filterTag); + ~DataExport(); + + +private: + //data + Ui::DataExport *ui; + QDir exDir; + QString filter; + QList fonts; + //methods + int copyFiles(); + int buildIndex(); + int buildHtml(); + int buildTemplate(const QString& templateDirPath); + +private slots: + void doExport(); }; #endif diff -Nru fontmatrix-0.6.0+svn20100107/src/dataexport.ui fontmatrix-0.6.0+svn20110930/src/dataexport.ui --- fontmatrix-0.6.0+svn20100107/src/dataexport.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/dataexport.ui 2010-09-14 16:10:56.000000000 +0000 @@ -0,0 +1,71 @@ + + + DataExport + + + + 0 + 0 + 499 + 307 + + + + Export Data + + + + + + + + + The font files currently filtered and selected here will be copied in a directory of your choice. + + + true + + + + + + + + + + Cancel + + + + + + + Continue + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + listWidget + label + widget + horizontalSpacer + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/familywidget.cpp fontmatrix-0.6.0+svn20110930/src/familywidget.cpp --- fontmatrix-0.6.0+svn20100107/src/familywidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/familywidget.cpp 2010-09-17 14:41:51.000000000 +0000 @@ -0,0 +1,330 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "familywidget.h" +#include "ui_familywidget.h" +#include "typotek.h" +#include "fmpreviewlist.h" +#include "fmfontdb.h" +#include "fontitem.h" +#include "fminfodisplay.h" +#include "floatingwidgetsregister.h" +#include "samplewidget.h" +#include "chartwidget.h" +#include "activationwidget.h" +#include "fmvariants.h" + + +#include +#include +#include +#include + + +FamilyWidget::FamilyWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::FamilyWidget), + sample(0), + chart(0), + activation(0), + currentPage(FAMILY_VIEW_INFO), + currentIndex(0) +{ + ui->setupUi(this); + + + ui->familyPreview->setNumCol(1); + ui->familyPreview->setModelColumn(1); + ui->familyPreview->setViewMode(QListView::IconMode); + ui->familyPreview->setIconSize(QSize(qRound(ui->familyPreview->width() ), 1.3 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0)); + ui->familyPreview->setUniformItemSizes(true); + ui->familyPreview->setMovement(QListView::Static); + + previewModel = new FMPreviewModel( this, ui->familyPreview ); + previewModel->setSpecString(""); + ui->familyPreview->setModel(previewModel); + + + + connect(ui->returnListButton, SIGNAL(clicked()), this, SIGNAL(backToList())); + connect(ui->familyPreview, SIGNAL(widthChanged(int)),this,SLOT(slotPreviewUpdateSize(int))); + connect(ui->familyPreview,SIGNAL(activated ( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); + connect(ui->familyPreview,SIGNAL(clicked ( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); + connect(ui->familyPreview,SIGNAL(pressed( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); + connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(slotShowInfo())); + connect(ui->sampleButton, SIGNAL(clicked()), this, SLOT(slotShowSample())); + connect(ui->chartButton, SIGNAL(clicked()), this, SLOT(slotShowChart())); + connect(ui->activationButton, SIGNAL(clicked()), this, SLOT(slotShowActivation())); + +} + +FamilyWidget::~FamilyWidget() +{ + delete ui; +} + +TagsWidget* FamilyWidget::tagWidget() +{ + return ui->tagsWidget; +} + +QWebView* FamilyWidget::info() +{ + return ui->webView; +} + +void FamilyWidget::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void FamilyWidget::keyPressEvent(QKeyEvent *event) +{ + if(event->modifiers().testFlag(Qt::ControlModifier) && (event->key() == Qt::Key_PageUp)) + { + switch(currentPage) + { + case FAMILY_VIEW_SAMPLE: slotShowActivation(); + break; + case FAMILY_VIEW_CHART: slotShowSample(); + break; + case FAMILY_VIEW_INFO: slotShowChart(); + break; + case FAMILY_VIEW_ACTIVATION: slotShowInfo(); + default:break; + } + } + else if(event->modifiers().testFlag(Qt::ControlModifier) && (event->key() == Qt::Key_PageDown)) + { + switch(currentPage) + { + case FAMILY_VIEW_INFO: slotShowActivation(); + break; + case FAMILY_VIEW_ACTIVATION: slotShowSample(); + break; + case FAMILY_VIEW_SAMPLE: slotShowChart(); + break; + case FAMILY_VIEW_CHART: slotShowInfo(); + default:break; + } + } +} + +void FamilyWidget::slotPreviewUpdateSize(int w) +{ + ui->familyPreview->setIconSize(QSize(qRound(w ), 1.3 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0)); +} + +void FamilyWidget::setFamily(const QString &f) +{ + if(f != family) + { + family = f; + ui->familyLabel->setText(family); + QList fl( FMVariants::Order(FMFontDb::DB()->FamilySet(family))); + ui->tagsWidget->prepare(fl); + previewModel->resetBase(fl); + if(!fl.isEmpty()) + { + ui->familyPreview->setCurrentIndex( previewModel->index(0) ); + curVariant = fl.first()->path(); + emit fontSelected(curVariant); + } + delete sample; + sample = 0; + delete chart; + chart = 0; + delete activation; + activation = 0; + + uniBlock = QString(); + slotShowSample(); + } +} + +void FamilyWidget::slotPreviewUpdate() +{ + previewModel->dataChanged(); +} + +void FamilyWidget::slotPreviewSelected(const QModelIndex &index) +{ + QString fid(index.data(FMPreviewModel::PathRole).toString()); + if(fid != curVariant) + { + if(chart != 0) + uniBlock = reinterpret_cast(chart)->currentBlock(); + delete sample; + delete chart; + sample = chart = 0; + curVariant = fid; + currentIndex = index.row(); + switch(currentPage) + { + case FAMILY_VIEW_INFO: slotShowInfo(); + break; + case FAMILY_VIEW_SAMPLE: slotShowSample(); + break; + case FAMILY_VIEW_CHART: slotShowChart(); + break; + default: + break; + } + + emit fontSelected(curVariant); + } +} + + +void FamilyWidget::slotShowSample() +{ + FloatingWidget * fw(FloatingWidgetsRegister::Widget(curVariant, SampleWidget::Name)); + if(fw == 0) + { + if(0 == sample) + { + SampleWidget *sw(new SampleWidget(curVariant, ui->pageSample)); + ui->displayStack->insertWidget(FAMILY_VIEW_SAMPLE, sw); + sample = sw; + connect(sample, SIGNAL(detached()), this, SLOT(slotDetachSample())); + } + ui->displayStack->setCurrentWidget(sample); + } + else + { + fw->show(); + } + currentPage = FAMILY_VIEW_SAMPLE; + updateButtons(); +} + +void FamilyWidget::slotShowInfo() +{ + FMInfoDisplay fid(FMFontDb::DB()->Font(curVariant)); + ui->webView->setContent(fid.getHtml().toUtf8(), "application/xhtml+xml"); + ui->displayStack->setCurrentIndex(FAMILY_VIEW_INFO); + currentPage = FAMILY_VIEW_INFO; + updateButtons(); +} + +void FamilyWidget::slotShowChart() +{ + FloatingWidget * fw(FloatingWidgetsRegister::Widget(curVariant, ChartWidget::Name)); + if(fw == 0) + { + if(0 == chart) + { + ChartWidget *cw(new ChartWidget(curVariant, uniBlock, ui->pageChart)); + ui->displayStack->insertWidget(FAMILY_VIEW_CHART, cw); + chart = cw; + connect(chart, SIGNAL(detached()), this, SLOT(slotDetachChart())); + } + ui->displayStack->setCurrentWidget(chart); + } + else + { + fw->show(); + } + currentPage = FAMILY_VIEW_CHART; + updateButtons(); +} + +void FamilyWidget::slotShowActivation() +{ + FloatingWidget * fw(FloatingWidgetsRegister::Widget(curVariant, ActivationWidget::Name)); + if(fw == 0) + { + if(0 == activation) + { + ActivationWidget *aw(new ActivationWidget(family, ui->pageActivation)); + ui->displayStack->insertWidget(FAMILY_VIEW_ACTIVATION, aw); + activation = aw; + connect(activation, SIGNAL(familyStateChanged()), this, SLOT(slotStateChange())); + } + ui->displayStack->setCurrentWidget(activation); + } + else + { + fw->show(); + } + currentPage = FAMILY_VIEW_ACTIVATION; + updateButtons(); +} + +void FamilyWidget::slotDetachSample() +{ + disconnect(sample, SIGNAL(detached()), this, SLOT(slotDetachSample())); + sample = 0; + slotShowInfo(); +} + +void FamilyWidget::slotDetachChart() +{ + disconnect(chart, SIGNAL(detached()), this, SLOT(slotDetachChart())); + uniBlock = reinterpret_cast(chart)->currentBlock(); + chart = 0; + slotShowInfo(); +} + +void FamilyWidget::slotStateChange() +{ + previewModel->resetBase(FMVariants::Order(FMFontDb::DB()->FamilySet(family))); + emit familyStateChanged(); +} + +void FamilyWidget::updateButtons() +{ + static QList buttons; + if(buttons.isEmpty()) + { + buttons << ui->sampleButton + << ui->infoButton + << ui->chartButton + << ui->activationButton; + foreach(QToolButton * b, buttons) + { + b->setCheckable(true); + } + } + foreach(QToolButton * b, buttons) + { + b->setChecked(false); + } + switch(currentPage) + { + case FAMILY_VIEW_SAMPLE: ui->sampleButton->setChecked(true); + break; + case FAMILY_VIEW_ACTIVATION: ui->activationButton->setChecked(true); + break; + case FAMILY_VIEW_CHART: ui->chartButton->setChecked(true); + break; + case FAMILY_VIEW_INFO : ui->infoButton->setChecked(true); + break; + default:break; + } +} + diff -Nru fontmatrix-0.6.0+svn20100107/src/familywidget.h fontmatrix-0.6.0+svn20110930/src/familywidget.h --- fontmatrix-0.6.0+svn20100107/src/familywidget.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/familywidget.h 2010-09-17 14:41:51.000000000 +0000 @@ -0,0 +1,97 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FAMILYWIDGET_H +#define FAMILYWIDGET_H + +#include +#include +#include +#include + + +#define FAMILY_VIEW_INFO 0 +#define FAMILY_VIEW_SAMPLE 1 +#define FAMILY_VIEW_CHART 2 +#define FAMILY_VIEW_ACTIVATION 3 + +class FMPreviewModel; +class FontItem; +class TagsWidget; +class QWebView; +class FloatingWidget; + +namespace Ui { + class FamilyWidget; +} + +class FamilyWidget : public QWidget +{ + Q_OBJECT + +public: + explicit FamilyWidget(QWidget *parent = 0); + ~FamilyWidget(); + + void setFamily(const QString& f); + TagsWidget* tagWidget(); + QWebView * info(); + QString family; + QString curVariant; + +protected: + void changeEvent(QEvent *e); + void keyPressEvent ( QKeyEvent * event ); + + void buildList(const QList& fl); + +private: + Ui::FamilyWidget *ui; + FMPreviewModel * previewModel; + FloatingWidget *sample; + FloatingWidget *chart; + FloatingWidget *activation; + + unsigned int currentIndex; + unsigned int currentPage; + QString uniBlock; + + void updateButtons(); + +signals: + void backToList(); + void fontSelected(const QString& path); + void familyStateChanged(); + +private slots: + void slotPreviewUpdate(); + void slotPreviewUpdateSize(int); + void slotPreviewSelected(const QModelIndex & index); + void slotShowInfo(); + void slotShowSample(); + void slotShowChart(); + void slotShowActivation(); + void slotDetachSample(); + void slotDetachChart(); +// void slotDetachActivation(); + void slotStateChange(); +}; + +#endif // FAMILYWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/familywidget.ui fontmatrix-0.6.0+svn20110930/src/familywidget.ui --- fontmatrix-0.6.0+svn20100107/src/familywidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/familywidget.ui 2010-09-15 08:10:13.000000000 +0000 @@ -0,0 +1,236 @@ + + + FamilyWidget + + + + 0 + 0 + 674 + 627 + + + + Form + + + + 2 + + + 2 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 2 + + + + + + + + 0 + 0 + + + + + 200 + 24 + + + + Return To List + + + + + + + Qt::Vertical + + + + + + + + 16777215 + 24 + + + + Sample + + + + + + + + 16777215 + 24 + + + + Chart + + + + + + + + 16777215 + 24 + + + + Info + + + + + + + + 16777215 + 24 + + + + Activation + + + + + + + Qt::Horizontal + + + + 100 + 20 + + + + + + + + + 75 + true + + + + Family Name + + + + + + + + + + + + + 0 + 30 + + + + Qt::Horizontal + + + + + 0 + + + + + Qt::Vertical + + + + + 0 + 2 + + + + + + + 0 + 1 + + + + + + + + + + + + 0 + + + + + + about:blank + + + + + + + + + + + + + + + + + QWebView + QWidget +
QtWebKit/QWebView
+ 1 +
+ + FMPreviewView + QListView +
fmpreviewlist.h
+
+ + TagsWidget + QWidget +
tagswidget.h
+ 1 +
+
+ + +
diff -Nru fontmatrix-0.6.0+svn20100107/src/filterbar.cpp fontmatrix-0.6.0+svn20110930/src/filterbar.cpp --- fontmatrix-0.6.0+svn20100107/src/filterbar.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filterbar.cpp 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,684 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filterbar.h" +#include "ui_filterbar.h" +#include "fmfontdb.h" +#include "panosewidget.h" +#include "metawidget.h" +#include "filtersdialogitem.h" +#include "filteritem.h" +#include "filtertag.h" +#include "filterpanose.h" +#include "filtermeta.h" +#include "fmpaths.h" +#include "filtersdialog.h" +#include "typotek.h" +#include "mainviewwidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QString FilterBar::andOpString = FilterBar::tr("And"); +QString FilterBar::notOpString = FilterBar::tr("Not"); +QString FilterBar::orOpString = FilterBar::tr("Or"); + +TagListModel::TagListModel(QObject *parent) + :QAbstractListModel(parent), + specialTagsCount(1) +{ +// ui->tagsCombo->clear(); +// // tagsetIcon = QIcon(":/fontmatrix_tagseteditor.png"); + +// ui->tagsCombo->addItem(tr("Tags"),"NO_KEY"); +// ui->tagsCombo->addItem(tr("All activated"),"ALL_ACTIVATED"); + +// QStringList tl_tmp = FMFontDb::DB()->getTags(); +//// qDebug()<< "T"<< tl_tmp.join("||"); +// tl_tmp.sort(); +// foreach(QString tag, tl_tmp ) +// { +// if(!FMFontDb::DB()->Fonts(tag, FMFontDb::Tags ).isEmpty()) +// ui->tagsCombo->addItem(tag, "TAG"); +// } +} + +int TagListModel::rowCount(const QModelIndex &parent) const +{ + if(parent.isValid()) + return 0; + return FMFontDb::DB()->getTags().count() + specialTagsCount; +} + +int TagListModel::columnCount(const QModelIndex &parent) const +{ + if(parent.isValid()) + return 0; + return 1; // let's start simple +} + +QVariant TagListModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid() && index.column() != 0) + return QVariant(); + QStringList tl_tmp = FMFontDb::DB()->getTags(); + tl_tmp.sort(); + // specials + QString tagActivated(tr("Activated")); + tl_tmp.prepend(tagActivated); + + QString tag(tl_tmp.at(index.row())); + if(role == Qt::DisplayRole) + { +// return tag; + return QVariant(); +// return QString("
%1
").arg(tag); + } + else if(role == Qt::EditRole) + return tag; + else if(role == Qt::DecorationRole) + { +// return QVariant(); + QString ts("%1 (%2)"); + int tc(tag == tagActivated ? + FMFontDb::DB()->Fonts(1, FMFontDb::Activation ).count() + :FMFontDb::DB()->Fonts(tag, FMFontDb::Tags ).count()); + QRect pr(0,0,1024,18); + QPixmap pm(pr.size()); + QPainter p; + p.begin(&pm); + p.drawText(pr,Qt::AlignLeft | Qt::TextDontClip | Qt::TextSingleLine, ts.arg(tag).arg(tc) , &pr); + p.end(); + QPixmap tagPix(pr.width() + 18, 18); + tagPix.fill(Qt::transparent); + p.begin(&tagPix); + p.setRenderHint(QPainter::Antialiasing); + p.save(); + p.setBrush(QColor(210,210,210)); + if(currentTags.contains(tag)) + p.setBrush(QColor(180,180,180)); + p.setPen(Qt::NoPen); + p.drawRoundedRect(tagPix.rect(), 5,5); + p.restore(); + pr.translate(9,0); + p.drawText(pr, ts.arg(tag).arg(tc)); + p.end(); + return tagPix; + } + else if(role == TagType) + { + if(index.row() < specialTagsCount) + { + return QString("ALL_ACTIVATED"); + } + return QString("TAG"); + } + else if(role == TagString) + { + return tag; + } + return QVariant(); +} + +bool TagListModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if(!index.isValid()) + return false; + if(value.toString().isEmpty()) + return false; + QStringList tl_tmp = FMFontDb::DB()->getTags(); + tl_tmp.sort(); + if(value.toString() == tl_tmp.at(index.row() - specialTagsCount)) + return false; + FMFontDb::DB()->editTag ( tl_tmp.at(index.row() - specialTagsCount), value.toString()); + emit dataChanged(index, index); + return true; +} + +Qt::ItemFlags TagListModel::flags(const QModelIndex &index) const +{ +// if(index.row() > specialTagsCount - 1) +// return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +void TagListModel::clearCurrents() +{ + if(!currentTags.isEmpty()) + { + currentTags.clear(); + emit dataChanged(index(0,0),index(FMFontDb::DB()->getTags().count() + specialTagsCount -1 ,columnCount() -1)); + } +} + +void TagListModel::addToCurrents(const QString &t) +{ + if(!currentTags.contains(t)) + { + currentTags << t; + emit dataChanged(index(0,0),index(FMFontDb::DB()->getTags().count() + specialTagsCount -1 ,columnCount() -1)); + } +} + +void TagListModel::removeFromCurrents(const QString &t) +{ + if(currentTags.contains(t)) + { + currentTags.removeAll(t); + emit dataChanged(index(0,0),index(FMFontDb::DB()->getTags().count() + specialTagsCount -1 ,columnCount() -1)); + } +} + + +void TagListModel::tagsDBChanged() +{ + emit dataChanged(index(0,0),index(FMFontDb::DB()->getTags().count() + specialTagsCount -1 ,columnCount() -1)); +} + +FilterBar::FilterBar(QWidget *parent) : + QWidget(parent), + ui(new Ui::FilterBar) +{ + ui->setupUi(this); + + tagListModel = new TagListModel(this); +// ui->tagsView->setShowGrid(false); +// ui->tagsView->horizontalHeader()->setStretchLastSection(true); +// ui->tagsView->verticalHeader()->hide(); +// ui->tagsView->horizontalHeader()->hide(); + ui->tagsView->setModel(tagListModel); + +// metaFieldsMenu = new QMenu(tr("Fields"), this); + QList ln; + metaFieldKey = int(FMFontDb::AllInfo); + ln << FMFontDb::AllInfo + << FMFontDb::FontFamily + << FMFontDb::FontSubfamily + << FMFontDb::Designer + << FMFontDb::Description + << FMFontDb::Copyright + << FMFontDb::Trademark + << FMFontDb::ManufacturerName + << FMFontDb::LicenseDescription; + for(int gIdx(0); gIdx < ln.count() ; ++gIdx) + { + FMFontDb::InfoItem k(ln[gIdx]); + { + QString fieldname(FontStrings::Names().value(k)); +// QAction * ma(new QAction(fieldname, metaFieldsMenu)); +// ma->setData(int(k)); +// metaFieldsMenu->addAction(ma); + ui->fieldCombo->addItem(fieldname, int(k)); + } + } +// ui->metadataTool->setMenu(metaFieldsMenu); +// ui->metaFieldLabel->setText(FontStrings::Names().value(FMFontDb::AllInfo)); + mModel = new QStringListModel; + mModel->setStringList(mList); + ui->metadataLineEdit->setCompleter(new QCompleter(mModel)); + + loadFilters(); + + + connect(ui->tagsView, SIGNAL(clicked(QModelIndex)), this, SLOT(slotTagSelect(QModelIndex))); + connect(ui->tagsView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotTagEdit(QModelIndex))); + + connect(ui->metadataLineEdit, SIGNAL(editingFinished()), this, SLOT(metaFilter())); + connect(ui->fieldCombo, SIGNAL(activated(int)), this, SLOT(metaSelectField(int))); +// connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(slotClearFilter())); + connect(ui->panoseWidget, SIGNAL(filterChanged()), this, SLOT(slotPanoFilter())); + connect(FMFontDb::DB(), SIGNAL(tagsChanged()), tagListModel, SLOT(tagsDBChanged())); + + connect(ui->tagsArrow, SIGNAL(openChanged(bool)), this, SLOT(slotToggleTags(bool))); + connect(ui->metadataArrow, SIGNAL(openChanged(bool)), this, SLOT(slotToggleMeta(bool))); + connect(ui->panoseArrow, SIGNAL(openChanged(bool)), this, SLOT(slotTogglePano(bool))); + connect(ui->filtersArrow, SIGNAL(openChanged(bool)), this, SLOT(slotToggleFilter(bool))); + + QSettings settings; + ui->tagsArrow->changeOpen(settings.value("FilterBar/TagsOpen", true).toBool()); + ui->metadataArrow->changeOpen(settings.value("FilterBar/MetaOpen", false).toBool()); + ui->panoseArrow->changeOpen(settings.value("FilterBar/PanoseOpen", false).toBool()); + ui->filtersArrow->changeOpen(settings.value("FilterBar/FiltersOpen", true).toBool()); +} + +FilterBar::~FilterBar() +{ + QSettings settings; + settings.setValue("FilterBar/TagsOpen", ui->tagsArrow->isOpen()); + settings.setValue("FilterBar/MetaOpen", ui->metadataArrow->isOpen()); + settings.setValue("FilterBar/PanoseOpen", ui->panoseArrow->isOpen()); + settings.setValue("FilterBar/FiltersOpen", ui->filtersArrow->isOpen()); + delete ui; +} + +void FilterBar::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + + + +void FilterBar::metaFilter() +{ + if(ui->metadataLineEdit->text().isEmpty()) + return; + + FilterMeta *fm(new FilterMeta); + + if(!mList.contains(ui->metadataLineEdit->text())) + { + mList.append(ui->metadataLineEdit->text()); + mModel->setStringList(mList); + } + + fm->setData(FilterData::Text, FontStrings::Names().value(static_cast(metaFieldKey)) + QString(" : ") + ui->metadataLineEdit->text()); + fm->setData(FilterMeta::Field, metaFieldKey); + fm->setData(FilterMeta::Value, ui->metadataLineEdit->text()); + // fm->setData(FilterData::Or, false); + // fm->setData(FilterData::And, true); + addFilterItem(fm, false); + + ui->metadataLineEdit->clear(); + processFilters(); + +} + +void FilterBar::processFilters() +{ + if(filters.count() > 0) + { + FMFontDb::DB()->clearFilteredFonts(); + bool first(true); + foreach(FilterItem* d, filters) + { + if(first) + { + d->hideOperation(FilterItem::AND); + first = false; + } + d->filter()->operate(); + } + emit filterChanged(); + } +} + +void FilterBar::slotRemoveFilterItem(bool process) +{ + FilterItem * fi(reinterpret_cast(sender())); + if(fi != 0) + { + filters.removeAll(fi); + if(filters.count() == 0) + { + FMFontDb::DB()->filterAllFonts(); + curFilterWidget->setVisible(false); + emit filterChanged(); + } + fi->deleteLater(); + if(process && (filters.count() > 0) ) + processFilters(); + } +} + +void FilterBar::removeAllFilters() +{ + FMFontDb::DB()->filterAllFonts(); + foreach(FilterItem* d, filters) + { + d->deleteLater(); + } + filters.clear(); + curFilterWidget->setVisible(false); +} + +void FilterBar::addFilterItem(FilterData *f, bool process) +{ + if(f != 0) + { + curFilterWidget->setVisible(true); + FilterItem * it(f->item()); + if(!filters.contains(it)) + { + if(f->data(FilterData::Replace).toBool()) + removeAllFilters(); + connect(it, SIGNAL(remove()), this, SLOT(slotRemoveFilterItem())); + connect(f, SIGNAL(Changed()), this, SLOT(processFilters())); + filters.append(it); + filterListLayout->addWidget(it); + + if(process) + processFilters(); + } + } +} + +QString FilterBar::filterString(FilterData *d, bool first) +{ + QString fs; + if(first) + { + first = false; + if(d->data(FilterData::Not).toBool()) + fs += notOpString + QString(" [%1] ").arg(d->getText()); + else + fs += QString("[%1] ").arg(d->getText()); + } + else + { + if(d->data(FilterData::Or).toBool()) + fs += orOpString; + else + fs += andOpString; + + if(d->data(FilterData::Not).toBool()) + fs += QString(" %1").arg(notOpString); + fs += QString(" [%1] ").arg(d->getText()); + } + return fs; +} + +void FilterBar::loadFilters() +{ + foreach(FiltersDialogItem* i, items) + delete i; + items.clear(); + + QDir fbasedir(FMPaths::FiltersDir()); + QStringList fbaselist(fbasedir.entryList(QDir::NoDotAndDotDot|QDir::Dirs,QDir::Name)); + foreach(QString fname, fbaselist) + { + QDir fdir(FMPaths::FiltersDir() + fname); + QStringList flist(fdir.entryList(QDir::NoDotAndDotDot|QDir::Files, QDir::Name)); + QString fString; + bool first(true); + foreach(QString fn, flist) + { + QStringList l(fn.split(QString("-"))); + if(l.count() == 2) + { + QString type(l.at(1)); + QFile file(fdir.absoluteFilePath(fn)); + if(file.open(QIODevice::ReadOnly)) + { + FilterData *f; + if(type == QString("Meta")) + { + f = new FilterMeta; + } + else if(type == QString("Panose")) + { + f = new FilterPanose; + } + else if(type == QString("Tag")) + { + f = new FilterTag; + } + f->fromByteArray(file.readAll()); + if(first) + { + first = false; + fString += filterString(f, true); + } + else + fString += filterString(f); + delete f; + } + } + } + FiltersDialogItem *fdi(new FiltersDialogItem(fname, fString, this)); + items.append(fdi); + ui->filtersLayout->addWidget(fdi, 0, Qt::AlignTop); + connect(fdi, SIGNAL(Filter(QString)), this, SLOT(slotLoadFilter(QString))); + connect(fdi, SIGNAL(Remove(QString)), this, SLOT(slotRemoveFilter(QString))); + } +} + +void FilterBar::slotTagSelect(const QModelIndex & index) +{ + QString tag(tagListModel->data(index, TagListModel::TagString).toString()); + QString key(tagListModel->data(index,TagListModel::TagType).toString()); + +// int selCount(ui->tagsView->selectionModel()->selectedIndexes().count()); +// if(selCount == 1) + { + foreach(FilterItem* f, filters) + { + if(f->filter()->data(FilterTag::Tag).toString() == tag) + return; + } + } + + int andTag(ui->tagsView->getAndKey()); + if(0 == andTag) + { + slotClearFilter(); + tagListModel->clearCurrents(); + } + FilterTag * ft(new FilterTag); + ft->setData(FilterData::Text, tag); + ft->setData(FilterTag::Key, key); + ft->setData(FilterTag::Tag, tag); + if(1 == andTag) + { + ft->setData(FilterData::And, true); + ft->setData(FilterData::Or, false); + } + else if (2 == andTag) + { + ft->setData(FilterData::And, true); + ft->setData(FilterData::Or, false); + ft->setData(FilterData::Not, true); + } + tagListModel->addToCurrents(tag); + addFilterItem(ft); +} + +void FilterBar::slotTagEdit(const QModelIndex &index) +{ + QString tag(tagListModel->data(index, TagListModel::TagString).toString()); + bool ok; + QString newTag(QInputDialog::getText(this, tr("Fontmatrix - edit tag"), tr("Edit tag: ") + tag, QLineEdit::Normal, QString(), &ok)); + if(!ok || newTag.isEmpty()) + return; + FMFontDb::DB()->editTag(tag, newTag); + ui->tagsView->update(index); + +} + +void FilterBar::slotPanoFilter() +{ + QMap > pv(ui->panoseWidget->getFilter()); + const QMap< FontStrings::PanoseKey, QMap >& ps(FontStrings::Panose()); + foreach(int k, pv.keys()) + { + foreach(int v, pv[k]) + { + FontStrings::PanoseKey pk (static_cast(k)); + QString text(FontStrings::PanoseKeyName(pk) + QString(" : ") + ps.value(pk).value(v)); + FilterPanose *fp(new FilterPanose); + fp->setData(FilterData::Text, text); + fp->setData(FilterPanose::Param, k); + fp->setData(FilterPanose::Value, v); + addFilterItem(fp); + } + } + +} + +void FilterBar::metaSelectField(int idx) +{ +// metaFieldKey = action->data().toInt(); +// ui->metaFieldLabel->setText(FontStrings::Names().value(FMFontDb::InfoItem(metaFieldKey))); + metaFieldKey = ui->fieldCombo->itemData(idx).toInt(); +} + +void FilterBar::slotClearFilter() +{ + removeAllFilters(); + tagListModel->clearCurrents(); + emit filterChanged(); +} + +void FilterBar::slotSaveFilter() +{ + if(filters.isEmpty() /*|| fname.isEmpty()*/) + return; + + bool ok; + QString fname = QInputDialog::getText(this, tr("Fontmatrix - Filter name"), + tr("Filter name:"), QLineEdit::Normal, + QString(""), &ok); + if (!ok || fname.isEmpty()) + return; + + QDir fdir(FMPaths::FiltersDir()); + if(!fdir.exists(fname)) + fdir.mkdir(fname); + fdir.cd(fname); + for(int i(0); i < filters.count(); ++i) + { + QFile f(fdir.absoluteFilePath( QString("%1-%2").arg(i, 3, 10, QChar('0')).arg(filters[i]->filter()->type()) )); + if(f.open(QIODevice::WriteOnly)) + { + f.write(filters[i]->filter()->toByteArray()); + f.close(); + } + } + loadFilters(); +} + +void FilterBar::slotLoadFilter(const QString &fname) +{ + removeAllFilters(); + QDir fdir(FMPaths::FiltersDir() + fname); + QStringList flist(fdir.entryList(QDir::NoDotAndDotDot|QDir::Files, QDir::Name)); + foreach(QString fn, flist) + { + QStringList l(fn.split(QString("-"))); + if(l.count() == 2) + { + QString type(l.at(1)); + QFile file(fdir.absoluteFilePath(fn)); + if(file.open(QIODevice::ReadOnly)) + { + FilterData *f; + if(type == QString("Meta")) + { + f = new FilterMeta; + } + else if(type == QString("Panose")) + { + f = new FilterPanose; + } + else if(type == QString("Tag")) + { + f = new FilterTag; + } + f->fromByteArray(file.readAll()); + addFilterItem(f); + } + } + } + processFilters(); +} + +void FilterBar::slotRemoveFilter(const QString &fname) +{ + + if(fname.isEmpty()) + return; + + QDir fdir(FMPaths::FiltersDir()); + if(fdir.exists(fname)) + { + fdir.cd(fname); + QStringList flist(fdir.entryList(QDir::NoDotAndDotDot|QDir::Files)); + foreach(QString fn, flist) + { + fdir.remove(fn); + } + fdir.cd(FMPaths::FiltersDir()); + fdir.rmdir(fname); + } + else + { + qDebug()<< "Directory does not exist:"<exec(); +} + +void FilterBar::slotToggleTags(bool t) +{ + if(t) + ui->tagsBox->show(); + else + ui->tagsBox->hide(); +} + +void FilterBar::slotToggleMeta(bool t) +{ + if(t) + ui->metadataBox->show(); + else + ui->metadataBox->hide(); +} + +void FilterBar::slotTogglePano(bool t) +{ + if(t) + ui->panoseBox->show(); + else + ui->panoseBox->hide(); +} + +void FilterBar::slotToggleFilter(bool t) +{ + if(t) + ui->filtersBox->show(); + else + ui->filtersBox->hide(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/filterbar.h fontmatrix-0.6.0+svn20110930/src/filterbar.h --- fontmatrix-0.6.0+svn20100107/src/filterbar.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filterbar.h 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,168 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERBAR_H +#define FILTERBAR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class FiltersDialogItem; +class FilterItem; +class FilterData; + + +class TagListModel : public QAbstractListModel +{ + Q_OBJECT + const int specialTagsCount; + + QStringList currentTags; +public: + enum TagListRole + { + TagType = Qt::UserRole, + TagString + }; + + TagListModel(QObject * parent); + int rowCount ( const QModelIndex & parent = QModelIndex() ) const; + int columnCount ( const QModelIndex & parent = QModelIndex() ) const; + QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; + bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); + Qt::ItemFlags flags ( const QModelIndex & index ) const; + + void clearCurrents(); + void addToCurrents(const QString& t); + void removeFromCurrents(const QString& t); + +public slots: + void tagsDBChanged(); + +}; + + +class TagListView : public QListView +{ + Q_OBJECT + + int m_andOrKey; +public: + TagListView(QWidget * parent): + QListView(parent), + m_andOrKey(0) + {} + + int getAndKey(){int ret(m_andOrKey), m_andOrKey = 0; return ret;} + +protected: + void mouseReleaseEvent(QMouseEvent *event) + { + if(event->modifiers().testFlag(Qt::ShiftModifier)) + m_andOrKey = 1; + else if(event->modifiers().testFlag(Qt::ControlModifier)) + m_andOrKey = 2; + else + m_andOrKey = 0; + QListView::mouseReleaseEvent(event); + } +}; + + +namespace Ui { + class FilterBar; +} + +class FilterBar : public QWidget +{ + Q_OBJECT + +public: + explicit FilterBar(QWidget *parent = 0); + ~FilterBar(); + + void setFilterListLayout(QHBoxLayout *l){filterListLayout = l;} + void setCurFilterWidget(QWidget * w){curFilterWidget = w;} + +protected: + void changeEvent(QEvent *e); + +private: + Ui::FilterBar *ui; + QHBoxLayout * filterListLayout; + QWidget * curFilterWidget; + + QList filters; + void addFilterItem(FilterData* f, bool process = true); + void removeAllFilters(); + TagListModel * tagListModel; +// QMenu * metaFieldsMenu; + int metaFieldKey; + + QString filterString(FilterData *d, bool first = false); + void loadFilters(); + QList items; + static QString andOpString; + static QString notOpString; + static QString orOpString; + + QStringListModel *mModel; + QStringList mList; + +signals: + void initSearch(int, QString); + void filterChanged(); + +private slots: + void processFilters(); + void slotPanoFilter(); + void metaFilter(); + void metaSelectField(int idx); + + void filtersDialog(); + + void slotLoadFilter(const QString& fname); + void slotRemoveFilter(const QString& fname); + + void slotRemoveFilterItem(bool process = true); + + void slotTagSelect(const QModelIndex & index); + void slotTagEdit(const QModelIndex & index); + void slotClearFilter(); + + void slotToggleTags(bool t); + void slotToggleMeta(bool t); + void slotTogglePano(bool t); + void slotToggleFilter(bool t); + +public slots: + void slotSaveFilter(); + +}; + +#endif // FILTERBAR_H diff -Nru fontmatrix-0.6.0+svn20100107/src/filterbar.ui fontmatrix-0.6.0+svn20110930/src/filterbar.ui --- fontmatrix-0.6.0+svn20100107/src/filterbar.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filterbar.ui 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,467 @@ + + + FilterBar + + + + 0 + 0 + 240 + 761 + + + + Form + + + + 6 + + + 2 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0 + + + 3 + + + + + + + Filters + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + true + + + + + 0 + 0 + 226 + 172 + + + + + 0 + 0 + + + + + 0 + + + + + 0 + + + + + + + Qt::Vertical + + + + 20 + 200 + + + + + + + + + + + + + + + + + 0 + + + + + + + Tags + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + + + 0 + + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 212 + 208 + 200 + + + + + + + + Qt::NoFocus + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + false + + + QAbstractItemView::DoubleClicked + + + QAbstractItemView::NoSelection + + + QListView::Static + + + QListView::Adjust + + + QListView::ListMode + + + 0 + + + false + + + + + + + + + + + + Qt::Horizontal + + + + + + + 0 + + + + + + + Metadata + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + + + 0 + + + + + 3 + + + 3 + + + 3 + + + + + 0 + + + + + Search + + + + + + + + 0 + 0 + + + + + 172 + 0 + + + + + + + + + + 0 + + + + + in + + + + + + + + 0 + 0 + + + + + 172 + 0 + + + + + + + + + + + + + + + + + 0 + + + 3 + + + 3 + + + + + + + Panose + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + + + 0 + + + + + + + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + PanoseWidget + QWidget +
panosewidget.h
+ 1 +
+ + OpenCloseArrow + QLabel +
openclosearrow.h
+
+ + TagListView + QListView +
filterbar.h
+
+
+ + +
diff -Nru fontmatrix-0.6.0+svn20100107/src/filterdata.cpp fontmatrix-0.6.0+svn20110930/src/filterdata.cpp --- fontmatrix-0.6.0+svn20100107/src/filterdata.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filterdata.cpp 2010-07-25 10:32:19.000000000 +0000 @@ -0,0 +1,228 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filterdata.h" +#include "fmfontdb.h" +#include "filteritem.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +FilterData::FilterData() +{ + vData.clear(); + // default operation + vData.insert(Replace, false); + vData.insert(Or, true); + vData.insert(And, false); + vData.insert(Not, false); +} + + +void FilterData::setData(int index, QVariant data, bool signalChange) +{ + vData.insert(index, data); + if(signalChange) + emit Changed(); +} + +QVariant FilterData::data(int index) const +{ + return vData.value(index); +} + + +QString FilterData::getText() const +{ + return vData.value(Text, QString("*")).toString(); +} + +FilterItem* FilterData::item() +{ + if(f.isNull()) + f = new FilterItem(this); + return f.data(); +} + +void FilterData::operateFilter(QListfl) +{ + QList sourceList = fl; + QList notList; + QList andList; + + bool notOp(vData[Not].toBool()); + bool andOp(vData[And].toBool()); + bool orOp(vData[Or].toBool()); + + FMFontDb* fmdb(FMFontDb::DB()); + + if(andOp) + { + andList = fmdb->getFilteredFonts(); + } + if(notOp) + notList = fmdb->AllFonts(); + + if(!orOp) + fmdb->clearFilteredFonts(); + + if(notOp) + { + if(andOp) + { + foreach(FontItem* f, notList) + { + if(!sourceList.contains(f) && andList.contains(f)) + fmdb->insertFilteredFont(f); + } + } + else + { + foreach(FontItem* f, notList) + { + if(!sourceList.contains(f)) + fmdb->insertFilteredFont(f); + } + } + } + else // not notOp + { + if(andOp) + { + foreach(FontItem* f, sourceList) + { + if(andList.contains(f)) + fmdb->insertFilteredFont(f); + } + } + else + { + foreach(FontItem* f, sourceList) + { + fmdb->insertFilteredFont(f); + } + } + } + + emit Operated(); +} + + +QByteArray FilterData::toByteArray() const +{ + QByteArray ba; + QDataStream ds(&ba, QIODevice::WriteOnly); + foreach(int idx, vData.keys()) + { + QVariant::Type t(vData.value(idx).type()); + QVariant v(vData[idx]); + ds << idx << t; + switch(t) + { + // We keep a large subset of supported types, but well, it's rather optimistic. + case QVariant::BitArray : { ds << v.value(); break; } + case QVariant::Bool : { ds << v.value(); break; } + case QVariant::ByteArray : { ds << v.value(); break; } + case QVariant::Char : { ds << v.value(); break; } + case QVariant::Double : { ds << v.value(); break; } + case QVariant::Icon : { ds << v.value(); break; } + case QVariant::Image : { ds << v.value(); break; } + case QVariant::Int : { ds << v.value(); break; } + case QVariant::Locale : { ds << v.value(); break; } + case QVariant::LongLong : { ds << v.value(); break; } + case QVariant::Matrix : { ds << v.value(); break; } + case QVariant::Transform : { ds << v.value(); break; } + case QVariant::Pixmap : { ds << v.value(); break; } + case QVariant::PointF : { ds << v.value(); break; } + case QVariant::RectF : { ds << v.value(); break; } + case QVariant::RegExp : { ds << v.value(); break; } + case QVariant::SizeF : { ds << v.value(); break; } + case QVariant::String : { ds << v.value(); break; } + case QVariant::Time : { ds << v.value(); break; } + case QVariant::UInt : { ds << v.value(); break; } + case QVariant::ULongLong : { ds << v.value(); break; } + case QVariant::Url : { ds << v.value(); break; } + } + + } + return ba; +} + +void FilterData::fromByteArray(const QByteArray &ba) +{ + QDataStream ds(ba); + int idx(0); + ds >> idx; + while(idx != 0) + { + QVariant::Type t; + ds >> t; + QVariant v(t); + switch(t) + { + case QVariant::BitArray : { QBitArray data; ds >> data ; v.setValue(data); break; } + case QVariant::Bitmap : { QBitmap data; ds >> data ; v.setValue(data); break; } + case QVariant::Bool : { bool data; ds >> data ; v.setValue(data); break; } + case QVariant::ByteArray : { QByteArray data; ds >> data ; v.setValue(data); break; } + case QVariant::Char : { QChar data; ds >> data ; v.setValue(data); break; } + case QVariant::Double : { double data; ds >> data ; v.setValue(data); break; } + case QVariant::Icon : { QIcon data; ds >> data ; v.setValue(data); break; } + case QVariant::Image : { QImage data; ds >> data ; v.setValue(data); break; } + case QVariant::Int : { int data; ds >> data ; v.setValue(data); break; } + case QVariant::Locale : { QLocale data; ds >> data ; v.setValue(data); break; } + case QVariant::LongLong : { qlonglong data; ds >> data ; v.setValue(data); break; } + case QVariant::Matrix : { QMatrix data; ds >> data ; v.setValue(data); break; } + case QVariant::Transform : { QTransform data; ds >> data ; v.setValue(data); break; } + case QVariant::Pixmap : { QPixmap data; ds >> data ; v.setValue(data); break; } + case QVariant::PointF : { QPointF data; ds >> data ; v.setValue(data); break; } + case QVariant::RectF : { QRectF data; ds >> data ; v.setValue(data); break; } + case QVariant::RegExp : { QRegExp data; ds >> data ; v.setValue(data); break; } + case QVariant::SizeF : { QSizeF data; ds >> data ; v.setValue(data); break; } + case QVariant::String : { QString data; ds >> data ; v.setValue(data); break; } + case QVariant::Time : { QTime data; ds >> data ; v.setValue(data); break; } + case QVariant::UInt : { uint data; ds >> data ; v.setValue(data); break; } + case QVariant::ULongLong : { qulonglong data; ds >> data ; v.setValue(data); break; } + case QVariant::Url : { QUrl data; ds >> data ; v.setValue(data); break; } + + } + vData.insert(idx, v); + + ds >> idx; + } + +} diff -Nru fontmatrix-0.6.0+svn20100107/src/filterdata.h fontmatrix-0.6.0+svn20110930/src/filterdata.h --- fontmatrix-0.6.0+svn20100107/src/filterdata.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filterdata.h 2010-07-17 11:27:10.000000000 +0000 @@ -0,0 +1,73 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERDATA_H +#define FILTERDATA_H + +#include +#include +#include +#include +#include +#include +#include + +class FilterItem; +class FontItem; + +class FilterData : public QObject +{ + Q_OBJECT + +public: + FilterData(); + + enum Index{ + Replace = 1, + Or, + And, + Not, + Text, + UserIndex = 16 + }; + + virtual void setData(int index, QVariant data, bool signalChange = false); + virtual QVariant data(int index) const; + virtual QString getText() const; + virtual QByteArray toByteArray() const; + virtual void fromByteArray(const QByteArray& ba); + virtual FilterItem* item(); + + virtual QString type() const = 0; + virtual void operate() = 0; + +protected: + QMap vData; + virtual void operateFilter(QList fl); + +private: + QPointer f; + +signals: + void Operated(); + void Changed(); +}; + +#endif // FILTERDATA_H diff -Nru fontmatrix-0.6.0+svn20100107/src/filteritem.cpp fontmatrix-0.6.0+svn20110930/src/filteritem.cpp --- fontmatrix-0.6.0+svn20100107/src/filteritem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filteritem.cpp 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filteritem.h" +#include "ui_filteritem.h" +#include "filterdata.h" + +FilterItem::FilterItem(FilterData *filter, QWidget *parent) : + QWidget(parent), + d(filter), + ui(new Ui::FilterItem) +{ + ui->setupUi(this); + + QString ssheet; + ssheet += QString("QToolButton{border:none;}"); + ssheet += QString("QToolButton:checked{border-bottom:2px solid black;}"); + ssheet += QString("QToolButton:hover{background:white;}"); +// ssheet += QString(); +// ssheet += QString(); +// ssheet += QString(); +// ssheet += QString(); + this->setStyleSheet(ssheet); + + ui->filterLabel->setText(d->getText()); + ui->andButton->setChecked(d->data(FilterData::And).toBool()); + ui->noButton->setChecked(d->data(FilterData::Not).toBool()); + + connect(ui->andButton, SIGNAL(clicked(bool)), this, SLOT(setAndMode(bool))); + connect(ui->noButton, SIGNAL(clicked(bool)), this, SLOT(setNoMode(bool))); + connect(ui->removeButton, SIGNAL(clicked()), this, SIGNAL(remove())); +} + +FilterItem::~FilterItem() +{ + delete ui; + delete d; +} + + +void FilterItem::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + + +void FilterItem::setAndMode(bool c) +{ + d->setData(FilterData::Or, !c, true); + d->setData(FilterData::And, c, true); +} + +void FilterItem::setNoMode(bool c) +{ + d->setData(FilterData::Not, c, true); +} + + +void FilterItem::hideOperation(Operation op) +{ + if(op == AND) + { + if(d->data(FilterData::And).toBool()) + { + d->setData(FilterData::Or, true); + d->setData(FilterData::And, false); + } + ui->andButton->hide(); + } +} diff -Nru fontmatrix-0.6.0+svn20100107/src/filteritem.h fontmatrix-0.6.0+svn20110930/src/filteritem.h --- fontmatrix-0.6.0+svn20100107/src/filteritem.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filteritem.h 2010-07-25 10:32:19.000000000 +0000 @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERITEM_H +#define FILTERITEM_H + +#include + +class FilterData; + +namespace Ui { + class FilterItem; +} + +class FilterItem : public QWidget +{ + Q_OBJECT + + FilterData* d; + QString text; +public: + enum Operation{ + AND, + OR, + NOT + }; + + explicit FilterItem(FilterData *filter, QWidget *parent = 0); + ~FilterItem(); + + FilterData* filter(){return d;} + void hideOperation(Operation op); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::FilterItem *ui; + +signals: + void remove(); + +private slots: + void setAndMode(bool c); + void setNoMode(bool c); + +}; + +#endif // FILTERITEM_H diff -Nru fontmatrix-0.6.0+svn20100107/src/filteritem.ui fontmatrix-0.6.0+svn20110930/src/filteritem.ui --- fontmatrix-0.6.0+svn20100107/src/filteritem.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filteritem.ui 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,167 @@ + + + FilterItem + + + + 0 + 0 + 149 + 31 + + + + Form + + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + + + + 16777215 + 24 + + + + + 11 + 75 + true + + + + TextLabel + + + + + + + 2 + + + + + + 16 + 16 + + + + + 75 + true + + + + Remove Filter + + + + + + X + + + + :/graphic-resources/filter-remove.png:/graphic-resources/filter-remove.png + + + true + + + + + + + + 16 + 16 + + + + + 75 + true + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If set, the filter will <span style=" font-weight:600;">intersect</span> with the previous filters.</p></td></tr></table></body></html> + + + && + + + + :/graphic-resources/filter-and.png:/graphic-resources/filter-and.png + + + true + + + true + + + + + + + + 16 + 16 + + + + + 75 + true + + + + if set, it will filter all the fonts but these matching this filter + + + ! + + + true + + + true + + + + + + + + + + + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/filtermeta.cpp fontmatrix-0.6.0+svn20110930/src/filtermeta.cpp --- fontmatrix-0.6.0+svn20100107/src/filtermeta.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtermeta.cpp 2010-07-16 16:35:25.000000000 +0000 @@ -0,0 +1,91 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filtermeta.h" +#include "fmfontdb.h" +#include "fontitem.h" +#include "fmfontstrings.h" + +FilterMeta::FilterMeta(): + FilterData() +{ +} + + +QString FilterMeta::type() const +{ + return QString("Meta"); +} + +void FilterMeta::operate() +{ + QString fs ( vData[Value].toString() ); + int ff(vData[Field].toInt()); + + if(ff == FILTER_FIELD_SPECIAL_UNICODE) //Unicode + { + QList allList = FMFontDb::DB()->AllFonts(); + QList tl; + int startC(0xFFFFFFFF); + int endC(0); + int patCount(fs.count()); + for(int a(0); a < patCount; ++a) + { + unsigned int ca(fs[a].unicode()); + if( ca < startC) + startC = ca; + if(ca > endC) + endC = ca; + } + + int superSetCount(allList.count()); + for ( int i =0; i < superSetCount; ++i ) + { + int cc(allList[i]->countCoverage ( startC, endC ) ); + if ( cc >= patCount ) + { + tl.append ( allList[i]); + } + } + + operateFilter(tl); + } + else if(ff == FMFontDb::AllInfo) + { + FMFontDb::InfoItem k; + QList tmpList; + tmpList.clear(); + for(int gIdx(0); gIdx < FontStrings::Names().keys().count() ; ++gIdx) + { + k = FontStrings::Names().keys()[gIdx]; + if(k != FMFontDb::AllInfo) + { + tmpList += FMFontDb::DB()->Fonts(fs,k); + } + } + + operateFilter(tmpList); + + } + else + { + operateFilter(FMFontDb::DB()->Fonts(fs, FMFontDb::InfoItem(ff))); + } +} diff -Nru fontmatrix-0.6.0+svn20100107/src/filtermeta.h fontmatrix-0.6.0+svn20110930/src/filtermeta.h --- fontmatrix-0.6.0+svn20100107/src/filtermeta.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtermeta.h 2010-07-16 08:53:23.000000000 +0000 @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERMETA_H +#define FILTERMETA_H + +#include "filterdata.h" + +#define FILTER_FIELD_SPECIAL_UNICODE 2001 + +class FilterMeta : public FilterData +{ +public: + FilterMeta(); + + enum TagIndex{ + Field = FilterData::UserIndex, + Value + }; + + QString type() const; + void operate(); +}; + +#endif // FILTERMETA_H diff -Nru fontmatrix-0.6.0+svn20100107/src/filterpanose.cpp fontmatrix-0.6.0+svn20110930/src/filterpanose.cpp --- fontmatrix-0.6.0+svn20100107/src/filterpanose.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filterpanose.cpp 2010-07-16 08:23:49.000000000 +0000 @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filterpanose.h" +#include "fmfontdb.h" + +FilterPanose::FilterPanose(): + FilterData() +{ +} + +QString FilterPanose::type() const +{ + return QString("Panose"); +} + + +void FilterPanose::operate() +{ + QList dbresult( FMFontDb::DB()->getValues( FMFontDb::Panose ) ); + QList fil; + int paramIdx(vData[Param].toInt()); + int val(vData[Value].toInt()); + int fv(0); + for(int i(0); i < dbresult.count() ; ++i) + { + QStringList pl(dbresult[i].second.split(":")); + fv = pl[paramIdx].toInt(); + if(fv == val) + fil << dbresult[i].first; + } + operateFilter(fil); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/filterpanose.h fontmatrix-0.6.0+svn20110930/src/filterpanose.h --- fontmatrix-0.6.0+svn20100107/src/filterpanose.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filterpanose.h 2010-07-16 08:23:49.000000000 +0000 @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERPANOSE_H +#define FILTERPANOSE_H + +#include "filterdata.h" + +class FilterPanose : public FilterData +{ +public: + FilterPanose(); + + enum TagIndex{ + Param = FilterData::UserIndex, + Value + }; + + QString type() const; + void operate(); +}; + +#endif // FILTERPANOSE_H diff -Nru fontmatrix-0.6.0+svn20100107/src/filtersdialog.cpp fontmatrix-0.6.0+svn20110930/src/filtersdialog.cpp --- fontmatrix-0.6.0+svn20100107/src/filtersdialog.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtersdialog.cpp 2010-09-14 14:26:51.000000000 +0000 @@ -0,0 +1,180 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filtersdialog.h" +#include "ui_filtersdialog.h" + +#include "filtersdialogitem.h" +#include "filtertag.h" +#include "filterpanose.h" +#include "filtermeta.h" +#include "fmpaths.h" +#include "filteritem.h" + +#include +#include + +QString FiltersDialog::andOpString = FiltersDialog::tr("And"); +QString FiltersDialog::notOpString = FiltersDialog::tr("Not"); +QString FiltersDialog::orOpString = FiltersDialog::tr("Or"); + + +FiltersDialog::FiltersDialog(const QList& currentFilters, QWidget *parent) : + QDialog(parent), + ui(new Ui::FiltersDialog) +{ + setAttribute(Qt::WA_DeleteOnClose); + ui->setupUi(this); + + loadFilters(); + + connect(ui->addButton, SIGNAL(clicked()), this, SLOT(slotAddFilter())); +// connect(ui->moreButton, SIGNAL(clicked(bool)), this, SLOT(showAdd(bool))); + + if(!currentFilters.isEmpty()) + { + QString fs; + bool first(true); + foreach(FilterItem *f, currentFilters) + { + FilterData *d(f->filter()); + if(first) + { + first = false; + fs += filterString(d, true); + } + else + fs += filterString(d); + + } + ui->curFilter->setText(fs); + ui->messageStack->setCurrentWidget(ui->pagePossible); + } + else + { + ui->messageStack->setCurrentWidget(ui->pageImpossible); + } +} + +FiltersDialog::~FiltersDialog() +{ + delete ui; +} + + +QString FiltersDialog::filterString(FilterData *d, bool first) +{ + QString fs; + if(first) + { + first = false; + if(d->data(FilterData::Not).toBool()) + fs += notOpString + QString(" [%1] ").arg(d->getText()); + else + fs += QString("[%1] ").arg(d->getText()); + } + else + { + if(d->data(FilterData::Or).toBool()) + fs += orOpString; + else + fs += andOpString; + + if(d->data(FilterData::Not).toBool()) + fs += QString(" %1").arg(notOpString); + fs += QString(" [%1] ").arg(d->getText()); + } + return fs; +} + +void FiltersDialog::loadFilters() +{ + foreach(FiltersDialogItem* i, items) + delete i; + items.clear(); + + QDir fbasedir(FMPaths::FiltersDir()); + QStringList fbaselist(fbasedir.entryList(QDir::NoDotAndDotDot|QDir::Dirs,QDir::Name)); + foreach(QString fname, fbaselist) + { + QDir fdir(FMPaths::FiltersDir() + fname); + QStringList flist(fdir.entryList(QDir::NoDotAndDotDot|QDir::Files, QDir::Name)); + QString fString; + bool first(true); + foreach(QString fn, flist) + { + QStringList l(fn.split(QString("-"))); + if(l.count() == 2) + { + QString type(l.at(1)); + QFile file(fdir.absoluteFilePath(fn)); + if(file.open(QIODevice::ReadOnly)) + { + FilterData *f; + if(type == QString("Meta")) + { + f = new FilterMeta; + } + else if(type == QString("Panose")) + { + f = new FilterPanose; + } + else if(type == QString("Tag")) + { + f = new FilterTag; + } + f->fromByteArray(file.readAll()); + if(first) + { + first = false; + fString += filterString(f, true); + } + else + fString += filterString(f); + delete f; + } + } + } + FiltersDialogItem *fdi(new FiltersDialogItem(fname, fString, this)); + items.append(fdi); + ui->filtersLayout->addWidget(fdi); + connect(fdi, SIGNAL(Filter(QString)), this, SIGNAL(Filter(QString))); + connect(fdi, SIGNAL(Filter(QString)), this, SLOT(close())); + connect(fdi, SIGNAL(Remove(QString)), this, SLOT(slotRemoveFilter(QString))); + } +} + + +void FiltersDialog::slotAddFilter() +{ + QString fname(ui->newName->text()); + if(!fname.isEmpty()) + emit AddFilter(fname); + + loadFilters(); +} + +void FiltersDialog::slotRemoveFilter(QString fs) +{ + emit RemoveFilter(fs); + loadFilters(); +} + + diff -Nru fontmatrix-0.6.0+svn20100107/src/filtersdialog.h fontmatrix-0.6.0+svn20110930/src/filtersdialog.h --- fontmatrix-0.6.0+svn20100107/src/filtersdialog.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtersdialog.h 2010-09-14 14:26:51.000000000 +0000 @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERSDIALOG_H +#define FILTERSDIALOG_H + +#include +#include +#include + +namespace Ui { + class FiltersDialog; +} + +class FiltersDialogItem; +class FilterItem; +class FilterData; + +class FiltersDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FiltersDialog(const QList& currentFilter, QWidget *parent = 0); + ~FiltersDialog(); + +private: + Ui::FiltersDialog *ui; + + void loadFilters(); + QString filterString(FilterData *d, bool first = false); + QList items; + + static QString andOpString; + static QString notOpString; + static QString orOpString; + +signals: + void Filter(QString); + void AddFilter(QString); + void RemoveFilter(QString); + +private slots: + void slotAddFilter(); + void slotRemoveFilter(QString fs); +}; + +#endif // FILTERSDIALOG_H diff -Nru fontmatrix-0.6.0+svn20100107/src/filtersdialogitem.cpp fontmatrix-0.6.0+svn20110930/src/filtersdialogitem.cpp --- fontmatrix-0.6.0+svn20100107/src/filtersdialogitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtersdialogitem.cpp 2011-02-17 10:42:06.000000000 +0000 @@ -0,0 +1,84 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filtersdialogitem.h" +#include "ui_filtersdialogitem.h" + + +#include + +FiltersDialogItem::FiltersDialogItem(const QString& name, const QString& f, QWidget *parent) : + QWidget(parent), + ui(new Ui::FiltersDialogItem), + filterName(name) +{ + ui->setupUi(this); + QString ssheet; + ssheet += QString("QToolButton{border:none;}"); + ssheet += QString("QToolButton:checked{border-bottom:2px solid black;}"); + ssheet += QString("QToolButton:hover{background:white;}"); +// ssheet += QString(); +// ssheet += QString(); +// ssheet += QString(); +// ssheet += QString(); + this->setStyleSheet(ssheet); +// setButtonsVisible(false); + ui->filterName->setText(filterName); + ui->filterName->setToolTip(f); +// ui->filters->setText(f); + + connect(ui->filterButton, SIGNAL(clicked()), this, SLOT(slotFilter())); + connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(slotRemove())); +} + +FiltersDialogItem::~FiltersDialogItem() +{ + delete ui; +} + + +void FiltersDialogItem::slotFilter() +{ + emit Filter(filterName); +} + + +void FiltersDialogItem::slotRemove() +{ + if(QMessageBox::question(0, tr("Remove Filter"), tr("Confirm deletion of filter:") + filterName, QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) == QMessageBox::Ok) + emit Remove(filterName); +} + +void FiltersDialogItem::setButtonsVisible(bool v) +{ + ui->filterButton->setVisible(v); + ui->removeButton->setVisible(v); + +} + +void FiltersDialogItem::enterEvent(QEvent *) +{ +// setButtonsVisible(true); +} + +void FiltersDialogItem::leaveEvent(QEvent *) +{ +// setButtonsVisible(false); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/filtersdialogitem.h fontmatrix-0.6.0+svn20110930/src/filtersdialogitem.h --- fontmatrix-0.6.0+svn20100107/src/filtersdialogitem.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtersdialogitem.h 2010-07-23 09:17:39.000000000 +0000 @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERSDIALOGITEM_H +#define FILTERSDIALOGITEM_H + +#include +#include + +namespace Ui { + class FiltersDialogItem; +} + +class FiltersDialogItem : public QWidget +{ + Q_OBJECT + +public: + explicit FiltersDialogItem(const QString& name, const QString& f, QWidget *parent = 0); + ~FiltersDialogItem(); + +protected: + void enterEvent(QEvent *); + void leaveEvent(QEvent *); + +private: + Ui::FiltersDialogItem *ui; + + void setButtonsVisible(bool v); + QString filterName; + +private slots: + void slotFilter(); + void slotRemove(); + +signals: + void Filter(QString); + void Remove(QString); +}; + +#endif // FILTERSDIALOGITEM_H diff -Nru fontmatrix-0.6.0+svn20100107/src/filtersdialogitem.ui fontmatrix-0.6.0+svn20110930/src/filtersdialogitem.ui --- fontmatrix-0.6.0+svn20100107/src/filtersdialogitem.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtersdialogitem.ui 2011-02-17 10:42:06.000000000 +0000 @@ -0,0 +1,134 @@ + + + FiltersDialogItem + + + + 0 + 0 + 203 + 34 + + + + Form + + + + 2 + + + 2 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 2 + + + 6 + + + 2 + + + 3 + + + 0 + + + + + + 0 + 0 + + + + + 1000 + 24 + + + + + 11 + 75 + true + + + + filter name + + + Qt::PlainText + + + false + + + + + + + + 16 + 16 + + + + Apply this filter to the list + + + Filter + + + + :/graphic-resources/filter.png:/graphic-resources/filter.png + + + + + + + + 16 + 16 + + + + Delete this filter + + + Remove + + + + :/graphic-resources/filter-remove.png:/graphic-resources/filter-remove.png + + + true + + + + + + + + + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/filtersdialog.ui fontmatrix-0.6.0+svn20110930/src/filtersdialog.ui --- fontmatrix-0.6.0+svn20100107/src/filtersdialog.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtersdialog.ui 2010-09-14 14:26:51.000000000 +0000 @@ -0,0 +1,229 @@ + + + FiltersDialog + + + + 0 + 0 + 494 + 448 + + + + Filters Manager + + + + 0 + + + + + + 0 + 2 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + true + + + + + 0 + 0 + 480 + 311 + + + + + + + + + + + + + + 0 + + + + + + + + + + In order to add filters, you have to first select some of tags, meta informations or classifications elements. + + + Qt::AutoText + + + true + + + + + + + + + + + + + + + + + + 75 + true + + + + Add Filter + + + + + + + + 0 + 10 + + + + Qt::Horizontal + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + Filter Name: + + + newName + + + + + + + + 10 + 0 + + + + + + + + + 0 + 0 + + + + Add + + + + + + + + + current filter + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 402 + 20 + + + + + + + + Close + + + + + + + + + + + + closeButton + clicked() + FiltersDialog + close() + + + 459 + 441 + + + 250 + 230 + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/filtertag.cpp fontmatrix-0.6.0+svn20110930/src/filtertag.cpp --- fontmatrix-0.6.0+svn20100107/src/filtertag.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtertag.cpp 2010-07-16 08:23:49.000000000 +0000 @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filtertag.h" +#include "filteritem.h" +#include "fmfontdb.h" + +FilterTag::FilterTag(): + FilterData() +{ +} + +QString FilterTag::type() const +{ + return QString("Tag"); +} + +void FilterTag::operate() +{ + QString key(vData.value(Key).toString()); + QString tag(vData.value(Tag).toString()); + + if(key == "TAG") // regular tag + { + operateFilter( FMFontDb::DB()->Fonts(tag, FMFontDb::Tags ) ); + } + else if(key == "ALL_ACTIVATED") + { + operateFilter( FMFontDb::DB()->Fonts(1, FMFontDb::Activation ) ); + } +} diff -Nru fontmatrix-0.6.0+svn20100107/src/filtertagdialog.cpp fontmatrix-0.6.0+svn20110930/src/filtertagdialog.cpp --- fontmatrix-0.6.0+svn20100107/src/filtertagdialog.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtertagdialog.cpp 2010-06-18 10:28:36.000000000 +0000 @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "filtertagdialog.h" +#include "ui_filtertagdialog.h" + +FilterTagDialog::FilterTagDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::FilterTagDialog) +{ + ui->setupUi(this); +} + +FilterTagDialog::~FilterTagDialog() +{ + delete ui; +} + +void FilterTagDialog::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff -Nru fontmatrix-0.6.0+svn20100107/src/filtertagdialog.h fontmatrix-0.6.0+svn20110930/src/filtertagdialog.h --- fontmatrix-0.6.0+svn20100107/src/filtertagdialog.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtertagdialog.h 2010-06-18 10:28:36.000000000 +0000 @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERTAGDIALOG_H +#define FILTERTAGDIALOG_H + +#include + +namespace Ui { + class FilterTagDialog; +} + +class FilterTagDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FilterTagDialog(QWidget *parent = 0); + ~FilterTagDialog(); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::FilterTagDialog *ui; +}; + +#endif // FILTERTAGDIALOG_H diff -Nru fontmatrix-0.6.0+svn20100107/src/filtertagdialog.ui fontmatrix-0.6.0+svn20110930/src/filtertagdialog.ui --- fontmatrix-0.6.0+svn20100107/src/filtertagdialog.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtertagdialog.ui 2010-06-18 10:28:36.000000000 +0000 @@ -0,0 +1,18 @@ + + FilterTagDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/filtertag.h fontmatrix-0.6.0+svn20110930/src/filtertag.h --- fontmatrix-0.6.0+svn20100107/src/filtertag.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/filtertag.h 2010-07-16 08:23:49.000000000 +0000 @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FILTERTAG_H +#define FILTERTAG_H + +#include "filterdata.h" + + + +class FilterTag : public FilterData +{ +public: + FilterTag(); + + enum TagIndex{ + Key = FilterData::UserIndex, + Tag + }; + + QString type() const; + void operate(); +}; + +#endif // FILTERTAG_H diff -Nru fontmatrix-0.6.0+svn20100107/src/floatingwidget.cpp fontmatrix-0.6.0+svn20110930/src/floatingwidget.cpp --- fontmatrix-0.6.0+svn20100107/src/floatingwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/floatingwidget.cpp 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,91 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "floatingwidget.h" +#include "floatingwidgetsregister.h" +#include "typotek.h" +#include "fmfontdb.h" +#include "fontitem.h" + +FloatingWidget::FloatingWidget(const QString &f, const QString& typ, QWidget *parent) : + QWidget(parent), + fName(f), + fType(typ), + printer(0), + printDialog(0) +{ + setAttribute(Qt::WA_DeleteOnClose); + QString fn; + FontItem *fi(FMFontDb::DB()->Font(fName)); + if(fi != 0) + fn = fi->fancyName(); + else + fn = f; + actionName = QString("[%1]").arg(fType) + QString(" ") + fn; + wTitle = fn + QString(" - Fontmatrix"); + if(0 == parent) + { + ddetach(); + } +} + +FloatingWidget::~FloatingWidget() +{ + if(printer) + delete printer; + if(printDialog) + delete printDialog; +} + + +bool FloatingWidget::event(QEvent *e) +{ + // if(windowTitle().isEmpty()) + // { + // QWidget::setWindowTitle(wTitle); + // } + if((e->type() == QEvent::Show) || (e->type() == QEvent::Hide)) + emit visibilityChange(); + + return QWidget::event(e); +} + +void FloatingWidget::activate(bool a) +{ + if(a) + { + if(!isVisible()) + setVisible(true); + raise(); + } + else + hide(); +} + + +void FloatingWidget::ddetach() +{ + if(0 != parent()) + setParent(0, Qt::Window); + setWindowTitle(wTitle); + FloatingWidgetsRegister::Register(this, fName, fType); + show(); + emit detached(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/floatingwidget.h fontmatrix-0.6.0+svn20110930/src/floatingwidget.h --- fontmatrix-0.6.0+svn20100107/src/floatingwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/floatingwidget.h 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FLOATINGWIDGET_H +#define FLOATINGWIDGET_H + +#include +#include +#include +#include + +class FloatingWidget : public QWidget +{ + Q_OBJECT + + explicit FloatingWidget(QWidget *parent = 0){} +public: + explicit FloatingWidget(const QString &f, const QString& typ, QWidget *parent = 0); + ~FloatingWidget(); + + QString getActionName()const{return actionName;} + +private: + QString fName; + QString fType; + QString actionName; + QString wTitle; + +protected: + QPrinter * printer; + QPrintDialog * printDialog; + virtual bool event( QEvent * e ); + +signals: + void visibilityChange(); + void detached(); + +public slots: + void activate(bool a); + void ddetach(); // seems there's naming conflict with Qt4.7 + +}; + +#endif // FLOATINGWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/floatingwidgetsregister.cpp fontmatrix-0.6.0+svn20110930/src/floatingwidgetsregister.cpp --- fontmatrix-0.6.0+svn20100107/src/floatingwidgetsregister.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/floatingwidgetsregister.cpp 2010-06-25 14:44:48.000000000 +0000 @@ -0,0 +1,78 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "floatingwidgetsregister.h" + +#include "floatingwidget.h" + +FloatingWidgetsRegister * FloatingWidgetsRegister::instance = 0; + +FloatingWidgetsRegister::FloatingWidgetsRegister() +{ +} + +FloatingWidgetsRegister * FloatingWidgetsRegister::that() +{ + if(instance == 0) + instance = new FloatingWidgetsRegister; + return instance; +} + + +void FloatingWidgetsRegister::Register(FloatingWidget * f, const QString &fid, const QString &typ) +{ + FloatingWidgetsRegister *fwr(that()); + fwr->fwMap[typ][fid] = f; +} + +FloatingWidget * FloatingWidgetsRegister::Widget(const QString &fid, const QString &typ) +{ + FloatingWidgetsRegister *fwr(that()); + if(fwr->fwMap.contains(typ)) + { + if(fwr->fwMap[typ].contains(fid)) + { + if(fwr->fwMap[typ][fid].isNull()) + fwr->fwMap[typ].remove(fid); + else + return fwr->fwMap[typ][fid]; + } + } + return 0; +} + +QList FloatingWidgetsRegister::AllWidgets() +{ + QList ret; + FloatingWidgetsRegister *fwr(that()); + ret.clear(); + foreach(QString t, fwr->fwMap.keys()) + { + foreach(QString f, fwr->fwMap[t].keys()) + { + if(fwr->fwMap[t][f].isNull()) + fwr->fwMap[t].remove(f); + else + ret << fwr->fwMap[t][f].data(); + } + } + return ret; +} + diff -Nru fontmatrix-0.6.0+svn20100107/src/floatingwidgetsregister.h fontmatrix-0.6.0+svn20110930/src/floatingwidgetsregister.h --- fontmatrix-0.6.0+svn20100107/src/floatingwidgetsregister.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/floatingwidgetsregister.h 2010-06-25 14:44:48.000000000 +0000 @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FLOATINGWIDGETSREGISTER_H +#define FLOATINGWIDGETSREGISTER_H + +//#include +#include +#include +#include +#include + +class FloatingWidget; + +class FloatingWidgetsRegister +{ + static FloatingWidgetsRegister * instance; + FloatingWidgetsRegister(); + ~FloatingWidgetsRegister(){} + static FloatingWidgetsRegister* that(); +public: + static void Register(FloatingWidget* f, const QString& fid, const QString& typ); + static FloatingWidget* Widget(const QString& fid, const QString& typ); + static QList AllWidgets(); + +private: + QMap< QString, QMap < QString, QPointer > > fwMap; // map[ type , [ fontID , pointer ] ] + + +}; + +#endif // FLOATINGWIDGETSREGISTER_H diff -Nru fontmatrix-0.6.0+svn20100107/src/floatingwidgettoolbar.cpp fontmatrix-0.6.0+svn20110930/src/floatingwidgettoolbar.cpp --- fontmatrix-0.6.0+svn20100107/src/floatingwidgettoolbar.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/floatingwidgettoolbar.cpp 2011-02-17 10:42:06.000000000 +0000 @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "floatingwidgettoolbar.h" +#include "ui_floatingwidgettoolbar.h" + +#include "floatingwidget.h" + +#include +#include + +FloatingWidgetToolBar::FloatingWidgetToolBar(QWidget *parent) : + QWidget(parent), + ui(new Ui::FloatingWidgetToolBar), + noClose(false), + isDetached(false) +{ + ui->setupUi(this); + + connect(ui->closeButton, SIGNAL(clicked()), this, SIGNAL(Close())); + connect(ui->hideButton, SIGNAL(clicked()), this, SIGNAL(Hide())); + connect(ui->printButton, SIGNAL(clicked()), this, SIGNAL(Print())); + connect(ui->detachButton, SIGNAL(clicked()), this, SLOT(setDetached())); + setupMenu(); + +} + +FloatingWidgetToolBar::~FloatingWidgetToolBar() +{ + delete ui; +} + +void FloatingWidgetToolBar::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + + +void FloatingWidgetToolBar::setupMenu() +{ + if(isDetached) + { + if(!noClose) + ui->closeButton->show(); + else + ui->closeButton->hide(); + ui->hideButton->show(); + ui->detachButton->hide(); + } + else + { + ui->closeButton->hide(); + ui->hideButton->hide(); + ui->detachButton->show(); + } + ui->printButton->show(); +} + +void FloatingWidgetToolBar::setDetached() +{ + isDetached = true; + setupMenu(); + emit Detach(); +} + +void FloatingWidgetToolBar::setNoClose(bool c) +{ + noClose = c; + setupMenu(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/floatingwidgettoolbar.h fontmatrix-0.6.0+svn20110930/src/floatingwidgettoolbar.h --- fontmatrix-0.6.0+svn20100107/src/floatingwidgettoolbar.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/floatingwidgettoolbar.h 2011-02-17 10:42:06.000000000 +0000 @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FLOATINGWIDGETTOOLBAR_H +#define FLOATINGWIDGETTOOLBAR_H + +#include + +class QMenu; +class QAction; + +namespace Ui { + class FloatingWidgetToolBar; +} + +class FloatingWidgetToolBar : public QWidget +{ + Q_OBJECT + +public: + explicit FloatingWidgetToolBar(QWidget *parent = 0); + ~FloatingWidgetToolBar(); + + void setNoClose(bool c); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::FloatingWidgetToolBar *ui; + + bool noClose; + bool isDetached; + + void setupMenu(); + +public slots: + void setDetached(); + +signals: + void Close(); + void Hide(); + void Print(); + void Detach(); +}; + +#endif // FLOATINGWIDGETTOOLBAR_H diff -Nru fontmatrix-0.6.0+svn20100107/src/floatingwidgettoolbar.ui fontmatrix-0.6.0+svn20110930/src/floatingwidgettoolbar.ui --- fontmatrix-0.6.0+svn20100107/src/floatingwidgettoolbar.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/floatingwidgettoolbar.ui 2011-02-17 10:42:06.000000000 +0000 @@ -0,0 +1,125 @@ + + + FloatingWidgetToolBar + + + + 0 + 0 + 544 + 20 + + + + Form + + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 20 + + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Print + + + P + + + + + + + Detach from main window + + + D + + + + + + + + 16 + 16 + + + + ArrowCursor + + + Close window + + + ... + + + + :/graphic-resources/filter-remove.png:/graphic-resources/filter-remove.png + + + + + + + Hide window + + + H + + + + + + + + + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/fmfloatingpreview.cpp fontmatrix-0.6.0+svn20110930/src/fmfloatingpreview.cpp --- fontmatrix-0.6.0+svn20100107/src/fmfloatingpreview.cpp 2009-08-14 15:18:51.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmfloatingpreview.cpp 2010-09-14 12:49:16.000000000 +0000 @@ -33,6 +33,7 @@ #include #include #include +#include #if defined(Q_WS_X11) #include @@ -43,8 +44,9 @@ FMFloatingMenu::FMFloatingMenu(QWidget * parent, FontItem * item) :QWidget(parent), fontItem(item) { - menuLayout = new QHBoxLayout(this); + menuLayout = new QGridLayout(this); menuLayout->setContentsMargins(3,0,3,0); + menuLayout->setVerticalSpacing(0); QFont f(font()); double fs(f.pointSizeF()); @@ -56,27 +58,34 @@ f2.setBold(true); fontName = new QLabel(item->fancyName(), this); fontName->setFont(f2); - menuLayout->addWidget(fontName, 0); + menuLayout->addWidget(fontName, 0,0); } line = new QFrame(this); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); - menuLayout->addWidget(line, 2); + menuLayout->addWidget(line,0, 1); + bool act(false); if(item && !item->isActivated()) { actButton = new QPushButton(tr("Activate"),this); actButton->setFont(f); - menuLayout->addWidget(actButton, 0, Qt::AlignRight); + menuLayout->addWidget(actButton, 0,2, Qt::AlignRight); connect(actButton, SIGNAL(clicked()),this,SLOT(activateFont())); + act = true; } closeButton = new QPushButton(tr("close"), this); closeButton->setFont(f); - menuLayout->addWidget(closeButton, 0, Qt::AlignRight); + menuLayout->addWidget(closeButton, 0,act?3:2, Qt::AlignRight); + text = new QLineEdit(typotek::getInstance()->word(item), this); + text->setFont(f); + menuLayout->addWidget(text,1, 0, 1, -1); + + connect(text, SIGNAL(textEdited(QString)), reinterpret_cast(parent), SLOT(updatePreview(QString))); connect(closeButton, SIGNAL(clicked()), this, SLOT(forwardCloseClicked())); } @@ -146,6 +155,7 @@ void FMFloatingPreview::create(FontItem *item, QRect rect) { FMFloatingPreview * p(new FMFloatingPreview(typotek::getInstance(), item)); + p->fontItem = item; QColor bgC; if(p->canTransparent()) bgC = QColor(Qt::transparent); @@ -219,3 +229,16 @@ #endif return true; } + +void FMFloatingPreview::updatePreview(const QString &t) +{ + QColor bgC; + if(canTransparent()) + bgC = QColor(Qt::transparent); + else + bgC = QColor(Qt::white); + QPixmap preview = fontItem->oneLinePreviewPixmap(t, Qt::black, bgC, this->width()); + QRect r(preview.rect()); + previewLabel->setGeometry(r); + previewLabel->setPixmap(preview); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/fmfloatingpreview.h fontmatrix-0.6.0+svn20110930/src/fmfloatingpreview.h --- fontmatrix-0.6.0+svn20100107/src/fmfloatingpreview.h 2009-08-09 18:03:55.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmfloatingpreview.h 2010-09-14 12:49:16.000000000 +0000 @@ -25,10 +25,11 @@ #include class QPushButton; -class QHBoxLayout; +class QGridLayout; class QVBoxLayout; class QLabel; class QFrame; +class QLineEdit; class FontItem; @@ -48,8 +49,9 @@ QPushButton * closeButton; QPushButton * actButton; QFrame * line; - QHBoxLayout * menuLayout; + QGridLayout * menuLayout; QLabel * fontName; + QLineEdit * text; private slots: @@ -63,6 +65,8 @@ class FontItem; class FMFloatingPreview : public QWidget { + Q_OBJECT + FMFloatingPreview(QWidget * parent, FontItem * item); public: ~FMFloatingPreview(); @@ -76,6 +80,7 @@ void leaveEvent(QEvent *e); private: + FontItem *fontItem; bool hasMouseGrab; QPoint refPoint; FMFloatingMenu * menuWidget; @@ -84,6 +89,9 @@ bool canTransparent(); +public slots: + void updatePreview(const QString& t); + }; #endif // FMFLOATINGPREVIEW_H diff -Nru fontmatrix-0.6.0+svn20100107/src/fmfontdb.cpp fontmatrix-0.6.0+svn20110930/src/fmfontdb.cpp --- fontmatrix-0.6.0+svn20100107/src/fmfontdb.cpp 2009-08-14 15:07:30.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmfontdb.cpp 2010-09-13 16:56:48.000000000 +0000 @@ -25,7 +25,7 @@ FMFontDb * FMFontDb::instance = 0; FMFontDb::FMFontDb() - :QSqlDatabase ( typotek::getInstance()->getDatabaseDriver() ) + :QSqlDatabase ( typotek::getInstance()->getDatabaseDriver() ) { fieldName[FontId] = "fontident"; fieldName[Id] = "digitident"; @@ -50,6 +50,13 @@ getIdStringFast = "SELECT %1 FROM %2 WHERE %3='%4'"; transactionDeep = 0; + + priorList << QString("Book") + << QString("Normal") + << QString("Regular") + << QString("Roman") + << QString("Plain") + << QString("Medium"); } FMFontDb * FMFontDb::DB() @@ -65,7 +72,7 @@ void FMFontDb::initRecord ( const QString & id ) { -// qDebug()<<"initRecord"< > & info ) { -// qDebug()<<"setInfoMap"< lF(fonts); if(fonts.isEmpty()) lF = AllFonts(); -// TODO really filter out results according to the font list given in argument + // TODO really filter out results according to the font list given in argument QList ret; QString qs ( QString ( "SELECT %1,%2 FROM %3" ) - .arg ( fieldName[Id]) - .arg ( fieldName[field] ) - .arg ( tableName[Data] )); + .arg ( fieldName[Id]) + .arg ( fieldName[field] ) + .arg ( tableName[Data] )); QSqlQuery query ( qs,*this ); if ( !query.exec() ) @@ -297,7 +304,7 @@ FontInfoMap FMFontDb::getInfoMap ( const QString & id ) { -// qDebug() <<"getInfoMap"<getDatabaseHostname() ); setDatabaseName ( typotek::getInstance()->getDatabaseDbName() ); @@ -574,7 +584,7 @@ .arg ( tableName[InternalId] ) .arg ( fId ) .arg ( fNumId ) - ); + ); QString iId(QString("CREATE INDEX iId ON %1(%2)").arg ( tableName[InternalId] ).arg(fieldName[FontId] )); QSqlQuery query ( *this ); @@ -637,7 +647,7 @@ // file DB and act as a proxy for most of requests. QString qs2 ( "SELECT %1,%2,%3,%4,%5 FROM %6" ); rq = query.exec ( qs2.arg ( fieldName[Id] ) - .arg ( fieldName[Family] ) + .arg ( fieldName[Family] ) .arg ( fieldName[Variant] ) .arg ( fieldName[Type] ) .arg ( fieldName[Activation] ) @@ -661,7 +671,7 @@ act = ( query.value ( 4 ).toInt() == 0 ) ? false : true; if ( ( path.isEmpty() ) || ( anId == 0 ) ) continue; -// qDebug()<isValid() ) { @@ -736,7 +746,7 @@ QList< FontItem * > FMFontDb::AllFonts() { -// if(!fontMap.isEmpty()) + // if(!fontMap.isEmpty()) return fontMap.values(); } @@ -746,6 +756,17 @@ return cacheId.keys(); } +QList< FontItem * > FMFontDb::FamilySet(const QString& family) +{ + QList< FontItem * > ret; + foreach(FontItem * f, fontMap.values()) + { + if(f->family() == family) + ret << f; + } + return ret; +} + void FMFontDb::TransactionBegin() { if ( transactionDeep > 0 ) @@ -759,13 +780,13 @@ } else qDebug()<< "Cannot BEGIN transaction"; -// qDebug() <<"TransactionBegin"; + // qDebug() <<"TransactionBegin"; } } bool FMFontDb::TransactionEnd() { -// qDebug() <<"TransactionEnd"<< (transactionDeep - 1); + // qDebug() <<"TransactionEnd"<< (transactionDeep - 1); --transactionDeep; if ( transactionDeep > 0 ) @@ -841,42 +862,47 @@ .arg ( codeLang ) .arg ( fieldName[InfoValue] ) .arg ( pattern.toString() ) ); -// qDebug()< FMFontDb::Fonts ( const QString & whereString, Table table ) +QList< FontItem * > FMFontDb::Fonts ( const QString & whereString, Table table) { - QList< FontItem * > ret; + // QList< FontItem * > ret; QString qs ( "SELECT %1 FROM %2 WHERE " + whereString ); QSqlQuery query ( qs.arg ( fieldName[Id] ) .arg ( tableName[table] ), *this ); if ( !query.exec() ) - return ret; + return QList< FontItem * >(); else { - QMap reg; - while ( query.next() ) + // if(!familyOnly) { - int id ( query.value ( 0 ).toInt() ); - if ( id > 0 ) + QMap reg; + while ( query.next() ) { - if( !fontMap.value(id) ) - qDebug()<<"ERROR : DB contains references to id"< 0 ) + { + if( !fontMap.value(id) ) + qDebug()<<"ERROR : DB contains references to id"<lock(); + // item->lock(); return true; } +void FMFontDb::clearFilteredFonts() +{ + currentFonts.clear(); + currentFamiliesCache.clear(); +} +QList FMFontDb::getFilteredFonts(bool familyOnly) +{ + if(!familyOnly) + return currentFonts; + if(currentFamiliesCache.isEmpty() && (!currentFonts.isEmpty())) + { + QMap > pools; + foreach(FontItem* it, currentFonts) + { + if(pools.contains(it->family())) + pools[it->family()].append(it); + else + { + QList< FontItem* > tl; + tl.append(it); + pools[it->family()] = tl; + } + } + foreach(const QString& k, pools.keys()) + { + FontItem* sel = pools[k].first(); + foreach(FontItem* it, pools[k]) + { + if(priorList.contains(it->variant(), Qt::CaseInsensitive)) + { + sel = it; + break; + } + } + currentFamiliesCache << sel; + } + } + return currentFamiliesCache; + +} + +void FMFontDb::setFilterdFonts(const QList &flist) +{ + currentFonts.clear(); + currentFamiliesCache.clear(); + currentFonts = flist; +} +int FMFontDb::countFilteredFonts() const +{ + return currentFonts.count(); +} +void FMFontDb::insertFilteredFont(FontItem *item) +{ + if((item != 0) && (!currentFonts.contains(item))) + { + currentFonts.append(item); + currentFamiliesCache.clear(); + } +} +void FMFontDb::removeFilteredFont(FontItem *item) +{ + if(item != 0) + { + currentFonts.removeAll(item); + currentFamiliesCache.clear(); + } +} +bool FMFontDb::isFiltered(FontItem *item) const +{ + return currentFonts.contains(item); +} +void FMFontDb::filterAllFonts() +{ + currentFonts.clear(); + currentFamiliesCache.clear(); + currentFonts = fontMap.values(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/fmfontdb.h fontmatrix-0.6.0+svn20110930/src/fmfontdb.h --- fontmatrix-0.6.0+svn20100107/src/fmfontdb.h 2009-08-14 15:07:30.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmfontdb.h 2010-09-13 16:56:48.000000000 +0000 @@ -115,6 +115,7 @@ QList AllFonts(); QStringList AllFontNames(); + QList FamilySet(const QString& family); // FontItem* FirstFont(); // FontItem* NextFont(); @@ -135,10 +136,21 @@ bool Remove ( const QString& id ); bool insertTemporaryFont ( const QString& path ); + void clearFilteredFonts(); + void filterAllFonts(); + QList getFilteredFonts(bool familyOnly = false); + void setFilterdFonts(const QList& flist); + int countFilteredFonts() const; + void insertFilteredFont(FontItem* item); + void removeFilteredFont(FontItem* item); + bool isFiltered(FontItem* item) const; + + private: // ensure tables are created void initFMDb(); + QStringList priorList; QMap fieldName; QMap tableName; QMap cacheId; @@ -154,11 +166,18 @@ // void clearFontMap(); QMap temporaryFont; + // Not sure it's that good idea but still, go to put current filtered fonts here + QList currentFonts; + QList currentFamiliesCache; + QList transactionError; QMap > rValueCache; int transactionDeep; + signals: + void tagsChanged(); + }; diff -Nru fontmatrix-0.6.0+svn20100107/src/fmfontstrings.cpp fontmatrix-0.6.0+svn20110930/src/fmfontstrings.cpp --- fontmatrix-0.6.0+svn20100107/src/fmfontstrings.cpp 2009-07-05 07:48:58.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmfontstrings.cpp 2010-09-17 13:49:00.000000000 +0000 @@ -23,6 +23,8 @@ fillCharsetMap(); fillTTTableList(); fillFSftypeMap(); + fillUniCat(); + fillScriptTagNames(); } FontStrings * FontStrings::getInstance() @@ -335,6 +337,112 @@ m_FsType[FontItem::BITMAP_ONLY] = tr("Only bitmaps contained in this font may be embedded. No outline data may be embedded. If there are no bitmaps available in this font, then it is considered unembeddable and the embedding services will fail. Other embedding restrictions specified in bits 0-3 and 8 also apply."); } +void FontStrings::fillUniCat() +{ + unicodeCategory[QChar::Mark_NonSpacing] = tr("Mark, NonSpacing" ); + unicodeCategory[QChar::Mark_SpacingCombining] = tr("Mark, SpacingCombining" ); + unicodeCategory[QChar::Mark_Enclosing] = tr("Mark, Enclosing" ); + unicodeCategory[QChar::Number_DecimalDigit] = tr("Number, DecimalDigit" ); + unicodeCategory[QChar::Number_Letter] = tr("Number, Letter" ); + unicodeCategory[QChar::Number_Other] = tr("Number, Other" ); + unicodeCategory[QChar::Separator_Space] = tr("Separator, Space" ); + unicodeCategory[QChar::Separator_Line] = tr("Separator, Line" ); + unicodeCategory[QChar::Separator_Paragraph] = tr("Separator, Paragraph" ); + unicodeCategory[QChar::Other_Control] = tr("Other, Control" ); + unicodeCategory[QChar::Other_Format] = tr("Other, Format" ); + unicodeCategory[QChar::Other_Surrogate] = tr("Other, Surrogate" ); + unicodeCategory[QChar::Other_PrivateUse] = tr("Other, PrivateUse" ); + unicodeCategory[QChar::Other_NotAssigned] = tr("Other, NotAssigned" ); + unicodeCategory[QChar::Letter_Uppercase] = tr("Letter, Uppercase" ); + unicodeCategory[QChar::Letter_Lowercase] = tr("Letter, Lowercase" ); + unicodeCategory[QChar::Letter_Titlecase] = tr("Letter, Titlecase" ); + unicodeCategory[QChar::Letter_Modifier] = tr("Letter, Modifier" ); + unicodeCategory[QChar::Letter_Other] = tr("Letter, Other" ); + unicodeCategory[QChar::Punctuation_Connector] = tr("Punctuation, Connector" ); + unicodeCategory[QChar::Punctuation_Dash] = tr("Punctuation, Dash" ); + unicodeCategory[QChar::Punctuation_Open] = tr("Punctuation, Open" ); + unicodeCategory[QChar::Punctuation_Close] = tr("Punctuation, Close" ); + unicodeCategory[QChar::Punctuation_InitialQuote] = tr("Punctuation, InitialQuote" ); + unicodeCategory[QChar::Punctuation_FinalQuote] = tr("Punctuation, FinalQuote" ); + unicodeCategory[QChar::Punctuation_Other] = tr("Punctuation, Other" ); + unicodeCategory[QChar::Symbol_Math] = tr("Symbol, Math" ); + unicodeCategory[QChar::Symbol_Currency] = tr("Symbol, Currency" ); + unicodeCategory[QChar::Symbol_Modifier] = tr("Symbol, Modifier" ); + unicodeCategory[QChar::Symbol_Other] = tr("Symbol, Other" ); +} + +void FontStrings::fillScriptTagNames() +{ + scriptTagNames[QString("arab")] = tr("Arabic"); + scriptTagNames[QString("armn")] = tr("Armenian"); + scriptTagNames[QString("bali")] = tr("Balinese"); + scriptTagNames[QString("beng")] = tr("Bengali"); + scriptTagNames[QString("bopo")] = tr("Bopomofo"); + scriptTagNames[QString("brai")] = tr("Braille"); + scriptTagNames[QString("bugi")] = tr("Buginese"); + scriptTagNames[QString("buhd")] = tr("Buhid"); + scriptTagNames[QString("byzm")] = tr("Byzantine Music"); + scriptTagNames[QString("cans")] = tr("Canadian Syllabics"); + scriptTagNames[QString("cher")] = tr("Cherokee"); + scriptTagNames[QString("hani")] = tr("CJK Ideographic"); + scriptTagNames[QString("copt")] = tr("Coptic"); + scriptTagNames[QString("cprt")] = tr("Cypriot Syllabary"); + scriptTagNames[QString("cyrl")] = tr("Cyrillic"); + scriptTagNames[QString("DFLT")] = tr("Default"); + scriptTagNames[QString("dsrt")] = tr("Deseret"); + scriptTagNames[QString("deva")] = tr("Devanagari"); + scriptTagNames[QString("ethi")] = tr("Ethiopic"); + scriptTagNames[QString("geor")] = tr("Georgian"); + scriptTagNames[QString("glag")] = tr("Glagolitic"); + scriptTagNames[QString("goth")] = tr("Gothic"); + scriptTagNames[QString("grek")] = tr("Greek"); + scriptTagNames[QString("gujr")] = tr("Gujarati"); + scriptTagNames[QString("guru")] = tr("Gurmukhi"); + scriptTagNames[QString("jamo")] = tr("Hangul Jamo"); + scriptTagNames[QString("hang")] = tr("Hangul"); + scriptTagNames[QString("hano")] = tr("Hanunoo"); + scriptTagNames[QString("hebr")] = tr("Hebrew"); + scriptTagNames[QString("kana")] = tr("Hiragana and Katakana"); + scriptTagNames[QString("java")] = tr("Javanese"); + scriptTagNames[QString("knda")] = tr("Kannada"); + scriptTagNames[QString("khar")] = tr("Kharosthi"); + scriptTagNames[QString("khmr")] = tr("Khmer"); + scriptTagNames[QString("lao ")] = tr("Lao"); + scriptTagNames[QString("latn")] = tr("Latin"); + scriptTagNames[QString("limb")] = tr("Limbu"); + scriptTagNames[QString("linb")] = tr("Linear B"); + scriptTagNames[QString("mlym")] = tr("Malayalam"); + scriptTagNames[QString("math")] = tr("Mathematical Alphanumeric Symbols"); + scriptTagNames[QString("mong")] = tr("Mongolian"); + scriptTagNames[QString("musc")] = tr("Musical Symbols"); + scriptTagNames[QString("mymr")] = tr("Myanmar"); + scriptTagNames[QString("nko ")] = tr("N'ko"); + scriptTagNames[QString("ogam")] = tr("Ogham"); + scriptTagNames[QString("ital")] = tr("Old Italic"); + scriptTagNames[QString("xpeo")] = tr("Old Persian Cuneiform"); + scriptTagNames[QString("orya")] = tr("Oriya"); + scriptTagNames[QString("osma")] = tr("Osmanya"); + scriptTagNames[QString("phag")] = tr("Phags-pa"); + scriptTagNames[QString("phnx")] = tr("Phoenician"); + scriptTagNames[QString("runr")] = tr("Runic"); + scriptTagNames[QString("shaw")] = tr("Shavian"); + scriptTagNames[QString("sinh")] = tr("Sinhala"); + scriptTagNames[QString("xsux")] = tr("Sumero-Akkadian Cuneiform"); + scriptTagNames[QString("sylo")] = tr("Syloti Nagri"); + scriptTagNames[QString("syrc")] = tr("Syriac"); + scriptTagNames[QString("tglg")] = tr("Tagalog"); + scriptTagNames[QString("tagb")] = tr("Tagbanwa"); + scriptTagNames[QString("tale")] = tr("Tai Le"); + scriptTagNames[QString("talu")] = tr("Tai Lu"); + scriptTagNames[QString("taml")] = tr("Tamil"); + scriptTagNames[QString("telu")] = tr("Telugu"); + scriptTagNames[QString("thaa")] = tr("Thaana"); + scriptTagNames[QString("thai")] = tr("Thai"); + scriptTagNames[QString("tibt")] = tr("Tibetan"); + scriptTagNames[QString("tfng")] = tr("Tifinagh"); + scriptTagNames[QString("ugar")] = tr("Ugaritic Cuneiform"); + scriptTagNames[QString("yi ")] = tr("Yi"); +} const QMap< FMFontDb::InfoItem, QString >& FontStrings::Names() { @@ -419,5 +527,17 @@ return InvalidPK; } +QString FontStrings::UnicodeCategory(QChar::Category cat) +{ + if(getInstance()->unicodeCategory.contains(cat)) + return getInstance()->unicodeCategory.value(cat); + return QString(); +} +QString FontStrings::scriptTagName(const QString &script) +{ + if(getInstance()->scriptTagNames.contains(script)) + return getInstance()->scriptTagNames.value(script); + return script; +} diff -Nru fontmatrix-0.6.0+svn20100107/src/fmfontstrings.h fontmatrix-0.6.0+svn20110930/src/fmfontstrings.h --- fontmatrix-0.6.0+svn20100107/src/fmfontstrings.h 2009-06-15 12:22:49.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmfontstrings.h 2010-09-17 13:49:00.000000000 +0000 @@ -51,6 +51,8 @@ static const QString Encoding(FT_Encoding enc); static const QMap& Tables(); static QString FsType(int fstype_part, bool shortString = true); + static QString UnicodeCategory(QChar::Category); + static QString scriptTagName(const QString& script); private: @@ -61,6 +63,8 @@ void panoseFromFile(const QString& path); void fillTTTableList(); void fillFSftypeMap(); + void fillUniCat(); + void fillScriptTagNames(); QMap< PanoseKey, QMap > m_panoseMap; QMap< PanoseKey, QString > m_panoseKeyName; @@ -68,6 +72,8 @@ QMap charsetMap; QMap tttableList;// QMap< int, QString > m_FsType; + QMap unicodeCategory; + QMap scriptTagNames; }; #endif diff -Nru fontmatrix-0.6.0+svn20100107/src/fmfreetypelib.cpp fontmatrix-0.6.0+svn20110930/src/fmfreetypelib.cpp --- fontmatrix-0.6.0+svn20100107/src/fmfreetypelib.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmfreetypelib.cpp 2010-09-29 11:05:22.000000000 +0000 @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "fmfreetypelib.h" + +#include +#include +#include + +FMFreetypeLib *FMFreetypeLib::instance = 0; + +FMFreetypeLib::FMFreetypeLib(QObject *parent) : + QObject(parent) +{ + FT_Library theLibrary; + FT_Init_FreeType ( &theLibrary ); + libraries.insert(thread(), theLibrary); + qDebug()<<"FT_Library"<libraries.value(that()->thread()); + QMutexLocker(that()->mutex); + if(that()->libraries.contains(t)) + return that()->libraries.value(t); + + FTLibFactory ff; + ff.moveToThread(t); + that()->libraries.insert(t, ff.createLib()); + connect(t, SIGNAL(terminated()), that(), SLOT(releaseLibrary())); + return that()->libraries.value(t); +} + +void FMFreetypeLib::releaseLibrary() +{ + if(sender()) + { + QThread *t(reinterpret_cast(sender())); + if(t && libraries.contains(t)) + { + FT_Done_FreeType(libraries[t]); + libraries.remove(t); + } + } +} diff -Nru fontmatrix-0.6.0+svn20100107/src/fmfreetypelib.h fontmatrix-0.6.0+svn20110930/src/fmfreetypelib.h --- fontmatrix-0.6.0+svn20100107/src/fmfreetypelib.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmfreetypelib.h 2010-09-29 11:05:22.000000000 +0000 @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FMFREETYPELIB_H +#define FMFREETYPELIB_H + +#include +#include FT_FREETYPE_H + +#include +#include +#include + +class FMFreetypeLib : public QObject +{ + Q_OBJECT + + static FMFreetypeLib * instance; + static FMFreetypeLib * that(); + explicit FMFreetypeLib(QObject *parent = 0); + + QMap libraries; + QMutex *mutex; + + class FTLibFactory : public QObject + { + public: + FT_Library createLib() + { + FT_Library theLibrary; + FT_Init_FreeType ( &theLibrary ); + return theLibrary; + } + }; + +public: + static FT_Library lib(QThread * t); + +private slots: + void releaseLibrary(); + +}; + +#endif // FMFREETYPELIB_H diff -Nru fontmatrix-0.6.0+svn20100107/src/fmglyphsview.cpp fontmatrix-0.6.0+svn20110930/src/fmglyphsview.cpp --- fontmatrix-0.6.0+svn20100107/src/fmglyphsview.cpp 2009-04-20 09:30:12.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmglyphsview.cpp 2010-06-28 13:29:33.000000000 +0000 @@ -127,8 +127,8 @@ void FMGlyphsView::hideEvent ( QHideEvent * event ) { - if ( m_state == SingleView ) - emit pleaseShowAll(); +// if ( m_state == SingleView ) +// emit pleaseShowAll(); } void FMGlyphsView::wheelEvent ( QWheelEvent * e ) diff -Nru fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp fontmatrix-0.6.0+svn20110930/src/fminfodisplay.cpp --- fontmatrix-0.6.0+svn20100107/src/fminfodisplay.cpp 2009-08-03 10:27:37.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fminfodisplay.cpp 2010-09-16 13:39:26.000000000 +0000 @@ -157,21 +157,29 @@ } } } - QString openElem ( QString ( "\n" ) - .arg ( horOffset ) - .arg ( maxHeight*1.6 )); + QString openElem ( QString ( "
\n" ) + .arg ( qRound(horOffset) ) + .arg ( qRound(maxHeight*1.6) )); - return openElem + svg + "\n"; + return openElem + svg + "
\n"; } QString FMInfoDisplay::writeOrderedInfo(FontItem * font) { QString ret; QMap orderedInfo; - - ret += "
"+ QObject::tr ( "Glyphs count" ) +"
"+ QString::number ( font->glyphsCount() ) +"
\n"; - ret += "
"+ QObject::tr ( "Font Type" ) +"
"+ font->type() +"
\n"; + QString modelItem ( "
%1
%2
\n" ); + QString fontType(font->type()); + if(fontType == QString("CFF")) + fontType = QString("OpenType"); + + ret += modelItem.arg(QObject::tr("File")) + .arg(font->path().replace("/","/­")); + ret += modelItem.arg( QObject::tr ( "Glyphs count" )) + .arg(QString::number ( font->glyphsCount() )); + ret += modelItem.arg(QObject::tr ( "Font Type" ) ) + .arg(fontType ); QStringList cmapStrings; @@ -208,39 +216,40 @@ } } - QString styleLangMatch; +// QString styleLangMatch("\"langundefined\""); for ( QMap >::const_iterator lit = moreInfo.begin(); lit != moreInfo.end(); ++lit ) { - if ( FMEncData::LangIdMap()[ lit.key() ].contains ( sysLang ) ) // lang match - { - styleLangMatch = "\"langmatch\""; - } - else if ( FMEncData::LangIdMap()[ lit.key() ] == "DEFAULT" ) // lang does not match but it’s international name - { - styleLangMatch = "\"langundefined\""; - } - else // lang does not match at all - { - styleLangMatch = "\"langnomatch\""; - } +// if ( FMEncData::LangIdMap()[ lit.key() ].contains ( sysLang ) ) // lang match +// { +// styleLangMatch = "\"langmatch\""; +// } +// else if ( FMEncData::LangIdMap()[ lit.key() ] == "DEFAULT" ) // lang does not match but it’s international name +// { +// styleLangMatch = "\"langundefined\""; +// } +// else // lang does not match at all +// { +// styleLangMatch = "\"langnomatch\""; +// } for ( QMap::const_iterator mit = lit.value().begin(); mit != lit.value().end(); ++mit ) { - if ( FMEncData::LangIdMap()[ lit.key() ].contains ( sysLang ) ) +// if ( FMEncData::LangIdMap()[ lit.key() ].contains ( sysLang ) ) { QString name_value(url2href(xhtmlifies(mit.value()))); // compact coding :) name_value.replace ( "\n","
" ); - QString dcname ( "
" + name_value +"
\n" ); - if ( !orderedInfo[ mit.key() ].contains ( dcname ) ) - orderedInfo[ mit.key() ] << dcname; - } - else if ( FMEncData::LangIdMap()[ lit.key() ] == "DEFAULT" && !localizedKeys.contains ( mit.key() ) ) - { - QString name_value(url2href(xhtmlifies(mit.value()))); - name_value.replace ( "\n","
" ); - QString dcname ( "
" + name_value +"
\n" ); - if ( !orderedInfo[ mit.key() ].contains ( dcname ) ) + QString dcname (name_value); +// if ( !orderedInfo[ mit.key() ].contains ( dcname ) ) + if(!orderedInfo.contains(mit.key())) orderedInfo[ mit.key() ] << dcname; } +// else if ( FMEncData::LangIdMap()[ lit.key() ] == "DEFAULT" && !localizedKeys.contains ( mit.key() ) ) +// { +// QString name_value(url2href(xhtmlifies(mit.value()))); +// name_value.replace ( "\n","
" ); +// QString dcname ( "
" + name_value +"
\n" ); +// if ( !orderedInfo[ mit.key() ].contains ( dcname ) ) +// orderedInfo[ mit.key() ] << dcname; +// } } } @@ -248,9 +257,6 @@ } - - QString modelItem ( "
%1
%2
\n" ); - /// Times to manually order presentation! QList order; @@ -289,6 +295,7 @@ QString FMInfoDisplay::writePanose(FontItem * font) { QString panBlockOut; + QString panoseLabel("
Panose
"); QString pN ( FMFontDb::DB()->getValue ( font->path(), FMFontDb::Panose, false ).toString() ); if ( !pN.isEmpty() ) { @@ -300,12 +307,12 @@ FontStrings::PanoseKey k ( FontStrings::Panose().keys() [i] ); int pValue ( pl[i].toInt() ); panBlockOut += "
" + FontStrings::PanoseKeyName ( k ) + "
\n"; - panBlockOut += "
" + FontStrings::Panose().value ( k ).value ( pValue ) + " - "+ pl[i] +"
\n"; + panBlockOut += "
" + FontStrings::Panose().value ( k ).value ( pValue )/* + " - "+ pl[i]*/ +"
\n"; } } } - return "
" + panBlockOut + "
\n"; + return "
" + panoseLabel + panBlockOut + "
\n"; } diff -Nru fontmatrix-0.6.0+svn20100107/src/fmlayout.cpp fontmatrix-0.6.0+svn20110930/src/fmlayout.cpp --- fontmatrix-0.6.0+svn20100107/src/fmlayout.cpp 2009-06-30 22:42:44.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmlayout.cpp 2010-09-29 11:05:22.000000000 +0000 @@ -33,6 +33,8 @@ // #include #include // #include +#include +#include #define OUT_OF_RECT 99999999.0 @@ -42,17 +44,17 @@ Node::ListItem::ListItem() :n ( 0 ), distance ( 0.0 ) { -// qDebug()<<"CV empty"; + // qDebug()<<"CV empty"; } Node::ListItem::ListItem ( Node * N, double D ) :n ( N ),distance ( D ) { -// qDebug()<<"CV n d"<index<index<index; + // qDebug()<<"~ListItem"<< n<index; if(n) { delete n; @@ -60,10 +62,12 @@ } } -Node::Node ( int i ) :index ( i ) +Node::Node (FMLayout * layoutEngine, int i ) + :lyt(layoutEngine), + index ( i ) { -// if(index == 0) -// qDebug()<<"+N"<< this<n->index<n->index< curList, QList< int > & theList, double & theScore ) { -// QList debugL; -// foreach(ListItem v, nodes) -// {debugL << v.n->index;} -// qDebug()<<"Node::sPath(" < debugL; + // foreach(ListItem v, nodes) + // {debugL << v.n->index;} + // qDebug()<<"Node::sPath(" <stopIt ) { theScore = 0; @@ -164,17 +168,17 @@ double disN = needWidth - lyt->lineWidth ( deep ) ; double compressValue( disN * 100.0 / spaceWidth ); -// qDebug()<<"PRE spaceWidth("< lyt->FM_LAYOUT_MAX_COMPRESSION) { break; } -// else -// qDebug()<<"["<hyphenList.contains ( soon ) ) disN *= lyt->FM_LAYOUT_HYPHEN_PENALTY; @@ -196,15 +200,15 @@ double compressValue( disF * 100.0 / spaceWidth ); if(compressValue <= lyt->FM_LAYOUT_MAX_COMPRESSION) { -// qDebug()<<"["<sepCount(cIdx, fit ,lyt->theString) <<") spaceWidth("<sepCount(cIdx, fit ,lyt->theString) <<") spaceWidth("<hyphenList.contains ( fit ) ) disF *= lyt->FM_LAYOUT_HYPHEN_PENALTY; - + Node::ListItem* vF = new Node::ListItem ( sF,qAbs ( disF * lyt->FM_LAYOUT_NODE_FIT_F ) ); - // curNode->nodes << vF; + // curNode->nodes << vF; nodes_insert ( vF ); } @@ -222,20 +226,20 @@ double compressValue( disL * 100.0 / spaceWidth ); if(compressValue > lyt->FM_LAYOUT_MAX_COMPRESSION) { -// qDebug()<<"break_ cV ="<hyphenList.contains ( late ) ) disL *= lyt->FM_LAYOUT_HYPHEN_PENALTY; Node::ListItem* vL = new Node::ListItem ( sL, qAbs ( disL * lyt->FM_LAYOUT_NODE_LATE_F ) ); nodes_insert ( vL ); - + if ( late < lyt->theString.count() && QChar ( lyt->theString[late].lChar ).category() == QChar::Separator_Space ) break; } @@ -250,17 +254,17 @@ } else // end of breaks list { -// qDebug()<<"END OF BREAKS"; + // qDebug()<<"END OF BREAKS"; int soon ( lyt->breakList[bIndex - 1] ); if ( soon != cIdx && !hasNode ( soon ) ) { Node* sN = 0; - sN = new Node ( soon ); + sN = new Node (lyt, soon ); double disN = lyt->lineWidth ( deep ) - lyt->distance ( cIdx, soon,lyt->theString ); Node::ListItem* vN = new Node::ListItem ( sN, qAbs ( disN * lyt->FM_LAYOUT_NODE_END_F ) ); -// curNode->nodes << vN; + // curNode->nodes << vN; nodes_insert ( vN ); } @@ -268,16 +272,16 @@ } } -// qDebug()<<"N"<distance / curList.count() /** dCorrection*/ ); double d2 ( theScore / qMax ( 1.0, ( double ) theList.count() ) ); if ( d1 < d2 ) @@ -287,14 +291,14 @@ else ++fm_layout_total_skip_nod_dbg; delete nodes.takeFirst(); -// nodes.removeFirst(); + // nodes.removeFirst(); } if ( isLeaf ) { double mDist ( dist / deep ); double mScore ( theScore / theList.count() ); -// qDebug() <<"D S N"<< mDist << mScore << curList; + // qDebug() <<"D S N"<< mDist << mScore << curList; if ( mDist < mScore ) { theScore = dist; @@ -304,24 +308,40 @@ } } -FMLayout *FMLayout::instance = 0; -FMLayout::FMLayout ( /*QGraphicsScene * scene, FontItem * font */ ) +//FMLayout *FMLayout::instance = 0; +FMLayout::FMLayout ( QGraphicsScene * scene, FontItem * font , QRectF rect ) + :theScene(scene), + theFont(font), + layoutIsFinished(true), + contextIsMainThread(true) { + if(rect.isNull()) + { + QRectF tmpRect = theScene->sceneRect(); + double sUnitW ( tmpRect.width() * .1 ); + double sUnitH ( tmpRect.height() * .1 ); + + theRect.setX ( 2.0 * sUnitW ); + theRect.setY ( 1.0 * sUnitH ); + theRect.setWidth ( 6.0 * sUnitW ); + theRect.setHeight ( 8.0 * sUnitH ); + } + else + theRect = rect; rules = new QGraphicsRectItem; - instance = this; node = 0; -// layoutMutex = new QMutex; + // layoutMutex = new QMutex; optionHasChanged = true; persistentScene = false; -// progressBar = new QProgressBar ; -// onSceneProgressBar = new QGraphicsProxyWidget ; -// onSceneProgressBar->setWidget ( progressBar ); -// onSceneProgressBar->setZValue ( 1000 ); - - connect ( this, SIGNAL ( paragraphFinished() ), this, SLOT( endOfParagraph() ) ); - connect ( this, SIGNAL ( layoutFinished() ), this, SLOT ( doDraw() ) ); - connect ( this, SIGNAL ( paintFinished() ), this, SLOT ( endOfRun() ) ); + // progressBar = new QProgressBar ; + // onSceneProgressBar = new QGraphicsProxyWidget ; + // onSceneProgressBar->setWidget ( progressBar ); + // onSceneProgressBar->setZValue ( 1000 ); + + // connect ( this, SIGNAL ( paragraphFinished() ), this, SLOT( endOfParagraph() ) ); + // connect ( this, SIGNAL ( layoutFinished() ), this, SLOT ( doDraw() ) ); + // connect ( this, SIGNAL ( paintFinished() ), this, SLOT ( endOfRun() ) ); FM_LAYOUT_NODE_SOON_F= 1200.0; FM_LAYOUT_NODE_FIT_F= 1000.0; @@ -330,8 +350,8 @@ FM_LAYOUT_HYPHEN_PENALTY = 1.5; FM_LAYOUT_MAX_COMPRESSION = 50.0; // 50% - optionDialog = new QDialog ( typotek::getInstance() ); - optionDialog->setWindowTitle ( tr ( "Text engine options" ) ); + optionDialog = new QWidget; + // optionDialog->setWindowTitle ( tr ( "Text engine options" ) ); optionLayout = new QGridLayout(optionDialog) ; optionsWidget = new FMLayOptWidget; @@ -351,39 +371,42 @@ optionLayout->addWidget(optionsWidget,0,0); - connect ( optionsWidget,SIGNAL ( valueChanged ( int ) ),this,SLOT ( slotOption ( int ) ) ); +// connect ( optionsWidget,SIGNAL ( valueChanged ( int ) ),this,SLOT ( slotOption ( int ) ) ); + connect(this, SIGNAL(objectWanted(QObject*)), typotek::getInstance(), SLOT(pushObject(QObject*))); } FMLayout::~ FMLayout() { + if(optionDialog) + delete optionDialog; } -FMLayout * FMLayout::getLayout() -{ - if(!instance) - { - instance = new FMLayout; - Q_ASSERT(instance); - } - return instance; -} +//FMLayout * FMLayout::getLayout() +//{ +// if(!instance) +// { +// instance = new FMLayout; +// Q_ASSERT(instance); +// } +// return instance; +//} void FMLayout::run() { - if(justRedraw) - emit layoutFinished(); - else +// if(justRedraw) +// doDraw(); +// else { for ( int i ( 0 ); i < paragraphs.count() ; ++ i ) { - // qDebug()<<"Oy Rb"< theRect.bottom() ) break; theString = paragraphs[i]; if ( theString.isEmpty() ) continue; -// node = new Node ( 0 ); + // node = new Node ( 0 ); doGraph(); clearCaches(); { @@ -392,29 +415,34 @@ fm_layout_total_nod_dbg = 0; fm_layout_total_skip_nod_dbg = 0; } - + doLines(); - -// qDebug() <<"NODES LEAVES SKIP"< & spec , double fs ) +void FMLayout::doLayout ( const QList & spec , double fs, FontItem* font) { + qDebug()<<"FMLayout::doLayout"<inBlock() == TextProgression::BLOCK_LTR ) origine.rx() = theRect.left(); -// qDebug()<<"LO"<startProgressJob( lines.count() ); +// // qDebug()<<"LAYOUT O : lines "<startProgressJob( lines.count() ); -// qDebug()<<"LAYOUT O : lines "<startProgressJob( paragraphs.count() + ( theRect.height() / fs*1.20 ) );// layout AND draw + // typotek::getInstance()->startProgressJob( paragraphs.count() + ( theRect.height() / fs*1.20 ) );// layout AND draw } lastOrigine = origine; fontSize = fs; paragraphs = spec; optionHasChanged = false; -// if ( node ) -// { -// delete node; -// node = 0; -// } + run(); + layoutIsFinished = true; + emit layoutFinished(); + qDebug()<< "FMLayout::doLayout return" << justRedraw; } void FMLayout::endOfRun() { -// qDebug() <<"FMLayout::endOfRun()"; -// theScene->removeItem ( onSceneProgressBar ); -// disconnect ( this,SIGNAL ( paragraphFinished ( int ) ),progressBar,SLOT ( setValue ( int ) ) ); -// if ( node ) -// { -// delete node; -// node = 0; -// } -// qDebug()<<"EOR A"<unlock(); + // qDebug() <<"FMLayout::endOfRun()"; + // theScene->removeItem ( onSceneProgressBar ); + // disconnect ( this,SIGNAL ( paragraphFinished ( int ) ),progressBar,SLOT ( setValue ( int ) ) ); + // if ( node ) + // { + // delete node; + // node = 0; + // } + // qDebug()<<"EOR A"<unlock(); if ( stopIt ) // We’re here after a interruption { stopIt = false; - typotek::getInstance()->endProgressJob(); + // typotek::getInstance()->endProgressJob(); emit updateLayout(); } - else - typotek::getInstance()->endProgressJob(); + // else + // typotek::getInstance()->endProgressJob(); -// qDebug()<<"EOR B"<(),indices,score ); -// qDebug()<<"================================"; -// qDebug()<< &locNode << locNode.nodes.count() << locNode.deepCount(); -// qDebug()<<"================================"; + // qDebug()<<"================================"; + // qDebug()<< &locNode << locNode.nodes.count() << locNode.deepCount(); + // qDebug()<<"================================"; clearCaches(); // la messe est dite ! :-) -// qDebug() <<"S I"< theRect.height())) break; int start1 ( /*!lIdx ?*/ indices[lIdx] /*: indices[lIdx] + 1*/ ); int end1 ( indices[ lIdx + 1 ] ); @@ -582,22 +610,22 @@ dStr += QChar ( rg.lChar ); dBk += rg.isBreak ? "#" : "_"; } -// qDebug() << "S"<inBlock() == TextProgression::INLINE_BTT || tp->inBlock() == TextProgression::INLINE_TTB ); -// qDebug()<<"lines finished"; + // qDebug()<<"lines finished"; for ( int lI ( startLine ); lIgetDpiX() ; actualW = actualW * 72.0 / typotek::getInstance()->getDpiX(); -// qDebug()<< "R2 A2"< refW ) // not last line or last line is too long { QList wsIds; -// qDebug()<< "Ref Dis"<< refW << distance ( 0, lg.count(), lg ); + // qDebug()<< "Ref Dis"<< refW << distance ( 0, lg.count(), lg ); for ( int ri ( 0 ); ri < lg.count() ; ++ri ) { if ( lg.at ( ri ).glyph && QChar ( lg.at ( ri ).lChar ).category() == QChar::Separator_Space ) @@ -750,10 +778,10 @@ } } double shareLost ( diff / qMax ( 1.0 , ( double ) wsIds.count() ) ); -// if(!oldIndy) -// shareLost *= typotek::getInstance()->getDpiX() / 72.0; -// qDebug() << "D N W"<getDpiX() / 72.0; + // qDebug() << "D N W"<getUnitPerEm(); double pixelAdjustX = typotek::getInstance()->getDpiX() / 72.0 ; - double pixelAdjustY = typotek::getInstance()->getDpiX() / 72.0 ; + double pixelAdjustY = typotek::getInstance()->getDpiY() / 72.0 ; + int pd =0; for ( int lIdx ( 0 ); lIdx < lines.count() ; ++lIdx ) { @@ -815,14 +844,18 @@ ++drawnLines; clearCaches(); GlyphList refGlyph ( lines[lIdx] ); - +// emit drawBaselineForMe(pen.y()); if ( !deviceIndy ) { for ( int i=0; i < refGlyph.count(); ++i ) { if ( !refGlyph[i].glyph ) continue; - QGraphicsPixmapItem *glyph = theFont->itemFromGindexPix ( refGlyph[i].glyph , fontSize ); + QGraphicsItem *glyph; + if(contextIsMainThread) + glyph = theFont->itemFromGindexPix ( refGlyph[i].glyph , fontSize ); + else + glyph = theFont->itemFromGindexPix_mt( refGlyph[i].glyph , fontSize ); if ( !glyph ) continue; if ( tp->inLine() == TextProgression::INLINE_RTL ) @@ -835,11 +868,33 @@ } /*************************************************/ - pixList << glyph; - theScene->addItem ( glyph ); - glyph->setZValue ( 100.0 ); - glyph->setPos ( pen.x() + ( refGlyph[i].xoffset * pixelAdjustX ) + glyph->data ( GLYPH_DATA_BITMAPLEFT ).toDouble() * scale , - pen.y() + ( refGlyph[i].yoffset * pixelAdjustY ) - glyph->data ( GLYPH_DATA_BITMAPTOP ).toInt() ); + if(contextIsMainThread) + { + pixList << reinterpret_cast(glyph); + theScene->addItem ( glyph ); + glyph->setZValue ( 100.0 ); + glyph->setPos ( pen.x() + + ( refGlyph[i].xoffset * pixelAdjustX ) + + glyph->data (GLYPH_DATA_BITMAPLEFT).toDouble() * scale , + pen.y() + + ( refGlyph[i].yoffset * pixelAdjustY ) + - glyph->data(GLYPH_DATA_BITMAPTOP).toDouble()); + } + else + { +// refGlyph[i].dump(); + MetaGlyphItem * mgi(reinterpret_cast(glyph)); +// qDebug()<metaData ( GLYPH_DATA_BITMAPTOP ).toDouble(); + ++pd; + emit drawPixmapForMe(refGlyph[i].glyph, + fontSize, + pen.x() + + (refGlyph[i].xoffset * pixelAdjustX) + + mgi->metaData(GLYPH_DATA_BITMAPLEFT).toDouble() * scale, + pen.y() + + (refGlyph[i].yoffset * pixelAdjustY) + - mgi->metaData(GLYPH_DATA_BITMAPTOP).toDouble()); + } /*************************************************/ if ( tp->inLine() == TextProgression::INLINE_LTR ) @@ -870,8 +925,8 @@ glyph->setPen(Qt::NoPen); #ifdef BUILD_TYPE_DEBUG // visual debug -// QColor dbgColor( i * 255 / refGlyph.count() , i * 255 / refGlyph.count() , 0, 125); -// glyph->setBrush(dbgColor); + // QColor dbgColor( i * 255 / refGlyph.count() , i * 255 / refGlyph.count() , 0, 125); + // glyph->setBrush(dbgColor); if(refGlyph[i].lChar == 32) glyph->setBrush(Qt::blue); //end visual debug #endif @@ -910,13 +965,14 @@ pen.rx() += adjustedSampleInter; } - typotek::getInstance()->runProgressJob(); -// qDebug() <<"P"<runProgressJob(); + // qDebug() <<"P"<update(theRect); + emit drawPixmapForMe(-1,0,0,0); + qDebug()<<"P emitted:"< start ) -// { -// --end; -// } -// } -// + // if ( QChar ( gList.first().lChar ).category() == QChar::Separator_Space ) + // { + // while ( QChar ( gList.first().lChar ).category() == QChar::Separator_Space && start < end ) + // { + // ++start; + // } + // } + // if ( QChar ( gList.last().lChar ).category() == QChar::Separator_Space ) + // { + // while ( QChar ( gList.last().lChar ).category() == QChar::Separator_Space && end > start ) + // { + // --end; + // } + // } + // TextProgression *tp = TextProgression::getInstance(); bool verticalLayout ( tp->inLine() == TextProgression::INLINE_BTT || tp->inLine() == TextProgression::INLINE_TTB ); -// qDebug()<<"IB VL"<inLine()<inLine()< start ) --bp ; ++bp; @@ -1195,12 +1251,12 @@ } else if ( hasHyph && gList.at ( EXend ).isBreak ) { -// qDebug()<<"- -" ; -// QString debStr; + // qDebug()<<"- -" ; + // QString debStr; GlyphList hr ( hyphList); for ( int ih ( 0 ); ih < hr.count(); ++ih ) { -// debStr += QChar(hr[ih].lChar); + // debStr += QChar(hr[ih].lChar); ret += hr[ih].xadvance; } @@ -1226,28 +1282,28 @@ } else { -// debStr += QChar(gList.at( i ).lChar); + // debStr += QChar(gList.at( i ).lChar); ret += gList.at ( i ).xadvance /*+ gList.at ( i ).xoffset*/; } } GlyphList hr2 ( gList.at ( EXend ).hyphen.first ); for ( int ih ( 0 ); ih < hr2.count(); ++ih ) { -// debStr += QChar(hr2[ih].lChar); + // debStr += QChar(hr2[ih].lChar); ret += hr2[ih].xadvance; } -// qDebug()<<"D(= =)"<getDpiX() / 72.0 ; -// if ( power ) -// { -// distCache[storeStart][storeEnd] = ret*ret; -// return ret*ret; -// } + // if ( power ) + // { + // distCache[storeStart][storeEnd] = ret*ret; + // return ret*ret; + // } distCache[start][end] = ret; return ret; } @@ -1256,7 +1312,11 @@ { if(persistentScene) return; - + if(!contextIsMainThread) + { + emit clearScene(); + return; + } int pCount ( pixList.count() ); for ( int i = 0; i < pCount ; ++i ) { @@ -1270,10 +1330,10 @@ pixList.removeAll(0); int gCount ( glyphList.count() ); -// QMap ss; + // QMap ss; for ( int i = 0; i < gCount; ++i ) { -// ss[glyphList[i]->scene()]++; + // ss[glyphList[i]->scene()]++; if ( glyphList[i]->scene() && (glyphList[i]->scene() == theScene) ) { glyphList[i]->scene()->removeItem ( glyphList[i] ); @@ -1282,43 +1342,43 @@ } } glyphList.removeAll(0); -// QString dbs; -// foreach(QGraphicsScene* qgs, ss) -// { -// dbs += "["+ QString::number(reinterpret_cast(qgs)) +"]"; -// } -// qDebug()<<"GC"<< ss <sceneRect(); - double sUnitW ( tmpRect.width() * .1 ); - double sUnitH ( tmpRect.height() * .1 ); - - theRect.setX ( 2.0 * sUnitW ); - theRect.setY ( 1.0 * sUnitH ); - theRect.setWidth ( 6.0 * sUnitW ); - theRect.setHeight ( 8.0 * sUnitH ); - } - else - { - theRect = rect; - } -// rules->setRect(theRect); -// rules->setZValue(9.9); -// if(rules->scene() != theScene) -// theScene->addItem(rules); -} - -void FMLayout::setTheFont ( FontItem* theValue ) -{ - theFont = theValue; - optionHasChanged = true; -} + // QString dbs; + // foreach(QGraphicsScene* qgs, ss) + // { + // dbs += "["+ QString::number(reinterpret_cast(qgs)) +"]"; + // } + // qDebug()<<"GC"<< ss <sceneRect(); +// double sUnitW ( tmpRect.width() * .1 ); +// double sUnitH ( tmpRect.height() * .1 ); + +// theRect.setX ( 2.0 * sUnitW ); +// theRect.setY ( 1.0 * sUnitH ); +// theRect.setWidth ( 6.0 * sUnitW ); +// theRect.setHeight ( 8.0 * sUnitH ); +// } +// else +// { +// theRect = rect; +// } +//// rules->setRect(theRect); +//// rules->setZValue(9.9); +//// if(rules->scene() != theScene) +//// theScene->addItem(rules); +//} + +//void FMLayout::setTheFont ( FontItem* theValue ) +//{ +// theFont = theValue; +// optionHasChanged = true; +//} double FMLayout::lineWidth ( int l ) { @@ -1326,26 +1386,26 @@ double offset ( ( double ) l * adjustedSampleInter ) ; if ( tp->inBlock() == TextProgression::BLOCK_TTB ) { -// if ( theRect.top() + offset > theRect.bottom() ) -// { -// return OUT_OF_RECT; -// } + // if ( theRect.top() + offset > theRect.bottom() ) + // { + // return OUT_OF_RECT; + // } return theRect.width(); } else if ( tp->inBlock() == TextProgression::BLOCK_RTL ) { -// if ( theRect.right() - offset < theRect.left() ) -// { -// return OUT_OF_RECT; -// } + // if ( theRect.right() - offset < theRect.left() ) + // { + // return OUT_OF_RECT; + // } return theRect.height() - adjustedSampleInter; } else if ( tp->inBlock() == TextProgression::BLOCK_LTR ) { -// if ( theRect.left() + offset > theRect.right() ) -// { -// return OUT_OF_RECT; -// } + // if ( theRect.left() + offset > theRect.right() ) + // { + // return OUT_OF_RECT; + // } return theRect.height() - adjustedSampleInter; } @@ -1402,10 +1462,18 @@ void FMLayout::endOfParagraph() { - typotek::getInstance()->runProgressJob(); + // typotek::getInstance()->runProgressJob(); } +void FMLayout::setContext(bool c) +{ + contextIsMainThread = c; +// if(c) +// theFont->moveToThread(QApplication::instance()->thread()); +// else +// emit objectWanted(theFont); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/fmlayout.h fontmatrix-0.6.0+svn20110930/src/fmlayout.h --- fontmatrix-0.6.0+svn20100107/src/fmlayout.h 2009-06-30 22:42:44.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmlayout.h 2010-09-29 11:05:22.000000000 +0000 @@ -45,7 +45,7 @@ #define INFINITE 99999999L - +class FMLayout; struct Node @@ -63,35 +63,35 @@ // ListItem (const ListItem& v); }; + Node (FMLayout * layoutEngine, int i ) ; + ~Node(); + QList nodes; + FMLayout *lyt; int index; - - Node() {} - Node ( int i ) ; - ~Node(); - bool hasNode ( int idx ) ; void nodes_clear(); void nodes_insert(ListItem * v); void sPath ( double dist, QList< int > curList, QList& theList, double& theScore ); int deepCount(); + +private: + Node() {} }; -class FMLayout : public QThread +class FMLayout : public QObject { Q_OBJECT - // Just think that the font must be set - FMLayout ( /*QGraphicsScene* scene, FontItem* font*/ ); - ~FMLayout(); + public: - void doLayout(const QList& spec , double fs); - static FMLayout *getLayout(); - void run(); + explicit FMLayout ( QGraphicsScene* scene, FontItem* font = 0, QRectF rect = QRectF()); + ~FMLayout(); + void doLayout(const QList& spec , double fs, FontItem* font = 0 ); private://methods /// Build a graph on node @@ -101,11 +101,15 @@ void clearCaches(); + void run(); + public:// utils double distance ( int start, int end, const GlyphList& gl , bool strip = false ); int sepCount( int start, int end, const GlyphList& gl); void resetScene(); + bool isLayoutFinished() {return layoutIsFinished;} + QList breakList; QList hyphenList; GlyphList theString; @@ -113,13 +117,16 @@ // QMutex *layoutMutex; bool stopIt; int drawnLines; + + void setContext(bool c); public slots: void stopLayout(); private:// data // Argued - static FMLayout *instance; +// static FMLayout *instance; + bool contextIsMainThread; QGraphicsScene* theScene; FontItem* theFont; QList paragraphs; @@ -153,8 +160,11 @@ bool deviceIndy; QPointF origine; + bool layoutIsFinished; + public: //accessors QRectF getRect()const{return theRect;} + void setRect(const QRectF& r){theRect = r;} void setProcessFeatures ( bool theValue ){processFeatures = theValue;} void setScript ( const QString& theValue ){script = theValue;} void setProcessScript ( bool theValue ) {processScript = theValue;} @@ -164,8 +174,8 @@ void setOrigine ( const QPoint& theValue ){origine = theValue;} void setFontSize ( bool theValue ){fontSize = theValue;} void setDeviceIndy( bool theValue ){deviceIndy = theValue;} - void setTheScene ( QGraphicsScene* theValue , QRectF rect = QRectF()); - void setTheFont ( FontItem* theValue ); +// void setTheScene ( QGraphicsScene* theValue , QRectF rect = QRectF()); +// void setTheFont ( FontItem* theValue ); void setPersistentScene(bool p){persistentScene = p;} @@ -178,12 +188,18 @@ void slotOption(int v); signals: + // needed if layout is executed outside the main (GUI) thread + // receiver is expected to know with what font and on which scene; + void drawPixmapForMe(int index, double fontsize, double x, double y); + void drawBaselineForMe(double y); + void clearScene(); + void objectWanted(QObject*); void updateLayout(); void layoutFinished(); void paragraphFinished(); void paintFinished(); public: - QDialog *optionDialog; + QWidget *optionDialog; double FM_LAYOUT_NODE_SOON_F; double FM_LAYOUT_NODE_FIT_F; diff -Nru fontmatrix-0.6.0+svn20100107/src/fmmatchraster.cpp fontmatrix-0.6.0+svn20110930/src/fmmatchraster.cpp --- fontmatrix-0.6.0+svn20100107/src/fmmatchraster.cpp 2009-05-19 13:07:48.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmmatchraster.cpp 2010-06-10 14:05:51.000000000 +0000 @@ -16,6 +16,7 @@ #include "typotek.h" #include "mainviewwidget.h" #include "fontitem.h" +#include "fmfontdb.h" #include #include @@ -119,7 +120,7 @@ buttonBox->setEnabled ( false ); if ( !m_waitingForButton ) { - remainFonts = compFonts = typotek::getInstance()->getCurrentFonts() ; + remainFonts = compFonts = FMFontDb::DB()->getFilteredFonts(); progressBar->setRange ( 0, compFonts.count() ); stackedWidget->setCurrentIndex ( 1 ); diff -Nru fontmatrix-0.6.0+svn20100107/src/fmpaths.cpp fontmatrix-0.6.0+svn20110930/src/fmpaths.cpp --- fontmatrix-0.6.0+svn20100107/src/fmpaths.cpp 2009-06-24 15:35:40.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmpaths.cpp 2010-07-16 09:36:48.000000000 +0000 @@ -91,6 +91,15 @@ return typotek::getInstance()->getOwnDir().absolutePath() + sep + "Samples"+ sep; } +QString FMPaths::FiltersDir() +{ + QString sep(QDir::separator()); + QDir bdir(typotek::getInstance()->getOwnDir().absolutePath()); + if (!bdir.exists(QString("Filters"))) + bdir.mkdir(QString("Filters")); + return typotek::getInstance()->getOwnDir().absolutePath() + sep + "Filters"+ sep; +} + QString FMPaths::LocalizedDirPath(const QString & base, const QString& fallback ) { QString sep("_"); diff -Nru fontmatrix-0.6.0+svn20100107/src/fmpaths.h fontmatrix-0.6.0+svn20110930/src/fmpaths.h --- fontmatrix-0.6.0+svn20100107/src/fmpaths.h 2009-06-24 15:35:40.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmpaths.h 2010-07-16 09:36:48.000000000 +0000 @@ -29,6 +29,8 @@ static QString ScriptsDir(); static QString SamplesDir(); + + static QString FiltersDir(); static QString LocalizedDirPath(const QString& base, const QString& fallback = QString("en")); diff -Nru fontmatrix-0.6.0+svn20100107/src/fmplayground.cpp fontmatrix-0.6.0+svn20110930/src/fmplayground.cpp --- fontmatrix-0.6.0+svn20100107/src/fmplayground.cpp 2009-10-13 12:34:51.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmplayground.cpp 2010-07-25 17:17:31.000000000 +0000 @@ -15,7 +15,10 @@ #include "fmglyphhighlight.h" #include "typotek.h" #include "mainviewwidget.h" +#include "playwidget.h" +#include +#include #include #include #include @@ -26,7 +29,7 @@ #endif FMPlayGround::FMPlayGround ( QWidget *parent ) - :QGraphicsView ( parent ) + :QGraphicsView ( parent ) { #ifdef HAVE_QTOPENGL @@ -157,7 +160,7 @@ } else if((e->key() == Qt::Key_Enter) || (e->key() == Qt::Key_Return)) - { + { closeLine(); blinkCursor(); CursorTimer->start(); @@ -169,11 +172,50 @@ curString.chop(1); updateLine(); } + else + removeLine(); } - else if(!e->text().isEmpty()) + else if(e->modifiers().testFlag(Qt::ControlModifier)) { - curString += e->text(); - updateLine(); + if(Qt::Key_A == e->key()) + { + closeLine(); + foreach(QGraphicsItemGroup *gi, glyphLines) + { + gi->setSelected(true); + } + } + else if(Qt::Key_V == e->key()) + { + QString subtype("plain"); + QString clipText( QApplication::clipboard()->text(subtype, QClipboard::Clipboard) ); + if(!clipText.isEmpty()) + { + QStringList cs(clipText.split(QString("\n"))); + bool first(true); + foreach(QString s, cs) + { + if(first) + { + first = false; + curString += s; + } + else + curString = s; + updateLine(); + closeLine(); + } + } + } + + } + else + { + if(!e->text().isEmpty()) + { + curString += e->text(); + updateLine(); + } } } @@ -188,7 +230,8 @@ ensureVisible ( CursorPos.x(), CursorPos.y(), spec.count(), fontS * 1.5 ); bool backedR ( fontI->rasterFreetype() ); fontI->setFTRaster ( false ); - TextProgression *tp = TextProgression::getInstance(); + // We deactivate "non-latin" layout atm + // TextProgression *tp = TextProgression::getInstance(); QPointF pen(CursorPos); foreach(RenderedGlyph g, fontI->glyphs( spec , fontS ) ) @@ -197,22 +240,22 @@ if(!glyph) continue; curLine << glyph; - if ( tp->inLine() == TextProgression::INLINE_RTL ) - { - pen.rx() -= g.xadvance ; - } - else if ( tp->inLine() == TextProgression::INLINE_BTT ) - { - pen.ry() -= g.yadvance ; - } + // if ( tp->inLine() == TextProgression::INLINE_RTL ) + // { + // pen.rx() -= g.xadvance ; + // } + // else if ( tp->inLine() == TextProgression::INLINE_BTT ) + // { + // pen.ry() -= g.yadvance ; + // } glyph->setPen(Qt::NoPen); scene()->addItem(glyph); glyph->setPos ( pen.x() + ( g.xoffset ), pen.y() + ( g.yoffset ) ); - if ( tp->inLine() == TextProgression::INLINE_LTR ) - pen.rx() += g.xadvance ; - else if ( tp->inLine() == TextProgression::INLINE_TTB ) - pen.ry() += g.yadvance; + // if ( tp->inLine() == TextProgression::INLINE_LTR ) + pen.rx() += g.xadvance ; + // else if ( tp->inLine() == TextProgression::INLINE_TTB ) + // pen.ry() += g.yadvance; } fontI->setFTRaster ( backedR ); @@ -229,7 +272,7 @@ foreach(QGraphicsItem * item, curLine) delete item; curLine.clear(); - displayGlyphs(curString, fi, typotek::getInstance()->getTheMainView()->playgroundFontSize()); + displayGlyphs(curString, fi, PlayWidget::getInstance()->playFontSize()); blinkCursor(); } CursorTimer->start(); @@ -241,7 +284,7 @@ if(curLine.count() > 0) { QGraphicsItemGroup *git(scene()->createItemGroup(curLine)); - CursorPos.ry() += typotek::getInstance()->getTheMainView()->playgroundFontSize() * 1.5; + CursorPos.ry() += PlayWidget::getInstance()->playFontSize() * 1.5; curLine.clear(); curString.clear(); git->setFlags ( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable ); @@ -291,14 +334,14 @@ QList lit = glyphLines; for ( int i = 0 ; i data(GLYPH_DATA_FONTNAME).toString(); -// -// if ( lit[i]->sceneBoundingRect().bottomRight().y() > allrect.bottomRight().y() -// || lit[i]->sceneBoundingRect().bottomRight().x() > allrect.bottomRight().x() -// || lit[i]->sceneBoundingRect().topLeft().y() > allrect.topLeft().y() -// || lit[i]->sceneBoundingRect().topRight().y() > allrect.topRight().y() -// ) - allrect = allrect.united ( lit[i]->sceneBoundingRect() ); + // qDebug()<< lit.at(i)->data(GLYPH_DATA_FONTNAME).toString(); + // + // if ( lit[i]->sceneBoundingRect().bottomRight().y() > allrect.bottomRight().y() + // || lit[i]->sceneBoundingRect().bottomRight().x() > allrect.bottomRight().x() + // || lit[i]->sceneBoundingRect().topLeft().y() > allrect.topLeft().y() + // || lit[i]->sceneBoundingRect().topRight().y() > allrect.topRight().y() + // ) + allrect = allrect.united ( lit[i]->sceneBoundingRect() ); } @@ -323,7 +366,7 @@ void FMPlayGround::blinkCursor() { - double h(typotek::getInstance()->getTheMainView()->playgroundFontSize()); + double h(PlayWidget::getInstance()->playFontSize()); new FMGlyphHighlight(scene(), QRectF(BlinkPos.x() -1, BlinkPos.y() - h , 1, h)); } diff -Nru fontmatrix-0.6.0+svn20100107/src/fmpreviewlist.cpp fontmatrix-0.6.0+svn20110930/src/fmpreviewlist.cpp --- fontmatrix-0.6.0+svn20100107/src/fmpreviewlist.cpp 2009-08-09 18:03:55.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmpreviewlist.cpp 2011-02-10 15:23:30.000000000 +0000 @@ -33,14 +33,26 @@ //#include #include #include +#include +#include +#define FM_MINIMUM_PREVIEW_WIDTH 280 + +bool FMPreviewIconEngine::initState = false; +QPen FMPreviewIconEngine::pen = QPen(); QVector FMPreviewIconEngine::m_selPalette; +QRgb FMPreviewIconEngine::activatedColor = qRgb (9,223,11); +QRgb FMPreviewIconEngine::deactivatedColor = qRgb (190,190,190); +QRgb FMPreviewIconEngine::partlyActivatedColor = qRgb (166,220,220); + FMPreviewIconEngine::FMPreviewIconEngine() - :QIconEngineV2() + :QIconEngineV2(), + activatedFont(NotActivated) { - if(m_selPalette.isEmpty()) + if(!initState) { + // setup palette QColor sColor( QApplication::palette().color(QPalette::Highlight) ); QColor tColor( QApplication::palette().color(QPalette::HighlightedText) ); m_selPalette.clear(); @@ -59,7 +71,15 @@ ((sg*sn) + (tg*tn)) /cpal, ((sb*sn) + (tb*tn)) /cpal ); } + + // setup "writing" pen +// pen.setColor(QColor(m_selPalette.at(128))); + pen.setColor(QColor(220,220,220)); + pen.setWidth(1); + + initState = true; } + } QVector FMPreviewIconEngine::actualSelPalette(const QVector& orig) @@ -104,8 +124,8 @@ FMPreviewIconEngine::~FMPreviewIconEngine() { -// if(m_p) -// delete m_p; + // if(m_p) + // delete m_p; } void FMPreviewIconEngine::paint ( QPainter * painter, const QRect & rect, QIcon::Mode mode, QIcon::State state ) @@ -115,14 +135,57 @@ painter->save(); painter->translate(rect.x(),rect.y()); QRect r(0 , 0 , rect.width(), rect.height()); + QPainterPath pp; + double rr(double(r.height()) / 5.0); + pp.addRoundedRect(r,rr,rr); + painter->setRenderHint(QPainter::Antialiasing, true); + // draw background + painter->save(); + painter->setPen(Qt::NoPen); + if(mode == QIcon::Selected) + painter->setBrush(QApplication::palette().color(QPalette::Highlight)); + else + painter->setBrush(QApplication::palette().color(QPalette::Base)); + painter->drawPath(pp); + painter->restore(); + // end of bg + painter->setPen(pen); + QRect tr(r); + tr.translate(0, (r.height() - m_p.height()) / 2); if(mode == QIcon::Selected) { QImage hm(m_p.toImage().convertToFormat(QImage::Format_Indexed8)); hm.setColorTable(actualSelPalette(hm.colorTable())); - painter->drawPixmap(r, QPixmap::fromImage(hm) , r); + painter->setClipPath(pp); + painter->drawPixmap(tr, QPixmap::fromImage(hm) , r); + painter->drawPath(pp); } else - painter->drawPixmap(r, m_p , r); + { + painter->drawPixmap(tr, m_p , r); + painter->drawPath(pp); + + } + if(activatedFont != NotActivated) + { + painter->setPen(Qt::NoPen); + QPainterPath activationPath; + double rr2(rr/2.0); + activationPath.moveTo(rr, 0); + activationPath.cubicTo(rr2,0, + 0,rr2, + 0,rr); + activationPath.lineTo(0,rect.height() - rr); + activationPath.cubicTo(0,rect.height() -rr2, + rr2,rect.height(), + rr,rect.height()); + activationPath.closeSubpath(); + if(activatedFont == Activated) + painter->setBrush(QBrush(activatedColor)); + else if(activatedFont == PartlyActivated) + painter->setBrush(QBrush(partlyActivatedColor)); + painter->drawPath(activationPath); + } painter->restore(); } } @@ -133,15 +196,18 @@ } -FMPreviewModel::FMPreviewModel( QObject * pa , FMPreviewView * wPa ) - : QAbstractListModel(pa) , m_view(wPa) +FMPreviewModel::FMPreviewModel( QObject * pa , FMPreviewView * wPa, QList db ) + : QAbstractListModel(pa) , m_view(wPa), base(db) { + familyMode = false; QSettings settings; styleTooltipName = settings.value("Preview/StyleTooltipName","font-weight:bold;").toString(); styleTooltipPath = settings.value("Preview/StyleTooltipPath","font-weight:normal;font-size:small;").toString(); + styleTooltipTags = settings.value("Preview/StyleTooltipTags","text-align:right;font-weight:normal;font-size:small;font-style:italic;").toString(); settings.setValue("Preview/StyleTooltipName", styleTooltipName); settings.setValue("Preview/StyleTooltipPath", styleTooltipPath); + settings.setValue("Preview/StyleTooltipTags", styleTooltipTags); } QVariant FMPreviewModel::data(const QModelIndex & index, int role) const @@ -150,19 +216,18 @@ return QVariant(); int row = index.row(); -// qDebug()<<"D"<getCurrentFonts().at(row)); + // qDebug()<<"D"<getFilteredFonts(true).at(row); + else + fit = base.at(row); if(!fit) return QVariant(); QColor bgColor(QApplication::palette().color(QPalette::Base)); QColor fgColor(QApplication::palette().color(QPalette::Text)); -// int borders( 2*(m_view->frameWidth() + m_view->lineWidth() + m_view->midLineWidth()) ); -// int scrollbar(m_view->verticalScrollBar()->width()); -// int width( m_view->width() - (borders + scrollbar) ); -// qDebug()<<"W"<width() * 0.92) ); + int width(m_view->getUsedWidth()); if(role == Qt::DisplayRole) @@ -174,16 +239,55 @@ } else if(role == Qt::DecorationRole) { - QString word(typotek::getInstance()->word(fit)); + QString word; + if(specString.isEmpty()) + word = typotek::getInstance()->word(fit); + else + word = typotek::getInstance()->word(fit, specString); QPixmap im(fit->oneLinePreviewPixmap(word,fgColor, bgColor, width ) ); - QIcon ic( new FMPreviewIconEngine ); + FMPreviewIconEngine * pie(new FMPreviewIconEngine); + if(!familyMode) + pie->setActivation(fit->isActivated() ? FMPreviewIconEngine::Activated : FMPreviewIconEngine::NotActivated); + else + { + bool hasActive(false); + bool hasNotActive(false); + foreach(FontItem * f, FMFontDb::DB()->FamilySet(fit->family())) + { + if(f->isActivated()) + hasActive = true; + else + hasNotActive = true; + if(hasActive && hasNotActive) + break; + } + if(hasNotActive && hasActive) + pie->setActivation(FMPreviewIconEngine::PartlyActivated); + else + { + pie->setActivation(hasActive ? FMPreviewIconEngine::Activated : FMPreviewIconEngine::NotActivated); + } + } + QIcon ic( pie ); ic.addPixmap(im); -// if(fit->path() == QString("/home/pierre/fontes/ttf/A028-Ext.ttf")) -// im.save("im.png"); + return ic; } else if(role == Qt::ToolTipRole) { + if(familyMode) + { + QList fam(FMFontDb::DB()->FamilySet(fit->family())); + QString sRet; + sRet+= "
" + fit->family() + " ("+QString::number(fam.count())+")
"; + sRet+= "
" + fit->tags().join(QString(", ")) + "
"; + + foreach(FontItem* ffi, fam) + { + sRet += "
" + ffi->variant() + "
"; + } + return sRet; + } if(typotek::getInstance()->getPreviewSubtitled()) { return QString("
" + fit->path() + "
"); @@ -216,31 +320,102 @@ { if(parent.isValid() || !typotek::getInstance()->getTheMainView()) return 0; - QList< FontItem * > cl(typotek::getInstance()->getCurrentFonts()); - return cl.count(); + int cl(0); + if(base.isEmpty()) + cl = FMFontDb::DB()->getFilteredFonts(true).count(); + else + cl = base.count(); + return cl; } void FMPreviewModel::dataChanged() { + QAbstractItemModel::dataChanged(index(0),index(rowCount(QModelIndex()) - 1)); m_view->updateLayout(); emit layoutChanged (); } -FMPreviewView::FMPreviewView(QWidget * parent) - :QListView(parent) +void FMPreviewModel::resetBase(QListdb) +{ + base = db; + dataChanged(); +} + +QList FMPreviewModel::getBase() +{ + if(base.isEmpty()) + return FMFontDb::DB()->getFilteredFonts(true); + else + return base; +} + + +FMPreviewView::FMPreviewView(QWidget * parent): + QListView(parent), + columns(1) { dragFlag = false; setDragEnabled(true); setDragDropMode(QAbstractItemView::DragDrop); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setSelectionRectVisible(false); + +} + +bool FMPreviewView::moveTo(const QString &fname) +{ + QList fl(reinterpret_cast(model())->getBase()); + + QString uname(fname.toUpper()); + const int fl_count(fl.count()); + int rFont(fl_count); + for(int i(0); i < fl_count ; ++i) + { + QString pname(fl[i]->fancyName().toUpper()); + pname.truncate(uname.count()); + if(uname == pname) + { + rFont = i; + break; + } + } + + if(rFont != fl_count) + { + QAbstractListModel *mod(reinterpret_cast(model())); + QModelIndex mi(mod->index(rFont)); + if(mi.isValid()) + { + selectionModel()->setCurrentIndex(mi, QItemSelectionModel::ClearAndSelect); + // scrollTo ( mi ); + return true; + } + } + + return false; } void FMPreviewView::resizeEvent(QResizeEvent * event) { - int borders( 2*(frameWidth() + lineWidth() + midLineWidth()) ); - int scrollbar(verticalScrollBar()->width()); - usedWidth = this->width() - (borders + scrollbar); - - emit widthChanged(usedWidth); + int actualWidth(width() - 20); // if we use the viewport size, it becomes funny when a resize shows/hides the scrollbar + setSpacing(0); + int gHeight(2.0 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0); + qDebug()<< "VW" << actualWidth<width()<< "S" <pos(); dragFlag = false; -// const QModelIndex idx ( indexAt(startDragPoint) ); -// if(idx.isValid()) -// emit pressed(idx); + // const QModelIndex idx ( indexAt(startDragPoint) ); + // if(idx.isValid()) + // emit pressed(idx); } QListView::mousePressEvent(event); } void FMPreviewView::mouseMoveEvent(QMouseEvent * event) { + if(!(event->modifiers().testFlag( Qt::ControlModifier ))) + return; if (!(event->buttons() & Qt::LeftButton)) return; if ((event->pos() - startDragPoint).manhattanLength() < QApplication::startDragDistance()) return; + FMPreviewModel * m(reinterpret_cast(model())); + if(m && m->getFamilyMode()) + return; // Create a window with the current preview if(currentIndex().isValid() && (!dragFlag)) { dragFlag = true; -// FontItem * sf(typotek::getInstance()->getSelectedFont()); + // FontItem * sf(typotek::getInstance()->getSelectedFont()); QModelIndex idx = indexAt(startDragPoint); QString fname = idx.data(FMPreviewModel::PathRole).toString(); if(!fname.isEmpty()) @@ -280,15 +460,24 @@ } +void FMPreviewView::keyPressEvent(QKeyEvent *event) +{ + qDebug()<<"FMPreviewView::keyPressEvent"<text().isEmpty()) && (event->text().at(0).isLetterOrNumber())) + emit keyPressed(event->text()); + else + QListView::keyPressEvent(event); +} void FMPreviewView::updateLayout() { - emit widthChanged(usedWidth); + update(); } void FMPreviewView::setCurrentFont(const QString & name) { - QList fl( typotek::getInstance()->getCurrentFonts() ); + QList fl(reinterpret_cast(model())->getBase()); + const int fl_count(fl.count()); int rFont(fl_count); for(int i(0); i < fl_count ; ++i) diff -Nru fontmatrix-0.6.0+svn20100107/src/fmpreviewlist.h fontmatrix-0.6.0+svn20110930/src/fmpreviewlist.h --- fontmatrix-0.6.0+svn20100107/src/fmpreviewlist.h 2009-08-09 18:03:55.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmpreviewlist.h 2010-09-20 10:19:32.000000000 +0000 @@ -26,6 +26,8 @@ #include #include #include +#include +#include class FontItem; class MainViewWidget; @@ -36,14 +38,27 @@ class FMPreviewIconEngine : public QIconEngineV2 { public: + enum Activation{ + NotActivated, + Activated, + PartlyActivated + }; FMPreviewIconEngine(); ~FMPreviewIconEngine(); void paint ( QPainter * painter, const QRect & rect, QIcon::Mode mode, QIcon::State state ); void addPixmap ( const QPixmap & pixmap, QIcon::Mode mode, QIcon::State state ); + void setActivation(Activation a){activatedFont = a;} private: QPixmap m_p; + Activation activatedFont; + static bool initState; + static QPen pen; static QVector m_selPalette; + static QRgb activatedColor; + static QRgb deactivatedColor; + static QRgb partlyActivatedColor; + QVector actualSelPalette(const QVector& orig); }; @@ -56,15 +71,21 @@ FMPreviewView(QWidget * parent = 0); ~FMPreviewView(){} int getUsedWidth() const{return usedWidth;} + // n = 1 for a single column layout (list); n = 2 for multi columns layout + void setNumCol(int n){columns = n;} + bool moveTo(const QString& fname); // fname can be the begining of a fancy name + protected: void resizeEvent ( QResizeEvent * event ); QPoint startDragPoint; bool dragFlag; virtual void mousePressEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event); + void keyPressEvent(QKeyEvent *event); private: int usedWidth; + int columns; public slots: void updateLayout(); @@ -72,17 +93,19 @@ signals: void widthChanged(int); + void keyPressed(QString); }; class FMPreviewModel : public QAbstractListModel { + Q_OBJECT public: enum PreviewItemRole{ PathRole = Qt::UserRole + 1 }; - FMPreviewModel ( QObject * pa , FMPreviewView * wPa); + FMPreviewModel ( QObject * pa , FMPreviewView * wPa, QList db = QList()); //returns a preview QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const; //returns flags for items @@ -90,14 +113,26 @@ //returns the number of items int rowCount ( const QModelIndex &parent ) const; - void dataChanged(); + void resetBase(QList db); + QList getBase(); + + void setFamilyMode(bool f){familyMode =f;} + void setSpecString(const QString& s){specString = s;} + bool getFamilyMode() const{return familyMode;} private: FMPreviewView *m_view; - + QList base; + QString specString; QString styleTooltipName; + QString styleTooltipTags; QString styleTooltipPath; + bool familyMode; + +public slots: + void dataChanged(); + }; diff -Nru fontmatrix-0.6.0+svn20100107/src/fmpython_w.cpp fontmatrix-0.6.0+svn20110930/src/fmpython_w.cpp --- fontmatrix-0.6.0+svn20100107/src/fmpython_w.cpp 2009-05-01 15:14:29.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmpython_w.cpp 2010-09-13 10:06:29.000000000 +0000 @@ -6,7 +6,7 @@ #include "typotek.h" #include "mainviewwidget.h" -#include "listdockwidget.h" +//#include "listdockwidget.h" #include "fmfontdb.h" #include "fmscriptconsole.h" @@ -108,30 +108,6 @@ /// "exported" methods -void FMPythonW::nextFace() -{ -// qDebug()<<"FMPythonW::nextFace"; - ListDockWidget::getInstance()->fontTree->slotNextFont(); -} - -void FMPythonW::previousFace() -{ -// qDebug()<<"FMPythonW::previousFace"; - ListDockWidget::getInstance()->fontTree->slotPreviousFont(); -} - -void FMPythonW::nextFamily() -{ -// qDebug()<<"FMPythonW::nextFamily"; - ListDockWidget::getInstance()->fontTree->slotNextFamily(); -} - -void FMPythonW::previousFamily() -{ -// qDebug()<<"FMPythonW::previousFamily"; - ListDockWidget::getInstance()->fontTree->slotPreviousFamily(); -} - QString FMPythonW::currentFontPath() { if ( !tk->getSelectedFont() ) @@ -159,7 +135,7 @@ if ( !tk->getSelectedFont() ) return ret; - foreach(FontItem* fi, tk->getCurrentFonts()) + foreach(FontItem* fi, FMFontDb::DB()->getFilteredFonts()) { ret << fi->path(); } @@ -168,9 +144,9 @@ QList FMPythonW::currentFonts() { - if ( !tk->getSelectedFont() ) - return QList(); - return tk->getCurrentFonts(); +// if ( !tk->getSelectedFont() ) +// return QList(); + return FMFontDb::DB()->getFilteredFonts(); } @@ -185,8 +161,3 @@ return FMFontDb::DB(); } -void FMPythonW::updateTree() -{ - typotek::getInstance()->getTheMainView()->slotUpdateTree(); -} - diff -Nru fontmatrix-0.6.0+svn20100107/src/fmpython_w.h fontmatrix-0.6.0+svn20110930/src/fmpython_w.h --- fontmatrix-0.6.0+svn20100107/src/fmpython_w.h 2009-04-05 17:20:56.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmpython_w.h 2010-09-13 10:06:29.000000000 +0000 @@ -34,13 +34,6 @@ void run(); public slots: - void nextFace(); - void previousFace(); - void nextFamily(); - void previousFamily(); - - void updateTree(); - QString currentFontPath(); QString currentFontFamily(); QString currentFontStyle(); diff -Nru fontmatrix-0.6.0+svn20100107/src/fmsampletextview.cpp fontmatrix-0.6.0+svn20110930/src/fmsampletextview.cpp --- fontmatrix-0.6.0+svn20100107/src/fmsampletextview.cpp 2009-06-23 11:04:26.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmsampletextview.cpp 2010-12-05 19:12:11.000000000 +0000 @@ -33,7 +33,7 @@ : QGraphicsView ( parent ), hasPendingUpdate ( false ) { -#ifdef HAVE_QTOPENGL +#if 0 QGLFormat glfmt; glfmt.setSampleBuffers ( true ); QGLWidget *glwgt = new QGLWidget ( glfmt ); @@ -51,7 +51,9 @@ } #endif - setInteractive ( true ); + setInteractive ( false ); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); theRect = 0; fPage = 0; isSelecting = false; diff -Nru fontmatrix-0.6.0+svn20100107/src/fmvariants.cpp fontmatrix-0.6.0+svn20110930/src/fmvariants.cpp --- fontmatrix-0.6.0+svn20100107/src/fmvariants.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmvariants.cpp 2010-09-22 15:31:04.000000000 +0000 @@ -0,0 +1,215 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "fmvariants.h" + +#include "fontitem.h" + +FMVariants * FMVariants::instance = 0; + +FMVariants::FMVariants() +{ + // init sorted variant names + variants.clear(); + QStringList weight; + weight << QString("Hairline") + << QString("Thin") + << QString("UltraLight") + << QString("ExtraLight") + << QString("Light") + << QString("Book") + << QString("Normal") + << QString("Regular") + << QString("Roman") + << QString("Plain") + << QString("Medium") + << QString() + << QString("Demi") + << QString("DemiBold") + << QString("SemiBold") + << QString("Bold") + << QString("ExtraBold") + << QString("Extra") + << QString("Heavy") + << QString("Black") + << QString("ExtraBlack") + << QString("UltraBlack") + << QString("Ultra"); + + QStringList slope; + slope << QString() + << QString("Italic") + << QString("Oblique") + << QString("Slanted"); + + QStringList width; + width << QString() + << QString("UltraCompressed") + << QString("Compressed") + << QString("UltraCondensed") + << QString("Condensed") + << QString("SemiCondensed") + << QString("Narrow") + << QString("SemiExtended") + << QString("SemiExpanded") + << QString("Extended") + << QString("Expanded") + << QString("ExtraExtended") + << QString("ExtraExpanded"); + + QStringList optical; + optical << QString() + << QString("Poster") + << QString("Display") + << QString("SubHead") + << QString("SmallText") + << QString("Caption"); + + foreach(const QString& w, weight) + { + foreach(const QString& s, slope) + { + foreach(const QString& wi, width) + { + foreach(const QString& o, optical) + { + appendVariants(w, s, wi, o); + } + } + } + } +// foreach(const QStringList& v, variants) +// qDebug()< FMVariants::Order(QList ul) +{ + if(instance == 0) + instance = new FMVariants; + + FMVariants *vs(instance); + + QList ret; + QMap fl; + foreach(FontItem* f, ul) + { + fl.insert(f, f->variant().split(QString(" "))); + } + foreach(const QStringList& v, vs->variants) + { + foreach(FontItem* f, fl.keys()) + { + if(vs->compareVariants(v,fl[f])) + { + ret.append(f); + fl.remove(f); + } + } + } + if(fl.count() > 0) + { + // for Univers-like fonts, we get the number key + QMap > ulikeFonts; + bool intOK(false); + foreach(FontItem* f, fl.keys()) + { + intOK = false; + QString fs(fl[f].first()); + int idx(fs.toInt(&intOK, 10)); + if(intOK) + { + ulikeFonts[idx][f->variant()] = f; + fl.remove(f); + } + } + foreach(int k, ulikeFonts.keys()) + { + foreach(const QString& v, ulikeFonts[k].keys()) + ret << ulikeFonts[k][v]; + } + + // still fonts unsorted; + if(fl.count() > 0) + { + QMap lastChance; + foreach(FontItem* f, fl.keys()) + { + lastChance[f->variant()] = f; + } + foreach(const QString& v, lastChance.keys()) + ret << lastChance[v]; + } + } + return ret; +} + + +FontItem * FMVariants::Preferred(QList ul) +{ + if(ul.isEmpty()) + return 0; + if(instance == 0) + instance = new FMVariants; + foreach(FontItem* it, ul) + { + if(instance->priorList.contains(it->variant(), Qt::CaseInsensitive)) + { + return it; + } + } + return ul.first(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/fmvariants.h fontmatrix-0.6.0+svn20110930/src/fmvariants.h --- fontmatrix-0.6.0+svn20100107/src/fmvariants.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fmvariants.h 2010-09-22 15:31:04.000000000 +0000 @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FMVARIANTS_H +#define FMVARIANTS_H + +#include +#include + +class FontItem; + +class FMVariants +{ + static FMVariants *instance; + FMVariants(); + + QList variants; + QStringList priorList; + void appendVariants(const QString& w, const QString& s, const QString& wi, const QString& o); + inline bool compareVariants(const QStringList& a, const QStringList& b); + +public: + static QList Order(QList ul); + static FontItem* Preferred(QList ul); + +}; + +#endif // FMVARIANTS_H diff -Nru fontmatrix-0.6.0+svn20100107/src/fontbook.cpp fontmatrix-0.6.0+svn20110930/src/fontbook.cpp --- fontmatrix-0.6.0+svn20100107/src/fontbook.cpp 2008-12-03 20:44:36.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fontbook.cpp 2010-12-05 19:12:11.000000000 +0000 @@ -14,12 +14,21 @@ #include "typotek.h" #include "fontitem.h" #include "fmlayout.h" +#include "fmfontdb.h" +#include "fmpaths.h" +#include "progressbarduo.h" +#include "fmvariants.h" #include +#include #include #include #include #include +#include +#include +#include +#include FontBook::FontBook() { @@ -49,6 +58,22 @@ mapPSize[ "Custom" ] = QPrinter::Custom ; + + QFile sf(FMPaths::ResourcesDir()+ QString("fontbook.strings")); + if(sf.open(QIODevice::ReadOnly)) + { + QString ss(QString::fromUtf8(sf.readAll())); + stringList = ss.split("\n", QString::SkipEmptyParts); + } + else + { + stringList << QString("Call me Ishmael. Some years ago —never mind how long precisely— having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world."); + stringList << QString("It is a way I have of driving off the spleen and regulating the circulation."); + stringList << QString("Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off —then, I account it high time to get to sea as soon as I can."); + stringList << QString("This is my substitute for pistol and ball."); + stringList << QString("With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship."); + stringList << QString("There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me."); + } } @@ -59,559 +84,997 @@ -void FontBook::doBook() +void FontBook::doBook(FontBook::Style s) { - FontBookDialog bookOption ( typotek::getInstance() ); - bookOption.exec(); + printer = new QPrinter( QPrinter::HighResolution ); + printerRect = printer->paperRect(QPrinter::Point); + QPrintDialog dialog(printer); + dialog.setWindowTitle("Fontmatrix - " + tr("Print Fontbook")); - if ( !bookOption.isOk ) + if ( dialog.exec() != QDialog::Accepted ) return; - if ( bookOption.getFileName().isEmpty() ) - return; - - outputFilePath = bookOption.getFileName(); + printer->setFullPage ( true ); + painter = new QPainter( printer ); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->setRenderHint(QPainter::TextAntialiasing, true); - if ( bookOption.isTemplate() ) + switch(s) { - doBookFromTemplate ( bookOption.getTemplate() ); - return; - } + case Full: doFullBook(); + break; + case OneLiner: doOneLinerBook(); + break; + default: break; + } + delete painter; + delete printer; } -void FontBook::doBookFromTemplate ( const QDomDocument &aTemplate ) +void FontBook::doFullBook() { - /** - We build lists of contexts - */ - QList conPage; - QList conFamily; - QList conSubfamily; + // Full book + // - QDomNodeList conList = aTemplate.elementsByTagName ( "context" ); - if ( conList.length() == 0 ) - { - qDebug ( ) << "ERROR: "<< conList.length() <<" context in template, see yourself :" ; - qDebug() << aTemplate.toString ( 1 ); - return; - } + progress = new ProgressBarDuo(typotek::getInstance()); - QMap svgRendered; - QMap qfontCache; // abit of optim. - for ( uint i = 0; i < conList.length(); ++i ) - { - FontBookContext fbc; - QDomNode context = conList.item ( i ); - QString levelString = context.toElement().attributeNode ( "level" ).value(); + doFullBookCover(); - fbc.textElement.e = context.namedItem ( "text" ).toElement().text(); - if ( !fbc.textElement.e.isEmpty() ) + progress->setLabel(QString("-"), 0); + progress->setLabel(QString("-"), 1); + progress->setMax(FMFontDb::DB()->getFilteredFonts(true).count(), 0); + progress->setMax(0, 1); + progress->show(); + + int familyCounter(0); + foreach(FontItem * family, FMFontDb::DB()->getFilteredFonts(true)) + { + progress->setLabel(family->family(), 0); + progress->setValue(++familyCounter, 0); + printer->newPage(); + if(doFullBookPageLeft(family->family())) { - // QString textInternalString = context.namedItem ( "text" ).toElement().attributeNode ( "internal" ).value(); - // fbc.textElement.internal = ( textInternalString == "true" ) ? true : false; - fbc.textElement.valid = true; - - QDomNode tStyle = context.namedItem ( "textstyle" ); - fbc.textStyle.name = tStyle.toElement().attributeNode ( "name" ).value(); - fbc.textStyle.font = tStyle.namedItem ( "font" ).toElement().text(); - fbc.textStyle.fontsize = QString ( tStyle.namedItem ( "fontsize" ).toElement().text() ).toDouble() ; - fbc.textStyle.color = QColor ( tStyle.namedItem ( "color" ).toElement().text() ); - - bool ital = false; - QFont::Weight bold = QFont::Normal; - if ( fbc.textStyle.font.contains ( "italic", Qt::CaseInsensitive ) ) - ital = true; - if ( fbc.textStyle.font.contains ( "bold", Qt::CaseInsensitive ) ) - bold = QFont::Bold; - qfontCache[fbc.textStyle.name] = QFont ( fbc.textStyle.font,10, bold, ital ); - qfontCache[fbc.textStyle.name].setPointSizeF(fbc.textStyle.fontsize ); - - fbc.textStyle.lineheight = QString ( tStyle.namedItem ( "lineheight" ).toElement().text() ).toDouble() ; - fbc.textStyle.margin_top = QString ( tStyle.namedItem ( "margintop" ).toElement().text() ).toDouble() ; - fbc.textStyle.margin_left = QString ( tStyle.namedItem ( "marginleft" ).toElement().text() ).toDouble() ; - fbc.textStyle.margin_bottom = QString ( tStyle.namedItem ( "marginbottom" ).toElement().text() ).toDouble() ; - fbc.textStyle.margin_right = QString ( tStyle.namedItem ( "marginright" ).toElement().text() ).toDouble() ; + printer->newPage(); + doFullBookPageRight(family->family()); } + } - QDomNode graphicNode = context.namedItem ( "graphic" ); - if ( graphicNode.isElement() ) - { -// QDomDocumentFragment svgFrag = aTemplate.createDocumentFragment(); - QDomNode svgNode = graphicNode.toElement().namedItem ( "svg" ).cloneNode ( true ); -// svgFrag.appendChild(svgNode); -// if(svgNode.isElement()) - { - fbc.graphic.name = graphicNode.toElement().attributeNode ( "name" ).value(); - fbc.graphic.x = QString ( graphicNode.toElement().attributeNode ( "xpos" ).value() ).toDouble(); - fbc.graphic.y = QString ( graphicNode.toElement().attributeNode ( "ypos" ).value() ).toDouble(); - - QDomDocument svgDoc; - QDomNode svg = svgDoc.importNode ( svgNode,true ); - svgDoc.appendChild ( svg ); - QString svgString ( "\n" + svgDoc.toString ( 0 ) ); - QSvgRenderer *doc = new QSvgRenderer ( svgString.toUtf8() ); - svgRendered[fbc.graphic.name] = doc; - fbc.graphic.valid = true; -// qDebug() << fbc.graphic.svg; - } + delete progress; +} + +void FontBook::doFullBookCover() +{ + QGraphicsScene pScene(printerRect); + QFont aFont; + aFont.setPointSizeF(26.0); + QGraphicsSimpleTextItem * title(pScene.addSimpleText(QString("Fontmatrix"),aFont)); + title->setPos(60, printerRect.height()*.9); + + int module(250); + double x(0); + double y(0); + double fsize(qrand() % module); + int gray(qrand() % 160); + foreach(FontItem * f, FMFontDb::DB()->getFilteredFonts()) + { + int lc(f->lastChar()); + int charcode(qrand() % lc); + while(!f->hasCharcode(charcode)) + charcode = qrand() % lc; + + QGraphicsPathItem *p(f->itemFromChar(charcode, fsize)); + if(p->data(GLYPH_DATA_ERROR).toBool()) + { + delete p; + continue; } + pScene.addItem(p); + p->setPos(x + (qrand() % qRound(printerRect.width())), y + (qrand() % qRound(printerRect.height()))); + p->setBrush(QColor(gray, gray, gray)); + p->setPen(Qt::NoPen); + gray = qrand() % 160; + fsize = qrand() % module; + } + pScene.render(painter, printer->paperRect(), printerRect); +} - if ( levelString == "page" ) - conPage << fbc; - else if ( levelString == "family" ) - conFamily << fbc; - else if ( levelString == "subfamily" ) - conSubfamily << fbc; - } - - - QString paperSize = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().text() ).toUpper(); - double prectx = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().attributeNode ( "bboxx" ).value() ).toDouble(); - double precty = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().attributeNode ( "bboxy" ).value() ).toDouble(); - double prectw = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().attributeNode ( "bboxw" ).value() ).toDouble(); - double precth = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().attributeNode ( "bboxh" ).value() ).toDouble(); - - QPrinter thePrinter ( QPrinter::HighResolution ); - thePrinter.setOutputFormat ( QPrinter::PdfFormat ); - thePrinter.setCreator ( "Fontmatrix " + QString::number ( FONTMATRIX_VERSION_MAJOR ) + "." + QString::number ( FONTMATRIX_VERSION_MINOR ) ); - thePrinter.setDocName ( "A font book" ); - thePrinter.setOutputFileName ( outputFilePath ); - thePrinter.setPageSize ( mapPSize[paperSize] ); - thePrinter.setFullPage ( true ); -// qDebug() << thePrinter.pageSize() << thePrinter.pageRect() << thePrinter.paperRect() << thePrinter.resolution() ; - double paperWidth = thePrinter.pageRect().width() / thePrinter.resolution() * 72.0; - double paperHeight = thePrinter.pageRect().height() / thePrinter.resolution() * 72.0; -// qDebug()<< paperSize << paperWidth << paperHeight; - QGraphicsScene theScene; - QGraphicsScene measurementScene; - measurementScene.setSceneRect( 0,0,paperWidth,paperHeight ); - theScene.setSceneRect ( 0,0,paperWidth,paperHeight ); - QPainter thePainter ( &thePrinter ); - QPointF thePos ( prectx,precty ); - QList renderedFont; - QList renderedGraphic; - QList renderedText; - - - - QList localFontMap = typotek::getInstance()->getCurrentFonts(); - QMap > keyList; - for ( int i=0; i < localFontMap.count();++i ) - { - keyList[localFontMap[i]->family() ].append ( localFontMap[i] ); - } - - QMap >::const_iterator kit; - QProgressDialog progress ( QObject::tr ( "Creating font book... " ), QObject::tr ( "cancel" ), 0, keyList.count(), typotek::getInstance() ); - progress.setWindowModality ( Qt::WindowModal ); - int progressindex=0; - - - QString pageNumStr; - int pageNumber = 0; - ///We begin in a PAGE context -// qDebug() << "PAGE"; - pageNumStr.setNum ( ++pageNumber ); - QMap pageReplace; - QMap familyReplace; - QMap subfamilyReplace; - - QString currentFamily; - QString currentSubfamily; - - /** Z policy is - PAGE_SVG 1 - PAGE_TEXT 10 - FAMILY_SVG 100 - FAMILY_TEXT 1000 - SUBFAMILY_SVG 10000 - SUBFAMILY_TEXT 100000 - */ +void FontBook::doFullBookPageRight(const QString &family) +{ + qDebug()<<"=>"< familyFonts = FMFontDb::DB()->FamilySet(family); - for ( int pIndex = 0; pIndex < conPage.count(); ++pIndex ) + QRectF halfPage(printerRect); + halfPage.setHeight(halfPage.height() * 0.7); + QGraphicsScene tmpScene(halfPage); + QGraphicsScene pScene(halfPage); + + /** BEGINING OF decorative multi sized samples */ + + QMap logWidth; + QMap logAscend; + QMap logDescend; + QMap sampleString; + QMap sampleFont; + + QString iString(stringList.join(" ")); + QStringList stl; + QList sizes; + if(familyFonts.count() > 1) { -// qDebug()<<"PI"<::const_iterator repIt = pageReplace.begin(); repIt != pageReplace.end(); ++repIt ) - place.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); - pagelines << place; + if((t.count() >= 2) + && !stl.contains(t) + && !sizes.contains(t.count())) + { + qDebug()<<"\t"<setPos ( conPage[pIndex].textStyle.margin_left , conPage[pIndex].textStyle.margin_top + ( pl * conPage[pIndex].textStyle.lineheight ) ); - ti->setZValue ( 10 ); - ti->setDefaultTextColor ( conPage[pIndex].textStyle.color ); + idxS = qrand() % (qMax(1, iString.count() / 3)); + idxE = qMax( familyFonts.count(), qrand() % module); } } - if ( conPage[pIndex].graphic.valid ) - { - QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); - svgIt->setSharedRenderer ( svgRendered[conPage[pIndex].graphic.name] ); - theScene.addItem ( svgIt ); - svgIt->setPos ( conPage[pIndex].graphic.x, conPage[pIndex].graphic.y ); - renderedGraphic << svgIt; - svgIt->setZValue ( 1 ); - } + } + else // mono variant families can make the algo above to loop + { + QStringList monoList; + monoList << "Ab" << "Cd" << "Ef" << "Gh" << "Ij" << "Kl" << "Mn" << "Op" << "Qr" << "St" << "Uv" << "Xy" << "Za"; + stl << monoList.at(qrand() % monoList.count()); + } + int diff ( familyFonts.count() ); + for (int i(0); i < diff; ++i) + { + sampleString[i] = stl[ i/* % stl.count() */]; } - /// Beginning of the big loop - for ( kit = keyList.begin(); kit != keyList.end(); ++kit ) + // first we’ll get widths for font size 1000 + for(int fidx(0); fidx < familyFonts.count(); ++fidx) { - /// We are in a FAMILY context -// qDebug() << "FAMILY"; + sampleFont[fidx] = familyFonts[fidx]; + bool rasterState(sampleFont[fidx]->rasterFreetype()); + sampleFont[fidx]->setFTRaster(false); + sampleFont[fidx]->setRenderReturnWidth(true); + logWidth[fidx] = familyFonts[fidx]->renderLine(&tmpScene, sampleString[fidx], QPointF(0.0, 1000.0) , 999999.0, 1000.0, 1) ; + sampleFont[fidx]->setRenderReturnWidth(false); + sampleFont[fidx]->setFTRaster(rasterState); + logAscend[fidx] = 1000.0 - tmpScene.itemsBoundingRect().top(); + logDescend[fidx] = tmpScene.itemsBoundingRect().bottom() - 1000.0; +// qDebug()<< sampleString[fidx] << logWidth[fidx]; + QList lgit(tmpScene.items()); + foreach(QGraphicsItem* git, lgit) { - if ( progress.wasCanceled() ) - break; - progress.setLabelText ( kit.key() ); - progress.setValue ( ++progressindex ); + tmpScene.removeItem(git); + delete git; } - currentFamily = kit.key(); - for ( int elemIndex = 0; elemIndex < conFamily.count() ; ++elemIndex ) - { - QStringList familylines; - QStringList tmplines = conFamily[elemIndex].textElement.e.split ( "\n" ); - familyReplace["##FAMILY##"] = kit.key(); - for ( int t = 0; t < tmplines.count(); ++t ) - { + } + const double defWidth( 480.0 ); + const double defHeight( 570.0 ); + const double xOff( 0.5 * (printerRect.width() - defWidth) ); + double yPos( 33.0 ); - QString place = tmplines[t]; - for ( QMap::const_iterator repIt = familyReplace.begin(); repIt != familyReplace.end(); ++repIt ) - place.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); - if ( !place.isEmpty() ) - familylines << place; - } + QFont nameFont; + nameFont.setPointSizeF(5.0); - double available = ( precty + precth ) - thePos.y(); - double needed = ( familylines.count() * conFamily[elemIndex].textStyle.lineheight ) - + conFamily[elemIndex].textStyle.margin_top - + conFamily[elemIndex].textStyle.margin_bottom; + for(int fidx(0); fidx < familyFonts.count(); ++fidx) + { + double fSize( (defWidth * 1000.0) / logWidth[fidx]); + double fAscend(logAscend[fidx] * fSize / 1000.0); + double fDescend(logDescend[fidx] * fSize / 1000.0 ); + if( (fidx > 0) && ((yPos + fAscend + fDescend) > defHeight)) + break; + + yPos += fAscend; + QPointF origine(xOff, yPos ); + +// qDebug()<< sampleString[fidx] << fSize; + + bool rasterState(sampleFont[fidx]->rasterFreetype()); + sampleFont[fidx]->setFTRaster(false); + sampleFont[fidx]->renderLine(&pScene, + sampleString[fidx], + origine, + printerRect.width() , + fSize, + 0); +// pScene.addLine(QLineF(origine, QPointF(xOff + defWidth, yPos))); + sampleFont[fidx]->setFTRaster(rasterState); + + yPos += 4.0; + QGraphicsSimpleTextItem * nameText = pScene.addSimpleText( QString("%1 %2pt").arg(familyFonts[fidx]->variant()) + .arg((fSize > 16.0) ? qRound(fSize) : (fSize, 0, 'f', 1)), + nameFont) ; + nameText->setPos(xOff, yPos); + nameText->setBrush(Qt::gray); - if ( needed > available ) - { - /// We are in a PAGE context -// qDebug() << "NFPAGE"; - // close, clean and create - theScene.render ( &thePainter ); - - thePos.ry() = precty; -// for ( int d = 0; d < renderedFont.count() ; ++d ) -// renderedFont[d]->deRenderAll(); - for ( int d = 0; d < renderedGraphic.count(); ++d ) - delete renderedGraphic[d]; - for ( int d = 0; d < renderedText.count(); ++d ) - delete renderedText[d]; - renderedFont.clear(); - renderedGraphic.clear(); - renderedText.clear(); -// theScene.removeItem ( theScene.createItemGroup ( theScene.items() ) ); + yPos += fDescend ; + yPos += nameText->boundingRect().height(); + } + pScene.addLine(QLineF(QPointF(xOff, defHeight + 30.0), QPointF(xOff + defWidth, defHeight + 30.0))); + pScene.render(painter, printer->paperRect(), printerRect); - thePrinter.newPage(); - pageNumStr.setNum ( ++pageNumber ); + /** END OF decorative multi sized samples */ - // - for ( int pIndex = 0; pIndex < conPage.count(); ++pIndex ) - { - QStringList pagelines ; - QStringList tmplines = conPage[pIndex].textElement.e.split ( "\n" ); - pageReplace["##PAGENUMBER##"] = pageNumStr; - pageReplace["##FAMILY##"] = currentFamily; - pageReplace["##SUBFAMILY##"] = currentSubfamily; - for ( int t = 0; t < tmplines.count(); ++t ) - { + /** BEGINING of paragraph preview */ + //lets setup a double column layout + QRectF colRectLayoutLeft(printerRect); + colRectLayoutLeft.setHeight(142.0); + colRectLayoutLeft.setWidth(200.0); + QRectF colRectLayoutRight(printerRect); + colRectLayoutRight.setHeight(142.0); + colRectLayoutRight.setWidth(260.0); + QRectF colLeftRect(colRectLayoutLeft); + colLeftRect.translate(xOff, 630.0); + QRectF colRightRect(colRectLayoutRight); + colRightRect.translate(xOff + 220.0, 630.0); + + // Select a font, regular preferred + FontItem * rFont(FMVariants::Preferred(familyFonts)); + + // Lets layout ! + + double littleSize(7.5); + double bigSize(10.0); + QGraphicsScene layoutLeftScene(printerRect); + QGraphicsScene layoutRightScene(printerRect); + FMLayout *layoutLeft = new FMLayout(&layoutLeftScene , rFont, colLeftRect); + FMLayout *layoutRight = new FMLayout(&layoutRightScene , rFont, colRightRect); + layoutLeft->setDeviceIndy(true); + layoutLeft->setAdjustedSampleInter( littleSize*1.2 ); +// layoutLeft->setRect(colLeftRect); + layoutRight->setDeviceIndy(true); + layoutRight->setAdjustedSampleInter( bigSize*1.2 ); +// layoutRight->setRect(colRightRect); + + bool rasterState(rFont->rasterFreetype()); + rFont->setFTRaster(false); + QList lgl; + foreach(QString s, stringList) + { + lgl << rFont->glyphs(s, littleSize); + } + layoutLeft->doLayout(lgl, littleSize); + lgl.clear(); + foreach(QString s, stringList) + { + lgl << rFont->glyphs(s, bigSize); + } + layoutRight->doLayout(lgl, bigSize); - QString pageplace = tmplines[t]; - for ( QMap::const_iterator repIt = pageReplace.begin(); repIt != pageReplace.end(); ++repIt ) - pageplace.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); - pagelines << pageplace; - } -// QFont pFont ( conPage[pIndex].textStyle.font, conPage[pIndex].textStyle.fontsize ); - for ( int pl = 0; pl < pagelines.count(); ++pl ) - { - QGraphicsTextItem * ti = theScene.addText ( pagelines[pl], qfontCache[conPage[pIndex].textStyle.name] ); - renderedText << ti; - ti->setPos ( conPage[pIndex].textStyle.margin_left + prectx, conPage[pIndex].textStyle.margin_top + ( pl * conPage[pIndex].textStyle.lineheight ) ); - ti->setZValue ( 10 ); - ti->setDefaultTextColor ( conPage[pIndex].textStyle.color ); - } - if ( conPage[pIndex].graphic.valid ) - { - QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); - svgIt->setSharedRenderer ( svgRendered[conPage[pIndex].graphic.name] ); - theScene.addItem ( svgIt ); - svgIt->setPos ( conPage[pIndex].graphic.x + prectx, conPage[pIndex].graphic.y ); - renderedGraphic << svgIt; - svgIt->setZValue ( 1 ); - } - } + rFont->setFTRaster(rasterState); + +// qDebug()<<"R"<getRect()<paperRect(), printerRect); + layoutRightScene.render(painter, printer->paperRect(), printerRect); + /** END of paragraph preview */ + + + // DEBUG +// QImage image(printer->paperRect(QPrinter::Point).size().toSize(), QImage::Format_ARGB32); +// QPainter debugPainter(&image); +// pScene.render(&debugPainter); +// layoutLeftScene.render(&debugPainter); +// layoutRightScene.render(&debugPainter); +// image.save(QString("/home/pierre/debug_%1.png").arg(QTime::currentTime().msec())); + //////// + + delete layoutLeft; + delete layoutRight; +} + +bool FontBook::doFullBookPageLeft(const QString &family) +{ + // TODOs + QList familyFonts = FMVariants::Order(FMFontDb::DB()->FamilySet(family)); + QGraphicsScene pScene(printerRect); + QFont nameFont; + nameFont.setPointSizeF(18.0); + QGraphicsSimpleTextItem * familyText( pScene.addSimpleText( QString("%1").arg(family), nameFont) ); + familyText->setPos(printerRect.width() * 0.1 , printerRect.height() * 0.1); + + double xPos(printerRect.width() * 0.1); + double yPos(printerRect.height() * 0.20); + double maxYPos(0); + int colBreak(0); + if(familyFonts.count() <= 60) + { + if((familyFonts.count() % 4) == 0) + colBreak = familyFonts.count() / 4; + else + colBreak = qMax( 1, familyFonts.count() / 3); + double colunit(100); + for(int fidx(0); fidx < familyFonts.count(); ++fidx) + { + if((fidx >= colBreak) && ((fidx % colBreak) == 0)) + { + xPos += colunit + 20 ; + yPos = printerRect.height() * 0.20; } - - for ( int fl = 0; fl < familylines.count(); ++fl ) + nameFont.setPointSizeF(4.0); + QGraphicsSimpleTextItem * varText( pScene.addSimpleText(familyFonts[fidx]->variant() , nameFont) ); + varText->setBrush(Qt::gray); + varText->setPos(xPos, yPos); + yPos += varText->boundingRect().height() * 2.2; + QPointF origine(xPos, yPos ); + + bool rasterState(familyFonts[fidx]->rasterFreetype()); + familyFonts[fidx]->setFTRaster(false); + familyFonts[fidx]->renderLine(&pScene, QString("foxy brown fox trot"), origine, printerRect.width() * 0.35 , 12.0); + familyFonts[fidx]->setFTRaster(rasterState); + + yPos += 12.0 ; + maxYPos = qMax(yPos, maxYPos); + } + + // Characters; + FontItem * pf(FMVariants::Preferred(familyFonts)); + int cCount(pf->countChars()); + int charcode(pf->firstChar()); + double ccX(printerRect.width() * 0.1); + double ccY(maxYPos + 30.0); + const double ccW(printerRect.width() * .9); + for(int i = 0; i < cCount; ++i) + { + if(ccY > 560) + break; + QGraphicsPathItem *p(pf->itemFromChar(charcode, 15.0)); + if(p->data(GLYPH_DATA_ERROR).toBool()) { - QGraphicsTextItem * ti = theScene.addText ( familylines[fl], qfontCache[conFamily[elemIndex].textStyle.name] ); - renderedText << ti; - ti->setPos ( conFamily[elemIndex].textStyle.margin_left + prectx, thePos.y() + ( conFamily[elemIndex].textStyle.margin_top + ( fl * conFamily[elemIndex].textStyle.lineheight ) ) ); - ti->setZValue ( 1000 ); - ti->setDefaultTextColor ( conFamily[elemIndex].textStyle.color ); + charcode = pf->nextChar(charcode); + delete p; + continue; } - if ( conFamily[elemIndex].graphic.valid ) + pScene.addItem(p); + p->setPen(Qt::NoPen); + double advance(p->data(GLYPH_DATA_HADVANCE_SCALED).toDouble()); + double fakeAdvance(advance * 1.5); + if((ccX + fakeAdvance) > ccW) { - QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); - svgIt->setSharedRenderer ( svgRendered[conFamily[elemIndex].graphic.name] ); - theScene.addItem ( svgIt ); - svgIt->setPos ( conFamily[elemIndex].graphic.x + prectx, conFamily[elemIndex].graphic.y + thePos.y() ); - renderedGraphic << svgIt; - svgIt->setZValue ( 100 ); + ccY += 22.0; + if(ccY > 560) + break; + ccX = printerRect.width() * 0.1; } + p->setPos(ccX, ccY); - thePos.ry() += needed; - } // end of FAMILY level elements - - /// Looping through all faces for the current family - for ( int fontIndex = 0;fontIndex < kit.value().count(); ++fontIndex ) + ccX += fakeAdvance; + charcode = pf->nextChar(charcode); + + } + + // Unicode Coverage + QStringList llist; + foreach(FontItem * fi, familyFonts) { - FontItem * theFont = kit.value() [fontIndex]; - - /// We are in a SUBFAMILY context - currentSubfamily = theFont->variant(); - for ( int elemIndex = 0; elemIndex < conSubfamily.count() ; ++elemIndex ) + foreach(const QString& sl, fi->supportedLangDeclaration()) { - // First, is there enough room for this element - QStringList sublines; - QStringList tmplines = conSubfamily[elemIndex].textElement.e.split ( "\n" ); - - subfamilyReplace["##FAMILY##"] = theFont->family(); - subfamilyReplace["##SUBFAMILY##"] = theFont->variant(); - subfamilyReplace["##FILE##"]= theFont->path(); - subfamilyReplace["##TAGS##"]= theFont->tags().join ( ";" ) ; - subfamilyReplace["##COUNT##"]= QString::number ( theFont->glyphsCount() ); - subfamilyReplace["##TYPE##"]= theFont->type(); - subfamilyReplace["##CHARSETS##"]=theFont->charmaps().join ( ";" ); + if(!llist.contains(sl)) + llist << sl; + } + } - for ( int t = 0; t < tmplines.count(); ++t ) - { + if(llist.count() > 0) + { + nameFont.setPointSizeF(6.0); + QGraphicsSimpleTextItem * uniText( pScene.addSimpleText(tr("Unicode coverage") , nameFont) ); + uniText->setPos(printerRect.width() * 0.5, 600); + nameFont.setPointSizeF(4.0); + QGraphicsTextItem * uniList(pScene.addText(llist.join(", ") + QString("."), nameFont)); + uniList->setTextWidth(printerRect.width() * .4); + uniList->setPos(printerRect.width() * 0.5, 630); + } - QString subplace = tmplines[t]; - for ( QMap::const_iterator repIt = subfamilyReplace.begin(); repIt != subfamilyReplace.end(); ++repIt ) - subplace.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); - if ( !subplace.isEmpty() ) - sublines << subplace; - } + // OpenType - double available = ( precty + precth ) - thePos.y(); - double needed (0);/*= ( sublines.count() * conSubfamily[elemIndex].textStyle.lineheight ) - + conSubfamily[elemIndex].textStyle.margin_top - + conSubfamily[elemIndex].textStyle.margin_bottom;*/ - double mwidth( conSubfamily[elemIndex].textStyle.margin_right - (conSubfamily[elemIndex].textStyle.margin_left + prectx) ); - - /// Let’s see how much room we need - // For that we’ll render all elements on a dedicated scene if needed. - if(conSubfamily[elemIndex].graphic.valid) - { - needed = svgRendered[conSubfamily[elemIndex].graphic.name]->defaultSize().height(); - } - else + + pScene.render(painter, printer->paperRect(), printerRect); + return true; + } + else // think Kepler :) + { + colBreak = 20; + double colunit(100); + bool more(false); + for(int fidx(0); fidx < familyFonts.count(); ++fidx) + { + if((fidx >= colBreak)) + { + if(fidx >= (4 * colBreak)) { - if ( conSubfamily[elemIndex].textStyle.font == "_FONTMATRIX_" ) // We’ll use the current font + if(fidx == (4 * colBreak)) { - QList gl; - for ( int sl = 0; sl < sublines.count(); ++sl ) - { - gl << theFont->glyphs ( sublines[sl].trimmed(), conSubfamily[elemIndex].textStyle.fontsize ); - } - QRectF rf( measurementScene.sceneRect() ); - rf.setWidth(mwidth); - FMLayout::getLayout()->setTheScene ( &measurementScene , rf ); - FMLayout::getLayout()->setPersistentScene(false); - FMLayout::getLayout()->setTheFont ( theFont ); - FMLayout::getLayout()->setAdjustedSampleInter ( conSubfamily[elemIndex].textStyle.lineheight ); - FMLayout::getLayout()->setDeviceIndy ( true ); - - FMLayout::getLayout()->doLayout ( gl , conSubfamily[elemIndex].textStyle.fontsize ); - FMLayout::getLayout()->run(); - - needed = FMLayout::getLayout()->drawnLines * conSubfamily[elemIndex].textStyle.lineheight; - - FMLayout::getLayout()->resetScene(); - + pScene.render(painter, printer->paperRect(), printerRect); + pScene.clear(); + printer->newPage(); + more = true; + xPos = printerRect.width() * 0.1; + yPos = printerRect.height() * 0.08; } - else + else if(((fidx - (4 * colBreak)) % (colBreak + 4)) == 0) { - for ( int sl = 0; sl < sublines.count(); ++sl ) - { - - QGraphicsTextItem gti( sublines[sl]); - gti.setFont( qfontCache[ conSubfamily[elemIndex].textStyle.name] ); - gti.setTextWidth( mwidth ); - needed = gti.document()->size().height(); - } + xPos += colunit + 20 ; + yPos = printerRect.height() * 0.08; } } - if ( needed > available ) + else if((fidx % colBreak) == 0) { - /// We are in a PAGE context -// qDebug() << "NSPAGE"; - // close, clean and create - theScene.render ( &thePainter ); - - thePos.ry() = precty; -// for ( int d = 0; d < renderedFont.count() ; ++d ) -// renderedFont[d]->deRenderAll(); - for ( int d = 0; d < renderedGraphic.count(); ++d ) - delete renderedGraphic[d]; - for ( int d = 0; d < renderedText.count(); ++d ) - delete renderedText[d]; - renderedFont.clear(); - renderedGraphic.clear(); - renderedText.clear(); -// theScene.removeItem ( theScene.createItemGroup ( theScene.items() ) ); + xPos += colunit + 20 ; + yPos = printerRect.height() * 0.20; + } + } - thePrinter.newPage(); - pageNumStr.setNum ( ++pageNumber ); + nameFont.setPointSizeF(4.0); + QGraphicsSimpleTextItem * varText( pScene.addSimpleText(familyFonts[fidx]->variant() , nameFont) ); + varText->setBrush(Qt::gray); + varText->setPos(xPos, yPos); + yPos += varText->boundingRect().height() * 2.2; + QPointF origine(xPos, yPos ); + + bool rasterState(familyFonts[fidx]->rasterFreetype()); + familyFonts[fidx]->setFTRaster(false); + familyFonts[fidx]->renderLine(&pScene, QString("foxy brown fox trot"), origine, printerRect.width() * 0.35 , 12.0); + familyFonts[fidx]->setFTRaster(rasterState); - // - for ( int pIndex = 0; pIndex < conPage.count(); ++pIndex ) - { - QStringList pagelines ; - QStringList tmplines = conPage[pIndex].textElement.e.split ( "\n" ); - pageReplace["##PAGENUMBER##"] = pageNumStr; - pageReplace["##FAMILY##"] = currentFamily; - pageReplace["##SUBFAMILY##"] = currentSubfamily; - for ( int t = 0; t < tmplines.count(); ++t ) - { - - QString pageplace = tmplines[t]; - for ( QMap::const_iterator repIt = pageReplace.begin(); repIt != pageReplace.end(); ++repIt ) - pageplace.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); - pagelines << pageplace; - } -// QFont pFont ( conPage[pIndex].textStyle.font, conPage[pIndex].textStyle.fontsize ); - for ( int pl = 0; pl < pagelines.count(); ++pl ) - { - QGraphicsTextItem * ti = theScene.addText ( pagelines[pl], qfontCache[conPage[pIndex].textStyle.name] ); - renderedText << ti; - ti->setPos ( conPage[pIndex].textStyle.margin_left + prectx, conPage[pIndex].textStyle.margin_top + ( pl * conPage[pIndex].textStyle.lineheight ) ); - ti->setZValue ( 10 ); - ti->setDefaultTextColor ( conPage[pIndex].textStyle.color ); - } - if ( conPage[pIndex].graphic.valid ) - { - QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); - svgIt->setSharedRenderer ( svgRendered[conPage[pIndex].graphic.name] ); - theScene.addItem ( svgIt ); - svgIt->setPos ( conPage[pIndex].graphic.x + prectx, conPage[pIndex].graphic.y ); - renderedGraphic << svgIt; - svgIt->setZValue ( 1 ); - } - } - } + yPos += 12.0 ; + } + pScene.render(painter, printer->paperRect(), printerRect); + return (!more); + } - - if ( conSubfamily[elemIndex].graphic.valid ) - { - QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); - renderedGraphic << svgIt; - svgIt->setSharedRenderer ( svgRendered[conSubfamily[elemIndex].graphic.name] ); - theScene.addItem ( svgIt ); - svgIt->setPos ( conSubfamily[elemIndex].graphic.x + prectx, conSubfamily[elemIndex].graphic.y + thePos.y() ); - svgIt->setZValue ( 100000 ); - thePos.ry() += svgRendered[conSubfamily[elemIndex].graphic.name]->defaultSize().height(); - } - else - { - if ( conSubfamily[elemIndex].textStyle.font == "_FONTMATRIX_" ) // We’ll use the current font - { - if(renderedFont.count() > 0) - { - FMLayout::getLayout()->setPersistentScene(true); -// FMLayout::getLayout()->resetScene(); - } - else - FMLayout::getLayout()->setPersistentScene(false); +} + + +void FontBook::doOneLinerBook() +{ + +} + + +// OBSOLETE +void FontBook::doBookFromTemplate ( const QDomDocument &aTemplate ) +{ +// /** +// We build lists of contexts +// */ +// QList conPage; +// QList conFamily; +// QList conSubfamily; + +// QDomNodeList conList = aTemplate.elementsByTagName ( "context" ); +// if ( conList.length() == 0 ) +// { +// qDebug ( ) << "ERROR: "<< conList.length() <<" context in template, see yourself :" ; +// qDebug() << aTemplate.toString ( 1 ); +// return; +// } + +// QMap svgRendered; +// QMap qfontCache; // abit of optim. +// for ( uint i = 0; i < conList.length(); ++i ) +// { +// FontBookContext fbc; +// QDomNode context = conList.item ( i ); +// QString levelString = context.toElement().attributeNode ( "level" ).value(); + +// fbc.textElement.e = context.namedItem ( "text" ).toElement().text(); +// if ( !fbc.textElement.e.isEmpty() ) +// { +// // QString textInternalString = context.namedItem ( "text" ).toElement().attributeNode ( "internal" ).value(); +// // fbc.textElement.internal = ( textInternalString == "true" ) ? true : false; +// fbc.textElement.valid = true; + +// QDomNode tStyle = context.namedItem ( "textstyle" ); +// fbc.textStyle.name = tStyle.toElement().attributeNode ( "name" ).value(); +// fbc.textStyle.font = tStyle.namedItem ( "font" ).toElement().text(); +// fbc.textStyle.fontsize = QString ( tStyle.namedItem ( "fontsize" ).toElement().text() ).toDouble() ; +// fbc.textStyle.color = QColor ( tStyle.namedItem ( "color" ).toElement().text() ); + +// bool ital = false; +// QFont::Weight bold = QFont::Normal; +// if ( fbc.textStyle.font.contains ( "italic", Qt::CaseInsensitive ) ) +// ital = true; +// if ( fbc.textStyle.font.contains ( "bold", Qt::CaseInsensitive ) ) +// bold = QFont::Bold; +// qfontCache[fbc.textStyle.name] = QFont ( fbc.textStyle.font,10, bold, ital ); +// qfontCache[fbc.textStyle.name].setPointSizeF(fbc.textStyle.fontsize ); + +// fbc.textStyle.lineheight = QString ( tStyle.namedItem ( "lineheight" ).toElement().text() ).toDouble() ; +// fbc.textStyle.margin_top = QString ( tStyle.namedItem ( "margintop" ).toElement().text() ).toDouble() ; +// fbc.textStyle.margin_left = QString ( tStyle.namedItem ( "marginleft" ).toElement().text() ).toDouble() ; +// fbc.textStyle.margin_bottom = QString ( tStyle.namedItem ( "marginbottom" ).toElement().text() ).toDouble() ; +// fbc.textStyle.margin_right = QString ( tStyle.namedItem ( "marginright" ).toElement().text() ).toDouble() ; +// } + +// QDomNode graphicNode = context.namedItem ( "graphic" ); +// if ( graphicNode.isElement() ) +// { +// // QDomDocumentFragment svgFrag = aTemplate.createDocumentFragment(); +// QDomNode svgNode = graphicNode.toElement().namedItem ( "svg" ).cloneNode ( true ); +// // svgFrag.appendChild(svgNode); +// // if(svgNode.isElement()) +// { +// fbc.graphic.name = graphicNode.toElement().attributeNode ( "name" ).value(); +// fbc.graphic.x = QString ( graphicNode.toElement().attributeNode ( "xpos" ).value() ).toDouble(); +// fbc.graphic.y = QString ( graphicNode.toElement().attributeNode ( "ypos" ).value() ).toDouble(); + +// QDomDocument svgDoc; +// QDomNode svg = svgDoc.importNode ( svgNode,true ); +// svgDoc.appendChild ( svg ); +// QString svgString ( "\n" + svgDoc.toString ( 0 ) ); +// QSvgRenderer *doc = new QSvgRenderer ( svgString.toUtf8() ); +// svgRendered[fbc.graphic.name] = doc; +// fbc.graphic.valid = true; +// // qDebug() << fbc.graphic.svg; +// } + +// } + + +// if ( levelString == "page" ) +// conPage << fbc; +// else if ( levelString == "family" ) +// conFamily << fbc; +// else if ( levelString == "subfamily" ) +// conSubfamily << fbc; +// } + + +// QString paperSize = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().text() ).toUpper(); +// double prectx = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().attributeNode ( "bboxx" ).value() ).toDouble(); +// double precty = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().attributeNode ( "bboxy" ).value() ).toDouble(); +// double prectw = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().attributeNode ( "bboxw" ).value() ).toDouble(); +// double precth = QString ( aTemplate.documentElement().namedItem ( "papersize" ).toElement().attributeNode ( "bboxh" ).value() ).toDouble(); + +// QPrinter thePrinter ( QPrinter::HighResolution ); +// thePrinter.setOutputFormat ( QPrinter::PdfFormat ); +// thePrinter.setCreator ( "Fontmatrix " + QString::number ( FONTMATRIX_VERSION_MAJOR ) + "." + QString::number ( FONTMATRIX_VERSION_MINOR ) ); +// thePrinter.setDocName ( "A font book" ); +// thePrinter.setOutputFileName ( outputFilePath ); +// thePrinter.setPageSize ( mapPSize[paperSize] ); +// thePrinter.setFullPage ( true ); +// // qDebug() << thePrinter.pageSize() << thePrinter.pageRect() << thePrinter.paperRect() << thePrinter.resolution() ; +// double paperWidth = thePrinter.pageRect().width() / thePrinter.resolution() * 72.0; +// double paperHeight = thePrinter.pageRect().height() / thePrinter.resolution() * 72.0; +// // qDebug()<< paperSize << paperWidth << paperHeight; +// QGraphicsScene theScene; +// QGraphicsScene measurementScene; +// measurementScene.setSceneRect( 0,0,paperWidth,paperHeight ); +// theScene.setSceneRect ( 0,0,paperWidth,paperHeight ); +// QPainter thePainter ( &thePrinter ); +// QPointF thePos ( prectx,precty ); +// QList renderedFont; +// QList renderedGraphic; +// QList renderedText; + + + +// QList localFontMap = FMFontDb::DB()->getFilteredFonts(); +// QMap > keyList; +// for ( int i=0; i < localFontMap.count();++i ) +// { +// keyList[localFontMap[i]->family() ].append ( localFontMap[i] ); +// } + +// QMap >::const_iterator kit; +// QProgressDialog progress ( QObject::tr ( "Creating font book... " ), QObject::tr ( "cancel" ), 0, keyList.count(), typotek::getInstance() ); +// progress.setWindowModality ( Qt::WindowModal ); +// int progressindex=0; + + +// QString pageNumStr; +// int pageNumber = 0; +// ///We begin in a PAGE context +// // qDebug() << "PAGE"; +// pageNumStr.setNum ( ++pageNumber ); +// QMap pageReplace; +// QMap familyReplace; +// QMap subfamilyReplace; + +// QString currentFamily; +// QString currentSubfamily; + +// /** Z policy is +// PAGE_SVG 1 +// PAGE_TEXT 10 +// FAMILY_SVG 100 +// FAMILY_TEXT 1000 +// SUBFAMILY_SVG 10000 +// SUBFAMILY_TEXT 100000 +// */ + +// for ( int pIndex = 0; pIndex < conPage.count(); ++pIndex ) +// { +// // qDebug()<<"PI"<::const_iterator repIt = pageReplace.begin(); repIt != pageReplace.end(); ++repIt ) +// place.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); +// pagelines << place; +// } +// // QFont pFont ( conPage[pIndex].textStyle.font, conPage[pIndex].textStyle.fontsize ); +// for ( int pl = 0; pl < pagelines.count(); ++pl ) +// { +// QGraphicsTextItem * ti = theScene.addText ( pagelines[pl], qfontCache[conPage[pIndex].textStyle.name] ); +// renderedText << ti; +// ti->setPos ( conPage[pIndex].textStyle.margin_left , conPage[pIndex].textStyle.margin_top + ( pl * conPage[pIndex].textStyle.lineheight ) ); +// ti->setZValue ( 10 ); +// ti->setDefaultTextColor ( conPage[pIndex].textStyle.color ); +// } +// } +// if ( conPage[pIndex].graphic.valid ) +// { +// QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); +// svgIt->setSharedRenderer ( svgRendered[conPage[pIndex].graphic.name] ); +// theScene.addItem ( svgIt ); +// svgIt->setPos ( conPage[pIndex].graphic.x, conPage[pIndex].graphic.y ); +// renderedGraphic << svgIt; +// svgIt->setZValue ( 1 ); +// } +// } + +// /// Beginning of the big loop +// for ( kit = keyList.begin(); kit != keyList.end(); ++kit ) +// { +// /// We are in a FAMILY context +// // qDebug() << "FAMILY"; +// { +// if ( progress.wasCanceled() ) +// break; +// progress.setLabelText ( kit.key() ); +// progress.setValue ( ++progressindex ); +// } +// currentFamily = kit.key(); +// for ( int elemIndex = 0; elemIndex < conFamily.count() ; ++elemIndex ) +// { +// QStringList familylines; +// QStringList tmplines = conFamily[elemIndex].textElement.e.split ( "\n" ); +// familyReplace["##FAMILY##"] = kit.key(); +// for ( int t = 0; t < tmplines.count(); ++t ) +// { + +// QString place = tmplines[t]; +// for ( QMap::const_iterator repIt = familyReplace.begin(); repIt != familyReplace.end(); ++repIt ) +// place.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); +// if ( !place.isEmpty() ) +// familylines << place; +// } + +// double available = ( precty + precth ) - thePos.y(); +// double needed = ( familylines.count() * conFamily[elemIndex].textStyle.lineheight ) +// + conFamily[elemIndex].textStyle.margin_top +// + conFamily[elemIndex].textStyle.margin_bottom; + +// if ( needed > available ) +// { +// /// We are in a PAGE context +// // qDebug() << "NFPAGE"; +// // close, clean and create +// theScene.render ( &thePainter ); + +// thePos.ry() = precty; +// // for ( int d = 0; d < renderedFont.count() ; ++d ) +// // renderedFont[d]->deRenderAll(); +// for ( int d = 0; d < renderedGraphic.count(); ++d ) +// delete renderedGraphic[d]; +// for ( int d = 0; d < renderedText.count(); ++d ) +// delete renderedText[d]; +// renderedFont.clear(); +// renderedGraphic.clear(); +// renderedText.clear(); +// // theScene.removeItem ( theScene.createItemGroup ( theScene.items() ) ); + +// thePrinter.newPage(); +// pageNumStr.setNum ( ++pageNumber ); + +// // +// for ( int pIndex = 0; pIndex < conPage.count(); ++pIndex ) +// { +// QStringList pagelines ; +// QStringList tmplines = conPage[pIndex].textElement.e.split ( "\n" ); +// pageReplace["##PAGENUMBER##"] = pageNumStr; +// pageReplace["##FAMILY##"] = currentFamily; +// pageReplace["##SUBFAMILY##"] = currentSubfamily; +// for ( int t = 0; t < tmplines.count(); ++t ) +// { + +// QString pageplace = tmplines[t]; +// for ( QMap::const_iterator repIt = pageReplace.begin(); repIt != pageReplace.end(); ++repIt ) +// pageplace.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); +// pagelines << pageplace; +// } +// // QFont pFont ( conPage[pIndex].textStyle.font, conPage[pIndex].textStyle.fontsize ); +// for ( int pl = 0; pl < pagelines.count(); ++pl ) +// { +// QGraphicsTextItem * ti = theScene.addText ( pagelines[pl], qfontCache[conPage[pIndex].textStyle.name] ); +// renderedText << ti; +// ti->setPos ( conPage[pIndex].textStyle.margin_left + prectx, conPage[pIndex].textStyle.margin_top + ( pl * conPage[pIndex].textStyle.lineheight ) ); +// ti->setZValue ( 10 ); +// ti->setDefaultTextColor ( conPage[pIndex].textStyle.color ); +// } +// if ( conPage[pIndex].graphic.valid ) +// { +// QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); +// svgIt->setSharedRenderer ( svgRendered[conPage[pIndex].graphic.name] ); +// theScene.addItem ( svgIt ); +// svgIt->setPos ( conPage[pIndex].graphic.x + prectx, conPage[pIndex].graphic.y ); +// renderedGraphic << svgIt; +// svgIt->setZValue ( 1 ); +// } +// } +// } + + +// for ( int fl = 0; fl < familylines.count(); ++fl ) +// { +// QGraphicsTextItem * ti = theScene.addText ( familylines[fl], qfontCache[conFamily[elemIndex].textStyle.name] ); +// renderedText << ti; +// ti->setPos ( conFamily[elemIndex].textStyle.margin_left + prectx, thePos.y() + ( conFamily[elemIndex].textStyle.margin_top + ( fl * conFamily[elemIndex].textStyle.lineheight ) ) ); +// ti->setZValue ( 1000 ); +// ti->setDefaultTextColor ( conFamily[elemIndex].textStyle.color ); +// } +// if ( conFamily[elemIndex].graphic.valid ) +// { +// QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); +// svgIt->setSharedRenderer ( svgRendered[conFamily[elemIndex].graphic.name] ); +// theScene.addItem ( svgIt ); +// svgIt->setPos ( conFamily[elemIndex].graphic.x + prectx, conFamily[elemIndex].graphic.y + thePos.y() ); +// renderedGraphic << svgIt; +// svgIt->setZValue ( 100 ); +// } + +// thePos.ry() += needed; +// } // end of FAMILY level elements + +// /// Looping through all faces for the current family +// for ( int fontIndex = 0;fontIndex < kit.value().count(); ++fontIndex ) +// { +// FontItem * theFont = kit.value() [fontIndex]; +// FMLayout *alay = new FMLayout(&theScene , theFont); +// /// We are in a SUBFAMILY context +// currentSubfamily = theFont->variant(); +// for ( int elemIndex = 0; elemIndex < conSubfamily.count() ; ++elemIndex ) +// { +// // First, is there enough room for this element +// QStringList sublines; +// QStringList tmplines = conSubfamily[elemIndex].textElement.e.split ( "\n" ); + +// subfamilyReplace["##FAMILY##"] = theFont->family(); +// subfamilyReplace["##SUBFAMILY##"] = theFont->variant(); +// subfamilyReplace["##FILE##"]= theFont->path(); +// subfamilyReplace["##TAGS##"]= theFont->tags().join ( ";" ) ; +// subfamilyReplace["##COUNT##"]= QString::number ( theFont->glyphsCount() ); +// subfamilyReplace["##TYPE##"]= theFont->type(); +// subfamilyReplace["##CHARSETS##"]=theFont->charmaps().join ( ";" ); + +// for ( int t = 0; t < tmplines.count(); ++t ) +// { + +// QString subplace = tmplines[t]; +// for ( QMap::const_iterator repIt = subfamilyReplace.begin(); repIt != subfamilyReplace.end(); ++repIt ) +// subplace.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); +// if ( !subplace.isEmpty() ) +// sublines << subplace; +// } + +// double available = ( precty + precth ) - thePos.y(); +// double needed (0);/*= ( sublines.count() * conSubfamily[elemIndex].textStyle.lineheight ) +// + conSubfamily[elemIndex].textStyle.margin_top +// + conSubfamily[elemIndex].textStyle.margin_bottom;*/ +// double mwidth( conSubfamily[elemIndex].textStyle.margin_right - (conSubfamily[elemIndex].textStyle.margin_left + prectx) ); + +// /// Let’s see how much room we need +// // For that we’ll render all elements on a dedicated scene if needed. +// if(conSubfamily[elemIndex].graphic.valid) +// { +// needed = svgRendered[conSubfamily[elemIndex].graphic.name]->defaultSize().height(); +// } +// else +// { +// if ( conSubfamily[elemIndex].textStyle.font == "_FONTMATRIX_" ) // We’ll use the current font +// { +// QList gl; +// for ( int sl = 0; sl < sublines.count(); ++sl ) +// { +// gl << theFont->glyphs ( sublines[sl].trimmed(), conSubfamily[elemIndex].textStyle.fontsize ); +// } +// QRectF rf( measurementScene.sceneRect() ); +// rf.setWidth(mwidth); +// FMLayout *tlay = new FMLayout( &measurementScene ,theFont, rf ); +// tlay->setPersistentScene(false); +// tlay->setAdjustedSampleInter ( conSubfamily[elemIndex].textStyle.lineheight ); +// tlay->setDeviceIndy ( true ); - QList gl; - for ( int sl = 0; sl < sublines.count(); ++sl ) - { - gl << theFont->glyphs ( sublines[sl].trimmed(), conSubfamily[elemIndex].textStyle.fontsize ); - } +// tlay->doLayout ( gl , conSubfamily[elemIndex].textStyle.fontsize ); +// // tlay->run(); - QRectF parRect ( conSubfamily[elemIndex].textStyle.margin_left + prectx, - thePos.y() + conSubfamily[elemIndex].textStyle.margin_top, - conSubfamily[elemIndex].textStyle.margin_right, - precth - thePos.y() ); +// needed = tlay->drawnLines * conSubfamily[elemIndex].textStyle.lineheight; - qDebug()<<"PAR("+theFont->fancyName()+")("<< gl.count() <<")"<setTheScene ( &theScene , parRect ); - FMLayout::getLayout()->setTheFont ( theFont ); - FMLayout::getLayout()->setAdjustedSampleInter ( conSubfamily[elemIndex].textStyle.lineheight ); - FMLayout::getLayout()->setDeviceIndy ( true ); +// delete tlay; + +// } +// else +// { +// for ( int sl = 0; sl < sublines.count(); ++sl ) +// { + +// QGraphicsTextItem gti( sublines[sl]); +// gti.setFont( qfontCache[ conSubfamily[elemIndex].textStyle.name] ); +// gti.setTextWidth( mwidth ); +// needed = gti.document()->size().height(); +// } +// } +// } +// if ( needed > available ) +// { +// /// We are in a PAGE context +// // qDebug() << "NSPAGE"; +// // close, clean and create +// theScene.render ( &thePainter ); + +// thePos.ry() = precty; +// // for ( int d = 0; d < renderedFont.count() ; ++d ) +// // renderedFont[d]->deRenderAll(); +// for ( int d = 0; d < renderedGraphic.count(); ++d ) +// delete renderedGraphic[d]; +// for ( int d = 0; d < renderedText.count(); ++d ) +// delete renderedText[d]; +// renderedFont.clear(); +// renderedGraphic.clear(); +// renderedText.clear(); +// // theScene.removeItem ( theScene.createItemGroup ( theScene.items() ) ); + +// thePrinter.newPage(); +// pageNumStr.setNum ( ++pageNumber ); + +// // +// for ( int pIndex = 0; pIndex < conPage.count(); ++pIndex ) +// { +// QStringList pagelines ; +// QStringList tmplines = conPage[pIndex].textElement.e.split ( "\n" ); +// pageReplace["##PAGENUMBER##"] = pageNumStr; +// pageReplace["##FAMILY##"] = currentFamily; +// pageReplace["##SUBFAMILY##"] = currentSubfamily; +// for ( int t = 0; t < tmplines.count(); ++t ) +// { + +// QString pageplace = tmplines[t]; +// for ( QMap::const_iterator repIt = pageReplace.begin(); repIt != pageReplace.end(); ++repIt ) +// pageplace.replace ( repIt.key(),repIt.value(),Qt::CaseSensitive ); +// pagelines << pageplace; +// } +// // QFont pFont ( conPage[pIndex].textStyle.font, conPage[pIndex].textStyle.fontsize ); +// for ( int pl = 0; pl < pagelines.count(); ++pl ) +// { +// QGraphicsTextItem * ti = theScene.addText ( pagelines[pl], qfontCache[conPage[pIndex].textStyle.name] ); +// renderedText << ti; +// ti->setPos ( conPage[pIndex].textStyle.margin_left + prectx, conPage[pIndex].textStyle.margin_top + ( pl * conPage[pIndex].textStyle.lineheight ) ); +// ti->setZValue ( 10 ); +// ti->setDefaultTextColor ( conPage[pIndex].textStyle.color ); +// } +// if ( conPage[pIndex].graphic.valid ) +// { +// QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); +// svgIt->setSharedRenderer ( svgRendered[conPage[pIndex].graphic.name] ); +// theScene.addItem ( svgIt ); +// svgIt->setPos ( conPage[pIndex].graphic.x + prectx, conPage[pIndex].graphic.y ); +// renderedGraphic << svgIt; +// svgIt->setZValue ( 1 ); +// } +// } +// } + + +// if ( conSubfamily[elemIndex].graphic.valid ) +// { +// QGraphicsSvgItem *svgIt = new QGraphicsSvgItem(); +// renderedGraphic << svgIt; +// svgIt->setSharedRenderer ( svgRendered[conSubfamily[elemIndex].graphic.name] ); +// theScene.addItem ( svgIt ); +// svgIt->setPos ( conSubfamily[elemIndex].graphic.x + prectx, conSubfamily[elemIndex].graphic.y + thePos.y() ); +// svgIt->setZValue ( 100000 ); +// thePos.ry() += svgRendered[conSubfamily[elemIndex].graphic.name]->defaultSize().height(); +// } +// else +// { +// if ( conSubfamily[elemIndex].textStyle.font == "_FONTMATRIX_" ) // We’ll use the current font +// { + +// QList gl; +// for ( int sl = 0; sl < sublines.count(); ++sl ) +// { +// gl << theFont->glyphs ( sublines[sl].trimmed(), conSubfamily[elemIndex].textStyle.fontsize ); +// } - FMLayout::getLayout()->doLayout ( gl , conSubfamily[elemIndex].textStyle.fontsize ); - FMLayout::getLayout()->run(); +// QRectF parRect ( conSubfamily[elemIndex].textStyle.margin_left + prectx, +// thePos.y() + conSubfamily[elemIndex].textStyle.margin_top, +// conSubfamily[elemIndex].textStyle.margin_right, +// precth - thePos.y() ); +// alay->setRect(parRect); +// if(renderedFont.count() > 0) +// { +// alay->setPersistentScene(true); +// // FMLayout::getLayout()->resetScene(); +// } +// else +// alay->setPersistentScene(false); + +// // qDebug()<<"PAR("+theFont->fancyName()+")("<< gl.count() <<")"<setTheScene ( ); +// // FMLayout::getLayout()->setTheFont ( theFont ); +// alay->setAdjustedSampleInter ( conSubfamily[elemIndex].textStyle.lineheight ); +// alay->setDeviceIndy ( true ); - thePos.ry() += FMLayout::getLayout()->drawnLines * conSubfamily[elemIndex].textStyle.lineheight; - renderedFont.append ( theFont ); - } - else - { - // QFont aFont ( conSubfamily[elemIndex].textStyle.font,conSubfamily[elemIndex].textStyle.fontsize ); - for ( int sl = 0; sl < sublines.count(); ++sl ) - { - QGraphicsTextItem * ti = theScene.addText ( sublines[sl], qfontCache[ conSubfamily[elemIndex].textStyle.name] ); - renderedText << ti; - ti->setTextWidth( mwidth ); - ti->setPos ( conSubfamily[elemIndex].textStyle.margin_left + prectx, thePos.y() + ( conSubfamily[elemIndex].textStyle.margin_top + ( sl * conSubfamily[elemIndex].textStyle.lineheight ) ) ); - ti->setZValue ( 10000 ); - ti->setDefaultTextColor ( conSubfamily[elemIndex].textStyle.color ); +// alay->doLayout ( gl , conSubfamily[elemIndex].textStyle.fontsize ); +// // alay->run(); + +// thePos.ry() += alay->drawnLines * conSubfamily[elemIndex].textStyle.lineheight; +// renderedFont.append ( theFont ); +// } +// else +// { +// // QFont aFont ( conSubfamily[elemIndex].textStyle.font,conSubfamily[elemIndex].textStyle.fontsize ); +// for ( int sl = 0; sl < sublines.count(); ++sl ) +// { +// QGraphicsTextItem * ti = theScene.addText ( sublines[sl], qfontCache[ conSubfamily[elemIndex].textStyle.name] ); +// renderedText << ti; +// ti->setTextWidth( mwidth ); +// ti->setPos ( conSubfamily[elemIndex].textStyle.margin_left + prectx, thePos.y() + ( conSubfamily[elemIndex].textStyle.margin_top + ( sl * conSubfamily[elemIndex].textStyle.lineheight ) ) ); +// ti->setZValue ( 10000 ); +// ti->setDefaultTextColor ( conSubfamily[elemIndex].textStyle.color ); - thePos.ry() += ti->document()->size().height(); - } - } - } - } // end of SUBFAMILY level elements -// qDebug() << "ENDOF_SUBFAMILY"; - } - } - if ( renderedFont.count() ) - { - theScene.render ( &thePainter ); - for ( int d = 0; d < renderedFont.count() ; ++d ) - { - renderedFont[d]->deRenderAll(); +// thePos.ry() += ti->document()->size().height(); +// } +// } +// } +// } // end of SUBFAMILY level elements +// // qDebug() << "ENDOF_SUBFAMILY"; +// delete alay; +// } +// } +// if ( renderedFont.count() ) +// { +// theScene.render ( &thePainter ); +// for ( int d = 0; d < renderedFont.count() ; ++d ) +// { +// renderedFont[d]->deRenderAll(); + +// } +// for ( int d = 0; d < renderedGraphic.count(); ++d ) +// delete renderedGraphic[d]; +// for ( int d = 0; d < renderedText.count(); ++d ) +// delete renderedText[d]; +// renderedFont.clear(); +// renderedGraphic.clear(); +// renderedText.clear(); + +// } +// for ( QMap::iterator sit ( svgRendered.begin() ); sit != svgRendered.end(); ++sit ) +// delete sit.value(); - } - for ( int d = 0; d < renderedGraphic.count(); ++d ) - delete renderedGraphic[d]; - for ( int d = 0; d < renderedText.count(); ++d ) - delete renderedText[d]; - renderedFont.clear(); - renderedGraphic.clear(); - renderedText.clear(); - - } - for ( QMap::iterator sit ( svgRendered.begin() ); sit != svgRendered.end(); ++sit ) - delete sit.value(); - - FMLayout::getLayout()->setPersistentScene(false); - FMLayout::getLayout()->setTheScene(&theScene); - FMLayout::getLayout()->resetScene(); - FMLayout::getLayout()->setTheScene(&measurementScene); - FMLayout::getLayout()->resetScene(); } diff -Nru fontmatrix-0.6.0+svn20100107/src/fontbookdialog.cpp fontmatrix-0.6.0+svn20110930/src/fontbookdialog.cpp --- fontmatrix-0.6.0+svn20100107/src/fontbookdialog.cpp 2008-10-23 16:15:42.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fontbookdialog.cpp 2010-06-18 10:28:36.000000000 +0000 @@ -21,6 +21,7 @@ #include "fontitem.h" #include "typotek.h" #include "fmpaths.h" +#include "fmfontdb.h" #include #include @@ -113,7 +114,7 @@ void FontBookDialog::fillFontsList() { - QListlocalFontMap = typotek::getInstance()->getCurrentFonts(); + QList localFontMap = FMFontDb::DB()->getFilteredFonts(); foreach(FontItem* fit, localFontMap) { selectedFontsList->addItem(fit->fancyName()); diff -Nru fontmatrix-0.6.0+svn20100107/src/fontbook.h fontmatrix-0.6.0+svn20110930/src/fontbook.h --- fontmatrix-0.6.0+svn20100107/src/fontbook.h 2008-01-25 18:48:34.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fontbook.h 2010-09-22 16:17:59.000000000 +0000 @@ -16,7 +16,13 @@ #include #include #include +#include +#include +#include +#include + +class ProgressBarDuo; /** @author Pierre Marchand @@ -58,7 +64,7 @@ - ... At some point, I’ll provide a reference. */ -// bool internal; OBSOLETE - substitution will be regexpizated ##KEYWORD## + // bool internal; OBSOLETE - substitution will be regexpizated ##KEYWORD## TextElement():valid(false){} TextElement ( QString elem) :e ( elem ), valid(true){} }; @@ -83,25 +89,43 @@ TextElement textElement; TextElementStyle textStyle; GraphicElement graphic; -/* + /* enum FBCLevel{PAGE, FAMILY, SUBFAMILY}; FBCLevel level;*/ }; -class FontBook +class FontBook : public QObject { - public: - FontBook(); - - ~FontBook(); - void doBook(); - private: - - QString outputFilePath; - QMap mapPSize; - void doBookFromTemplate ( const QDomDocument &aTemplate ); +public: + enum Style + { + Full, + OneLiner + }; + FontBook(); + + ~FontBook(); + void doBook(Style s); +private: + + void doFullBook(); + void doFullBookCover(); + // return true if uses only its page, false if it spreads over the 2 pages + bool doFullBookPageLeft(const QString& family); + void doFullBookPageRight(const QString& family); + void doOneLinerBook(); + + QPrinter * printer; + QPainter * painter; + QRectF printerRect; + QStringList stringList; + ProgressBarDuo * progress; + + QString outputFilePath; + QMap mapPSize; + void doBookFromTemplate ( const QDomDocument &aTemplate ); }; #endif diff -Nru fontmatrix-0.6.0+svn20100107/src/fontcomparewidget.cpp fontmatrix-0.6.0+svn20110930/src/fontcomparewidget.cpp --- fontmatrix-0.6.0+svn20100107/src/fontcomparewidget.cpp 2009-03-02 10:02:18.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fontcomparewidget.cpp 2010-09-13 08:24:09.000000000 +0000 @@ -24,6 +24,8 @@ #include #include +FontCompareWidget* FontCompareWidget::instance = 0; + FontCompareWidget::FontCompareWidget(QWidget * parent) :QWidget(parent),neverUsed(true) { @@ -41,6 +43,16 @@ } +FontCompareWidget* FontCompareWidget::getInstance() +{ + if(instance == 0) + { + instance = new FontCompareWidget(0); + Q_ASSERT(instance); + } + return instance; +} + void FontCompareWidget::initColors() { QSettings settings; diff -Nru fontmatrix-0.6.0+svn20100107/src/fontcomparewidget.h fontmatrix-0.6.0+svn20110930/src/fontcomparewidget.h --- fontmatrix-0.6.0+svn20100107/src/fontcomparewidget.h 2009-02-24 11:50:43.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fontcomparewidget.h 2010-09-13 08:24:09.000000000 +0000 @@ -19,8 +19,12 @@ class FontCompareWidget : public QWidget, private Ui::CompareWidget { Q_OBJECT + + static FontCompareWidget* instance; + FontCompareWidget(QWidget * parent); + public: - FontCompareWidget(QWidget * parent); + static FontCompareWidget* getInstance(); ~FontCompareWidget(); private: diff -Nru fontmatrix-0.6.0+svn20100107/src/fontitem.cpp fontmatrix-0.6.0+svn20110930/src/fontitem.cpp --- fontmatrix-0.6.0+svn20100107/src/fontitem.cpp 2009-10-13 11:26:08.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fontitem.cpp 2011-01-11 17:50:04.000000000 +0000 @@ -23,6 +23,7 @@ #include "fmencdata.h" #include "fmfontdb.h" #include "fmfontstrings.h" +#include "fmfreetypelib.h" #include "fmglyphsview.h" #include "glyphtosvghelper.h" #include "typotek.h" @@ -36,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +65,6 @@ int fm_num_face_opened = 0; -FT_Library FontItem::theLibrary = 0; QGraphicsScene *FontItem::theOneLineScene = 0; @@ -217,7 +218,7 @@ remoteCached = false; stopperDownload = false; m_face = 0; - facesRef = 0; + lastFace = 0; m_glyphsPerRow = 5; m_isEncoded = false; currentChar = -1; @@ -326,7 +327,6 @@ // m_lock = false; pixList.clear(); - sceneList.clear(); if ( m_family.isEmpty() ) return; @@ -344,7 +344,7 @@ remoteCached = false; stopperDownload = false; m_face = 0; - facesRef = 0; + lastFace = 0; m_glyphsPerRow = 5; m_isEncoded = false; currentChar = -1; @@ -379,6 +379,12 @@ m_type = type; } +FontItem * FontItem::Clone() +{ + FontItem *fitem = new FontItem ( m_path, m_family, m_variant, m_type, m_active ); + return fitem; +} + void FontItem::updateItem() { if(isUpToDate) @@ -442,18 +448,6 @@ } } -bool FontItem::ensureLibrary() -{ - if ( theLibrary ) - return true; - ft_error = FT_Init_FreeType ( &theLibrary ); - if ( ft_error ) - { - qDebug() << "Error loading ft_library "; - return false; - } - return true; -} void FontItem::encodeFace() { @@ -509,40 +503,39 @@ bool FontItem::ensureFace() { - if ( ensureLibrary() ) + FT_Library ftlib = FMFreetypeLib::lib(thread()); +// qDebug()<<"FontItem::ensureFace"<units_per_EM; - m_glyph = m_face->glyph; - ++facesRef; - ++fm_num_face_opened; - return true; } - return false; + unitPerEm = m_face->units_per_EM; + m_glyph = m_face->glyph; + facesRef = 1; + ++fm_num_face_opened; + return true; } void FontItem::releaseFace() @@ -559,6 +552,18 @@ } } +int FontItem::glyphsCount() const +{ + if(m_numGlyphs > 0) // this is normal case + { + return m_numGlyphs; + } + FontItem * that(const_cast(this)); + that->ensureFace(); + that->m_numGlyphs = m_face->num_glyphs; + that->releaseFace(); + return m_numGlyphs; +} QString FontItem::testFlag ( long flag, long against, QString yes, QString no ) { @@ -631,7 +636,9 @@ glyph->setBrush ( QBrush ( Qt::red ) ); glyph->setPath ( glyphPath ); glyph->setData ( GLYPH_DATA_GLYPH, index); - glyph->setData ( GLYPH_DATA_HADVANCE , ( double ) size ); + glyph->setData ( GLYPH_DATA_HADVANCE , ( double ) size * scalefactor); + glyph->setData ( GLYPH_DATA_HADVANCE_SCALED , ( double ) size ); + glyph->setData ( GLYPH_DATA_ERROR , true ); releaseFace(); return glyph; } @@ -655,8 +662,10 @@ glyph->setBrush ( brush ); glyph->setPen ( pen ); glyph->setPath ( errPath ); - glyph->setData ( GLYPH_DATA_HADVANCE , ( double ) size /scalefactor ); + glyph->setData ( GLYPH_DATA_HADVANCE , ( double ) m_glyph->metrics.horiAdvance ); + glyph->setData ( GLYPH_DATA_HADVANCE_SCALED , ( double ) m_glyph->metrics.horiAdvance *scalefactor); glyph->setData ( GLYPH_DATA_GLYPH, index); + glyph->setData ( GLYPH_DATA_ERROR , true ); } else { @@ -664,7 +673,9 @@ glyph->setPath ( glyphPath ); glyph->setData ( GLYPH_DATA_GLYPH, index); glyph->setData ( GLYPH_DATA_HADVANCE , ( double ) m_glyph->metrics.horiAdvance ); + glyph->setData ( GLYPH_DATA_HADVANCE_SCALED , ( double ) m_glyph->metrics.horiAdvance * scalefactor); glyph->setData ( 5, ( double ) m_glyph->metrics.vertAdvance ); + glyph->setData ( GLYPH_DATA_ERROR , false ); // glyph->scale ( scalefactor,-scalefactor ); } releaseFace(); @@ -718,8 +729,8 @@ } double takeAdvanceBeforeRender = m_glyph->metrics.horiAdvance * ( typotek::getInstance()->getDpiX() / 72.0 ); - double takeVertAdvanceBeforeRender = m_glyph->metrics.vertAdvance * ( typotek::getInstance()->getDpiX() / 72.0 ); - double takeLeftBeforeRender = ( double ) m_glyph->metrics.horiBearingX * ( typotek::getInstance()->getDpiX() / 72.0 ); + double takeVertAdvanceBeforeRender = m_glyph->metrics.vertAdvance * ( typotek::getInstance()->getDpiY() / 72.0 ); + double takeLeftBeforeRender = double(m_glyph->metrics.horiBearingX) * ( typotek::getInstance()->getDpiX() / 72.0 ); // if(m_FTHintMode != FT_LOAD_NO_HINTING) { @@ -768,7 +779,7 @@ // we need to transport more data glyph->setData ( GLYPH_DATA_GLYPH , index ); glyph->setData ( GLYPH_DATA_BITMAPLEFT , takeLeftBeforeRender ); - glyph->setData ( GLYPH_DATA_BITMAPTOP , m_face->glyph->bitmap_top ); + glyph->setData ( GLYPH_DATA_BITMAPTOP , double(m_face->glyph->bitmap_top) ); glyph->setData ( GLYPH_DATA_HADVANCE , takeAdvanceBeforeRender ); glyph->setData ( GLYPH_DATA_VADVANCE , takeVertAdvanceBeforeRender ); } @@ -777,6 +788,78 @@ return glyph; } +MetaGlyphItem * FontItem::itemFromGindexPix_mt(int index, double size) +{ + if ( !ensureFace() ) + return 0; + int charcode = index ; +// qDebug()<<"FontItem::itemFromGindexPix_mt"<< thread(); + MetaGlyphItem * glyph = new MetaGlyphItem; + double scaleFactor = size / m_face->units_per_EM; + + // Set size + FT_Set_Char_Size ( m_face, + qRound( size * 64 ), + 0, + typotek::getInstance()->getDpiX(), + typotek::getInstance()->getDpiY() ); + + // Grab metrics in FONT UNIT + ft_error = FT_Load_Glyph ( m_face, + charcode , + FT_LOAD_NO_SCALE ); + if ( ft_error ) + { + glyph->setMetaData ( GLYPH_DATA_GLYPH ,index ); + glyph->setMetaData ( GLYPH_DATA_BITMAPLEFT , 0 ); + glyph->setMetaData ( GLYPH_DATA_BITMAPTOP,size ); + glyph->setMetaData ( GLYPH_DATA_HADVANCE ,size / scaleFactor ); + releaseFace(); + return glyph; + } + + double takeAdvanceBeforeRender = m_glyph->metrics.horiAdvance * ( typotek::getInstance()->getDpiX() / 72.0 ); + double takeVertAdvanceBeforeRender = m_glyph->metrics.vertAdvance * ( typotek::getInstance()->getDpiX() / 72.0 ); + double takeLeftBeforeRender = ( double ) m_glyph->metrics.horiBearingX * ( typotek::getInstance()->getDpiX() / 72.0 ); + +// if(m_FTHintMode != FT_LOAD_NO_HINTING) + { + ft_error = FT_Load_Glyph ( m_face, charcode , FT_LOAD_DEFAULT | m_FTHintMode ); + } + // Render the glyph into a grayscale bitmap + ft_error = FT_Render_Glyph ( m_face->glyph, FT_RENDER_MODE_NORMAL ); + if ( ft_error ) + { + glyph->setMetaData ( GLYPH_DATA_GLYPH , index ); + glyph->setMetaData ( GLYPH_DATA_BITMAPLEFT , 0 ); + glyph->setMetaData ( GLYPH_DATA_BITMAPTOP,size ); + glyph->setMetaData ( GLYPH_DATA_HADVANCE ,size / scaleFactor ); + releaseFace(); + return glyph; + } + + + QImage img ( glyphImage() ); + + if ( img.isNull() && !spaceIndex.contains ( index ) ) + { + glyph->setMetaData ( GLYPH_DATA_GLYPH , index ); + glyph->setMetaData ( GLYPH_DATA_BITMAPLEFT , 0 ); + glyph->setMetaData ( GLYPH_DATA_BITMAPTOP,size ); + glyph->setMetaData ( GLYPH_DATA_HADVANCE ,size /scaleFactor ); + } + else + { + glyph->setMetaData ( GLYPH_DATA_GLYPH , index ); + glyph->setMetaData ( GLYPH_DATA_BITMAPLEFT , takeLeftBeforeRender ); + glyph->setMetaData ( GLYPH_DATA_BITMAPTOP , double(m_face->glyph->bitmap_top) ); + glyph->setMetaData ( GLYPH_DATA_HADVANCE , takeAdvanceBeforeRender ); + glyph->setMetaData ( GLYPH_DATA_VADVANCE , takeVertAdvanceBeforeRender ); + } + + releaseFace(); + return glyph; +} QImage FontItem::charImage(int charcode, double size) { @@ -831,8 +914,7 @@ QPointF origine, double lineWidth, double fsize , - double zindex , - bool record ) + double zindex ) { // qDebug() <units_per_EM; double pWidth = lineWidth ; @@ -874,8 +954,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -894,8 +972,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -913,8 +989,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -932,8 +1006,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -944,8 +1016,6 @@ retValue += glyph->data ( GLYPH_DATA_HADVANCE ).toDouble() * scalefactor; /************************************/ - if ( record ) - pixList.append ( glyph ); mayBeRemoved.append(glyph); @@ -975,8 +1045,8 @@ QList mayBeRemoved; for ( int i=0; i < spec.length(); ++i ) { - if ( !scene->sceneRect().contains ( pen ) && record ) - break; +// if ( !scene->sceneRect().contains ( pen ) && record ) +// break; QGraphicsPathItem *glyph = itemFromChar ( spec.at ( i ).unicode(), sizz ); if ( !glyph ) continue; @@ -997,8 +1067,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1017,8 +1085,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1036,8 +1102,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1055,8 +1119,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1065,8 +1127,6 @@ } /*********************************/ - if ( record ) - glyphList.append ( glyph ); scene->addItem ( glyph ); glyph->setPen(Qt::NoPen); @@ -1099,7 +1159,7 @@ } /// Featured line -double FontItem::renderLine ( OTFSet set, QGraphicsScene * scene, QString spec, QPointF origine,double lineWidth, double fsize, bool record ) +double FontItem::renderLine ( OTFSet set, QGraphicsScene * scene, QString spec, QPointF origine,double lineWidth, double fsize) { // qDebug()<<"Featured("<< spec <<")"; double retValue ( 0.0 ); @@ -1112,8 +1172,6 @@ otf = new FMOtf ( m_face, 0x10000 );// You think "What’s this 0x10000?", so am I! Just accept Harfbuzz black magic :) if ( !otf ) return retValue; - if ( record ) - sceneList.append ( scene ); double sizz = fsize; double scalefactor = sizz / m_face->units_per_EM ; double pixelAdjustX = scalefactor * ( typotek::getInstance()->getDpiX() / 72.0 ); @@ -1157,8 +1215,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -1177,8 +1233,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -1196,8 +1250,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -1215,8 +1267,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -1225,8 +1275,6 @@ } /*************************************************/ - if ( record ) - pixList.append ( glyph ); mayBeRemoved.append(glyph); @@ -1274,8 +1322,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1294,8 +1340,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1313,8 +1357,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1332,8 +1374,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1342,9 +1382,6 @@ } /**********************************************/ - if ( record ) - glyphList.append ( glyph ); - mayBeRemoved.append(glyph); if(renderReturnWidth) @@ -1374,7 +1411,7 @@ } /// Shaped line -double FontItem::renderLine ( QString script, QGraphicsScene * scene, QString spec, QPointF origine,double lineWidth, double fsize, bool record ) +double FontItem::renderLine ( QString script, QGraphicsScene * scene, QString spec, QPointF origine,double lineWidth, double fsize) { qDebug()<<"Shaped("<< spec <<")"; double retValue(0.0); @@ -1389,28 +1426,29 @@ return 0; FMShaperFactory *shaperfactory = 0; - switch(m_shaperType) - { - case FMShaperFactory::FONTMATRIX : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::FONTMATRIX ); - break; - case FMShaperFactory::HARFBUZZ : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::HARFBUZZ ); - break; - case FMShaperFactory::ICU : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::ICU ); - break; - case FMShaperFactory::M17N : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::M17N ); - break; - case FMShaperFactory::PANGO : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::PANGO ); - break; - case FMShaperFactory::OMEGA : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::OMEGA); - break; - default : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::FONTMATRIX ); - } - + // switch(m_shaperType) + // { + // case FMShaperFactory::FONTMATRIX : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::FONTMATRIX ); + // break; + // case FMShaperFactory::HARFBUZZ : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::HARFBUZZ ); + // break; + // case FMShaperFactory::ICU : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::ICU ); + // break; + // case FMShaperFactory::M17N : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::M17N ); + // break; + // case FMShaperFactory::PANGO : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::PANGO ); + // break; + // case FMShaperFactory::OMEGA : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::OMEGA); + // break; + // default : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::FONTMATRIX ); + // } + + /// Let's do it only with ICU atm. + shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::ICU ); + GlyphList refGlyph ( shaperfactory->doShape( spec ) ); delete shaperfactory; - - if ( record ) - sceneList.append ( scene ); + double sizz = fsize; double scalefactor = sizz / m_face->units_per_EM ; double pixelAdjustX = scalefactor * ( typotek::getInstance()->getDpiX() / 72.0 ); @@ -1454,8 +1492,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -1474,8 +1510,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -1493,8 +1527,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -1512,8 +1544,6 @@ foreach(QGraphicsPixmapItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - pixList.removeAll(rm); delete rm; } @@ -1522,8 +1552,6 @@ } /*************************************************/ - if ( record ) - pixList.append ( glyph ); mayBeRemoved.append(glyph); @@ -1571,8 +1599,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1591,8 +1617,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1610,8 +1634,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1629,8 +1651,6 @@ foreach(QGraphicsPathItem *rm, mayBeRemoved) { scene->removeItem( rm ); - if(record) - glyphList.removeAll(rm); delete rm; } @@ -1639,9 +1659,6 @@ } /**********************************************/ - if ( record ) - glyphList.append ( glyph ); - mayBeRemoved.append(glyph); if(renderReturnWidth) @@ -1669,22 +1686,6 @@ return retValue + 1; } -//deprecated -void FontItem::deRender ( QGraphicsScene *scene ) -{ - QList rem; - for ( int i = 0; i < pixList.count(); ++i ) - { - if ( pixList[i]->scene() == scene ) - { - scene->removeItem ( pixList[i] ); - rem.append ( i ); - } - } - for ( int i = rem.count() - 1; i >= 0; --i ) - pixList.removeAt ( rem[i] ); - -} void FontItem::deRenderAll() { @@ -1848,6 +1849,19 @@ return count;//something weird with freetype which put a valid glyph at the beginning of each lang ??? Or a bug here... } +bool FontItem::hasCharcode(int cc) +{ + if(!ensureFace()) + return false; + bool ret(true); + if( !FT_Get_Char_Index( m_face, cc ) ) + { + ret = false; + } + releaseFace(); + return ret; +} + bool FontItem::hasChars(const QString & s) { if(!ensureFace()) @@ -1871,11 +1885,16 @@ { ensureFace(); -// if ( allIsRendered ) -// return; -// scene->blockSignals(true); - FMGlyphsView *allView = reinterpret_cast ( scene->views() [0] ); -// qDebug() <<"renderAll("<< begin_code<<","<views().count() > 0) + allView = reinterpret_cast ( scene->views() [0] ); + else + { + releaseFace(); + return; + } + deRenderAll(); if ( !allView->isVisible() ) { @@ -2276,13 +2295,13 @@ QPixmap FontItem::oneLinePreviewPixmap ( QString oneline , QColor fg_color, QColor bg_color, int size_w , int size_f ) { - if ( m_remote ) - return fixedPixmap; - if ( !theOneLinePreviewPixmap.isNull() ) - { - if ( theOneLinePreviewPixmap.width() == size_w ) - return theOneLinePreviewPixmap; - } +// if ( m_remote ) +// return fixedPixmap; +// if ( !theOneLinePreviewPixmap.isNull() ) +// { +// if ( theOneLinePreviewPixmap.width() == size_w ) +// return theOneLinePreviewPixmap; +// } if ( !ensureFace() ) return QPixmap(); QRectF savedRect = theOneLineScene->sceneRect(); @@ -2302,7 +2321,7 @@ // qDebug() << theSize << theHeight << theWidth; theOneLineScene->setSceneRect ( 0,0,theWidth, theHeight ); bool pRTL = typotek::getInstance()->getPreviewRTL(); - QPointF pen ( pRTL ? theWidth - 20 : 20 , theSize * pt2px ); + QPointF pen ( pRTL ? theWidth - 16 : 16 , theSize * pt2px ); int fsize = qRound(theSize) * 64 ; double scalefactor = theSize / m_face->units_per_EM; @@ -2310,113 +2329,67 @@ QPixmap linePixmap ( qRound(theWidth), qRound(theHeight) ); linePixmap.fill ( bg_color ); QPainter apainter ( &linePixmap ); - QVector palette; - int notRenderedGlyphsCount ( 0 ); - for ( int i =0;i < oneline.count() ; ++i ) + bool canRender(true); + for ( int i(0);i < oneline.count() ; ++i ) { - int glyphIndex = FT_Get_Char_Index ( m_face, oneline[i].unicode() ); - if ( glyphIndex == 0 ) + if(FT_Get_Char_Index ( m_face, oneline[i].unicode() ) == 0) { - ++notRenderedGlyphsCount; - continue; - } - - FT_Set_Char_Size ( m_face, - fsize, - 0, - typotek::getInstance()->getDpiX(), - typotek::getInstance()->getDpiY() ); - - ft_error = FT_Load_Glyph ( m_face, glyphIndex, FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING ); - if ( ft_error ) - { - continue; - } - - ft_error = FT_Render_Glyph ( m_face->glyph, FT_RENDER_MODE_NORMAL ); - if ( ft_error ) - { - continue; + canRender = false; + break; } - - if ( pRTL ) - pen.rx() -= qRound ( m_glyph->linearHoriAdvance / 65536 ); - - apainter.drawImage ( pen.x() + m_glyph->bitmap_left , pen.y() - m_glyph->bitmap_top , glyphImage(fg_color) ); - - if ( !pRTL ) - pen.rx() += qRound ( m_glyph->linearHoriAdvance / 65536 ); - } - /// Check if we have drawn something - if ( notRenderedGlyphsCount == oneline.count() ) + if(canRender) { - pen.rx() = 0; // we don’t bother about RTL here. - //If not we draw first available characters. - FT_ULong charCode; - FT_UInt glyphIndex; - charCode = FT_Get_First_Char ( m_face, &glyphIndex ); - for ( int i =0;i < oneline.count() ; ++i ) // get same number of glyphs than normal preview word + for ( int i(0);i < oneline.count() ; ++i ) { - if ( glyphIndex == 0 ) - { - continue; - } - ft_error = FT_Load_Glyph ( m_face, glyphIndex, FT_LOAD_NO_SCALE ); - if ( ft_error ) - { - continue; - } - double advance = m_glyph->metrics.horiAdvance * scalefactor * pt2px; - double leftBearing = ( double ) m_glyph->metrics.horiBearingX * scalefactor * pt2px; -// qDebug() << oneline[i] << m_glyph->metrics.horiAdvance << advance ; + int glyphIndex = FT_Get_Char_Index ( m_face, oneline[i].unicode() ); + FT_Set_Char_Size ( m_face, - fsize, - 0, + fsize, + 0, typotek::getInstance()->getDpiX(), typotek::getInstance()->getDpiY() ); - ft_error = FT_Load_Glyph ( m_face, glyphIndex, FT_LOAD_DEFAULT ); - if ( ft_error ) - { + + if(FT_Load_Glyph ( m_face, glyphIndex, FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING ) > 0) continue; - } - ft_error = FT_Render_Glyph ( m_face->glyph, FT_RENDER_MODE_NORMAL ); - if ( ft_error ) - { + if(FT_Render_Glyph ( m_face->glyph, FT_RENDER_MODE_NORMAL ) > 0) continue; - } - - pen.ry() = ( theSize * pt2px ) - m_glyph->bitmap_top; - - apainter.drawImage ( qRound(pen.x() + leftBearing),qRound( pen.y()), glyphImage(fg_color) ); - - pen.rx() += advance; - - charCode = FT_Get_Next_Char ( m_face, charCode, &glyphIndex ); + if ( pRTL ) + pen.rx() -= qRound ( m_glyph->linearHoriAdvance / 65536 ); + apainter.drawImage ( pen.x() + m_glyph->bitmap_left , pen.y() - m_glyph->bitmap_top , glyphImage(fg_color) ); + if ( !pRTL ) + pen.rx() += qRound ( m_glyph->linearHoriAdvance / 65536 ); } } + else + { + QString cantRenderString(tr("(%1)", "when doing the font preview, used to denote a font that can not displayed its name")); + apainter.drawText(pen.x(),pen.y(), cantRenderString.arg(oneline)); + } + apainter.end(); releaseFace(); - theOneLinePreviewPixmap = linePixmap; + return linePixmap; +// theOneLinePreviewPixmap = linePixmap; - if ( !theOneLinePreviewPixmap.isNull() ) - return theOneLinePreviewPixmap; +// if ( !theOneLinePreviewPixmap.isNull() ) +// return theOneLinePreviewPixmap; - theOneLinePreviewPixmap = QPixmap ( qRound(theWidth), qRound(theHeight) ); - theOneLinePreviewPixmap.fill ( Qt::lightGray ); - return theOneLinePreviewPixmap; +// theOneLinePreviewPixmap = QPixmap ( qRound(theWidth), qRound(theHeight) ); +// theOneLinePreviewPixmap.fill ( Qt::lightGray ); +// return theOneLinePreviewPixmap; } void FontItem::clearPreview() { - if ( m_remote ) - return; - if ( !theOneLinePreviewPixmap.isNull() ) - theOneLinePreviewPixmap = QPixmap(); +// if ( m_remote ) +// return; +// if ( !theOneLinePreviewPixmap.isNull() ) +// theOneLinePreviewPixmap = QPixmap(); } @@ -2933,7 +2906,7 @@ int ref ( fancyGlyphs.count() ); QRect allRect ( view->rect() ); - QRect targetRect ( view->mapToScene ( allRect.topLeft() ).toPoint(), view->mapToScene ( allRect.topRight() ) .toPoint() ) ; + QRect targetRect ( view->mapToScene ( allRect.topLeft() ).toPoint(), view->mapToScene ( allRect.bottomRight() ).toPoint() ) ; // qDebug() << allRect.topLeft() << view->mapToScene ( allRect.topLeft() ); // We’ll try to have a square subRect that fit in view ;-) @@ -3022,64 +2995,41 @@ QGraphicsTextItem *textIt = new QGraphicsTextItem; - textIt->setTextWidth ( squareSide ); + textIt->setTextWidth ( allRect.width() ); + + QString itemNameStyle ( "background-color:#000;color:#fff;font-weight:bold;font-size:13pt;padding:0 3px;" ); + QString itemValueStyle ( "background-color:#fff;color:#000;font-size:9pt;padding:0 3px;" ); - QString itemNameStyle ( "background-color:#333;color:white;font-weight:bold;font-size:10pt" ); - QString itemValueStyle ( "background-color:#eee;color:black;font-style:italic;font-size:10pt" ); if ( charcodeIsAGlyphIndex ) { - QString html; - - html = " Index "; - html += " "+ QString::number ( charcode ) +" "; + QString html(QString(" %2 - Index %4 ") + .arg(itemNameStyle) + .arg(glyphName(charcode)) + .arg(itemValueStyle) + .arg(QString::number ( charcode ))); textIt->setHtml ( html ); } else { - QString html; - QString catString; - int cat ( QChar::category ( static_cast ( charcode ) ) ); - if ( cat == QChar::Mark_NonSpacing ) catString = QObject::tr ( "Mark, NonSpacing" ); - else if ( cat == QChar::Mark_SpacingCombining ) catString = QObject::tr ( "Mark, SpacingCombining" ); - else if ( cat == QChar::Mark_Enclosing ) catString = QObject::tr ( "Mark, Enclosing" ); - else if ( cat == QChar::Number_DecimalDigit ) catString = QObject::tr ( "Number, DecimalDigit" ); - else if ( cat == QChar::Number_Letter ) catString = QObject::tr ( "Number, Letter" ); - else if ( cat == QChar::Number_Other ) catString = QObject::tr ( "Number, Other" ); - else if ( cat == QChar::Separator_Space ) catString = QObject::tr ( "Separator, Space" ); - else if ( cat == QChar::Separator_Line ) catString = QObject::tr ( "Separator, Line" ); - else if ( cat == QChar::Separator_Paragraph ) catString = QObject::tr ( "Separator, Paragraph" ); - else if ( cat == QChar::Other_Control ) catString = QObject::tr ( "Other, Control" ); - else if ( cat == QChar::Other_Format ) catString = QObject::tr ( "Other, Format" ); - else if ( cat == QChar::Other_Surrogate ) catString = QObject::tr ( "Other, Surrogate" ); - else if ( cat == QChar::Other_PrivateUse ) catString = QObject::tr ( "Other, PrivateUse" ); - else if ( cat == QChar::Other_NotAssigned ) catString = QObject::tr ( "Other, NotAssigned" ); - else if ( cat == QChar::Letter_Uppercase ) catString = QObject::tr ( "Letter, Uppercase" ); - else if ( cat == QChar::Letter_Lowercase ) catString = QObject::tr ( "Letter, Lowercase" ); - else if ( cat == QChar::Letter_Titlecase ) catString = QObject::tr ( "Letter, Titlecase" ); - else if ( cat == QChar::Letter_Modifier ) catString = QObject::tr ( "Letter, Modifier" ); - else if ( cat == QChar::Letter_Other ) catString = QObject::tr ( "Letter, Other" ); - else if ( cat == QChar::Punctuation_Connector ) catString = QObject::tr ( "Punctuation, Connector" ); - else if ( cat == QChar::Punctuation_Dash ) catString = QObject::tr ( "Punctuation, Dash" ); - else if ( cat == QChar::Punctuation_Open ) catString = QObject::tr ( "Punctuation, Open" ); - else if ( cat == QChar::Punctuation_Close ) catString = QObject::tr ( "Punctuation, Close" ); - else if ( cat == QChar::Punctuation_InitialQuote ) catString = QObject::tr ( "Punctuation, InitialQuote" ); - else if ( cat == QChar::Punctuation_FinalQuote ) catString = QObject::tr ( "Punctuation, FinalQuote" ); - else if ( cat == QChar::Punctuation_Other ) catString = QObject::tr ( "Punctuation, Other" ); - else if ( cat == QChar::Symbol_Math ) catString = QObject::tr ( "Symbol, Math" ); - else if ( cat == QChar::Symbol_Currency ) catString = QObject::tr ( "Symbol, Currency" ); - else if ( cat == QChar::Symbol_Modifier ) catString = QObject::tr ( "Symbol, Modifier" ); - else if ( cat == QChar::Symbol_Other ) catString = QObject::tr ( "Symbol, Other" ); + catString = FontStrings::UnicodeCategory(QChar::category(static_cast ( charcode ))); - html = " "+ tr ( "Category" ) + " "; - html += " "+ catString +" "; + QString html(QString(" %2 %4 - U+%5 <&#%6;> ") + .arg(itemNameStyle) + .arg(glyphName(charcode)) + .arg(itemValueStyle) + .arg(catString) + .arg(QString("%1").arg(charcode, 4, 16, QChar('0')).toUpper()) + .arg(charcode)); textIt->setHtml ( html ); } // qDebug()<< textIt->toHtml(); - QPointF tPos ( subRect.left() + 20.0 , subRect.bottom() + 2 ); - textIt->setPos ( view->mapToScene ( tPos.toPoint() ) ); +// QPointF tPos ( subRect.left() + 18.0 , subRect.bottom() ); + QRectF tRect(textIt->boundingRect()); + QPointF tPos ( -3, targetRect.bottom() - tRect.height() +5); + textIt->setPos ( tPos ); textIt->setZValue ( 2000000 ); textIt->setEnabled ( true ); textIt->setFlags ( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable ); @@ -3176,7 +3126,7 @@ m_variant = v; m_type = t; // m_cacheInfo = i; - fixedPixmap = p; +// fixedPixmap = p; } /// the same, but just for speedup startup with a lot of font files @@ -3742,23 +3692,23 @@ return Gret; } FMShaperFactory *shaperfactory = 0; - switch(m_shaperType) - { - case FMShaperFactory::FONTMATRIX : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::FONTMATRIX ); - break; - case FMShaperFactory::HARFBUZZ : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::HARFBUZZ ); - break; - case FMShaperFactory::ICU : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::ICU ); - break; - case FMShaperFactory::M17N : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::M17N ); - break; - case FMShaperFactory::PANGO : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::PANGO ); - break; - case FMShaperFactory::OMEGA : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::OMEGA); - break; - default : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::FONTMATRIX ); - } - +// switch(m_shaperType) +// { +// case FMShaperFactory::FONTMATRIX : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::FONTMATRIX ); +// break; +// case FMShaperFactory::HARFBUZZ : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::HARFBUZZ ); +// break; +// case FMShaperFactory::ICU : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::ICU ); +// break; +// case FMShaperFactory::M17N : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::M17N ); +// break; +// case FMShaperFactory::PANGO : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::PANGO ); +// break; +// case FMShaperFactory::OMEGA : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::OMEGA); +// break; +// default : shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::FONTMATRIX ); +// } + shaperfactory = new FMShaperFactory(otf,script, FMShaperFactory::ICU ); /// HYPHENATION diff -Nru fontmatrix-0.6.0+svn20100107/src/fontitem.h fontmatrix-0.6.0+svn20110930/src/fontitem.h --- fontmatrix-0.6.0+svn20100107/src/fontitem.h 2009-06-30 14:44:43.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/fontitem.h 2010-09-29 11:05:22.000000000 +0000 @@ -32,6 +32,9 @@ #include #include // #include +#include +#include +#include #include #include FT_FREETYPE_H @@ -45,6 +48,7 @@ struct OTFSet; class FMOtf; class QGraphicsView; +class QGraphicsObject; class QProgressDialog; class QHttp; @@ -63,6 +67,8 @@ #define GLYPH_DATA_BITMAPTOP 3 #define GLYPH_DATA_HADVANCE 4 #define GLYPH_DATA_VADVANCE 5 +#define GLYPH_DATA_HADVANCE_SCALED 6 +#define GLYPH_DATA_ERROR 7 #define GLYPH_DATA_FONTNAME 100 @@ -83,6 +89,22 @@ QPixmap pix; }; +class MetaGlyphItem : public QGraphicsItem +{ + QMap m_Data; +public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){} + QRectF boundingRect() const {return QRectF();} + void setMetaData(int key, const QVariant &value) + { + m_Data.insert(key,value); + } + QVariant metaData(int key) const + { + return m_Data.value(key); + } +}; + class FontItem : public QObject { Q_OBJECT @@ -107,6 +129,7 @@ FontItem ( QString path , bool remote = false, bool faststart = false); FontItem (QString path, QString family, QString variant, QString type , bool active); + FontItem * Clone(); /** Needed when the item has been instantiate with "faststart=true" */ void updateItem(); ~FontItem(); @@ -156,9 +179,11 @@ bool m_isOpenType; FMOtf *otf; - static FT_Library theLibrary; +// FT_Library theLibrary; + FT_Face m_face; + FT_Face lastFace; FT_Error ft_error; - FT_Face m_face; +// QMap faces; int facesRef; FT_GlyphSlot m_glyph; @@ -170,8 +195,7 @@ bool m_rasterFreetype; unsigned int m_FTHintMode; // unsigned int m_FTRenderMode;not yet implemented - - bool ensureLibrary(); + bool ensureFace(); void releaseFace(); void encodeFace(); @@ -187,12 +211,10 @@ QList glyphList; QList labList; QList selList; - QList sceneList; QMap fancyGlyphs; QMap fancyTexts; QMap > fancyAlternates; - QPixmap fixedPixmap; bool allIsRendered; bool isDerendered; @@ -210,8 +232,8 @@ QMap advanceCache; - QIcon theOneLinePreviewIcon; - QPixmap theOneLinePreviewPixmap; +// QIcon theOneLinePreviewIcon; +// QPixmap theOneLinePreviewPixmap; static QGraphicsScene *theOneLineScene; @@ -243,6 +265,7 @@ public slots: QString renderSVG(const QString& s, const double& size); int countCoverage ( int begin_code, int end_code ); + bool hasCharcode(int cc); bool hasChars(const QString& s); int firstChar(); int lastChar(); @@ -268,7 +291,7 @@ QString family() const {return m_family;} QString variant() const {return m_variant;} QStringList tags() const ; - int glyphsCount() const {return m_numGlyphs;} + int glyphsCount() const; QString type(){return m_type;} QStringList charmaps(); void setTags ( QStringList l ); @@ -290,15 +313,16 @@ // QString value ( QString k ); // QString panose( QString k ); - double renderLine ( QGraphicsScene *scene, QString spec, QPointF origine, double lineWidth, double fsize, double zindex = 100.0 ,bool record = true ); - double renderLine ( OTFSet set, QGraphicsScene *scene, QString spec, QPointF origine, double lineWidth,double fsize, bool record = true ); - double renderLine ( QString script, QGraphicsScene *scene, QString spec, QPointF origine, double lineWidth,double fsize, bool record = true ); + double renderLine ( QGraphicsScene *scene, QString spec, QPointF origine, double lineWidth, double fsize, double zindex = 100.0); + double renderLine ( OTFSet set, QGraphicsScene *scene, QString spec, QPointF origine, double lineWidth,double fsize); + double renderLine ( QString script, QGraphicsScene *scene, QString spec, QPointF origine, double lineWidth,double fsize); QGraphicsPathItem* itemFromChar ( int charcode, double size ); QGraphicsPathItem* itemFromGindex ( int index, double size ); - QGraphicsPixmapItem* itemFromCharPix ( int charcode, double size ); - QGraphicsPixmapItem* itemFromGindexPix ( int index, double size ); - QGraphicsPixmapItem* itemFromGindexPix_mt ( int index, double size ); + QGraphicsPixmapItem* itemFromCharPix ( int charcode, double size); + QGraphicsPixmapItem* itemFromGindexPix ( int index, double size); + // cant have qpixmap outside main thread and QGraphicsPixmapItem create at least a null one when instantiated + MetaGlyphItem* itemFromGindexPix_mt ( int index, double size ); QImage charImage(int charcode, double size); QImage glyphImage(int index, double size); @@ -308,8 +332,7 @@ void renderAll ( QGraphicsScene *scene, int begin_code, int end_code ); //return count codes that remain int renderChart(QGraphicsScene *scene, int begin_code, int end_code ,double pwidth, double pheight); - - void deRender ( QGraphicsScene *scene ); + void deRenderAll(); //Return a ref that will be asked for destroy the element. -1 if failed Binary files /tmp/dRWqftaY8E/fontmatrix-0.6.0+svn20100107/src/graphic-resources/filter-and.png and /tmp/mzUVGYJgMP/fontmatrix-0.6.0+svn20110930/src/graphic-resources/filter-and.png differ Binary files /tmp/dRWqftaY8E/fontmatrix-0.6.0+svn20100107/src/graphic-resources/filter.png and /tmp/mzUVGYJgMP/fontmatrix-0.6.0+svn20110930/src/graphic-resources/filter.png differ Binary files /tmp/dRWqftaY8E/fontmatrix-0.6.0+svn20100107/src/graphic-resources/filter-remove.png and /tmp/mzUVGYJgMP/fontmatrix-0.6.0+svn20110930/src/graphic-resources/filter-remove.png differ diff -Nru fontmatrix-0.6.0+svn20100107/src/graphic-resources/html-css/fontmatrix.js fontmatrix-0.6.0+svn20110930/src/graphic-resources/html-css/fontmatrix.js --- fontmatrix-0.6.0+svn20100107/src/graphic-resources/html-css/fontmatrix.js 2009-06-17 07:01:49.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/graphic-resources/html-css/fontmatrix.js 2010-09-16 13:39:26.000000000 +0000 @@ -2,4 +2,218 @@ This file is loaded each time the selected font changed. */ -/* alert("JS loaded"); */ \ No newline at end of file +/* alert("JS loaded"); */ + +/*! + * jQuery JavaScript Library v1.4.2 + * http://jquery.com/ + * + * Copyright 2010, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2010, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Sat Feb 13 22:33:48 2010 -0500 + */ +(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/, +Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&& +(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this, +a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b=== +"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this, +function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b
a"; +var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected, +parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent= +false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n= +s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true, +applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando]; +else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this, +a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b=== +w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i, +cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected= +c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed"); +a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g, +function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split("."); +k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a), +C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B=0){a.type= +e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&& +f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive; +if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data", +e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a, +"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a, +d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, +e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift(); +t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D|| +g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()}, +CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m, +g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)}, +text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}}, +setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return hl[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h= +h[3];l=0;for(m=h.length;l=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m=== +"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g, +h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&& +q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML=""; +if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="

";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}(); +(function(){var g=s.createElement("div");g.innerHTML="
";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}: +function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var j=d;j0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j= +{},i;if(f&&a.length){e=0;for(var o=a.length;e-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a=== +"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode", +d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")? +a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType=== +1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/"},F={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
","
"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= +c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, +wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, +prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, +this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); +return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja, +""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]); +return this}else{e=0;for(var j=d.length;e0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["", +""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]===""&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e= +c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]? +c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja= +function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter= +Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a, +"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f= +a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b= +a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=//gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!== +"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("
").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this}, +serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), +function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href, +global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&& +e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)? +"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache=== +false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B= +false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since", +c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E|| +d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x); +g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status=== +1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b=== +"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional; +if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration=== +"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]|| +c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start; +this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now= +this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem, +e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b
"; +a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b); +c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a, +d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top- +f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset": +"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in +e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window); + +// End of JQuery + +var shortHeight = "6pt"; +var initialInfoElemHeight = new Object; + +var idCount = 0; +function anIdDear() +{ + return "xXdDfFgGplok_" + idCount++; +} + +function toggleInfoElem() +{ + var h = shortHeight; + var that = $(this); + if(that.hasClass("overflow")) + { + if(that.hasClass("unfolded")) + { + that.removeClass("unfolded"); + } + else + { + that.addClass("unfolded"); + h = initialInfoElemHeight[that.attr("id")]; + } + that.next().animate({ + height: h + }, + 500, + 'linear', + function(){}); + } +} + +function initFM() +{ +// shortHeight = $(".infoname").height(); + $(".infoname").each(function() + { + var id = anIdDear(); + $(this).attr("id",id); + var that = $(this).next(); + initialInfoElemHeight[id] = that.height(); + var t = that.text(); + that.text("A"); + if(that.height() < initialInfoElemHeight[id]) + { + $(this).addClass("overflow"); + } + that.text(t); + that.css("height", shortHeight ); + }); + + $(".infoname").live("click", toggleInfoElem); +} + +$(document).ready(initFM); diff -Nru fontmatrix-0.6.0+svn20100107/src/graphic-resources/html-css/info.css fontmatrix-0.6.0+svn20110930/src/graphic-resources/html-css/info.css --- fontmatrix-0.6.0+svn20100107/src/graphic-resources/html-css/info.css 2009-06-29 06:50:54.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/graphic-resources/html-css/info.css 2010-09-16 13:39:26.000000000 +0000 @@ -7,37 +7,27 @@ border:0; margin:0; padding:0; + font-family: sans-serif; } body{ background-color : #fefefe; } -#headline { -/* text-shadow: black 4px 4px 2px; */ - background-color : #ff3f00; - color : white; - font-family : 'sans-serif'; - font-size : 18pt; - font-weight : bold; - line-height : 30pt; - padding-bottom : 4pt; - padding-left : 6pt; - padding-right : 4pt; - padding-top : 4pt; - } - #file { - text-align:right; + display:none; +/* text-align:right; background-color : #ddd; color : #333; font-family : monospace; - font-size : 10pt; + font-size : 10pt;*/ } #general{ - float:left; - width:75%; + position: absolute; + top: 142px; + width:620px; +/* background-color:green; */ } .encodingcurrent{ @@ -47,8 +37,9 @@ .infoblock { clear:both; } + .infoblock:hover .langundefined { - border-left : 10pt solid red ; + border-left : 1pt solid red ; color:black; } .infoblock:hover .infoname @@ -56,101 +47,76 @@ color:red; } - .infoname { text-align:right; background-color : #fefefe; color:#333; -/* background-image : url('css-info-propertyname.png'); */ - background-repeat : repeat-y; float : left; - font-family : 'sans-serif'; - font-size : 10pt; - font-style : italic; + font-size : 8pt; font-weight : bold; - line-height : 200%; - padding-right : 1%; - width : 30%; + width : 180px; + height:6pt; } +.overflow{ + cursor: pointer; + color:#666; +} -.langmatch { - color: #333; - background-color : #fefefe; - margin-left : 31%; - border-left : 10pt solid gray ; - padding-left: 6pt; - font-family : 'sans-serif'; - font-size : 10pt; - line-height : 20pt; - } +.unfolded{ + color: #333; +} .langundefined { color: #444; background-color : #fefefe; - margin-left : 31%; - border-left : 10pt solid gray ; - padding-left: 6pt; - font-family : 'sans-serif'; - font-size : 10pt; - line-height : 20pt; - } - - -.langnomatch { - color: #444; - background-color : #fefefe; - margin-left : 31%; - border-left : 10pt solid gray ; + margin-left : 186px; + border-left : 1pt solid gray ; + padding-bottom:9pt; padding-left: 6pt; - font-family : 'sans-serif'; - font-style : italic; - font-size : 10pt; - line-height : 20pt; + font-size : 8pt; + line-height : 12pt; + overflow:hidden; } #panose_block { - background-color : #fafafa; - margin-left:80%; - padding:1pt; -/* border-left: 2px solid black; */ - } + position: absolute; + top: 142px; + left: 490px; + width: 300px; +} +#panoselabel{ + font-size:12pt; +} .panose_name { + float:left; text-align:left; - font-style:italic; - font-size : 9pt; - color : gray; + font-size : 8pt; +/* padding-left:8pt; */ + color : #aaa; + padding-right:4pt; } .panose_desc { -text-align:center; - font-size:9pt; +text-align:left; + font-size:8pt; color:#333; } - - -.panose_desc:hover { - background-color:white; - color:black; - } - - #langblock{ - margin-left:80%; + position: absolute; + top:322px; + left: 550px; + width: 300px; } .langblockname { - margin-top:8pt; - border-top :2pt solid #222; - font-weight:bold; - font-size:10pt; -/* padding-left:4pt; */ + font-size:12pt; } #langblock ul{ @@ -159,9 +125,9 @@ #langblock ul li{ /* font-style:italic; */ - font-size:9pt; + font-size:8pt; color:#666; - padding-left:4pt; +/* padding-left:8pt; */ } #langblock ul li:hover{ @@ -169,25 +135,43 @@ } #fstype { - margin-top:24pt; - font-style:monospace; +/* margin-top:24pt; */ +position:fixed; +bottom:0; +width:400px; +padding-right:200px; +background-color:#fff; } #fstype > div{ margin:4pt 0; padding:2pt 0 2pt 2pt; - border-left:20pt solid black; + border-left:6pt solid black; } .fsname { float:left; - padding-right: 1em; + padding-right: 9pt; font-weight:bold; line-height:9pt; - font-size:9pt; + font-size:12pt; } .fsdesc{ - line-height:9pt; - font-style:italic; - font-size:8pt; + line-height:8pt; +/* font-style:italic; */ + font-size:7pt; +/* font-family:serif; */ } + +#previewblock{ + text-align:center; + width:800px; +} + +svg{ +/* margin-left: 182px;*/ + margin-bottom:62px; + padding:1% 1% 0 1%; + border-bottom:1px solid black; +} + diff -Nru fontmatrix-0.6.0+svn20100107/src/graphic-resources/info.css fontmatrix-0.6.0+svn20110930/src/graphic-resources/info.css --- fontmatrix-0.6.0+svn20100107/src/graphic-resources/info.css 2008-09-18 20:38:26.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/graphic-resources/info.css 2010-09-16 13:39:26.000000000 +0000 @@ -1 +1,177 @@ -MOVED TO /src/graphic-resources/html-css/info.css \ No newline at end of file +/* + Informations (Fontmatrix) + base style +*/ + +*{ + border:0; + margin:0; + padding:0; + font-family: sans-serif; +} + +body{ + background-color : #fefefe; +} + +#file { + display:none; +/* text-align:right; + background-color : #ddd; + color : #333; + font-family : monospace; + font-size : 10pt;*/ +} + +#general{ + position: absolute; + top: 142px; + width:620px; +/* background-color:green; */ +} + +.encodingcurrent{ + font-weight:bold; +} + +.infoblock { + clear:both; +} + +.infoblock:hover .langundefined { + border-left : 1pt solid red ; + color:black; +} +.infoblock:hover .infoname +{ + color:red; +} + +.infoname { + text-align:right; + background-color : #fefefe; + color:#333; + float : left; + font-size : 8pt; + font-weight : bold; + width : 180px; + height:6pt; + } + +.overflow{ + cursor: pointer; + color:#666; +} + +.unfolded{ + color: #333; +} + + +.langundefined { + color: #444; + background-color : #fefefe; + margin-left : 186px; + border-left : 1pt solid gray ; + padding-bottom:9pt; + padding-left: 6pt; + font-size : 8pt; + line-height : 12pt; + overflow:hidden; + } + + +#panose_block { + position: absolute; + top: 142px; + left: 490px; + width: 300px; +} + +#panoselabel{ + font-size:12pt; +} + +.panose_name { + float:left; + text-align:left; + font-size : 8pt; +/* padding-left:8pt; */ + color : #aaa; + padding-right:4pt; + } + + +.panose_desc { +text-align:left; + font-size:8pt; + color:#333; + } + +#langblock{ + position: absolute; + top:322px; + left: 550px; + width: 300px; + } + +.langblockname { + font-size:12pt; + } + + #langblock ul{ + list-style-type:none + } + + #langblock ul li{ +/* font-style:italic; */ + font-size:8pt; + color:#666; +/* padding-left:8pt; */ + } + + #langblock ul li:hover{ + color:#222; + } + +#fstype { +/* margin-top:24pt; */ +position:fixed; +bottom:0; +width:400px; +padding-right:200px; +background-color:#fff; +} + +#fstype > div{ + margin:4pt 0; + padding:2pt 0 2pt 2pt; + border-left:6pt solid black; +} + +.fsname { + float:left; + padding-right: 9pt; + font-weight:bold; + line-height:9pt; + font-size:12pt; +} +.fsdesc{ + line-height:8pt; +/* font-style:italic; */ + font-size:7pt; +/* font-family:serif; */ +} + +#previewblock{ + text-align:center; + width:800px; +} + +svg{ +/* margin-left: 182px;*/ + margin-bottom:62px; + padding:1% 1% 0 1%; + border-bottom:1px solid black; +} + diff -Nru fontmatrix-0.6.0+svn20100107/src/importtags.cpp fontmatrix-0.6.0+svn20110930/src/importtags.cpp --- fontmatrix-0.6.0+svn20100107/src/importtags.cpp 2009-06-17 13:12:05.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/importtags.cpp 2010-09-13 10:06:29.000000000 +0000 @@ -11,7 +11,7 @@ // #include "importtags.h" #include "fmfontdb.h" -#include "listdockwidget.h" +//#include "listdockwidget.h" #include @@ -56,7 +56,7 @@ tagText->clear(); FMFontDb::DB()->addTagToDB ( nTag ); - ListDockWidget::getInstance()->reloadTagsCombo(); +// ListDockWidget::getInstance()->reloadTagsCombo(); } void ImportTags::slotEnd() diff -Nru fontmatrix-0.6.0+svn20100107/src/listdockwidget.cpp fontmatrix-0.6.0+svn20110930/src/listdockwidget.cpp --- fontmatrix-0.6.0+svn20100107/src/listdockwidget.cpp 2009-11-22 20:29:46.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/listdockwidget.cpp 2010-09-13 10:06:29.000000000 +0000 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "listdockwidget.h" +//#include "listdockwidget.h" #include "typotek.h" #include "fontitem.h" #include "fmfontdb.h" @@ -59,17 +59,17 @@ saveFilterButton->setVisible(false); - listPreview->setModelColumn(1); - listPreview->setViewMode(QListView::IconMode); - listPreview->setIconSize(QSize(listPreview->width(), 1.3 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0)); - listPreview->setUniformItemSizes(true); - listPreview->setMovement(QListView::Static); - - previewModel = new FMPreviewModel( this, listPreview ); - listPreview->setModel(previewModel); - previewText->setText(typotek::getInstance()->word()); - previewText->setToolTip(tr("You can use the following keywords to be replaced by data from fonts: <name> ; <family> ; <variant>")); - previewSize->setValue(typotek::getInstance()->getPreviewSize()); +// listPreview->setModelColumn(1); +// listPreview->setViewMode(QListView::IconMode); +// listPreview->setIconSize(QSize(qRound(listPreview->width() ), 1.3 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0)); +// listPreview->setUniformItemSizes(true); +// listPreview->setMovement(QListView::Static); + +// previewModel = new FMPreviewModel( this, listPreview ); +// listPreview->setModel(previewModel); +// previewText->setText(typotek::getInstance()->word()); +// previewText->setToolTip(tr("You can use the following keywords to be replaced by data from fonts: <name> ; <family> ; <variant>")); +// previewSize->setValue(typotek::getInstance()->getPreviewSize()); // Folders tree ffilter << "*.otf" << "*.ttf" << "*.pfb"; @@ -205,13 +205,13 @@ connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotTabChanged(int))); - connect(typotek::getInstance(),SIGNAL(previewHasChanged()),this,SLOT(slotPreviewUpdate())); - connect(listPreview, SIGNAL(widthChanged(int)),this,SLOT(slotPreviewUpdateSize(int))); - connect(listPreview,SIGNAL(activated ( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); - connect(listPreview,SIGNAL(clicked ( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); - connect(listPreview,SIGNAL(pressed( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); - connect(previewText, SIGNAL(textChanged( const QString& )), this, SLOT(slotPreviewText( const QString&))); - connect(previewSize, SIGNAL(valueChanged( double )), this, SLOT(slotPreviewSize(double))); +// connect(typotek::getInstance(),SIGNAL(previewHasChanged()),this,SLOT(slotPreviewUpdate())); +// connect(listPreview, SIGNAL(widthChanged(int)),this,SLOT(slotPreviewUpdateSize(int))); +// connect(listPreview,SIGNAL(activated ( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); +// connect(listPreview,SIGNAL(clicked ( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); +// connect(listPreview,SIGNAL(pressed( const QModelIndex&)),this,SLOT( slotPreviewSelected(const QModelIndex& ))); +// connect(previewText, SIGNAL(textChanged( const QString& )), this, SLOT(slotPreviewText( const QString&))); +// connect(previewSize, SIGNAL(valueChanged( double )), this, SLOT(slotPreviewSize(double))); } @@ -541,14 +541,14 @@ void ListDockWidget::slotPreviewUpdateSize(int w) { - listPreview->setIconSize(QSize(w, 1.3 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0)); +// listPreview->setIconSize(QSize(qRound(w ), 1.3 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0)); // previewModel->dataChanged(); } void ListDockWidget::slotPreviewSelected(const QModelIndex & index) { qDebug()<<"slotPreviewSelected("<getCurrentFonts().at(index.row())); + FontItem * fItem(FMFontDb::DB()->getFilteredFonts(true).at(index.row())); if(!fItem) { qDebug()<<"\t-FontItme invalid"; @@ -557,7 +557,9 @@ QString fName(fItem->path()); qDebug()<<"\t+"<< fName; if(!fName.isEmpty()) + { typotek::getInstance()->getTheMainView()->slotFontSelectedByName(fName); + } } diff -Nru fontmatrix-0.6.0+svn20100107/src/listsdock.ui fontmatrix-0.6.0+svn20110930/src/listsdock.ui --- fontmatrix-0.6.0+svn20100107/src/listsdock.ui 2009-08-14 15:07:30.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/listsdock.ui 2010-06-21 12:42:25.000000000 +0000 @@ -23,7 +23,7 @@ Form - + :/fontmatrix_icon.png:/fontmatrix_icon.png @@ -394,38 +394,6 @@ - - - Previews - - - - 2 - - - - - Qt::ScrollBarAlwaysOff - - - QListView::Adjust - - - QListView::SinglePass - - - true - - - - - - - - - - - Folders @@ -453,12 +421,9 @@ QTreeWidget
fmnamelist.h
- - FMPreviewView - QListView -
fmpreviewlist.h
-
- + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/main.cpp fontmatrix-0.6.0+svn20110930/src/main.cpp --- fontmatrix-0.6.0+svn20100107/src/main.cpp 2009-06-30 22:29:12.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/main.cpp 2010-09-13 10:06:29.000000000 +0000 @@ -32,7 +32,7 @@ #include "typotek.h" #include "mainviewwidget.h" -#include "listdockwidget.h" +//#include "listdockwidget.h" #include "fmpaths.h" #include "systray.h" @@ -124,7 +124,7 @@ LazyInit lazyInit; - QObject::connect ( &lazyInit, SIGNAL ( endOfRun() ), ListDockWidget::getInstance(), SLOT ( unlockFilter() ) ); +// QObject::connect ( &lazyInit, SIGNAL ( endOfRun() ), ListDockWidget::getInstance(), SLOT ( unlockFilter() ) ); lazyInit.start ( QThread::LowestPriority ); mw->postInit(); diff -Nru fontmatrix-0.6.0+svn20100107/src/mainview.ui fontmatrix-0.6.0+svn20110930/src/mainview.ui --- fontmatrix-0.6.0+svn20100107/src/mainview.ui 2009-08-14 15:07:30.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/mainview.ui 2011-02-08 14:43:38.000000000 +0000 @@ -23,635 +23,108 @@ main view widget - - - 2 - - - 12 - - - 2 - - - 2 + + + 0 0 - - - true - - - - 1 - 0 - - - - true - - - - - - - - - Qt::LeftToRight - - - QTabWidget::North - - - QTabWidget::Rounded - + 0 - - Qt::ElideRight - - - - - :/fontmatrix_info.png:/fontmatrix_info.png - - - Font Information - - + + 0 - - - - - 0 - 5 - - - - - - - - - - :/fontmatrix_sampletext.png:/fontmatrix_sampletext.png - - - Sample Text - - - - 0 - - + 0 - - - - - 0 - 0 - - - - - 0 - - - - - - 0 - 0 - - - - - 24 - 16777215 - - - - Sample text rendering options - - - Display settings - - - true - - - false - - - false - - - true - - - - - - - - 0 - 0 - - - - - 24 - 16777215 - - - - Enable and disable OpenType features implemented in the font - - - OpenType features - - - true - - - false - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - - 24 - 16777215 - - - - Choose a sample text from your collection - - - Samples collection - - - true - - - true - - - true - - - - - - - - - - - 1 - 0 - - - - QFrame::NoFrame - + + Qt::Horizontal - + - 5 + 1 0 - - 0 + + QFrame::StyledPanel - - - - 0 - - - - - Qt::NoFocus - - - QFrame::NoFrame - - - - - - - - - 0 - - - - - Qt::NoFocus - - - QFrame::NoFrame - - - - - + + QFrame::Raised + + + + 2 + + + + + - + - 1 + 6 0 - - 2 - - - - + + + 0 + + + 0 + + + + + QListView::Adjust + + + true + + + + + - - - - Qt::Vertical - - - - - 0 - 0 - - - - Qt::NoFocus - - - true - - - 2 - - - - OpenType Features - - - - - Friendly Name - - - - - - - - - - Qt::Horizontal - - - - 53 - 20 - - - - - - + + - Save as default + Quick Search: - - - - - - Reset Default + + quickSearch - - - - - - - - - - Appearance - - - - - - - - - 2 - 0 - - - - Font Size - - - liveFontSizeSpin - - - - - - - - 1 - 0 - - - - false - - - true - - - - - - pt - - - 1.000000000000000 - - - 999.990000000000009 - - - - - - - - - 0 - - - - - - 0 - 0 - - - - FreeType based rasterized rendering - - - Rasterized - - - true - - - - - - - - 0 - - - 0 - - - - - No hinting - - - true - - - - - - - Light Hinting - - - - - - - Normal Hinting - - - - - - - - - - - 0 - 0 - - - - Freely scalable vector rendering using native toolkit (Qt) - - - Vector - - - - - - - - - - - - World is wide - - - - 2 - - - 3 - - - - - - 2 - 0 - - - - - - - - - 2 - 0 - - - - - - - - - 1 - 0 - - - - Script - - - langCombo - - - - - - - - 1 - 0 - - - - Shaper type - - - shaperTypeCombo - - - - - - - - - - - 0 - 0 - - - - Use shaper - - - - - - - Qt::Horizontal - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - QAbstractItemView::NoEditTriggers - - - true - - - - 1 - - - - - - - - + + + + + Qt::Horizontal - 80 - 20 + 176 + 24 - - + + Qt::Horizontal @@ -663,254 +136,91 @@ - - - - - 0 - 0 - - - - - 1000 - 24 - - - - Edit sample text - - - Edit - - + +
+ + + + + + 0 + + + 0 + + + + + 4 + + + + + 3 + + + 3 + + + 3 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 11 + + + + Save + + + + + + + + 11 + + + + clear + + + + - - - + + + - - - - :/fontmatrix_glypg.png:/fontmatrix_glypg.png - - - Glyphs - - - - - - - - - 0 - 0 - - - - Coverage of Unicode Interval - - - Block: - - - 2 - - - uniPlaneCombo - - - - - - - - 0 - 0 - - - - true - - - QComboBox::AdjustToContents - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Search: - - - charSearchLine - - - - - - - Search a character by its codepoint (expressed in hexadecimal -and prefixed with "U+", "u+" or "+") or a glyph by its name. -Press enter after editing to run the search. - - - - - - - - - - - - - - - - 0 - 2 - - - - Qt::NoFocus - - - Clicking on a glyph will show details about it - - - QFrame::NoFrame - - - Qt::IntersectsItemBoundingRect - - - - - - - - - - 0 - 0 - - - - Set Mode "Copy Character to Clipboard" - - - Copy Mode - - - - :/action-copy-char:/action-copy-char - - - true - - - Qt::ToolButtonTextOnly - - - true - - - - - - - - - - - - - - :/fontmatrix_playground.png:/fontmatrix_playground.png - - - Playground - - - - - - QFrame::NoFrame - - - - - - - Font Size: - - - playFontSize - - - - - - - pt - - - 1.000000000000000 - - - 999.990000000000009 - - - 24.000000000000000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - :/fontmatrix_compare.png:/fontmatrix_compare.png - - - Compare - - + + + + 0 + - + @@ -920,60 +230,23 @@ - QWebView - QWidget -
QtWebKit/QWebView
- 1 -
- - FMSampleTextView - QGraphicsView -
fmsampletextview.h
-
- - FMGlyphsView - QGraphicsView -
fmglyphsview.h
-
- - TextProgression - QWidget -
textprogression.h
- 1 -
- - FMPlayGround - QGraphicsView -
fmplayground.h
-
- - FMVerticalButton - QToolButton -
fmverticalbutton.h
+ FMPreviewView + QListView +
fmpreviewlist.h
- FontCompareWidget + FamilyWidget QWidget -
fontcomparewidget.h
+
familywidget.h
1
- FMAltSelector + FilterBar QWidget -
fmaltselector.h
+
filterbar.h
1
- - openTypeButton - shaperTypeCombo - langCombo - playView - settingsButton - playFontSize - saveDefOTFBut - resetDefOTFBut - diff -Nru fontmatrix-0.6.0+svn20100107/src/mainviewwidget.cpp fontmatrix-0.6.0+svn20110930/src/mainviewwidget.cpp --- fontmatrix-0.6.0+svn20100107/src/mainviewwidget.cpp 2009-11-20 14:59:52.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/mainviewwidget.cpp 2011-02-08 14:43:38.000000000 +0000 @@ -32,8 +32,8 @@ #include "fmpreviewlist.h" #include "fmuniblocks.h" #include "fontitem.h" -#include "listdockwidget.h" -#include "opentypetags.h" +//#include "listdockwidget.h" +//#include "opentypetags.h" #include "panosematch.h" #include "systray.h" #include "typotek.h" @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -76,603 +77,440 @@ MainViewWidget::MainViewWidget ( QWidget *parent ) - : QWidget ( parent ) + : QWidget ( parent ) { setupUi ( this ); - + filterBar->setFilterListLayout(filterListLayout); + filterBar->setCurFilterWidget(curFilterWidget); + curFilterWidget->setVisible(false); + quickSearchWidget->setVisible(false); + + quickSearchWait = 4000; + quickSearchTimer = 0; m_forceReloadSelection = false; - uRangeIsNotEmpty = false; - currentFonts.clear(); + FMFontDb::DB()->clearFilteredFonts(); + + listView->setNumCol(4); + listView->setModelColumn(1); + listView->setViewMode(QListView::IconMode); + listView->setIconSize(QSize(qRound(listView->width() ), 1.3 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0)); + listView->setUniformItemSizes(true); + listView->setMovement(QListView::Static); + + previewModel = new FMPreviewModel( this, listView ); + previewModel->setSpecString(""); + previewModel->setFamilyMode(true); + listView->setModel(previewModel); + - QSettings settings; - sampleFontSize = settings.value("Sample/FontSize", 14.0).toDouble(); - sampleInterSize = settings.value("Sample/Interline", 18.0).toDouble(); - sampleRatio = sampleInterSize / sampleFontSize ; - liveFontSizeSpin->setValue(sampleFontSize); iconPS1 = QIcon(":/icon-PS1"); iconTTF = QIcon(":/icon-TTF"); iconOTF = QIcon(":/icon-OTF"); - - unMapGlyphName = tr("Un-Mapped Glyphs"); - allMappedGlyphName = tr("View all mapped glyphs"); - - textLayout = FMLayout::getLayout(); - - radioRenderGroup = new QButtonGroup(); - radioRenderGroup->addButton(freetypeRadio); - radioRenderGroup->addButton(nativeRadio); - stackedTools->setCurrentIndex(VIEW_PAGE_SAMPLES); - toolPanelWidth = splitter_2->sizes().at(1); - restoreSplitterState(); - if(toolPanelWidth == 0) - { - sampleButton->setChecked(false); - stackedTools->hide(); - toolPanelWidth = splitter_2->width()/3; - } - radioFTHintingGroup = new QButtonGroup(freetypeRadio); - radioFTHintingGroup->addButton(noHinting); - radioFTHintingGroup->addButton(lightHinting); - radioFTHintingGroup->addButton(normalHinting); + theVeryFont = 0; typo = typotek::getInstance(); - m_lists = ListDockWidget::getInstance(); -// currentFonts = typo->getAllFonts(); - currentFonts = FMFontDb::DB()->AllFonts(); +// m_lists = ListDockWidget::getInstance(); + // currentFonts = typo->getAllFonts(); + FMFontDb::DB()->filterAllFonts(); fontsetHasChanged = true; - curGlyph = 0; - fancyGlyphInUse = -1; + QSettings settings; activateByFamilyOnly = settings.value("ActivateOnlyFamily", false).toBool(); - m_lists->actFacesButton->setChecked(!activateByFamilyOnly); - -// fillUniPlanes(); - refillSampleList(); - uniLine->setEnabled(false); - - fontInfoText->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); - - abcScene = new QGraphicsScene; - loremScene = new QGraphicsScene; - ftScene = new QGraphicsScene; - playScene = new QGraphicsScene; - QRectF pageRect ( 0,0,597.6,842.4 ); //TODO find means to smartly decide of page size (here, iso A4) - - loremScene->setSceneRect ( pageRect ); -// QGraphicsRectItem *backp = loremScene->addRect ( pageRect,QPen(),Qt::white ); -// backp->setEnabled ( false ); - - ftScene->setSceneRect ( 0,0, 597.6 * typotek::getInstance()->getDpiX() / 72.0, 842.4 * typotek::getInstance()->getDpiX() / 72.0); - - - abcView->setScene ( abcScene ); - abcView->setRenderHint ( QPainter::Antialiasing, true ); - - loremView->setScene ( loremScene ); - loremView->locker = false; - double horiScaleT (typotek::getInstance()->getDpiX() / 72.0); - double vertScaleT ( typotek::getInstance()->getDpiY() / 72.0); - QTransform adjustAbsoluteViewT( horiScaleT , 0, 0,vertScaleT, 0, 0 ); - loremView->setTransform ( adjustAbsoluteViewT , false ); - - loremView_FT->setScene ( ftScene ); - loremView_FT->locker = false; - loremView_FT->fakePage(); - - playScene->setSceneRect ( 0,0,10000,10000 ); - playView->setScene( playScene ); - - sampleText= typo->namedSample (typo->defaultSampleName()); - - - QMap sTypes(FMShaperFactory::types()); - for(QMap::iterator sIt = sTypes.begin(); sIt != sTypes.end() ; ++sIt) - { - shaperTypeCombo->addItem(sIt.key(), sIt.value()); - } - currentOrdering = "family" ; - - QStringListModel* cslModel(new QStringListModel); - QCompleter* cslCompleter(new QCompleter(charSearchLine)); - cslCompleter->setModel(cslModel); - charSearchLine->setCompleter(cslCompleter); - doConnect(); + listView->setFocus(Qt::OtherFocusReason); } MainViewWidget::~MainViewWidget() { + delete filterBar; } void MainViewWidget::doConnect() { - connect(FMActivate::getInstance(), SIGNAL(activationEvent(const QStringList&)), this, SLOT(refreshActStatus(const QStringList&))); - - connect ( m_lists->fontTree,SIGNAL ( itemClicked ( QTreeWidgetItem*, int ) ),this,SLOT ( slotFontSelected ( QTreeWidgetItem*, int ) ) ); - connect ( m_lists->fontTree,SIGNAL ( currentChanged (QTreeWidgetItem*, int ) ), this,SLOT (slotFontSelected ( QTreeWidgetItem*, int ) ) ); - connect ( m_lists->searchString,SIGNAL ( returnPressed() ),this,SLOT ( slotSearch() ) ); - connect ( m_lists->viewAllButton,SIGNAL ( released() ),this,SLOT ( slotViewAll() ) ); - connect ( m_lists->fontTree,SIGNAL ( itemExpanded ( QTreeWidgetItem* ) ),this,SLOT ( slotItemOpened ( QTreeWidgetItem* ) ) ); - connect ( m_lists->tagsCombo,SIGNAL ( activated ( const QString& ) ),this,SLOT ( slotFilterTag ( QString ) ) ); - connect ( m_lists, SIGNAL(folderSelectFont(const QString&)), this, SLOT(slotSelectFromFolders(const QString&))); - connect ( this, SIGNAL(listChanged()), m_lists, SLOT(slotPreviewUpdate())); - connect ( m_lists->actFacesButton, SIGNAL(toggled( bool )), this, SLOT(toggleFacesCheckBoxes(bool)) ); - - connect ( this, SIGNAL(listChanged()), typo, SLOT(showToltalFilteredFonts())); - - connect( fontInfoText, SIGNAL(linkClicked ( const QUrl& )), this, SLOT(slotWebLink(const QUrl&))); - connect( fontInfoText, SIGNAL(loadStarted () ),this,SLOT(slotWebStart())); - connect( fontInfoText, SIGNAL(loadProgress ( int ) ),this, SLOT(slotWebLoad(int))); - connect( fontInfoText, SIGNAL(loadFinished ( bool ) ),this,SLOT(slotWebFinished(bool))); - - connect (radioRenderGroup,SIGNAL(buttonClicked( QAbstractButton* )),this,SLOT(slotChangeViewPage(QAbstractButton*))); - connect (radioFTHintingGroup, SIGNAL(buttonClicked(int)),this,SLOT(slotHintChanged(int))); - - connect (openTypeButton,SIGNAL(clicked( bool )),this,SLOT(slotChangeViewPageSetting( bool ))); - connect (settingsButton,SIGNAL(clicked( bool )),this,SLOT(slotChangeViewPageSetting( bool ))); - connect (sampleButton,SIGNAL(clicked( bool )),this,SLOT(slotChangeViewPageSetting( bool ))); - - connect ( abcView,SIGNAL ( pleaseShowSelected() ),this,SLOT ( slotShowOneGlyph() ) ); - connect ( abcView,SIGNAL ( pleaseShowAll() ),this,SLOT ( slotShowAllGlyph() ) ); - connect ( abcView,SIGNAL ( refit ( int ) ),this,SLOT ( slotAdjustGlyphView ( int ) ) ); - connect ( abcView, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateGView())); - connect ( abcView, SIGNAL(pleaseUpdateSingle()), this, SLOT(slotUpdateGViewSingle())); - connect ( uniPlaneCombo,SIGNAL ( activated ( int ) ),this,SLOT ( slotPlaneSelected ( int ) ) ); - connect ( clipboardCheck, SIGNAL (toggled ( bool )),this,SLOT(slotShowULine(bool))); - connect ( charSearchLine, SIGNAL(returnPressed()), this, SLOT(slotSearchCharName())); - - connect ( loremView, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateSView())); - connect ( loremView, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); - - - connect ( loremView_FT, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); - connect ( loremView_FT, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateRView())); - - connect ( textLayout, SIGNAL(updateLayout()),this, SLOT(slotView())); - connect ( this, SIGNAL(stopLayout()), textLayout,SLOT(stopLayout())); + connect(familyWidget, SIGNAL(familyStateChanged()), previewModel, SLOT(dataChanged())); - connect ( playView, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); - - - connect ( sampleTextTree,SIGNAL ( itemSelectionChanged ()),this,SLOT ( slotSampleChanged() ) ); - connect ( sampleTextButton, SIGNAL(released()),this, SLOT(slotEditSampleText())); - connect ( liveFontSizeSpin, SIGNAL( editingFinished() ),this,SLOT(slotLiveFontSize())); - - connect ( OpenTypeTree, SIGNAL ( itemClicked ( QTreeWidgetItem*, int ) ), this, SLOT ( slotFeatureChanged() ) ); - connect ( saveDefOTFBut, SIGNAL(released()),this,SLOT(slotDefaultOTF())); - connect ( resetDefOTFBut, SIGNAL(released()),this,SLOT(slotResetOTF())); - connect ( shaperTypeCombo,SIGNAL ( activated ( int ) ),this,SLOT ( slotChangeScript() ) ); - connect ( langCombo,SIGNAL ( activated ( int ) ),this,SLOT ( slotChangeScript() ) ); - - connect ( textProgression, SIGNAL ( stateChanged ( ) ),this ,SLOT(slotProgressionChanged())); - connect ( useShaperCheck,SIGNAL ( stateChanged ( int ) ),this,SLOT ( slotWantShape() ) ); - - - connect( PanoseWidget::getInstance(), SIGNAL(filterChanged(QMap >)), this, SLOT(slotPanoseFilter(QMap >))); + connect(filterBar,SIGNAL(filterChanged()),previewModel,SLOT(dataChanged())); + connect(filterBar,SIGNAL(filterChanged()),typo, SLOT(showToltalFilteredFonts())); + connect(saveButton, SIGNAL(clicked()), filterBar, SLOT(slotSaveFilter())); + connect(clearButton, SIGNAL(clicked()), filterBar, SLOT(slotClearFilter())); + + + connect(listView, SIGNAL(widthChanged(int)),this,SLOT(slotPreviewUpdateSize(int))); + connect(listView, SIGNAL(activated(const QModelIndex&)), this, SLOT(slotShowFamily(const QModelIndex&))); + connect(familyWidget, SIGNAL(backToList()), this, SLOT(slotQuitFamily())); + connect(familyWidget, SIGNAL(fontSelected(const QString&)), this, SLOT(slotFontSelectedByName(const QString&))); + + connect(quickSearch, SIGNAL(textEdited(QString)), this, SLOT(slotQuickSearch(QString))); + connect(quickSearch, SIGNAL(returnPressed()), this, SLOT(slotSelectFromQuickSearch())); + connect(listView, SIGNAL(keyPressed(QString)), this, SLOT(slotQuickSearch(QString))); } void MainViewWidget::disConnect() { - disconnect(FMActivate::getInstance(), SIGNAL(activationEvent(const QStringList&)), this, SLOT(refreshActStatus(const QStringList&))); - - disconnect ( m_lists->fontTree,SIGNAL ( itemClicked ( QTreeWidgetItem*, int ) ),this,SLOT ( slotFontSelected ( QTreeWidgetItem*, int ) ) ); - disconnect ( m_lists->fontTree,SIGNAL ( currentChanged (QTreeWidgetItem*, int ) ), this,SLOT (slotFontSelected ( QTreeWidgetItem*, int ) ) ); - disconnect ( m_lists->searchString,SIGNAL ( returnPressed() ),this,SLOT ( slotSearch() ) ); - disconnect ( m_lists->viewAllButton,SIGNAL ( released() ),this,SLOT ( slotViewAll() ) ); - disconnect ( m_lists->fontTree,SIGNAL ( itemExpanded ( QTreeWidgetItem* ) ),this,SLOT ( slotItemOpened ( QTreeWidgetItem* ) ) ); - disconnect ( m_lists->tagsCombo,SIGNAL ( activated ( const QString& ) ),this,SLOT ( slotFilterTag ( QString ) ) ); - disconnect ( m_lists, SIGNAL(folderSelectFont(const QString&)), this, SLOT(slotSelectFromFolders(const QString&))); - disconnect ( this, SIGNAL(listChanged()), m_lists, SLOT(slotPreviewUpdate())); - disconnect ( m_lists->actFacesButton, SIGNAL(toggled( bool )), this, SLOT(toggleFacesCheckBoxes(bool)) ); - - disconnect ( this, SIGNAL(listChanged()), typo, SLOT(showToltalFilteredFonts())); - - disconnect( fontInfoText, SIGNAL(linkClicked ( const QUrl& )), this, SLOT(slotWebLink(const QUrl&))); - disconnect( fontInfoText, SIGNAL(loadStarted () ),this,SLOT(slotWebStart())); - disconnect( fontInfoText, SIGNAL(loadProgress ( int ) ),this, SLOT(slotWebLoad(int))); - disconnect( fontInfoText, SIGNAL(loadFinished ( bool ) ),this,SLOT(slotWebFinished(bool))); - - disconnect (radioRenderGroup,SIGNAL(buttonClicked( QAbstractButton* )),this,SLOT(slotChangeViewPage(QAbstractButton*))); - disconnect (radioFTHintingGroup, SIGNAL(buttonClicked(int)),this,SLOT(slotHintChanged(int))); - - disconnect (openTypeButton,SIGNAL(clicked( bool )),this,SLOT(slotChangeViewPageSetting( bool ))); - disconnect (settingsButton,SIGNAL(clicked( bool )),this,SLOT(slotChangeViewPageSetting( bool ))); - disconnect (sampleButton,SIGNAL(clicked( bool )),this,SLOT(slotChangeViewPageSetting( bool ))); - - disconnect ( abcView,SIGNAL ( pleaseShowSelected() ),this,SLOT ( slotShowOneGlyph() ) ); - disconnect ( abcView,SIGNAL ( pleaseShowAll() ),this,SLOT ( slotShowAllGlyph() ) ); - disconnect ( abcView,SIGNAL ( refit ( int ) ),this,SLOT ( slotAdjustGlyphView ( int ) ) ); - disconnect ( abcView, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateGView())); - disconnect ( abcView, SIGNAL(pleaseUpdateSingle()), this, SLOT(slotUpdateGViewSingle())); - disconnect ( uniPlaneCombo,SIGNAL ( activated ( int ) ),this,SLOT ( slotPlaneSelected ( int ) ) ); - disconnect ( clipboardCheck, SIGNAL (toggled ( bool )),this,SLOT(slotShowULine(bool))); - disconnect ( charSearchLine, SIGNAL(returnPressed()), this, SLOT(slotSearchCharName())); - - disconnect ( loremView, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateSView())); - disconnect ( loremView, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); - - - disconnect ( loremView_FT, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); - disconnect ( loremView_FT, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateRView())); - - disconnect ( textLayout, SIGNAL(updateLayout()),this, SLOT(slotView())); - disconnect ( this, SIGNAL(stopLayout()), textLayout,SLOT(stopLayout())); - - disconnect ( playView, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); - - - disconnect ( sampleTextTree,SIGNAL ( itemSelectionChanged() ),this,SLOT ( slotSampleChanged() ) ); - disconnect ( sampleTextButton, SIGNAL(released()),this, SLOT(slotEditSampleText())); - disconnect ( liveFontSizeSpin, SIGNAL( editingFinished() ),this,SLOT(slotLiveFontSize())); - - disconnect ( OpenTypeTree, SIGNAL ( itemClicked ( QTreeWidgetItem*, int ) ), this, SLOT ( slotFeatureChanged() ) ); - disconnect ( saveDefOTFBut, SIGNAL(released()),this,SLOT(slotDefaultOTF())); - disconnect ( resetDefOTFBut, SIGNAL(released()),this,SLOT(slotResetOTF())); - disconnect ( shaperTypeCombo,SIGNAL ( activated ( int ) ),this,SLOT ( slotChangeScript() ) ); - disconnect ( langCombo,SIGNAL ( activated ( int ) ),this,SLOT ( slotChangeScript() ) ); - - disconnect ( textProgression, SIGNAL ( stateChanged ( ) ),this ,SLOT(slotProgressionChanged())); - disconnect ( useShaperCheck,SIGNAL ( stateChanged ( int ) ),this,SLOT ( slotWantShape() ) ); - - disconnect( PanoseWidget::getInstance(), SIGNAL(filterChanged(QMap >)), this, SLOT(slotPanoseFilter(QMap >))); -} + disconnect(familyWidget, SIGNAL(familyStateChanged()), previewModel, SLOT(dataChanged())); -void MainViewWidget::fillTree() -{ -// qDebug()<< "MainViewWidget::fillTree("<< curItemName <<")"; -// QTime fillTime(0, 0, 0, 0); -// fillTime.start(); - m_lists->savePosition(); - QTreeWidgetItem *curItem = 0; - - // We log expanded families item - openKeys.clear(); - for ( int i=0; i < m_lists->fontTree->topLevelItemCount();++i ) - { - QTreeWidgetItem *topit = m_lists->fontTree->topLevelItem ( i ); - for ( int j=0;j < topit->childCount();++j ) - if ( topit->child ( j )->isExpanded() ) - openKeys << topit->child ( j )->text ( 0 ); - } - m_lists->fontTree->clear(); - -// qDebug("LOGS Time elapsed: %d ms", fillTime.elapsed()); -// fillTime.restart(); - - // build the in-memory tree that hold the ordered current fonts set - QMap< QChar,QMap< QString,QMap< QString,FontItem*> > > keyList; - QMap< QString,QString > realFamilyName; - orderedCurrentFonts.clear(); - for ( int i=0; i < currentFonts.count();++i ) - { - QString family = currentFonts[i]->family(); - QString ordFamily = family.toUpper(); - QString variant = currentFonts[i]->variant(); - if( keyList.contains(ordFamily[0]) && keyList[ordFamily[0]].contains(ordFamily) && keyList[ordFamily[0]][ordFamily].contains(variant) ) - { - int unique = 2; - QString uniString(variant +" -%1"); - while(keyList[ordFamily[0]][ordFamily].contains(uniString.arg(unique,2))) - { - ++unique; - } - variant = uniString.arg(unique,2); - } - keyList[ordFamily[0]][ordFamily][variant] = ( currentFonts[i] ); - realFamilyName[ordFamily] = family; - } - -// qDebug("MULTI Time elapsed: %d ms", fillTime.elapsed()); -// fillTime.restart(); - - // Rebuild the the tree - QFont alphaFont ( "helvetica",14,QFont::Bold,false ); - - QMap< QChar,QMap< QString,QMap< QString,FontItem*> > >::const_iterator kit; - QMap< QString,QMap< QString,FontItem*> >::const_iterator oit; - QMap< QString,FontItem*>::const_iterator fit; - -// QTime tt(0,0); -// tt.start(); -// int tttotal(0); -// int tcount(0); - - QMap act ; - FMFontDb::DB()->TransactionBegin(); - for( kit = keyList.constBegin() ; kit != keyList.constEnd() ; ++kit ) - { - for (oit = kit.value().constBegin(); oit != kit.value().constEnd(); ++ oit ) - { - for(fit = oit.value().constBegin(); fit != oit.value().constEnd(); ++fit) - { - act[fit.value()] = fit.value()->isActivated(); - } - } - } - FMFontDb::DB()->TransactionEnd(); + disconnect(filterBar,SIGNAL(filterChanged()),previewModel,SLOT(dataChanged())); + disconnect(filterBar,SIGNAL(filterChanged()),typo, SLOT(showToltalFilteredFonts())); + disconnect(saveButton, SIGNAL(clicked()), filterBar, SLOT(slotSaveFilter())); + disconnect(clearButton, SIGNAL(clicked()), filterBar, SLOT(slotClearFilter())); + + disconnect(listView, SIGNAL(widthChanged(int)),this,SLOT(slotPreviewUpdateSize(int))); + disconnect(listView, SIGNAL(activated(const QModelIndex&)), this, SLOT(slotShowFamily(const QModelIndex&))); + disconnect(familyWidget, SIGNAL(backToList()), this, SLOT(slotQuitFamily())); + disconnect(familyWidget, SIGNAL(fontSelected(const QString&)), this, SLOT(slotFontSelectedByName(const QString&))); + + disconnect(quickSearch, SIGNAL(textEdited(QString)), this, SLOT(slotQuickSearch(QString))); +} + +//void MainViewWidget::fillTree() +//{ +// // qDebug()<< "MainViewWidget::fillTree("<< curItemName <<")"; +// // QTime fillTime(0, 0, 0, 0); +// // fillTime.start(); +//// m_lists->savePosition(); +// QTreeWidgetItem *curItem = 0; + +// // We log expanded families item +// openKeys.clear(); +// for ( int i=0; i < m_lists->fontTree->topLevelItemCount();++i ) +// { +// QTreeWidgetItem *topit = m_lists->fontTree->topLevelItem ( i ); +// for ( int j=0;j < topit->childCount();++j ) +// if ( topit->child ( j )->isExpanded() ) +// openKeys << topit->child ( j )->text ( 0 ); +// } +// m_lists->fontTree->clear(); + +// // qDebug("LOGS Time elapsed: %d ms", fillTime.elapsed()); +// // fillTime.restart(); + +// // build the in-memory tree that hold the ordered current fonts set +// QMap< QChar,QMap< QString,QMap< QString,FontItem*> > > keyList; +// QMap< QString,QString > realFamilyName; +// orderedCurrentFonts.clear(); +// QList currentFonts(FMFontDb::DB()->getFilteredFonts()); +// int cfi(currentFonts.count()); +// for ( int i=0; i < cfi;++i ) +// { +// QString family = currentFonts[i]->family(); +// QString ordFamily = family.toUpper(); +// QString variant = currentFonts[i]->variant(); +// if( keyList.contains(ordFamily[0]) && keyList[ordFamily[0]].contains(ordFamily) && keyList[ordFamily[0]][ordFamily].contains(variant) ) +// { +// int unique = 2; +// QString uniString(variant +" -%1"); +// while(keyList[ordFamily[0]][ordFamily].contains(uniString.arg(unique,2))) +// { +// ++unique; +// } +// variant = uniString.arg(unique,2); +// } +// keyList[ordFamily[0]][ordFamily][variant] = ( currentFonts[i] ); +// realFamilyName[ordFamily] = family; +// } + +// // qDebug("MULTI Time elapsed: %d ms", fillTime.elapsed()); +// // fillTime.restart(); + +// // Rebuild the the tree +// QFont alphaFont ( "helvetica",14,QFont::Bold,false ); + +// QMap< QChar,QMap< QString,QMap< QString,FontItem*> > >::const_iterator kit; +// QMap< QString,QMap< QString,FontItem*> >::const_iterator oit; +// QMap< QString,FontItem*>::const_iterator fit; + +// // QTime tt(0,0); +// // tt.start(); +// // int tttotal(0); +// // int tcount(0); + +// QMap act ; +// FMFontDb::DB()->TransactionBegin(); +// for( kit = keyList.constBegin() ; kit != keyList.constEnd() ; ++kit ) +// { +// for (oit = kit.value().constBegin(); oit != kit.value().constEnd(); ++ oit ) +// { +// for(fit = oit.value().constBegin(); fit != oit.value().constEnd(); ++fit) +// { +// act[fit.value()] = fit.value()->isActivated(); +// } +// } +// } +// FMFontDb::DB()->TransactionEnd(); - for( kit = keyList.constBegin() ; kit != keyList.constEnd() ; ++kit ) - { - QChar firstChar ( kit.key() ); - QTreeWidgetItem *alpha = new QTreeWidgetItem ( m_lists->fontTree ); - alpha->setText ( 0, firstChar ); - alpha->setFont ( 0, alphaFont ); - alpha->setData ( 0,100,"alpha" ); - alpha->setBackgroundColor ( 0,Qt::lightGray ); - alpha->setBackgroundColor ( 1,Qt::lightGray ); - bool alphaIsUsed = false; - for (oit = kit.value().constBegin(); oit != kit.value().constEnd(); ++ oit ) - { +// for( kit = keyList.constBegin() ; kit != keyList.constEnd() ; ++kit ) +// { +// QChar firstChar ( kit.key() ); +// QTreeWidgetItem *alpha = new QTreeWidgetItem ( m_lists->fontTree ); +// alpha->setText ( 0, firstChar ); +// alpha->setFont ( 0, alphaFont ); +// alpha->setData ( 0,100,"alpha" ); +// alpha->setBackgroundColor ( 0,Qt::lightGray ); +// alpha->setBackgroundColor ( 1,Qt::lightGray ); +// bool alphaIsUsed = false; +// for (oit = kit.value().constBegin(); oit != kit.value().constEnd(); ++ oit ) +// { - QString fam( realFamilyName[oit.key()] ); - bool isExpanded = false; - QTreeWidgetItem *ord = new QTreeWidgetItem ( alpha ); +// QString fam( realFamilyName[oit.key()] ); +// bool isExpanded = false; +// QTreeWidgetItem *ord = new QTreeWidgetItem ( alpha ); - ord->setData ( 0,100,"family" ); - ord->setCheckState ( 0,Qt::Unchecked ); - bool chekno = false; - bool checkyes = false; - if ( openKeys.contains ( fam ) ) - { - ord->setExpanded ( true ); - isExpanded = true; - } - - for(fit = oit.value().constBegin(); fit != oit.value().constEnd(); ++fit) - { -// ++tcount; -// tt.restart(); - FontItem *fPointer = fit.value(); - orderedCurrentFonts << fPointer; - QString var( fit.key() ); - if(typo->isSysFont(fit.value())) - var+="*"; - QTreeWidgetItem *entry = new QTreeWidgetItem ( ord ); - entry->setText ( 0, var ); -// entry->setText ( 1, fPointer->path() ); - entry->setToolTip( 0, fPointer->path() ); - entry->setData ( 0, 100, "fontfile" ); - if(/*fPointer->isLocked() ||*/ fPointer->isRemote() ) - { - entry->setFlags(Qt::ItemIsSelectable); - } - - if(fPointer->type() == "CFF") - entry->setIcon(0, iconOTF ); - else if(fPointer->type() == "TrueType") - entry->setIcon(0, iconTTF); - else if(fPointer->type() == "Type 1") - entry->setIcon(0, iconPS1); +// ord->setData ( 0,100,"family" ); +// ord->setCheckState ( 0,Qt::Unchecked ); +// bool chekno = false; +// bool checkyes = false; +// if ( openKeys.contains ( fam ) ) +// { +// ord->setExpanded ( true ); +// isExpanded = true; +// } + +// for(fit = oit.value().constBegin(); fit != oit.value().constEnd(); ++fit) +// { +// // ++tcount; +// // tt.restart(); +// FontItem *fPointer = fit.value(); +// orderedCurrentFonts << fPointer; +// QString var( fit.key() ); +// if(typo->isSysFont(fit.value())) +// var+="*"; +// QTreeWidgetItem *entry = new QTreeWidgetItem ( ord ); +// entry->setText ( 0, var ); +// // entry->setText ( 1, fPointer->path() ); +// entry->setToolTip( 0, fPointer->path() ); +// entry->setData ( 0, 100, "fontfile" ); +// if(/*fPointer->isLocked() ||*/ fPointer->isRemote() ) +// { +// entry->setFlags(Qt::ItemIsSelectable); +// } + +// if(fPointer->type() == "CFF") +// entry->setIcon(0, iconOTF ); +// else if(fPointer->type() == "TrueType") +// entry->setIcon(0, iconTTF); +// else if(fPointer->type() == "Type 1") +// entry->setIcon(0, iconPS1); - if ( act[fPointer] ) - { - checkyes = true; - } - else - { - chekno = true; - } - if( !activateByFamilyOnly ) - { - entry->setCheckState ( 0 , act[fPointer] ? Qt::Checked : Qt::Unchecked ); - } +// if ( act[fPointer] ) +// { +// checkyes = true; +// } +// else +// { +// chekno = true; +// } +// if( !activateByFamilyOnly ) +// { +// entry->setCheckState ( 0 , act[fPointer] ? Qt::Checked : Qt::Unchecked ); +// } - entry->setData ( 0,200, entry->checkState ( 0 ) ); +// entry->setData ( 0,200, entry->checkState ( 0 ) ); - if ( entry->toolTip( 0 ) == curItemName ) - curItem = entry; -// tttotal += tt.elapsed(); - } - - if ( checkyes && chekno ) - ord->setCheckState ( 0,Qt::PartiallyChecked ); - else if ( checkyes ) - ord->setCheckState ( 0,Qt::Checked ); - // track checkState - ord->setData ( 0,200,ord->checkState ( 0 ) ); - ord->setText ( 0, fam + " ["+ QString::number ( ord->childCount() ) +"]"); -// ord->setText ( 1, QString::number ( ord->childCount() ) ); - alphaIsUsed = true; +// if ( entry->toolTip( 0 ) == curItemName ) +// curItem = entry; +// // tttotal += tt.elapsed(); +// } - } - if ( alphaIsUsed ) - { - m_lists->fontTree->addTopLevelItem ( alpha ); - alpha->setExpanded ( true ); - } - else - { - delete alpha; - } - } -// qDebug()<<"SUB TREE Time Total: "<setCheckState ( 0,Qt::PartiallyChecked ); +// else if ( checkyes ) +// ord->setCheckState ( 0,Qt::Checked ); +// // track checkState +// ord->setData ( 0,200,ord->checkState ( 0 ) ); +// ord->setText ( 0, fam + " ["+ QString::number ( ord->childCount() ) +"]"); +// // ord->setText ( 1, QString::number ( ord->childCount() ) ); +// alphaIsUsed = true; -// m_lists->previewList->slotRefill ( currentFonts, fontsetHasChanged ); - if ( curItem ) - { -// qDebug() << "get curitem : " << curItem->text ( 0 ) << curItem->text ( 1 ); - m_lists->restorePosition(); - if( !m_lists->nameItemIsVisible(curItem) ) - { - m_lists->fontTree->scrollToItem ( curItem, QAbstractItemView::PositionAtCenter ); - } +// } +// if ( alphaIsUsed ) +// { +// m_lists->fontTree->addTopLevelItem ( alpha ); +// alpha->setExpanded ( true ); +// } +// else +// { +// delete alpha; +// } +// } +// // qDebug()<<"SUB TREE Time Total: "<previewList->slotRefill ( currentFonts, fontsetHasChanged ); +// if ( curItem ) +// { +// // qDebug() << "get curitem : " << curItem->text ( 0 ) << curItem->text ( 1 ); +// m_lists->restorePosition(); +// if( !m_lists->nameItemIsVisible(curItem) ) +// { +// m_lists->fontTree->scrollToItem ( curItem, QAbstractItemView::PositionAtCenter ); +// } -// // QColor scol (255,240,221,255); -// // QColor pcol (255,211,155,255); -// QColor scol (QApplication::palette().highlight().color()); -// QColor pcol (scol); -// QFont selFont; -// selFont.setBold(true); -// curItem->parent()->setBackgroundColor ( 0,pcol ); -// curItem->parent()->setBackgroundColor ( 1,pcol ); -// curItem->parent()->setFont(0, selFont); -// curItem->setBackgroundColor ( 0,scol ); -// // curItem->setBackgroundColor ( 1,scol ); -// curItem->setFont(0,selFont); - QFont selFont; - selFont.setBold ( true ); - curItem->parent()->setFont ( 0, selFont ); - curItem->setSelected(true); - } - else - { - qDebug() << "NO CURITEM"; - } - m_lists->fontTree->resizeColumnToContents ( 0 ) ; -// m_lists->fontTree->resizeColumnToContents ( 1 ) ; -// m_lists->fontTree->setColumnWidth(0,200); - - fontsetHasChanged = false; - listChanged(); -// m_lists->slotPreviewUpdate(); -// qDebug("END Time elapsed: %d ms", fillTime.elapsed()); -} - -void MainViewWidget::updateTree ( bool checkFontActive ) -{ - QTreeWidgetItem *curItem = 0; - QFont deselect; - int topCount ( m_lists->fontTree->topLevelItemCount() ); - for ( int topIdx ( 0 ) ; topIdx < topCount; ++topIdx ) - { - QTreeWidgetItem *topItem ( m_lists->fontTree->topLevelItem ( topIdx ) ); - int famCount ( topItem->childCount() ); - for ( int famIdx ( 0 ); famIdx < famCount; ++ famIdx ) - { - QTreeWidgetItem *famItem ( topItem->child ( famIdx ) ); - int varCount ( famItem->childCount() ); - for ( int varIdx ( 0 ); varIdx < varCount; ++ varIdx ) - { - QTreeWidgetItem *varItem ( famItem->child ( varIdx ) ); - if ( varItem->toolTip ( 0 ) == lastIndex ) - { - varItem->setFont ( 0, deselect ); - varItem->setBackgroundColor ( 0, Qt::transparent ); - varItem->setBackgroundColor ( 1, Qt::transparent ); - varItem->parent()->setFont ( 0, deselect ); - varItem->parent()->setBackgroundColor ( 0, Qt::transparent ); - varItem->parent()->setBackgroundColor ( 1, Qt::transparent ); - varItem->setSelected(false); - } - else if ( varItem->toolTip ( 0 ) == curItemName ) - { - curItem = varItem; - } - } - } - } +// // // QColor scol (255,240,221,255); +// // // QColor pcol (255,211,155,255); +// // QColor scol (QApplication::palette().highlight().color()); +// // QColor pcol (scol); +// // QFont selFont; +// // selFont.setBold(true); +// // curItem->parent()->setBackgroundColor ( 0,pcol ); +// // curItem->parent()->setBackgroundColor ( 1,pcol ); +// // curItem->parent()->setFont(0, selFont); +// // curItem->setBackgroundColor ( 0,scol ); +// // // curItem->setBackgroundColor ( 1,scol ); +// // curItem->setFont(0,selFont); +// QFont selFont; +// selFont.setBold ( true ); +// curItem->parent()->setFont ( 0, selFont ); +// curItem->setSelected(true); +// } +// else +// { +// qDebug() << "NO CURITEM"; +// } +// m_lists->fontTree->resizeColumnToContents ( 0 ) ; +// // m_lists->fontTree->resizeColumnToContents ( 1 ) ; +// // m_lists->fontTree->setColumnWidth(0,200); + +// fontsetHasChanged = false; +// listChanged(); +// // m_lists->slotPreviewUpdate(); +// // qDebug("END Time elapsed: %d ms", fillTime.elapsed()); +//} + +//void MainViewWidget::updateTree ( bool checkFontActive ) +//{ +// QTreeWidgetItem *curItem = 0; +// QFont deselect; +// int topCount ( m_lists->fontTree->topLevelItemCount() ); +// for ( int topIdx ( 0 ) ; topIdx < topCount; ++topIdx ) +// { +// QTreeWidgetItem *topItem ( m_lists->fontTree->topLevelItem ( topIdx ) ); +// int famCount ( topItem->childCount() ); +// for ( int famIdx ( 0 ); famIdx < famCount; ++ famIdx ) +// { +// QTreeWidgetItem *famItem ( topItem->child ( famIdx ) ); +// int varCount ( famItem->childCount() ); +// for ( int varIdx ( 0 ); varIdx < varCount; ++ varIdx ) +// { +// QTreeWidgetItem *varItem ( famItem->child ( varIdx ) ); +// if ( varItem->toolTip ( 0 ) == lastIndex ) +// { +// varItem->setFont ( 0, deselect ); +// varItem->setBackgroundColor ( 0, Qt::transparent ); +// varItem->setBackgroundColor ( 1, Qt::transparent ); +// varItem->parent()->setFont ( 0, deselect ); +// varItem->parent()->setBackgroundColor ( 0, Qt::transparent ); +// varItem->parent()->setBackgroundColor ( 1, Qt::transparent ); +// varItem->setSelected(false); +// } +// else if ( varItem->toolTip ( 0 ) == curItemName ) +// { +// curItem = varItem; +// } +// } +// } +// } - // Check if active - if ( checkFontActive ) - { - for ( int topIdx ( 0 ) ; topIdx < topCount; ++topIdx ) - { - QTreeWidgetItem *topItem ( m_lists->fontTree->topLevelItem ( topIdx ) ); - int famCount ( topItem->childCount() ); - for ( int famIdx ( 0 ); famIdx < famCount; ++ famIdx ) - { - QTreeWidgetItem *famItem ( topItem->child ( famIdx ) ); - int varCount ( famItem->childCount() ); - if ( famItem->isExpanded() ) - { - for ( int varIdx ( 0 ); varIdx < varCount; ++ varIdx ) - { - QTreeWidgetItem *varItem ( famItem->child ( varIdx ) ); - // Check if active - - QString s ( varItem->toolTip ( 0 ) ); - FontItem* f ( FMFontDb::DB()->Font ( s ) ); - if ( f && f->isActivated()) - { - if( !activateByFamilyOnly ) - varItem->setCheckState ( 0,Qt::Checked ); - } - else - { - if( !activateByFamilyOnly ) - varItem->setCheckState ( 0,Qt::Unchecked ); - } - } - } - } - } - } -// m_lists->previewList->slotRefill ( currentFonts, false ); - if ( curItem ) - { - QFont selFont; - selFont.setBold ( true ); - curItem->parent()->setFont ( 0, selFont ); - curItem->setSelected(true); - } - else - { - qDebug() << "NO CURITEM"; - } - if ( !m_lists->nameItemIsVisible ( curItem ) ) - { - m_lists->fontTree->scrollToItem ( curItem, QAbstractItemView::PositionAtCenter ); - } - fontsetHasChanged = false; -} - -void MainViewWidget::refreshActStatus(const QStringList& flist) -{ - if(flist.isEmpty()) - return; - QStringList l_flist(flist); - int topCount ( m_lists->fontTree->topLevelItemCount() ); - for ( int topIdx ( 0 ) ; topIdx < topCount; ++topIdx ) - { - QTreeWidgetItem *topItem ( m_lists->fontTree->topLevelItem ( topIdx ) ); - int famCount ( topItem->childCount() ); - for ( int famIdx ( 0 ); famIdx < famCount; ++ famIdx ) - { - QTreeWidgetItem *famItem ( topItem->child ( famIdx ) ); - int varCount ( famItem->childCount() ); - if ( famItem->isExpanded() ) - { - for ( int varIdx ( 0 ); varIdx < varCount; ++ varIdx ) - { - QTreeWidgetItem *varItem ( famItem->child ( varIdx ) ); - // Check if active - - QString s ( varItem->toolTip ( 0 ) ); - if(l_flist.contains(s)) - { - FontItem* f ( FMFontDb::DB()->Font ( s ) ); - if ( f && f->isActivated()) - varItem->setCheckState ( 0, Qt::Checked ); - else - varItem->setCheckState ( 0, Qt::Unchecked ); - - l_flist.removeAll(s); - if(l_flist.isEmpty()) - return; - } - } - } - } - } -} - -void MainViewWidget::slotItemOpened ( QTreeWidgetItem * item ) -{ -// if(item->data(0,100).toString() == "family") -// { -// slotFontSelected (item, 0); -// } -// -} +// // Check if active +// if ( checkFontActive ) +// { +// for ( int topIdx ( 0 ) ; topIdx < topCount; ++topIdx ) +// { +// QTreeWidgetItem *topItem ( m_lists->fontTree->topLevelItem ( topIdx ) ); +// int famCount ( topItem->childCount() ); +// for ( int famIdx ( 0 ); famIdx < famCount; ++ famIdx ) +// { +// QTreeWidgetItem *famItem ( topItem->child ( famIdx ) ); +// int varCount ( famItem->childCount() ); +// if ( famItem->isExpanded() ) +// { +// for ( int varIdx ( 0 ); varIdx < varCount; ++ varIdx ) +// { +// QTreeWidgetItem *varItem ( famItem->child ( varIdx ) ); +// // Check if active + +// QString s ( varItem->toolTip ( 0 ) ); +// FontItem* f ( FMFontDb::DB()->Font ( s ) ); +// if ( f && f->isActivated()) +// { +// if( !activateByFamilyOnly ) +// varItem->setCheckState ( 0,Qt::Checked ); +// } +// else +// { +// if( !activateByFamilyOnly ) +// varItem->setCheckState ( 0,Qt::Unchecked ); +// } +// } +// } +// } +// } +// } +// // m_lists->previewList->slotRefill ( currentFonts, false ); +// if ( curItem ) +// { +// QFont selFont; +// selFont.setBold ( true ); +// curItem->parent()->setFont ( 0, selFont ); +// curItem->setSelected(true); +// } +// else +// { +// qDebug() << "NO CURITEM"; +// } +// if ( !m_lists->nameItemIsVisible ( curItem ) ) +// { +// m_lists->fontTree->scrollToItem ( curItem, QAbstractItemView::PositionAtCenter ); +// } +// fontsetHasChanged = false; +//} + +//void MainViewWidget::refreshActStatus(const QStringList& flist) +//{ +// if(flist.isEmpty()) +// return; +// QStringList l_flist(flist); +// int topCount ( m_lists->fontTree->topLevelItemCount() ); +// for ( int topIdx ( 0 ) ; topIdx < topCount; ++topIdx ) +// { +// QTreeWidgetItem *topItem ( m_lists->fontTree->topLevelItem ( topIdx ) ); +// int famCount ( topItem->childCount() ); +// for ( int famIdx ( 0 ); famIdx < famCount; ++ famIdx ) +// { +// QTreeWidgetItem *famItem ( topItem->child ( famIdx ) ); +// int varCount ( famItem->childCount() ); +// if ( famItem->isExpanded() ) +// { +// for ( int varIdx ( 0 ); varIdx < varCount; ++ varIdx ) +// { +// QTreeWidgetItem *varItem ( famItem->child ( varIdx ) ); +// // Check if active + +// QString s ( varItem->toolTip ( 0 ) ); +// if(l_flist.contains(s)) +// { +// FontItem* f ( FMFontDb::DB()->Font ( s ) ); +// if ( f && f->isActivated()) +// varItem->setCheckState ( 0, Qt::Checked ); +// else +// varItem->setCheckState ( 0, Qt::Unchecked ); + +// l_flist.removeAll(s); +// if(l_flist.isEmpty()) +// return; +// } +// } +// } +// } +// } +//} void MainViewWidget::slotOrderingChanged ( QString s ) @@ -680,136 +518,136 @@ //Update "m_lists->fontTree" -// currentFonts = typo->getAllFonts(); + // currentFonts = typo->getAllFonts(); currentOrdering = s; - fillTree(); +// fillTree(); } /// Should be renamed in slotNameItemSelected -void MainViewWidget::slotFontSelected ( QTreeWidgetItem * item, int column ) -{ - qDebug() << "font select"<data ( 0,100 ).toString() == "alpha" ) - { -// qDebug() << "Item is an alpha"; - return; -// fillTree(); - } - - else if ( item->data ( 0,100 ).toString() == "family" ) - { -// qDebug() << "Item is a family"; - item->setExpanded(true); - bool wantView = true; - bool hasChild = false; - QStringList names; - QMap variantMap; - for ( int i=0; i < item->childCount(); ++i ) - { - hasChild = true; - if ( item->child( i )->toolTip(0) == curItemName ) - wantView = false; - names << item->child( i )->toolTip( 0 ) ; - variantMap[item->child ( i )->text ( 0 ) ] = item->child ( i )->toolTip(0) ; - } - if(!slotFontActionByNames ( names )) - { - delete(new FMMissingFontHelper(names)); - return; - } - int oldc = item->data ( 0,200 ).toInt(); - if ( oldc == item->checkState ( 0 ) ) // filters when checkbox has not been hit - { - // TODO keep an eye on it -// fillTree(); +//void MainViewWidget::slotFontSelected ( QTreeWidgetItem * item, int column ) +//{ +// qDebug() << "font select"<data ( 0,100 ).toString() == "alpha" ) +// { +// // qDebug() << "Item is an alpha"; +// return; +// // fillTree(); +// } + +// else if ( item->data ( 0,100 ).toString() == "family" ) +// { +// // qDebug() << "Item is a family"; +// item->setExpanded(true); +// bool wantView = true; +// bool hasChild = false; +// QStringList names; +// QMap variantMap; +// for ( int i=0; i < item->childCount(); ++i ) +// { +// hasChild = true; +// if ( item->child( i )->toolTip(0) == curItemName ) +// wantView = false; +// names << item->child( i )->toolTip( 0 ) ; +// variantMap[item->child ( i )->text ( 0 ) ] = item->child ( i )->toolTip(0) ; +// } +// // if(!slotFontActionByNames ( names )) +// // { +// // delete(new FMMissingFontHelper(names)); +// // return; +// // } +// int oldc = item->data ( 0,200 ).toInt(); +// if ( oldc == item->checkState ( 0 ) ) // filters when checkbox has not been hit +// { +// // TODO keep an eye on it +// // fillTree(); - } - else if ( item->checkState ( 0 ) != Qt::PartiallyChecked ) - { +// } +// else if ( item->checkState ( 0 ) != Qt::PartiallyChecked ) +// { - bool cs = item->checkState ( 0 ) == Qt::Checked ? true : false; - item->setData( 0,200, item->checkState ( 0 ) ); - QList todo; - for ( int i=0; ichildCount(); ++i ) - { - todo << FMFontDb::DB()->Font( item->child ( i )->toolTip(0) ); - } -// for (int fIndex(0);fIndex < todo.count(); ++fIndex) -// { -// FontItem* afont = todo[fIndex]; -// if(fIndex == todo.count() - 1) -// activation ( afont, cs , true); -// else -// activation ( afont, cs , false); -// } - activation ( todo, cs ); +// bool cs = item->checkState ( 0 ) == Qt::Checked ? true : false; +// item->setData( 0,200, item->checkState ( 0 ) ); +// QList todo; +// for ( int i=0; ichildCount(); ++i ) +// { +// todo << FMFontDb::DB()->Font( item->child ( i )->toolTip(0) ); +// } +// // for (int fIndex(0);fIndex < todo.count(); ++fIndex) +// // { +// // FontItem* afont = todo[fIndex]; +// // if(fIndex == todo.count() - 1) +// // activation ( afont, cs , true); +// // else +// // activation ( afont, cs , false); +// // } +// activation ( todo, cs ); - } - else - { - qDebug() << "Something wrong, Qt::PartiallyChecked should not be reached" ; +// } +// else +// { +// qDebug() << "Something wrong, Qt::PartiallyChecked should not be reached" ; - } - if ( wantView && hasChild ) - { - QString select; +// } +// if ( wantView && hasChild ) +// { +// QString select; - if ( variantMap.contains ( "Regular" ) ) - select = variantMap["Regular"]; - else if ( variantMap.contains ( "Roman" ) ) - select = variantMap["Roman"]; - else if ( variantMap.contains ( "Medium" ) ) - select = variantMap["Medium"]; - else if ( variantMap.contains ( "Book" ) ) - select = variantMap["Book"]; - else - select = * ( variantMap.begin() ); +// if ( variantMap.contains ( "Regular" ) ) +// select = variantMap["Regular"]; +// else if ( variantMap.contains ( "Roman" ) ) +// select = variantMap["Roman"]; +// else if ( variantMap.contains ( "Medium" ) ) +// select = variantMap["Medium"]; +// else if ( variantMap.contains ( "Book" ) ) +// select = variantMap["Book"]; +// else +// select = * ( variantMap.begin() ); -// m_lists->previewList->slotSelect(select); - slotFontSelectedByName(select); +// // m_lists->previewList->slotSelect(select); +// slotFontSelectedByName(select); - } - return; - } +// } +// return; +// } - else if ( item->data ( 0,100 ).toString() == "fontfile" ) - { - QString fontname(item->toolTip(0)); - bool wantActivate = (item->checkState(0) == Qt::Checked) ? true : false; -// m_lists->previewList->slotSelect(fontname); - if(!slotFontSelectedByName(fontname)) - { - delete(new FMMissingFontHelper(fontname)); - return; - } -// if ( !theVeryFont->isLocked() ) - { - if(theVeryFont->isActivated()) - { - if(!wantActivate) - { - QList fl; - fl << theVeryFont; - activation(fl,false); - } - } - else - { - if(wantActivate) - { - QList fl; - fl << theVeryFont; - activation(fl,true); - } - } - } - } - return; +// else if ( item->data ( 0,100 ).toString() == "fontfile" ) +// { +// QString fontname(item->toolTip(0)); +// bool wantActivate = (item->checkState(0) == Qt::Checked) ? true : false; +// // m_lists->previewList->slotSelect(fontname); +// if(!slotFontSelectedByName(fontname)) +// { +// delete(new FMMissingFontHelper(fontname)); +// return; +// } +// // if ( !theVeryFont->isLocked() ) +// { +// if(theVeryFont->isActivated()) +// { +// if(!wantActivate) +// { +// QList fl; +// fl << theVeryFont; +// activation(fl,false); +// } +// } +// else +// { +// if(wantActivate) +// { +// QList fl; +// fl << theVeryFont; +// activation(fl,true); +// } +// } +// } +// } +// return; -} +//} -bool MainViewWidget::slotFontSelectedByName ( QString fname ) +bool MainViewWidget::slotFontSelectedByName (const QString& fname ) { if ( fname.isEmpty() @@ -821,1097 +659,505 @@ curItemName = faceIndex; { -// qDebug() << "Font has changed \n\tOLD : "<state() == FMGlyphsView::SingleView) - slotShowAllGlyph(); + // qDebug() << "Font has changed \n\tOLD : "<Font( faceIndex ); if(!theVeryFont) - return false; -// theVeryFont->updateItem(); - slotFontActionByName ( fname ); -// if(theVeryFont->isRemote()) -// { -// qDebug() << faceIndex <<" is remote"; -// if(!theVeryFont->isCached()) -// { -// connect(theVeryFont,SIGNAL(dowloadFinished()), this, SLOT(slotRemoteFinished())); -// theVeryFont->getFromNetwork(); -// currentDownload = faceIndex ; -// faceIndex = lastIndex; -// return false; -// } -// else -// { -// currentDownload = ""; -// } -// } - fillOTTree(); - fillUniPlanesCombo ( theVeryFont ); - QStringListModel *m = reinterpret_cast(charSearchLine->completer()->model()); - if(m) - m->setStringList(theVeryFont->getNames()); - slotView ( true ); + return false; + // theVeryFont->updateItem(); + // slotFontActionByName ( fname ); + // if(theVeryFont->isRemote()) + // { + // qDebug() << faceIndex <<" is remote"; + // if(!theVeryFont->isCached()) + // { + // connect(theVeryFont,SIGNAL(dowloadFinished()), this, SLOT(slotRemoteFinished())); + // theVeryFont->getFromNetwork(); + // currentDownload = faceIndex ; + // faceIndex = lastIndex; + // return false; + // } + // else + // { + // currentDownload = ""; + // } + // } + // fillOTTree(); + + // slotView ( true ); typo->setWindowTitle ( theVeryFont->fancyName() + " - Fontmatrix" ); - m_lists->fontTree->headerItem()->setText(0, tr("Names")+" ("+theVeryFont->family()+")"); +// m_lists->fontTree->headerItem()->setText(0, tr("Names")+" ("+theVeryFont->family()+")"); typo->presentFontName ( theVeryFont->fancyName() ); -// fillTree(); - updateTree(); - m_lists->listPreview->setCurrentFont(theVeryFont->path()); - abcView->verticalScrollBar()->setValue ( 0 ); - } - - return true; -} - - -void MainViewWidget::slotInfoFont() -{ - if(theVeryFont) - { - FMInfoDisplay fid(theVeryFont); - fontInfoText->setContent(fid.getHtml().toUtf8(), "application/xhtml+xml"); - } - - -} - -void MainViewWidget::slotView ( bool needDeRendering ) -{ - QTime t; - t.start(); - FontItem *l = FMFontDb::DB()->Font( lastIndex ); - FontItem *f = FMFontDb::DB()->Font( faceIndex ); - if ( !f ) - return; - if ( needDeRendering ) - { - if ( l ) - { - l->deRenderAll(); - } - f->deRenderAll(); - - curGlyph = 0; + // fillTree(); +// updateTree(); + // m_lists->listPreview->setCurrentFont(theVeryFont->path()); } - bool wantDeviceDependant = loremView_FT->isVisible(); - unsigned int storedHinting(theVeryFont->getFTHintMode()); - if(wantDeviceDependant) - { - theVeryFont->setFTHintMode(hinting()); - } - - if(textProgression->inLine() == TextProgression::INLINE_LTR ) - theVeryFont->setProgression(PROGRESSION_LTR ); - else if(textProgression->inLine() == TextProgression::INLINE_RTL ) - theVeryFont->setProgression(PROGRESSION_RTL); - else if(textProgression->inLine() == TextProgression::INLINE_TTB ) - theVeryFont->setProgression(PROGRESSION_TTB ); - else if(textProgression->inLine() == TextProgression::INLINE_BTT ) - theVeryFont->setProgression(PROGRESSION_BTT); - - theVeryFont->setFTRaster ( wantDeviceDependant ); - theVeryFont->setShaperType(shaperTypeCombo->itemData( shaperTypeCombo->currentIndex() ).toInt() ); - - if ( loremView->isVisible() || loremView_FT->isVisible() ) - { -// qDebug()<<"lv(ft) is visible"; - if(textLayout->isRunning()) - { -// qDebug()<<"tl is running"; - textLayout->stopLayout(); - } - else - { -// qDebug()<<"tl is NOT running"; - QGraphicsScene *targetScene; - loremView_FT->unSheduleUpdate(); - loremView->unSheduleUpdate(); - if(loremView->isVisible()) - { - targetScene = loremScene; - } - else if(loremView_FT->isVisible()) - { - targetScene = ftScene; - } - - bool processFeatures = f->isOpenType() && !deFillOTTree().isEmpty(); - QString script = langCombo->currentText(); - bool processScript = f->isOpenType() && ( useShaperCheck->checkState() == Qt::Checked ) && ( !script.isEmpty() ); - - textLayout->setTheFont(theVeryFont); - textLayout->setDeviceIndy(!wantDeviceDependant); - textLayout->setTheScene(targetScene); - textLayout->setAdjustedSampleInter( sampleInterSize ); - - double fSize(sampleFontSize); - - QList list; - QStringList stl( typo->namedSample(sampleTextTree->currentItem()->data(0, Qt::UserRole).toString() ).split("\n")); - if ( processScript ) - { - for(int p(0);pglyphs( stl[p] , fSize, script ); - } - } - else if(processFeatures) - { - // Experimental code to handle alternate is commented out - // Do not uncomment -// FMAltContext * actx ( FMAltContextLib::SetCurrentContext(sampleTextTree->currentText(), theVeryFont->path())); -// int rs(0); -// actx->setPar(rs); - for(int p(0);pglyphs( stl[p] , fSize, deFillOTTree()); -// actx->setPar(++rs); - } -// actx->cleanup(); -// FMAltContextLib::SetCurrentContext(sampleTextTree->currentText(), theVeryFont->path()); - } - else - { - for(int p(0);pglyphs( stl[p] , fSize ); - } - textLayout->doLayout(list, fSize); -// if (loremView->isVisible() /*&& fitViewCheck->isChecked()*/ ) -// { -// loremView->fitInView ( textLayout->getRect(), Qt::KeepAspectRatio ); -// } - textLayout->start(QThread::LowestPriority); - } - } - else if(!loremView->isVisible() && !loremView_FT->isVisible()) - { - loremView->sheduleUpdate(); - loremView_FT->sheduleUpdate(); - } - - slotUpdateGView(); - slotInfoFont(); - -} - - -void MainViewWidget::slotSearch() -{ -// qDebug()<<"slotSearch"; - m_lists->fontTree->clear(); -// m_lists->previewList->slotRefill(QList(), true); - fontsetHasChanged = true; - - QApplication::setOverrideCursor ( Qt::WaitCursor ); - QString fs ( m_lists->searchString->text() ); - - int field( m_lists->getCurrentFieldAction()->data().toInt() ); - QList tmpList; - - if(field == FILTER_FIELD_SPECIAL_UNICODE) //Unicode - { - QList allList; - - int startC(0xFFFFFFFF); - int endC(0); - int patCount(fs.count()); - for(int a(0); a < patCount; ++a) - { - unsigned int ca(fs[a].unicode()); - if( ca < startC) - startC = ca; - if(ca > endC) - endC = ca; - } - - // FontItem->countCoverage is very costly, so we take some code from operateFilter - // to avoid calling it too much, if possible. - bool queue(m_lists->getOperation().contains("AND")); - allList = queue ? currentFonts : FMFontDb::DB()->AllFonts(); - int superSetCount(allList.count()); - for ( int i =0; i < superSetCount; ++i ) - { - int cc(allList[i]->countCoverage ( startC, endC ) ); - if ( cc >= patCount ) - { - tmpList.append ( allList[i]); - } - } - - operateFilter( tmpList, QString("U://") + QString(fs) ); - } - else if(field == FMFontDb::AllInfo) - { - FMFontDb::InfoItem k; - - tmpList.clear(); - for(int gIdx(0); gIdx < FontStrings::Names().keys().count() ; ++gIdx) - { - k = FontStrings::Names().keys()[gIdx]; - if(k != FMFontDb::AllInfo) - { - tmpList += FMFontDb::DB()->Fonts(fs,k); - } - } - - operateFilter(tmpList, fs); - - } - else - { - tmpList = FMFontDb::DB()->Fonts(fs, FMFontDb::InfoItem(field ) ); - operateFilter(tmpList, fs); - } - - currentOrdering = "family"; - fillTree(); - m_lists->searchString->clear(); - - QApplication::restoreOverrideCursor(); -} - - -void MainViewWidget::slotFilterTag ( QString tag ) -{ - int tIdx(m_lists->tagsCombo->currentIndex()); - if(tIdx < 0) - return; - - QString key(m_lists->tagsCombo->itemData(tIdx).toString()); - - if(key == "TAG") // regular tag - { - m_lists->fontTree->clear(); - fontsetHasChanged = true; - operateFilter( FMFontDb::DB()->Fonts(tag, FMFontDb::Tags ), tag); - currentOrdering = "family"; - fillTree(); - } - else if(key == "ALL_ACTIVATED") - { - m_lists->fontTree->clear(); - fontsetHasChanged = true; - operateFilter( FMFontDb::DB()->Fonts(1, FMFontDb::Activation ), tr("Activated")); - currentOrdering = "family"; - fillTree(); - } - else if(key == "SIMILAR") - { - if(theVeryFont) - { - m_lists->fontTree->clear(); - fontsetHasChanged = true; - operateFilter( PanoseMatchFont::similar(theVeryFont, typo->getPanoseMatchTreshold() ), "S://"+ theVeryFont->family()); - fillTree(); - } - } -} - -void MainViewWidget::operateFilter(QList< FontItem * > allFiltered, const QString filterName) -{ - QList tmpList = allFiltered; - QList negList; - QList queList; - - QStringList ops(m_lists->getOperation()); - bool negate(ops.contains("NOT")); - bool queue(ops.contains("AND")); - m_lists->clearOperation(); - - if(queue) - { - addFilterToCrumb((negate?"!":"") +filterName); - queList = currentFonts; - } - else - { - setCrumb(); - addFilterToCrumb((negate?"!":"") +filterName); - } - if(negate) - negList = FMFontDb::DB()->AllFonts(); - - currentFonts.clear(); - - if(negate) - { - if(queue) - { - foreach(FontItem* f, negList) - { - if(!currentFonts.contains(f) && !tmpList.contains(f) && queList.contains(f)) - currentFonts.append(f); - } - } - else // not queue - { - foreach(FontItem* f, negList) - { - if(!currentFonts.contains(f) && !tmpList.contains(f)) - currentFonts.append(f); - } - } - } - else // not negate - { - if(queue) - { - foreach(FontItem* f, tmpList) - { - if(!currentFonts.contains(f) && queList.contains(f)) - currentFonts.append(f); - } - } - else // not queue - { - foreach(FontItem* f, tmpList) - { - if(!currentFonts.contains(f)) - currentFonts.append(f); - } - } - } -} - - -void MainViewWidget::slotFontAction ( QTreeWidgetItem * item, int column ) -{ -// qDebug()<<"MainViewWidget::slotFontAction"; - if ( column >2 ) return; - - FontItem * FoIt = FMFontDb::DB()->Font( item->text ( 1 ) ); - if ( FoIt/* && (!FoIt->isLocked())*/ ) - { - QList fl; - fl.append ( FoIt ); - TagsWidget::getInstance()->prepare ( fl ); - } -} - -bool MainViewWidget::slotFontActionByName (const QString &fname ) -{ -// qDebug()<<"MainViewWidget::slotFontActionByName ("<< fname <<")"; - FontItem * FoIt = FMFontDb::DB()->Font( fname ); - if ( FoIt/* && (!FoIt->isLocked())*/ ) - { - QList fl; - fl.append ( FoIt ); - TagsWidget::getInstance()->prepare ( fl ); - } - else - return false; - return true; -} - -bool MainViewWidget::slotFontActionByNames ( QStringList fnames ) -{ -// qDebug()<<"MainViewWidget::slotFontActionByNames ("<< fnames.join(";") <<")"; - QList FoIt; - for ( int i= 0; i < fnames.count() ; ++i ) - { - FontItem* ti(FMFontDb::DB()->Font( fnames[i] )); - if(ti) - FoIt.append ( ti ); - else - { - return false; - } - } - if ( FoIt.count() ) - TagsWidget::getInstance()->prepare ( FoIt ); - return true; -} - - -void MainViewWidget::slotEditAll() -{ - QList fl; - for ( int i =0; i< currentFonts.count(); ++i ) - { - fl.append ( currentFonts[i] ); - } - if ( fl.isEmpty() ) - return; - - TagsWidget::getInstance()->prepare ( fl ); -} - - -void MainViewWidget::slotZoom ( int z ) -{ - double delta = 1.0 + ( z/1000.0 ) ; - QTransform trans; - trans.scale ( delta,delta ); - - QGraphicsView * concernedView; - if ( loremView_FT->isVisible() ) - concernedView = loremView_FT; - else if ( loremView->isVisible() ) - { - concernedView = loremView; - if ( delta == 1.0 ) - { - double horiScaleT (typotek::getInstance()->getDpiX() / 72.0); - double vertScaleT ( typotek::getInstance()->getDpiY() / 72.0); - QTransform adjustAbsoluteViewT( horiScaleT , 0, 0,vertScaleT, 0, 0 ); - trans = adjustAbsoluteViewT; - } - } - else if ( playView->isVisible() ) - concernedView = playView; - - concernedView->setTransform ( trans, ( z == 0 ) ? false : true ); - -} - -void MainViewWidget::slotAppendTag ( QString tag ) -{ - emit newTag ( tag ); - m_lists->reloadTagsCombo(); -} - -void MainViewWidget::activation(QList< FontItem * > fit, bool act) -{ - // First check if one of the font is in a different state than required - QList< FontItem * > actualF; - for(int i(0); i < fit.count(); ++i) - { - if(fit[i]->isActivated() != act) - actualF.append(fit[i]); - } - if(actualF.count() == 0) - return; - - // TODO check for duplicates before we activate them. - - // we tr("purge") errors; - FMActivate::getInstance()->errors(); - FMActivate::getInstance()->activate(actualF, act); - QMap actErr(FMActivate::getInstance()->errors()); - if(actErr.count() > 0) - { - FMActivationReport ar(this, actErr); - ar.exec(); - } - -// updateTree(true); -} - -void MainViewWidget::slotDesactivateAll() -{ - activation(currentFonts, false); -} - -void MainViewWidget::slotActivateAll() -{ - activation(currentFonts, true); -} - -void MainViewWidget::slotSetSampleText ( QString s ) -{ - sampleText = s ; - slotView ( true ); - -} - -void MainViewWidget::slotActivate ( bool act, QTreeWidgetItem * item, int column ) -{ - if ( column >2 ) return; - FontItem * FoIt = FMFontDb::DB()->Font( item->text ( 1 ) ); - if ( FoIt ) - { - QList fl; - fl.append(FoIt); - activation ( fl, act ); - } -} - -void MainViewWidget::slotReloadFontList() -{ - currentFonts.clear(); - currentFonts = FMFontDb::DB()->AllFonts(); - fontsetHasChanged = true; - fillTree(); -} - -void MainViewWidget::slotSwitchAntiAlias ( bool aa ) -{ - loremView->setRenderHint ( QPainter::Antialiasing, aa ); -} - - -void MainViewWidget::slotViewAll() -{ - fontsetHasChanged = true; - currentFonts = FMFontDb::DB()->AllFonts(); - fillTree(); - setCrumb(); -} - -void MainViewWidget::slotViewActivated() -{ -// slotFilterTag ( "Activated_On" ); -} - -void MainViewWidget::fillUniPlanesCombo ( FontItem* item ) -{ - QString stickyRange(uniPlaneCombo->currentText()); -// qDebug()<<"STiCKyRaNGe :: "<clear(); - - int begin(0); - int end(0); - QString lastBlock(FMUniBlocks::lastBlock(begin, end)); - QString block(FMUniBlocks::firstBlock( begin, end )); - bool first(true); - do - { - if(first) - first = false; - else - block = FMUniBlocks::nextBlock(begin, end); - - int codecount ( item->countCoverage ( begin , end ) ); - if ( codecount > 0 ) - { -// qDebug() << p << codecount; - uniPlaneCombo->addItem ( block ); - if(block == stickyRange) - { - stickyIndex = uniPlaneCombo->count() - 1; - uRangeIsNotEmpty = true; - } - } - else - { - if(block == stickyRange) - { - stickyIndex = uniPlaneCombo->count() - 1; - uRangeIsNotEmpty = true; - } - } - - } while(lastBlock != block); - if(item->countCoverage ( -1 , 100 ) > 0) - { - uniPlaneCombo->addItem( unMapGlyphName ); - if(unMapGlyphName == stickyRange) - { - stickyIndex = uniPlaneCombo->count() - 1; - uRangeIsNotEmpty = true; - } - } - uniPlaneCombo->addItem( allMappedGlyphName ); - if(allMappedGlyphName == stickyRange) - { - stickyIndex = uniPlaneCombo->count() - 1; - uRangeIsNotEmpty = true; - } - - uniPlaneCombo->setCurrentIndex ( stickyIndex ); - -} - -void MainViewWidget::keyPressEvent ( QKeyEvent * event ) -{ -// qDebug() << " MainViewWidget::keyPressEvent(QKeyEvent * "<key() == Qt::Key_Space && event->modifiers().testFlag ( Qt::ControlModifier ) ) -// { -// // Switch list view -// if ( m_lists->fontlistTab->currentIndex() == 0 ) -// m_lists->fontlistTab->setCurrentIndex ( 1 ); -// else -// m_lists->fontlistTab->setCurrentIndex ( 0 ); -// } -} - -void MainViewWidget::slotAdjustGlyphView ( int width ) -{ - if ( !theVeryFont ) - return; - -// theVeryFont->adjustGlyphsPerRow ( width ); - slotView ( true ); -} - -void MainViewWidget::fillOTTree() -{ - OpenTypeTree->clear(); - langCombo->clear(); - langCombo->setEnabled ( false ); - useShaperCheck->setCheckState ( Qt::Unchecked ); - useShaperCheck->setEnabled ( false ); - QStringList scripts; - if ( theVeryFont && theVeryFont->isOpenType() ) - { - FMOtf * otf = theVeryFont->takeOTFInstance(); - foreach ( QString table, otf->get_tables() ) - { - otf->set_table ( table ); - QTreeWidgetItem *tab_item = new QTreeWidgetItem ( OpenTypeTree,QStringList ( table ) ); - tab_item->setExpanded ( true ); - foreach ( QString script, otf->get_scripts() ) - { - scripts << script; - otf->set_script ( script ); - QTreeWidgetItem *script_item = new QTreeWidgetItem ( tab_item, QStringList ( script ) ); - script_item->setExpanded ( true ); - foreach ( QString lang, otf->get_langs() ) - { - otf->set_lang ( lang ); - QTreeWidgetItem *lang_item = new QTreeWidgetItem ( script_item, QStringList ( lang ) ); - lang_item->setExpanded ( true ); - foreach ( QString feature, otf->get_features() ) - { - QStringList f ( feature ); - f << OTTagMeans ( feature ); - QTreeWidgetItem *feature_item = new QTreeWidgetItem ( lang_item, f ); - feature_item->setCheckState ( 0, Qt::Unchecked ); - if(table == "GPOS") - { - if(typo->getDefaultOTFScript() == script && typo->getDefaultOTFLang() == lang && typo->getDefaultOTFGPOS().contains(feature) ) - { - feature_item->setCheckState ( 0, Qt::Checked ); - } - } - else if(table == "GSUB") - { - if(typo->getDefaultOTFScript() == script && typo->getDefaultOTFLang() == lang && typo->getDefaultOTFGSUB().contains(feature) ) - { - feature_item->setCheckState ( 0, Qt::Checked ); - } - } - } - } - } - } - OpenTypeTree->resizeColumnToContents ( 0 ) ; - theVeryFont->releaseOTFInstance ( otf ); - } - scripts = scripts.toSet().toList(); -// scripts.removeAll ( "latn" ); - if ( !scripts.isEmpty() ) - { - langCombo->setEnabled ( true ); - useShaperCheck->setEnabled ( true ); - langCombo->addItems ( scripts ); - } -} - -OTFSet MainViewWidget::deFillOTTree() -{ -// qDebug() << "MainViewWidget::deFillOTTree()"; - OTFSet ret; -// qDebug() << OpenTypeTree->topLevelItemCount(); - for ( int table_index = 0; table_index < OpenTypeTree->topLevelItemCount(); ++table_index ) //tables - { -// qDebug() << "table_index = " << table_index; - QTreeWidgetItem * table_item = OpenTypeTree->topLevelItem ( table_index ) ; -// qDebug() << table_item->text(0); - for ( int script_index = 0; script_index < table_item->childCount();++script_index ) //scripts - { - QTreeWidgetItem * script_item = table_item->child ( script_index ); -// qDebug() << "\tscript_index = " << script_index << script_item->text(0); - for ( int lang_index = 0; lang_index < script_item->childCount(); ++lang_index ) //langs - { - QTreeWidgetItem * lang_item = script_item->child ( lang_index ); -// qDebug() << "\t\tlang_index = "<< lang_index << lang_item->text(0); - for ( int feature_index = 0; feature_index < lang_item->childCount(); ++feature_index ) //features - { -// qDebug() << lang_item->childCount() <<" / "<< feature_index; - QTreeWidgetItem * feature_item = lang_item->child ( feature_index ); -// qDebug() << "\t\t\tfeature_item -> "<< feature_item->text(0); - if ( feature_item->checkState ( 0 ) == Qt::Checked ) - { - if ( table_item->text ( 0 ) == "GPOS" ) - { - ret.script = script_item->text ( 0 ); - ret.lang = lang_item->text ( 0 ); - ret.gpos_features.append ( feature_item->text ( 0 ) ); - } - if ( table_item->text ( 0 ) == "GSUB" ) - { - ret.script = script_item->text ( 0 ); - ret.lang = lang_item->text ( 0 ); - ret.gsub_features.append ( feature_item->text ( 0 ) ); - } - } - } - } - } - } -// qDebug() << "endOf"; - return ret; - + return true; } -void MainViewWidget::slotDefaultOTF() -{ - OTFSet ots(deFillOTTree()); - - typo->setDefaultOTFScript(ots.script); - typo->setDefaultOTFLang(ots.lang); - typo->setDefaultOTFGPOS(ots.gpos_features); - typo->setDefaultOTFGSUB(ots.gsub_features); -} +//void MainViewWidget::slotInfoFont() +//{ +// if(theVeryFont) +// { +// FMInfoDisplay fid(theVeryFont); +// fontInfoText->setContent(fid.getHtml().toUtf8(), "application/xhtml+xml"); +// } + + +//} + +//void MainViewWidget::slotView ( bool needDeRendering ) +//{ +// QTime t; +// t.start(); +// FontItem *l = FMFontDb::DB()->Font( lastIndex ); +// FontItem *f = FMFontDb::DB()->Font( faceIndex ); +// if ( !f ) +// return; +// if ( needDeRendering ) +// { +// if ( l ) +// { +// l->deRenderAll(); +// } +// f->deRenderAll(); -void MainViewWidget::slotResetOTF() -{ - typo->setDefaultOTFScript(QString()); - typo->setDefaultOTFLang(QString()); - typo->setDefaultOTFGPOS(QStringList()); - typo->setDefaultOTFGSUB(QStringList()); -} +// curGlyph = 0; +// } -void MainViewWidget::slotFeatureChanged() -{ -// OTFSet ret = deFillOTTree(); - slotView ( true ); -} +// bool wantDeviceDependant = loremView_FT->isVisible(); +// unsigned int storedHinting(theVeryFont->getFTHintMode()); +// if(wantDeviceDependant) +// { +// theVeryFont->setFTHintMode(hinting()); +// } + +// if(textProgression->inLine() == TextProgression::INLINE_LTR ) +// theVeryFont->setProgression(PROGRESSION_LTR ); +// else if(textProgression->inLine() == TextProgression::INLINE_RTL ) +// theVeryFont->setProgression(PROGRESSION_RTL); +// else if(textProgression->inLine() == TextProgression::INLINE_TTB ) +// theVeryFont->setProgression(PROGRESSION_TTB ); +// else if(textProgression->inLine() == TextProgression::INLINE_BTT ) +// theVeryFont->setProgression(PROGRESSION_BTT); + +// theVeryFont->setFTRaster ( wantDeviceDependant ); +// theVeryFont->setShaperType(shaperTypeCombo->itemData( shaperTypeCombo->currentIndex() ).toInt() ); + +// if ( loremView->isVisible() || loremView_FT->isVisible() ) +// { +//// qDebug()<<"lv(ft) is visible"; +// if(textLayout->isRunning()) +// { +//// qDebug()<<"tl is running"; +// textLayout->stopLayout(); +// } +// else +// { +//// qDebug()<<"tl is NOT running"; +// QGraphicsScene *targetScene; +// loremView_FT->unSheduleUpdate(); +// loremView->unSheduleUpdate(); +// if(loremView->isVisible()) +// { +// targetScene = loremScene; +// } +// else if(loremView_FT->isVisible()) +// { +// targetScene = ftScene; +// } -void MainViewWidget::slotSampleChanged() -{ - slotView ( true ); -} +// bool processFeatures = f->isOpenType() && !deFillOTTree().isEmpty(); +// QString script = langCombo->currentText(); +// bool processScript = f->isOpenType() && ( useShaperCheck->checkState() == Qt::Checked ) && ( !script.isEmpty() ); + +// textLayout->setTheFont(theVeryFont); +// textLayout->setDeviceIndy(!wantDeviceDependant); +// textLayout->setTheScene(targetScene); +// textLayout->setAdjustedSampleInter( sampleInterSize ); + +// double fSize(sampleFontSize); + +// QList list; +// QStringList stl( typo->namedSample(sampleTextTree->currentItem()->data(0, Qt::UserRole).toString() ).split("\n")); +// if ( processScript ) +// { +// for(int p(0);pglyphs( stl[p] , fSize, script ); +// } +// } +// else if(processFeatures) +// { +// // Experimental code to handle alternate is commented out +// // Do not uncomment +//// FMAltContext * actx ( FMAltContextLib::SetCurrentContext(sampleTextTree->currentText(), theVeryFont->path())); +//// int rs(0); +//// actx->setPar(rs); +// for(int p(0);pglyphs( stl[p] , fSize, deFillOTTree()); +//// actx->setPar(++rs); +// } +//// actx->cleanup(); +//// FMAltContextLib::SetCurrentContext(sampleTextTree->currentText(), theVeryFont->path()); +// } +// else +// { +// for(int p(0);pglyphs( stl[p] , fSize ); +// } +// textLayout->doLayout(list, fSize); +//// if (loremView->isVisible() /*&& fitViewCheck->isChecked()*/ ) +//// { +//// loremView->fitInView ( textLayout->getRect(), Qt::KeepAspectRatio ); +//// } +// textLayout->start(QThread::LowestPriority); +// } +// } +// else if(!loremView->isVisible() && !loremView_FT->isVisible()) +// { +// loremView->sheduleUpdate(); +// loremView_FT->sheduleUpdate(); +// } + +// slotUpdateGView(); +//// slotInfoFont(); + +//} + + +//void MainViewWidget::slotSearch(int field, QString text) +//{ +// // qDebug()<<"slotSearch"; +//// m_lists->fontTree->clear(); +// // m_lists->previewList->slotRefill(QList(), true); +// fontsetHasChanged = true; + +// QApplication::setOverrideCursor ( Qt::WaitCursor ); +// QString fs ( text ); + +// QList tmpList; + +// if(field == FILTER_FIELD_SPECIAL_UNICODE) //Unicode +// { +// QList allList; + +// int startC(0xFFFFFFFF); +// int endC(0); +// int patCount(fs.count()); +// for(int a(0); a < patCount; ++a) +// { +// unsigned int ca(fs[a].unicode()); +// if( ca < startC) +// startC = ca; +// if(ca > endC) +// endC = ca; +// } + +// // FontItem->countCoverage is very costly, so we take some code from operateFilter +// // to avoid calling it too much, if possible. +// bool queue(m_lists->getOperation().contains("AND")); +// allList = queue ? FMFontDb::DB()->getFilteredFonts() : FMFontDb::DB()->AllFonts(); +// int superSetCount(allList.count()); +// for ( int i =0; i < superSetCount; ++i ) +// { +// int cc(allList[i]->countCoverage ( startC, endC ) ); +// if ( cc >= patCount ) +// { +// tmpList.append ( allList[i]); +// } +// } + +// operateFilter( tmpList, QString("U://") + QString(fs) ); +// } +// else if(field == FMFontDb::AllInfo) +// { +// FMFontDb::InfoItem k; -#define MAX_PALYSTRING_LEN 30 +// tmpList.clear(); +// for(int gIdx(0); gIdx < FontStrings::Names().keys().count() ; ++gIdx) +// { +// k = FontStrings::Names().keys()[gIdx]; +// if(k != FMFontDb::AllInfo) +// { +// tmpList += FMFontDb::DB()->Fonts(fs,k); +// } +// } + +// operateFilter(tmpList, fs); -void MainViewWidget::refillSampleList() -{ - sampleTextTree->clear(); +// } +// else +// { +// tmpList = FMFontDb::DB()->Fonts(fs, FMFontDb::InfoItem(field ) ); +// operateFilter(tmpList, fs); +// } + +// currentOrdering = "family"; +//// fillTree(); +//// m_lists->searchString->clear(); + +// QApplication::restoreOverrideCursor(); +//} - QTreeWidgetItem * curIt = 0; - QMap > sl = typo->namedSamplesNames(); - QList ul( sl.take(QString("User")) ); - if(ul.count()) +void MainViewWidget::slotShowFamily(const QModelIndex& familyIdx) +{ + FontItem * fItem(FMFontDb::DB()->getFilteredFonts(true).at(familyIdx.row())); + if(!fItem) { - QTreeWidgetItem * uRoot = new QTreeWidgetItem(sampleTextTree); - //: Identify root of user defined sample texts - uRoot->setText(0, tr("User")); - bool first(true); - foreach(QString uk, ul) - { - if(first) - { - first = false; - uRoot->setData(0, Qt::UserRole , QString("User::") + uk); - curIt = uRoot; - } - QTreeWidgetItem * it = new QTreeWidgetItem(); - it->setText(0, uk); - it->setData(0, Qt::UserRole , QString("User::") + uk); - uRoot->addChild(it); - } + qDebug()<<"\t-FontItme invalid"; + return; } - foreach(QString k, sl.keys()) + QList fl(FMFontDb::DB()->FamilySet(fItem->family())); + foreach(FontItem* f,fl) { - QTreeWidgetItem * kRoot = new QTreeWidgetItem(sampleTextTree); - kRoot->setText(0, k); - bool first(true); - foreach(QString n, sl[k]) - { - if(first) - { - first = false; - kRoot->setData(0, Qt::UserRole , k + QString("::") + n); - if(!curIt) - curIt = kRoot; - } - QTreeWidgetItem * it = new QTreeWidgetItem(); - it->setText(0, n); - it->setData(0, Qt::UserRole, k + QString("::") + n); - kRoot->addChild(it); - } + qDebug() <<"F"<< f->fancyName(); } - - sampleTextTree->setCurrentItem(curIt); + familyWidget->setFamily(fItem->family()); + previewStack->setCurrentIndex(1); } -void MainViewWidget::slotFTRasterChanged() -{ -// fitViewCheck->setChecked(false); - slotView ( true ); -} +void MainViewWidget::slotQuitFamily() +{ + previewStack->setCurrentIndex(0); +} + +//void MainViewWidget::slotFilterTag ( QString tag ) +//{ +// int tIdx(filterBar->tagsCombo()->currentIndex()); +// if(tIdx < 0) +// return; + +// QString key(filterBar->tagsCombo()->itemData(tIdx).toString()); + +// if(key == "TAG") // regular tag +// { +// m_lists->fontTree->clear(); +// fontsetHasChanged = true; +// operateFilter( FMFontDb::DB()->Fonts(tag, FMFontDb::Tags ), tag); +// currentOrdering = "family"; +// fillTree(); +// } +// else if(key == "ALL_ACTIVATED") +// { +// m_lists->fontTree->clear(); +// fontsetHasChanged = true; +// operateFilter( FMFontDb::DB()->Fonts(1, FMFontDb::Activation ), tr("Activated")); +// currentOrdering = "family"; +// fillTree(); +// } +// else if(key == "SIMILAR") +// { +// if(theVeryFont) +// { +// m_lists->fontTree->clear(); +// fontsetHasChanged = true; +// operateFilter( PanoseMatchFont::similar(theVeryFont, typo->getPanoseMatchTreshold() ), "S://"+ theVeryFont->family()); +// fillTree(); +// } +// } +//} -void MainViewWidget::slotWantShape() -{ - slotView ( true ); -} +//void MainViewWidget::operateFilter(QList< FontItem * > allFiltered, const QString filterName) +//{ +// QList tmpList = allFiltered; +// QList negList; +// QList queList; + +// QStringList ops(m_lists->getOperation()); +// bool negate(ops.contains("NOT")); +// bool queue(ops.contains("AND")); +// m_lists->clearOperation(); + +// FMFontDb* fmdb(FMFontDb::DB()); + +// if(queue) +// { +// addFilterToCrumb((negate?"!":"") +filterName); +// queList = fmdb->getFilteredFonts(); +// } +// else +// { +// setCrumb(); +// addFilterToCrumb((negate?"!":"") +filterName); +// } +// if(negate) +// negList = fmdb->AllFonts(); + +// fmdb->clearFilteredFonts(); + +// if(negate) +// { +// if(queue) +// { +// foreach(FontItem* f, negList) +// { +// if(!fmdb->isFiltered(f) && !tmpList.contains(f) && queList.contains(f)) +// fmdb->insertFilteredFont(f); +// } +// } +// else // not queue +// { +// foreach(FontItem* f, negList) +// { +// if(!fmdb->isFiltered(f) && !tmpList.contains(f)) +// fmdb->insertFilteredFont(f); +// } +// } +// } +// else // not negate +// { +// if(queue) +// { +// foreach(FontItem* f, tmpList) +// { +// if(!fmdb->isFiltered(f) && queList.contains(f)) +// fmdb->insertFilteredFont(f); +// } +// } +// else // not queue +// { +// foreach(FontItem* f, tmpList) +// { +// if(!fmdb->isFiltered(f)) +// fmdb->insertFilteredFont(f); +// } +// } +// } +//} -void MainViewWidget::slotChangeScript() -{ - if ( useShaperCheck->checkState() == Qt::Checked ) - { - slotView ( true ); - } -} +//void MainViewWidget::slotFontAction ( QTreeWidgetItem * item, int column ) +//{ +//// qDebug()<<"MainViewWidget::slotFontAction"; +// if ( column >2 ) return; + +// FontItem * FoIt = FMFontDb::DB()->Font( item->text ( 1 ) ); +// if ( FoIt/* && (!FoIt->isLocked())*/ ) +// { +// QList fl; +// fl.append ( FoIt ); +// familyWidget->tagWidget()->prepare ( fl ); +// } +//} + +//bool MainViewWidget::slotFontActionByName (const QString &fname ) +//{ +//// qDebug()<<"MainViewWidget::slotFontActionByName ("<< fname <<")"; +// FontItem * FoIt = FMFontDb::DB()->Font( fname ); +// if ( FoIt/* && (!FoIt->isLocked())*/ ) +// { +// QList fl; +// fl.append ( FoIt ); +// familyWidget->tagWidget()->prepare ( fl ); +// } +// else +// return false; +// return true; +//} + +//bool MainViewWidget::slotFontActionByNames ( QStringList fnames ) +//{ +//// qDebug()<<"MainViewWidget::slotFontActionByNames ("<< fnames.join(";") <<")"; +// QList FoIt; +// for ( int i= 0; i < fnames.count() ; ++i ) +// { +// FontItem* ti(FMFontDb::DB()->Font( fnames[i] )); +// if(ti) +// FoIt.append ( ti ); +// else +// { +// return false; +// } +// } +// if ( FoIt.count() ) +// familyWidget->tagWidget()->prepare ( FoIt ); +// return true; +//} + + +//void MainViewWidget::slotEditAll() +//{ +//// QList fl; +//// for ( int i =0; i< currentFonts.count(); ++i ) +//// { +//// fl.append ( currentFonts[i] ); +//// } +// if ( FMFontDb::DB()->countFilteredFonts() == 0 ) +// return; -void MainViewWidget::slotPlaneSelected ( int i ) -{ - qDebug()<<"slotPlaneSelected"<currentIndex(); - if(i != uniPlaneCombo->currentIndex()) - uniPlaneCombo->setCurrentIndex(i); - - bool stickState = uRangeIsNotEmpty; - uRangeIsNotEmpty = true; - slotShowAllGlyph(); - slotUpdateGView(); - if( (stickState == false) && theVeryFont) - { - fillUniPlanesCombo(theVeryFont); - } - abcView->verticalScrollBar()->setValue ( 0 ); -} +// familyWidget->tagWidget()->prepare ( FMFontDb::DB()->getFilteredFonts() ); +//} -void MainViewWidget::slotSearchCharName() -{ - if(!theVeryFont) - return; - QString name(charSearchLine->text()); - unsigned short cc(0); - bool searchCodepoint(false); - if(name.startsWith("U+") - || name.startsWith("u+") - || name.startsWith("+")) - { - QString vString(name.mid(name.indexOf("+"))); - bool ok(false); - cc = vString.toInt(&ok, 16); - if(!ok) - cc = 0; - searchCodepoint = true; - } - else - cc = theVeryFont->getNamedChar(name); -// qDebug()<<"CS"<clear(); - return; - } - - foreach(const QString& key, FMUniBlocks::blocks() ) - { - QPair p(FMUniBlocks::interval(key)); - if((cc >= p.first) - && (cc <= p.second)) - { - int idx(uniPlaneCombo->findText(key)); - slotPlaneSelected(idx); - int sv(0); - bool first(true); - do{ - if(first) - first = false; - else - { - abcView->verticalScrollBar()->setValue(sv + abcView->height()); - sv = abcView->verticalScrollBar()->value(); - } - foreach(QGraphicsItem* sit, abcScene->items()) - { - if((sit->data(1).toString() == "select") - && (sit->data(3).toInt() == cc)) - { - QGraphicsRectItem* ms(reinterpret_cast (sit)); - if(ms) - { - QRectF rf(ms->rect()); - new FMGlyphHighlight(abcScene, rf, 2000, 160); - } - else - qDebug()<<"ERROR: An select item not being a QRect?"; - return; - - } - } - }while(sv < abcView->verticalScrollBar()->maximum()); - return; - } - } - - // if user was looking for a name and we did not find it in - // Unicode blocks, it must be unmapped. - if(!searchCodepoint) - { - int idx(uniPlaneCombo->findText(unMapGlyphName)); - slotPlaneSelected(idx); - int sv(0); - bool first(true); - do{ - if(first) - first = false; - else - { - abcView->verticalScrollBar()->setValue(sv + abcView->height()); - sv = abcView->verticalScrollBar()->value(); - } - foreach(QGraphicsItem* sit, abcScene->items()) - { - if((sit->data(1).toString() == "select") - && (sit->data(3).toInt() == cc)) - { - QGraphicsRectItem* ms(reinterpret_cast (sit)); - if(ms) - { - QRectF rf(ms->rect()); - new FMGlyphHighlight(abcScene, rf, 2000, 160); - } - else - qDebug()<<"ERROR: An select item not being a QRect?"; - return; - - } - } - }while(sv < abcView->verticalScrollBar()->maximum()); - return; - } - -} -void MainViewWidget::slotShowOneGlyph() + +void MainViewWidget::activation(QList< FontItem * > fit, bool act) { - qDebug() <<"slotShowOneGlyph()"<selectedItems().count(); - if ( abcScene->selectedItems().isEmpty() ) - return; - if ( abcView->lock() ) + // First check if one of the font is in a different state than required + QList< FontItem * > actualF; + for(int i(0); i < fit.count(); ++i) { - curGlyph = reinterpret_cast ( abcScene->selectedItems().first() ); - curGlyph->setSelected ( false ); - if ( fancyGlyphInUse < 0 ) - { - if ( curGlyph->data ( 3 ).toInt() > 0 ) // Is a codepoint - { - fancyGlyphData = curGlyph->data ( 3 ).toInt(); - if(clipboardCheck->isChecked()) - { - new FMGlyphHighlight(abcScene, curGlyph->rect()); - QString simpleC; - simpleC += QChar(fancyGlyphData); - QApplication::clipboard()->setText(simpleC, QClipboard::Clipboard); - uniLine->setText(uniLine->text() + simpleC); - } - else - fancyGlyphInUse = theVeryFont->showFancyGlyph ( abcView, fancyGlyphData ); - } - else // Is a glyph index - { - fancyGlyphData = curGlyph->data ( 2 ).toInt(); - fancyGlyphInUse = theVeryFont->showFancyGlyph ( abcView, fancyGlyphData , true ); - } - if ( fancyGlyphInUse < 0 ) - { - abcView->unlock(); - return; - } - abcView->setState ( FMGlyphsView::SingleView ); - } - abcView->unlock(); + if(fit[i]->isActivated() != act) + actualF.append(fit[i]); } - else - qDebug()<<"cannot lock ABCview"; -} - -void MainViewWidget::slotShowAllGlyph() -{ -// qDebug() <<"slotShowAllGlyph()"; - if ( fancyGlyphInUse < 0 ) + if(actualF.count() == 0) return; - if ( abcView->lock() ) - { -// qDebug()<<"View Locked"; - theVeryFont->hideFancyGlyph ( fancyGlyphInUse ); - fancyGlyphInUse = -1; - abcView->setState ( FMGlyphsView::AllView ); - abcView->unlock(); - } -// qDebug() <<"ENDOF slotShowAllGlyph()"; -} + // TODO check for duplicates before we activate them. -void MainViewWidget::slotUpdateGView() -{ -// qDebug()<<"slotUpdateGView"<currentText(); -// printBacktrace(32); - // If all is how I think it must be, we don’t need to check anything here :) - if(theVeryFont && abcView->lock()) + // we tr("purge") errors; + FMActivate::getInstance()->errors(); + FMActivate::getInstance()->activate(actualF, act); + QMap actErr(FMActivate::getInstance()->errors()); + if(actErr.count() > 0) { - QPair uniPair; - QString curBlockText(uniPlaneCombo->currentText()); - if(curBlockText == unMapGlyphName) - uniPair = qMakePair(-1,100); - else if(curBlockText == allMappedGlyphName) - uniPair = qMakePair(0, 0x10FFFF); - else - uniPair = FMUniBlocks::interval( curBlockText ); - - int coverage = theVeryFont->countCoverage ( uniPair.first, uniPair.second ); - int interval = uniPair.second - uniPair.first; - coverage = coverage * 100 / ( interval + 1 );// against /0 exception - - QString statstring(tr("Block (%1):").arg( QString::number ( coverage ) + "\%")); - unicodeCoverageStat->setText ( statstring ); - - theVeryFont->renderAll ( abcScene , uniPair.first, uniPair.second ); - abcView->unlock(); + FMActivationReport ar(this, actErr); + ar.exec(); } -} + // updateTree(true); +} -void MainViewWidget::slotUpdateGViewSingle() +void MainViewWidget::slotDesactivateAll() { -// qDebug()<<"slotUpdateGViewSingle"; - if ( theVeryFont && abcView->lock()) - { -// qDebug() <<"1.FGI"<hideFancyGlyph ( fancyGlyphInUse ); - if ( fancyGlyphData > 0 ) // Is a codepoint - { - fancyGlyphInUse = theVeryFont->showFancyGlyph ( abcView, fancyGlyphData ); -// qDebug() <<"2.FGI"<showFancyGlyph ( abcView, fancyGlyphData , true ); -// qDebug() <<"3.FGI"<unlock(); - - } + activation(FMFontDb::DB()->getFilteredFonts(), false); +} +void MainViewWidget::slotActivateAll() +{ + activation(FMFontDb::DB()->getFilteredFonts(), true); } -void MainViewWidget::slotUpdateSView() -{ - if(loremView->isVisible()) - slotView(true); -} +//void MainViewWidget::slotActivate ( bool act, QTreeWidgetItem * item, int column ) +//{ +// if ( column >2 ) return; +// FontItem * FoIt = FMFontDb::DB()->Font( item->text ( 1 ) ); +// if ( FoIt ) +// { +// QList fl; +// fl.append(FoIt); +// activation ( fl, act ); +// } +//} -void MainViewWidget::slotUpdateRView() + +void MainViewWidget::keyPressEvent ( QKeyEvent * e ) { - if(loremView_FT->isVisible()) - slotView(true); + qDebug() << " MainViewWidget::keyPressEvent(QKeyEvent * "<text().isEmpty() || (!e->text().at(0).isLetterOrNumber())) + return; + slotQuickSearch(e->text()); } -void MainViewWidget::slotUpdateTree() -{ - updateTree(true); -} +#define MAX_PALYSTRING_LEN 30 -void MainViewWidget::slotEditSampleText() -{ - typo->slotPrefsPanel(PrefsPanelDialog::PAGE_SAMPLETEXT); -} void MainViewWidget::slotRemoveCurrentItem() { @@ -1925,351 +1171,118 @@ if( QMessageBox::question ( this, tr("Fontmatrix safe"), tr("You are about to remove a font from Fontmatrix database") +"\n"+curItemName+"\n" + tr("Do you want to continue?"),QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes ) { theVeryFont->deRenderAll(); - currentFonts.removeAll(theVeryFont); - TagsWidget::getInstance()->removeFromTagged(theVeryFont); + FMFontDb::DB()->removeFilteredFont(theVeryFont); theVeryFont = 0 ; typo->removeFontItem(curItemName); curItemName = lastIndex = faceIndex = ""; fontsetHasChanged = true; - fillTree(); +// fillTree(); } } -void MainViewWidget::slotLiveFontSize() -{ - double fs( liveFontSizeSpin->value() ); - reSize(fs, fs * sampleRatio); - slotView(true); -} - -void MainViewWidget::slotRemoteFinished() -{ - qDebug()<<"slotRemoteFinished : "<currentItem()->data(0, Qt::UserRole).toString() ); + QString ret/*( sampleTextTree->currentItem()->data(0, Qt::UserRole).toString() )*/; if (ret.isEmpty()) ret = typo->defaultSampleName(); return ret; } -void MainViewWidget::displayWelcomeMessage() -{ - if(!typotek::getInstance()->welcomeURL().isEmpty()) - { - fontInfoText->load(QUrl(typotek::getInstance()->welcomeURL())); - return; - } - - QString welcomeFontName; - QString welcomeSVG; - if(FMFontDb::DB()->FontCount() > 0) - { - QList fl(FMFontDb::DB()->AllFonts()); - QString welcomeString(tr("Welcome to Fontmatrix") ); - if(fl.count() > 0) - { - int flcount(fl.count()); - int rIdx( std::rand() % flcount ); - QList triedFont; - while(triedFont.count() < flcount) - { - while(triedFont.contains(rIdx)) - rIdx = std::rand() % flcount; - triedFont << rIdx; - FontItem * f(fl[rIdx]); - if(f->hasChars(welcomeString)) - { - QStringList wList(welcomeString.split(" ")); - foreach(const QString& wPart, wList) - { - welcomeSVG += "
"; - welcomeSVG += f->renderSVG( wPart , QString(QSettings().value("General/WelcomeSize", tr("122.0", "Size of the welcome message" )).toString()).toDouble()); - welcomeSVG += "
"; - } - welcomeFontName = f->fancyName(); - break; - } - } - } - } -// QString ResPat(FMPaths::ResourcesDir()); -// QFile wFile( ResPat + "welcome_"+ FMPaths::sysLoc() + ".html"); -// wFile.open(QIODevice::ReadOnly | QIODevice::Text); -// QByteArray wArray(wFile.readAll()); -// QString wString(QString::fromUtf8(wArray.data(),wArray.length())); -// wString.replace("##RECOURCES_DIR##", QUrl::fromLocalFile(ResPat).toString() ); -// wString.replace("##WELCOME_MESSAGE##", welcomeSVG); -// wString.replace("##WELCOME_FONT##", welcomeFontName); - QString wString; - wString += "\n" ; - wString += "" ; - wString += "" ; - wString += welcomeSVG ; - wString +="
"+welcomeFontName+"
"; - wString += "" ; - fontInfoText->setContent(wString.toUtf8(), "application/xhtml+xml"); -} - -// QTextDocument * MainViewWidget::infoDocument() -// { -// return fontInfoText->document(); -// } - -QGraphicsScene * MainViewWidget::currentSampleScene() -{ - if(!loremView->isVisible()) - { - tabWidget->setCurrentIndex(1); - stackedViews->setCurrentIndex(VIEW_PAGE_ABSOLUTE); - slotView(true); - } - return loremScene; -} - -FMPlayGround * MainViewWidget::getPlayground() -{ - return playView; -} - -void MainViewWidget::addFilterToCrumb(QString filter) -{ - QString t(m_lists->filtersCrumb->text()); - t += "[" + filter.trimmed() + "]"; - m_lists->filtersCrumb->setText(t); -} - -void MainViewWidget::setCrumb(QString text) -{ - m_lists->filtersCrumb->setText(text); -} - -// Don’t know if it’s really useful -// It will be used for track down problems at least -void MainViewWidget::slotSelectFromFolders(const QString &f) -{ -// qDebug()<<"or even this other"; - slotFontSelectedByName(f); -} - -QWebView * MainViewWidget::info() -{ - return fontInfoText; -} - -void MainViewWidget::slotChangeViewPageSetting ( bool ch ) -{ -// qDebug() <<"MainViewWidget::slotChangeViewPageSetting("<objectName() ); - if ( !ch ) - { - toolPanelWidth = splitter_2->sizes().at ( 1 ) ; - stackedTools->hide(); - } - else - { - stackedTools->show(); - if ( splitter_2->sizes().at ( 1 ) == 0 ) - { - QList li; - li << splitter_2->width() - toolPanelWidth << toolPanelWidth; - splitter_2->setSizes ( li ); - } - } - - QMap bmap; - QMap pmap; - bmap[ "settingsButton" ] = settingsButton; - bmap[ "openTypeButton" ] = openTypeButton; - bmap[ "sampleButton" ] = sampleButton; - pmap[ "settingsButton" ] = VIEW_PAGE_SETTINGS; - pmap[ "openTypeButton" ] = VIEW_PAGE_OPENTYPE; - pmap[ "sampleButton" ] = VIEW_PAGE_SAMPLES; - - foreach(QString pk, bmap.keys()) - { - if(butName == pk) - { - stackedTools->setCurrentIndex(pmap[pk]); - } - else - { - bmap[pk]->setChecked ( false ); - } - } -} - -void MainViewWidget::slotChangeViewPage(QAbstractButton* but) -{ - QString radioName( but->objectName() ); - - if(radioName == "freetypeRadio" ) - { - stackedViews->setCurrentIndex(VIEW_PAGE_FREETYPE); - hintingSelect->setEnabled(true); - } - else if(radioName == "nativeRadio" ) - { - stackedViews->setCurrentIndex(VIEW_PAGE_ABSOLUTE); - hintingSelect->setEnabled(false); - } - - slotView(true); -} void MainViewWidget::saveSplitterState() { QSettings settings; - settings.setValue( "WState/SplitterViewState", splitter_2->saveState()); - settings.setValue( "WState/SplitterList1", ListDockWidget::getInstance()->listSplit1->saveState()); - settings.setValue( "WState/SplitterList2", ListDockWidget::getInstance()->listSplit2->saveState()); + // settings.setValue( "WState/SplitterViewState", splitter_2->saveState()); +// settings.setValue( "WState/SplitterList1", ListDockWidget::getInstance()->listSplit1->saveState()); +// settings.setValue( "WState/SplitterList2", ListDockWidget::getInstance()->listSplit2->saveState()); } void MainViewWidget::restoreSplitterState() { QSettings settings; - splitter_2->restoreState(settings.value("WState/SplitterViewState").toByteArray()); - ListDockWidget::getInstance()->listSplit1->restoreState(settings.value("WState/SplitterList1").toByteArray()); - ListDockWidget::getInstance()->listSplit2->restoreState(settings.value("WState/SplitterList2").toByteArray()); -} - -unsigned int MainViewWidget::hinting() -{ - if(lightHinting->isChecked()) - return FT_LOAD_TARGET_LIGHT; - else if(normalHinting->isChecked()) - return FT_LOAD_TARGET_NORMAL; - - return FT_LOAD_NO_HINTING ; + // splitter_2->restoreState(settings.value("WState/SplitterViewState").toByteArray()); +// ListDockWidget::getInstance()->listSplit1->restoreState(settings.value("WState/SplitterList1").toByteArray()); +// ListDockWidget::getInstance()->listSplit2->restoreState(settings.value("WState/SplitterList2").toByteArray()); } -void MainViewWidget::slotHintChanged(int ) -{ - slotView(true); -} -void MainViewWidget::slotWebStart() -{ -// qDebug()<<"slotWebStart"; - typo->startProgressJob(100); -} -void MainViewWidget::slotWebFinished(bool status) +QList MainViewWidget::curFonts() { -// qDebug()<<"slotWebinished"<endProgressJob(); + // qDebug()<<"curFonts"< flist) { -// qDebug()<<"slotWebLoad("<runProgressJob(i); + FMFontDb::DB()->setFilterdFonts(flist); } -void MainViewWidget::slotWebLink(const QUrl & url) +void MainViewWidget::slotQuickSearch(const QString& text) { - if(typo->getWebBrowser() == QString( "Fontmatrix" )) + int t(quickSearchTime.elapsed()); + bool hasText(false); + qDebug()< quickSearchWait) ) { - typo->showStatusMessage(tr("Load") + " " + url.toString()); - fontInfoText->load(url); + quickSearchWidget->show(); + if(!quickSearchTimer) + { + quickSearchTimer = new QTimer; + connect(quickSearchTimer, SIGNAL(timeout()), this, SLOT(slotEndQuickSearch())); + } + quickSearchTimer->start(quickSearchWait); + quickSearchString = text; + quickSearch->setText(quickSearchString); + quickSearch->setFocus(Qt::OtherFocusReason); + quickSearchTime.start(); + hasText = listView->moveTo(quickSearchString); } - else + else if(t <= quickSearchWait) { - QStringList arguments(typo->getWebBrowserOptions().split(" ", QString::SkipEmptyParts)); - arguments << url.toString(); - - if(!QProcess::startDetached(typo->getWebBrowser(), arguments)) + if(sender() != quickSearch) { - arguments.removeLast(); - QMessageBox::warning(this,"Fontmatrix", QString(tr("An error occured when tried to load %1\nwith command: %2", "%1 is an url and %2 a program")).arg(url.toString()).arg( typo->getWebBrowser() + " " + arguments.join(" "))); + quickSearch->setText(quickSearchString); + quickSearchString += text; } - } -} - -QList MainViewWidget::curFonts() -{ -// qDebug()<<"curFonts"< flist) -{ - currentFonts = flist; - fillTree(); - -} - + else + quickSearchString = text; + quickSearchTime.restart(); + quickSearchTimer->start(quickSearchWait); + hasText = listView->moveTo(quickSearchString); -void MainViewWidget::slotShowULine(bool checked) -{ - if(checked) - { - uniLine->setText(""); - uniLine->setEnabled(true); } else { - uniLine->setEnabled(false); + quickSearchString.clear(); + quickSearchWidget->hide(); } + if(hasText) + quickSearch->setStyleSheet(QString()); + else + quickSearch->setStyleSheet(QString("background-color:#F44;")); } -void MainViewWidget::slotPanoseFilter(const QMap >& filter) +void MainViewWidget::slotEndQuickSearch() { - QList dbresult( FMFontDb::DB()->getValues( FMFontDb::Panose ) ); - QList fil; - for(int i(0); i < dbresult.count() ; ++i) - { - QList list; - QString p(dbresult[i].second); - QStringList pl(p.split(":")); - bool match(true); - foreach(const int& k , filter.keys()) - { - if(!filter[k].contains(pl[k].toInt())) - { - match = false; - break; - } - } - if(match) - fil << dbresult[i].first; - } - currentFonts = fil; -// setCrumb(classificationView->filterAsString()); - fillTree(); + quickSearchWidget->hide(); + quickSearchString.clear(); + quickSearchTimer->stop(); + listView->setFocus(Qt::OtherFocusReason); + quickSearch->setStyleSheet(QString()); } - -void MainViewWidget::toggleFacesCheckBoxes(bool state) +void MainViewWidget::slotSelectFromQuickSearch() { - if(state == activateByFamilyOnly) - { - activateByFamilyOnly = !state; - fillTree(); - } + slotEndQuickSearch(); + slotShowFamily( listView->currentIndex() ); } -void MainViewWidget::forceReloadSelection() +void MainViewWidget::slotPreviewUpdateSize(int w) { - m_forceReloadSelection = true; + listView->setIconSize(QSize(qRound(w ), 1.3 * typotek::getInstance()->getPreviewSize() * typotek::getInstance()->getDpiY() / 72.0)); } -double MainViewWidget::playgroundFontSize() -{ - return playFontSize->value(); -} diff -Nru fontmatrix-0.6.0+svn20100107/src/mainviewwidget.h fontmatrix-0.6.0+svn20110930/src/mainviewwidget.h --- fontmatrix-0.6.0+svn20100107/src/mainviewwidget.h 2009-11-20 14:59:52.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/mainviewwidget.h 2011-02-08 14:43:38.000000000 +0000 @@ -24,12 +24,9 @@ #include #include +#include + -#define VIEW_PAGE_FREETYPE 0 -#define VIEW_PAGE_ABSOLUTE 1 -#define VIEW_PAGE_OPENTYPE 0 -#define VIEW_PAGE_SETTINGS 1 -#define VIEW_PAGE_SAMPLES 2 class QGraphicsScene; class typotek; @@ -39,9 +36,12 @@ class QTreeWidgetItem; class QGraphicsRectItem; class QButtonGroup; -class ListDockWidget; +class QWebView; +//class ListDockWidget; struct OTFSet; class FMLayout; +class FMPreviewModel; +class QTimer; /** MainViewWidget inherits from an ui designed. @@ -57,184 +57,73 @@ ~MainViewWidget(); private: - QGraphicsScene *abcScene; - QGraphicsScene *loremScene; - QGraphicsScene *ftScene; - QGraphicsScene *playScene; - FMLayout *textLayout; QStringList ord; QStringList fields; typotek *typo; - ListDockWidget *m_lists; +// ListDockWidget *m_lists; QString faceIndex; QString lastIndex; - QList currentFonts; +// QList currentFonts; *moved to FMFontDB* QList orderedCurrentFonts; - QString sampleText; +// QString sampleText; QGridLayout *tagLayout; QString currentOrdering; FontItem *theVeryFont; bool fontsetHasChanged; - QGraphicsRectItem *curGlyph; bool activateByFamilyOnly; bool m_forceReloadSelection; + QString quickSearchString; + QTime quickSearchTime; + QTimer *quickSearchTimer; + int quickSearchWait; void doConnect(); void disConnect(); void allActivation(bool act); void activation(QList fit, bool act); - void fillTree(); - void updateTree(bool checkFontActive = false); - - - void operateFilter(QList allFiltered, const QString filterName); - - QStringList openKeys; + QString curItemName; - double sampleFontSize; - double sampleInterSize; - double sampleRatio; - -// QMap > uniPlanes; -// void fillUniPlanes(); - void fillUniPlanesCombo(FontItem* item); - - void fillOTTree(); - OTFSet deFillOTTree(); - bool renderingLock; - int fancyGlyphInUse; - int fancyGlyphData; - - bool uRangeIsNotEmpty; - - -// void prepare(QList fonts); -// QList theTaggedFonts; -// bool contextMenuReq; -// QPoint contextMenuPos; QIcon iconPS1; QIcon iconTTF; QIcon iconOTF; - - QString currentDownload; - - QUrl infoCSSUrl; - - QButtonGroup *radioRenderGroup; - QButtonGroup *radioFTHintingGroup; - - unsigned int hinting(); - - int toolPanelWidth; - - QString unMapGlyphName; - QString allMappedGlyphName; - + + FMPreviewModel * previewModel; + public slots: void slotOrderingChanged ( QString s ); - void slotFontSelected ( QTreeWidgetItem * item, int column ); - bool slotFontSelectedByName(QString fname); - void slotInfoFont(); - void slotView(bool needDeRendering = false); - void slotShowOneGlyph(); - void slotShowAllGlyph(); - void slotSearch(); - - void slotFontAction(QTreeWidgetItem * item, int column ); - bool slotFontActionByName(const QString &fname); - bool slotFontActionByNames(QStringList fnames); - void slotEditAll(); - void slotZoom(int z); - void slotAppendTag(QString tag); - void slotFilterTag(QString tag); + bool slotFontSelectedByName(const QString& fname); + void slotPreviewUpdateSize(int w); + void slotShowFamily(const QModelIndex& familyIdx); + void slotQuitFamily(); void slotDesactivateAll(); void slotActivateAll(); - void slotSetSampleText(QString); - void slotActivate(bool act, QTreeWidgetItem * item, int column); - void slotReloadFontList(); - - void slotSwitchAntiAlias(bool aa); - - void slotItemOpened(QTreeWidgetItem * item); - void slotViewAll(); - void slotViewActivated(); - void slotPlaneSelected(int); - void slotSearchCharName(); - void slotAdjustGlyphView(int width); - void slotFeatureChanged(); - void slotSampleChanged(); - void slotFTRasterChanged(); - void slotWantShape(); - void slotChangeScript(); - - - void slotProgressionChanged(); - void slotUpdateGView(); - void slotUpdateGViewSingle(); - void slotUpdateSView(); - void slotUpdateRView(); - void slotUpdateTree(); - void slotEditSampleText(); void slotRemoveCurrentItem(); - void slotPanoseFilter(const QMap >& filter); - - //lists - void slotSelectFromFolders(const QString&); - - //glyphs view - void slotShowULine(bool); - private slots: - void slotLiveFontSize(); - void slotRemoteFinished(); + void slotQuickSearch(const QString& text); + void slotEndQuickSearch(); + void slotSelectFromQuickSearch(); - void slotDefaultOTF(); - void slotResetOTF(); - - void slotChangeViewPageSetting(bool); - void slotChangeViewPage(QAbstractButton* ); - void slotHintChanged(int); - - - void slotWebLink(const QUrl & url ); - void slotWebStart(); - void slotWebLoad(int i); - void slotWebFinished(bool); - - - void toggleFacesCheckBoxes(bool); - - void refreshActStatus(const QStringList& flist); signals: void faceChanged(); - void newTag(QString); - void tagAdded(QString); - void stopLayout(); void listChanged(); public: QString defaultOrd() {return ord[0];} - QGraphicsScene* glyphsScene()const{return abcScene;} - QGraphicsScene* textScene()const{return loremScene;} QList curFonts(); void setCurFonts(QList flist); FontItem* selectedFont(){return theVeryFont;} - - void reSize(double fSize, double lSize){sampleFontSize = fSize; sampleInterSize = lSize;} - void refillSampleList(); + QString sampleName(); - void displayWelcomeMessage(); +// void displayWelcomeMessage(); QWebView *info(); - QGraphicsScene *currentSampleScene(); - FMPlayGround *getPlayground(); void addFilterToCrumb(QString filter); void setCrumb(QString text = QString()); @@ -244,7 +133,7 @@ void forceReloadSelection(); - double playgroundFontSize(); + protected: void keyPressEvent ( QKeyEvent * event ) ; diff -Nru fontmatrix-0.6.0+svn20100107/src/messages/fontmatrix-ru.ts fontmatrix-0.6.0+svn20110930/src/messages/fontmatrix-ru.ts --- fontmatrix-0.6.0+svn20100107/src/messages/fontmatrix-ru.ts 2009-07-03 12:35:01.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/messages/fontmatrix-ru.ts 2010-08-12 17:41:37.000000000 +0000 @@ -1,6 +1,6 @@ - - + + About @@ -14,6 +14,7 @@ Заставка + TextLabel TextLabel @@ -102,6 +103,73 @@ + ChartWidget + + + Form + Form + + + + Coverage of Unicode Interval + Охват блока Unicode + + + + Block: + Блок: + + + + Search: + Искать: + + + + Search a character by its codepoint (expressed in hexadecimal +and prefixed with "U+", "u+" or "+") or a glyph by its name. +Press enter after editing to run the search. + Поиск глифа по его коду (шестнадцатиричное значение +с префиксом в виде "U+", "u+" или "+") или названию. +Нажатие клавиши ввода запускает поиск. + + + + Clicking on a glyph will show details about it + Щелкните по символу для подробного просмотра + + + + Set Mode "Copy Character to Clipboard" + Включить режим копирования символов в буфер обмена + + + + Copy Mode + Режим копирования + + + + Un-Mapped Glyphs + Несвязанные глифы + + + + View all mapped glyphs + Все связанные глифы + + + + Block (%1): + Блок (%1): + + + + Print Chart + Печать таблицы символов + + + CompareWidget @@ -225,36 +293,55 @@ Unable to link + Activation subroutine failed to make a symbolic link to the font file Не удалось связать Font already activated + The Font asked for activation is already activated Шрифт уже активирован Unable to un-link + Activation subroutine failed to remove a symbolic link to the font file Не удалось снять связь Font already de-activated + The Font asked for de-activation is already de-activated Шрифт уже деактивирован Cannot link or copy the metrics file + A postcript font (pfb) without its metrics file (afm) Не удалось связать или скопировать файл метрик Error activation + A generic error in activation or deactivation process Ошибка + FMFloatingMenu + + + Activate + Активировать + + + + close + Закрыть + + + FMFontExtract @@ -277,9 +364,8 @@ FMLayout - Text engine options - Параметры текстового движка + Параметры текстового движка @@ -291,12 +377,35 @@ - + No font match the submitted image Ни один шрифт в коллекции не соответствует указанному образцу + FMMissingFontHelper + + + + Missing Font File + Отсутствует файл шрифта + + + + Fontmatrix has been unable to load the font in file +%1. + Please check missing files. + + + + + Fontmatrix has been unable to load fonts in files +%1. + Please check missing files. + + + + FMScriptConsole @@ -315,24 +424,305 @@ + FamilyWidget + + + Form + Form + + + + Return To List + Вернуться в коллекцию + + + + Info + Сводка + + + + Sample + Образец + + + + Chart + Таблица символов + + + + Activate + Активировать + + + + Deactivate + Деактивировать + + + + Family Name + Название гарнитуры + + + + about:blank + about:blank + + + + FilterBar + + + Form + Form + + + + Add Filter: + Добавить фильтр: + + + Meta + Мета + + + + Add a generic metadata field to the filter + Добавить в фильтр поле из типовых метаданных шрифта + + + + Metadata + Метаданные + + + + Add a Panose metadata field to the filter + Добавить в фильтр поле из метаданных Panose + + + + Panose + Panose + + + + Manage named filters + Управление именованными фильтрами + + + + + Filters + Фильтры + + + + Clear + Очистить + + + + Tags + Метки + + + + All activated + Все активированные + + + + FilterItem + + + Form + Form + + + + TextLabel + Метка + + + + Remove Filter + Удалить фильтры + + + + X + X + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> +<table style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If set, the filter will <span style=" font-weight:600;">intersect</span> with the previous filters.</p></td></tr></table></body></html> + + + + + && + && + + + + if set, it will filter all the fonts but these matching this filter + + + + + ! + ! + + + + FilterTagDialog + + + Dialog + Диалог + + + + FiltersDialog + + Dialog + Диалог + + + + Filters Manager + Управление фильтрами + + + + Filter Name: + Название фильтра: + + + + OK + ОК + + + + current filter + Текущий фильтр + + + + Add Filter + Добавить фильтр + + + + And + И + + + + Not + НЕ + + + + Or + ИЛИ + + + + FiltersDialogItem + + + Form + Form + + + + filter name + Название фильтра + + + + Apply this filter to the list + Применить этот фильтр к списку + + + + Filter + Фильтр + + + + Delete this filter + Удалить этот фильтр + + + + Remove + Удалить + + + + TextLabel + TextLabel + + + + FloatingWidgetToolBar + + + Form + Form + + + + Close + Закрыть + + + + Hide + Скрыть + + + + Detach + Отцепить + + + + Print + Печать + + + FolderViewMenu - + Import recursively Импортировать рекурсивно - + Import Directory Импортировать каталог - + Import File Импортировать файл - Reload Tree Повторно загрузить дерево @@ -358,7 +748,7 @@ FontBookDialog - + Save fontBook Сохранить каталог шрифтов @@ -418,17 +808,17 @@ FontItem - + Fontmatrix - Download Fontmatrix — Скачать - + Downloading %1. Скачивается %1. - + Category Категория @@ -541,11 +931,29 @@ Все поля + + + + + + + + + Any Любой вариант + + + + + + + + + No Fit Все остальное @@ -1416,6 +1824,7 @@ + &Print... &Печать... @@ -1426,6 +1835,7 @@ + &Find... &Найти... @@ -1445,12 +1855,16 @@ &Добавить закладку + + &Delete &Удалить + + D&elete All &Удалить все @@ -1481,6 +1895,7 @@ <h2><p>Извините, но руководство пользователя не установлено!</p><p>Свяжитесь с создателем пакета дял вашего дистрибутива, либо, если вы самостоятельно собирали Fontmatrix, с разработчиками программы.</p></h2> + Fontmatrix Help Справка по Fontmatrix @@ -1506,6 +1921,7 @@ &Искать + 1 1 @@ -1619,6 +2035,9 @@ Вес переменных + + + score @@ -1672,52 +2091,52 @@ ListDock - + Form Form - + Filter view by chosing tag Отфильтровать список шрифтов выбором метки - + + Names Названия - + Show complete collection of available fonts Показать всю коллекцию шрифтов - + F П - + TextLabel TextLabel - Previews - Миниатюры + Миниатюры - + Folders Папки - + reset Сбросить - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -1732,27 +2151,27 @@ - + Not НЕ - + And И - + save Сохранить - + Collapse or expand Развернуть/Свернуть - + Show face boxes Отключаемые начертания @@ -1760,7 +2179,7 @@ ListDockWidget - + All activated Все активированные @@ -1770,7 +2189,7 @@ Юникодный символ - + Similar to current Схожие с текущим @@ -1780,9 +2199,8 @@ Метки - You can use the following keywords to be replaced by data from fonts: <strong>&#60;name&#62;</strong> ; <strong>&#60;family&#62;</strong> ; <strong>&#60;variant&#62;</strong> - Вы можете использовать следующие ключевые слова для подстановки метаданных шрифтов: <strong>&#60;name&#62;</strong> ; <strong>&#60;family&#62;</strong> ; <strong>&#60;variant&#62;</strong> + Вы можете использовать следующие ключевые слова для подстановки метаданных шрифтов: <strong>&#60;name&#62;</strong> ; <strong>&#60;family&#62;</strong> ; <strong>&#60;variant&#62;</strong> @@ -1813,348 +2231,289 @@ main view widget - + + Quick Search: + Быстрый поиск: + + Font Information - Сводка + Сводка - Sample Text - Образец текста + Образец текста - Font Size - Кегль шрифта + Кегль шрифта - pt - pt + pt - Use shaper - Использовать шейпер + Использовать шейпер - OpenType Features - Функции OpenType + Функции OpenType - Friendly Name - Удобочитаемое название + Удобочитаемое название - Glyphs - Глифы + Глифы - Clicking on a glyph will show details about it - Щелкните по символу для подробного просмотра + Щелкните по символу для подробного просмотра - Playground - Песочница + Песочница - push Добавить - Settings Параметры - OpenType OpenType - Save as default - Запомнить + Запомнить - Reset Default - Сбросить + Сбросить - FreeType Отрисовка через FreeType - Native Qt objects Отрисовка средствами Qt - World is wide - Мир велик + Мир велик - Shaper type - Шейпер: + Шейпер: - Set Mode "Copy Character to Clipboard" - Включить режим копирования символов в буфер обмена + Включить режим копирования символов в буфер обмена - No hinting - Без уточнения + Без уточнения - Light Hinting - Слабое уточнение + Слабое уточнение - Normal Hinting - Обычное уточнение + Обычное уточнение - Display Settings Параметры отображения - Classification - Классификация + Классификация - Compare - Сравнение глифов + Сравнение глифов - Script Writing system - Письменность: + Письменность: - Edit sample text - Изменить текст образца + Изменить текст образца - Edit - Изменить + Изменить - FreeType based rasterized rendering - Растрированный рендеринг на основе FreeType + Растрированный рендеринг на основе FreeType - Vectorized rendering using native toolkit (Qt) Векторный рендеринг средствами графической библиотеки Qt - Coverage of Unicode Interval - Охват блока Unicode + Охват блока Unicode - Block: - Блок: + Блок: - More Options - Больше параметров + Больше параметров - ... - ... + ... - Search: - Искать: + Искать: - Copy Mode - Режим копирования + Режим копирования - 1 - 1 + 1 - Search a character by its codepoint (expressed in hexadecimal and prefixed with "U+", "u+" or "+") or a glyph by its name. Press enter after editing to run the search. - Поиск глифа по его коду (шестнадцатиричное значение + Поиск глифа по его коду (шестнадцатиричное значение с префиксом в виде "U+", "u+" или "+") или названию. Нажатие клавиши ввода запускает поиск. - Sample Выбор текста - Appearance - Отрисовка + Отрисовка - Font Size: - Кегль шрифта: + Кегль шрифта: - Sample text rendering options - Параметры отрисовки образца текста + Параметры отрисовки образца текста - Display settings - Параметры отображения + Параметры отображения - Enable and disable OpenType features implemented in the font - Включение и отключение функций OpenType, доступных в выбранном шрифте + Включение и отключение функций OpenType, доступных в выбранном шрифте - OpenType features - Функции OpenType + Функции OpenType - Choose a sample text from your collection - Выбор образцов текста из коллекции + Выбор образцов текста из коллекции - Samples collection - Образцы текста + Образцы текста - Rasterized - Растрированная + Растрированная - Freely scalable vector rendering using native toolkit (Qt) - Свободно масштабируемая отрисовка текста + Свободно масштабируемая отрисовка текста - Vector - Векторная + Векторная MainViewWidget - + Names Названия - + Fontmatrix takes care of you Fontmatrix заботится о вас - + is activated. If you want to remove it from Fontmatrix database, please deactivate it first. активирован. Если вы хотите убрать его из базы данных Fontmatrix, деактивируйте его для начала. - + Fontmatrix safe Fontmatrix волнуется - + You are about to remove a font from Fontmatrix database Вы собираетесь удалить шрифт из базы данных Fontmatrix - + Do you want to continue? Вы хотите продолжить? - Welcome to Fontmatrix - Добро пожаловать в Fontmatrix + Добро пожаловать в Fontmatrix - Load - Загрузить + Загрузить - - Activated - - - - An error occured when tried to load %1 with command: %2 %1 is an url and %2 a program - Произошла ошибка при попытке загрузить %1 + Произошла ошибка при попытке загрузить %1 командой: %2 - 122.0 Size of the welcome message - 18.0 + 18.0 - Block (%1): - Блок (%1): + Блок (%1): - User - Добавленный + Добавленный - Un-Mapped Glyphs - Несвязанные глифы + Несвязанные глифы - View all mapped glyphs - Все связанные глифы + Все связанные глифы @@ -2241,6 +2600,24 @@ + MetaWidget + + + Form + Form + + + + Fill-in a text field and press enter to filter on a single domain or click "Add Filters" button for multiple filters. + + + + + Add Filters + Добавить фильтры + + + PanoseDialog @@ -2254,6 +2631,51 @@ + PanoseWidget + + Form + Form + + + + Panose Metadata + Метаданные Panose + + + + Panose Attributes + Атрибуты Panose + + + + PlayWidget + + + Form + Form + + + + Font Size: + Кегль шрифта: + + + + pt + pt + + + + Playground + Песочница + + + + Print Playground + Печать содержимого песочницы + + + PrefsPanel @@ -2261,6 +2683,7 @@ Диалог настройки + General Общие @@ -2286,6 +2709,9 @@ Справа налево + + + pt pt @@ -2301,6 +2727,10 @@ /usr/bin/fontforge + + + + Browse... Просмотреть... @@ -2341,6 +2771,7 @@ http:// + Remove Удалить @@ -2435,7 +2866,7 @@ + + - + @@ -2564,21 +2995,25 @@ Выберите вариант из списка или добавьте собственный. + Alt Alt + Ctrl Ctrl + Shift Shift + Meta Meta @@ -2609,7 +3044,7 @@ Заменить - + Shortcut is already in use for action name will be appended to this Комбинация уже используется для @@ -2664,172 +3099,173 @@ Копируются файлы - + + cancel Отменить - + Unable to copy Не удалось скопировать - + Creating font book... Создается каталог шрифтов... - + codepoint is U+ - + Mark, NonSpacing - + Mark, SpacingCombining - + Mark, Enclosing - + Number, DecimalDigit Числа, десятичные - + Number, Letter - + Number, Other Числа, прочие - + Separator, Space Разделители, пробелы - + Separator, Line Разделители, строки - + Separator, Paragraph Разделители, абзацы - + Other, Control - + Other, Format - + Other, Surrogate - + Other, PrivateUse - + Other, NotAssigned - + Letter, Uppercase Буквы, прописные - + Letter, Lowercase Буквы, строчные - + Letter, Titlecase Буквы, Заглавные - + Letter, Modifier Буквы, модификаторы - + Letter, Other Буквы, прочие - + Punctuation, Connector Знаки препинания, соединители - + Punctuation, Dash Знаки препинания, тире - + Punctuation, Open Знаки препинания, открывающие - + Punctuation, Close Знаки препинания, закрывающие - + Punctuation, InitialQuote Знаки препинания, открывающие кавычки - + Punctuation, FinalQuote Знаки препинания, закрывающие кавычки - + Punctuation, Other Знаки препинания, прочие - + Symbol, Math Символы, математика - + Symbol, Currency Символы, валюта - + Symbol, Modifier Символы, модификаторы - + Symbol, Other Символы, прочее @@ -3474,890 +3910,833 @@ Стилистический набор 20 - + Glyphs count Число глифов - + Font Type Тип шрифта - + Charmaps List Список кодировок - Basic Latin - Основная латиница + Основная латиница - Latin-1 Supplement - Latin-1, дополнение 1 + Latin-1, дополнение 1 - Latin Extended-A - Латиница, расширение А + Латиница, расширение А - Latin Extended-B - Латиница, расширение B + Латиница, расширение B - IPA Extensions - Расширения IPA + Расширения IPA - Spacing Modifier Letters - Модификаторы пробелов + Модификаторы пробелов - Combining Diacritical Marks - Объединяющие диакритические знаки + Объединяющие диакритические знаки - Greek and Coptic - Греческий и коптский + Греческий и коптский - Cyrillic - Кириллица + Кириллица - Cyrillic Supplement - Кириллица, дополнение + Кириллица, дополнение - Armenian - Армянский + Армянский - Hebrew - Иврит + Иврит - Arabic - Арабский + Арабский - Syriac - Сирийский + Сирийский - Arabic Supplement - Арабские дополнительные + Арабские дополнительные - Thaana - Таана + Таана - NKo - Н'ко + Н'ко - Devanagari - Деванагари + Деванагари - Bengali - Бенгали + Бенгали - Gurmukhi - Гурмухи + Гурмухи - Gujarati - Гуджарати + Гуджарати - Oriya - Орийя + Орийя - Tamil - Тамильский + Тамильский - Telugu - Телугу + Телугу - Kannada - Каннада + Каннада - Malayalam - Малайский + Малайский - Sinhala - Сингалезский + Сингалезский - Thai - Тайский + Тайский - Lao - Лаосский + Лаосский - Tibetan - Тибетский + Тибетский - - Myanmar - - - - Georgian - Грузинский + Грузинский - Hangul Jamo - Хангул Ямо + Хангул Ямо - Ethiopic - Эфиопский + Эфиопский - Ethiopic Supplement - Эфиопский, дополнение + Эфиопский, дополнение - Cherokee - Чероки + Чероки - - Unified Canadian Aboriginal Syllabics - - - - Ogham - Огамическое письмо + Огамическое письмо - Runic - Руническое письмо + Руническое письмо - Tagalog - Тагалог + Тагалог - Hanunoo - Хануноо + Хануноо - Buhid - Бухид + Бухид - Tagbanwa - Тагбанва + Тагбанва - Khmer - Кхмерский + Кхмерский - Mongolian - Монгольский + Монгольский - Limbu - Лимбу + Лимбу - Tai Le - Тайский Ле + Тайский Ле - New Tai Lue - Новый Тайский Ле + Новый Тайский Ле - Khmer Symbols - Кхмерские символы + Кхмерские символы - Buginese - Бугинский + Бугинский - Balinese - Балинезийский + Балинезийский - Sundanese - Сунданский + Сунданский - Lepcha - Лепча + Лепча - Ol Chiki - Ол Чики + Ол Чики - Phonetic Extensions - Фонетические расширения + Фонетические расширения - Phonetic Extensions Supplement - Фонетические расширения, дополнение + Фонетические расширения, дополнение - Combining Diacritical Marks Supplement - Комбинированные диакритические знаки, дополнение + Комбинированные диакритические знаки, дополнение - Latin Extended Additional - Латиница расширенная дополнительная + Латиница расширенная дополнительная - Greek Extended - Греческий расширенный + Греческий расширенный - General Punctuation - Общая пунктуация + Общая пунктуация - Superscripts and Subscripts - Надстрочные и подстрочные + Надстрочные и подстрочные - Currency Symbols - Символы валют + Символы валют - Combining Diacritical Marks for Symbols - Комбинированные диакритические знаки для символов + Комбинированные диакритические знаки для символов - Letterlike Symbols - Буквообразные символы + Буквообразные символы - Number Forms - Формы чисел + Формы чисел - Arrows - Стрелки + Стрелки - Mathematical Operators - Математические операторы + Математические операторы - Miscellaneous Technical - Различные технические символы + Различные технические символы - Control Pictures - Управляющие картинки + Управляющие картинки - Optical Character Recognition - Оптическое распознавание символов + Оптическое распознавание символов - Enclosed Alphanumerics - Алфавитно-цифровые символы в рамке + Алфавитно-цифровые символы в рамке - Box Drawing - Для рисования рамок + Для рисования рамок - Block Elements - Блочные элементы + Блочные элементы - Geometric Shapes - Геометрические фигуры + Геометрические фигуры - Miscellaneous Symbols - Различные символы + Различные символы - Dingbats - Условные знаки + Условные знаки - Miscellaneous Mathematical Symbols-A - Различные математические символы A + Различные математические символы A - Supplemental Arrows-A - Дополнительные стрелки A + Дополнительные стрелки A - Braille Patterns - Азбука Брайля + Азбука Брайля - Supplemental Arrows-B - Дополнительные стрелки B + Дополнительные стрелки B - Miscellaneous Mathematical Symbols-B - Различные математические символы B + Различные математические символы B - Supplemental Mathematical Operators - Дополнительные математические операторы + Дополнительные математические операторы - Miscellaneous Symbols and Arrows - Различные символы и стрелки + Различные символы и стрелки - Glagolitic - Глаголица + Глаголица - Latin Extended-C - Латиница, расширение C + Латиница, расширение C - Coptic - Коптский + Коптский - Georgian Supplement - Грузинский, дополнения + Грузинский, дополнения - Tifinagh - Тифинаг + Тифинаг - Ethiopic Extended - Эфиопский, расширенный + Эфиопский, расширенный - Cyrillic Extended-A - Кириллица, расширение А + Кириллица, расширение А - Supplemental Punctuation - Дополнительные знаки препинания + Дополнительные знаки препинания - CJK Radicals Supplement - Дополнения корней CJK + Дополнения корней CJK - Kangxi Radicals - Корни Кангхи + Корни Кангхи - Ideographic Description Characters - Символы идеографического описания + Символы идеографического описания - CJK Symbols and Punctuation - Символы и знаки препинания CJK + Символы и знаки препинания CJK - Hiragana - Хирагана + Хирагана - Katakana - Катакана + Катакана - Bopomofo - Бопомото + Бопомото - Hangul Compatibility Jamo - Хангул, совместимый с Ямо + Хангул, совместимый с Ямо - Kanbun - Канбун + Канбун - Bopomofo Extended - Бопомото, расширенный + Бопомото, расширенный - CJK Strokes - Росчерки CJK + Росчерки CJK - Katakana Phonetic Extensions - Катакана, фонетические расширения + Катакана, фонетические расширения - Enclosed CJK Letters and Months - Знаки и месяца CJK в рамке + Знаки и месяца CJK в рамке - CJK Compatibility - CJK, совместимость + CJK, совместимость - CJK Unified Ideographs Extension A - CJK, объединенные идеограммы, расширение A + CJK, объединенные идеограммы, расширение A - Yijing Hexagram Symbols - Гексаграммы Юиджинг + Гексаграммы Юиджинг - CJK Unified Ideographs - CJK, объединенные идеограммы + CJK, объединенные идеограммы - Yi Syllables - Слоги Юи + Слоги Юи - Yi Radicals - Корни Юи + Корни Юи - Vai - Ваи + Ваи - Cyrillic Extended-B - Кириллица, расширение B + Кириллица, расширение B - Modifier Tone Letters - Модификаторы тона + Модификаторы тона - Latin Extended-D - Латиница, расширение D + Латиница, расширение D - Syloti Nagri - Силоти Нагри + Силоти Нагри - Phags-pa - Фагс-па - - - - Saurashtra - - - - - Kayah Li - - - - - Rejang - - - - - Cham - + Фагс-па - Hangul Syllables - Слоги Хангул + Слоги Хангул - High Surrogates - Заменители в верхнем регистре + Заменители в верхнем регистре - High Private Use Surrogates - Заменители в верхнем регистре, пользовательские + Заменители в верхнем регистре, пользовательские - Low Surrogates - Заменители в нижнем регистре + Заменители в нижнем регистре - Private Use Area - Область пользователя + Область пользователя - CJK Compatibility Ideographs - CJK, идеограммы для совместимости + CJK, идеограммы для совместимости - Alphabetic Presentation Forms - Формы алфавитного представления (лигатуры) + Формы алфавитного представления (лигатуры) - Arabic Presentation Forms-A - Арабские формы представления A + Арабские формы представления A - - Variation Selectors - - - - Vertical Forms - Вертикальные формы + Вертикальные формы - - Combining Half Marks - - - - CJK Compatibility Forms - CJK, формы для совместимости + CJK, формы для совместимости - Small Form Variants - Малые варианты форм + Малые варианты форм - Arabic Presentation Forms-B - Арабские формы представления B - - - - Halfwidth and Fullwidth Forms - + Арабские формы представления B - Specials - Специальные + Специальные - Linear B Syllabary - Линейное слоговое письмо Б + Линейное слоговое письмо Б - Linear B Ideograms - Линейное идеографическое письмо Б + Линейное идеографическое письмо Б - Aegean Numbers - Эгейские числа + Эгейские числа - Ancient Greek Numbers - Древнегреческие числа + Древнегреческие числа - - Ancient Symbols - - - - Phaistos Disc - Фестский диск + Фестский диск - Lycian - Ликийский + Ликийский - Carian - Карийский + Карийский - Old Italic - Этрусский + Этрусский - Gothic - Готское письмо + Готское письмо - Ugaritic - Угаритский + Угаритский - Old Persian - Древнеперсидский + Древнеперсидский - Deseret - Дезерет + Дезерет - Shavian - Скорописный алфавит Бернарда Шоу + Скорописный алфавит Бернарда Шоу - Osmanya - Сомалийское письмо + Сомалийское письмо - Cypriot Syllabary - Кипрское письмо + Кипрское письмо - Phoenician - Финикийский + Финикийский - Lydian - Лидийский + Лидийский - Kharoshthi - Кхароштхи + Кхароштхи - Cuneiform - Клинопись + Клинопись - Cuneiform Numbers and Punctuation - Клинописные числа и знаки препинания + Клинописные числа и знаки препинания - Byzantine Musical Symbols - Визайнтийская нотная грамота + Визайнтийская нотная грамота - Musical Symbols - Нотная грамота + Нотная грамота - Ancient Greek Musical Notation - Древнегреческая нотная грамота - - - - Tai Xuan Jing Symbols - + Древнегреческая нотная грамота - Counting Rod Numerals - Счетные палочки + Счетные палочки - Mathematical Alphanumeric Symbols - Математические алфавитно-цифровые символы + Математические алфавитно-цифровые символы - Mahjong Tiles - Кости для игры в маджонг + Кости для игры в маджонг - Domino Tiles - Кости для игры в домино + Кости для игры в домино - CJK Unified Ideographs Extension B - CJK, объединенные идеограммы, расширение B + CJK, объединенные идеограммы, расширение B - - CJK Compatibility Ideographs Supplement - - - - Tags - Метки + Метки - - Variation Selectors Supplement - - - - Supplementary Private Use Area-A - Дополнительная область пользователя A + Дополнительная область пользователя A - Supplementary Private Use Area-B - Дополнительная область пользователя B + Дополнительная область пользователя B - + Unicode Ranges Блоки Unicode + + + Chart + Таблица символов + + + + Sample + Выбор текста + RemoteDir + Downloading Скачивается + SampleWidget + + + Form + Form + + + + OpenType Features + Функции OpenType + + + + Friendly Name + Удобочитаемое название + + + + Save as default + Запомнить + + + + Reset Default + Сбросить + + + + Appearance + Отрисовка + + + + Font Size + Кегль шрифта + + + + pt + pt + + + + FreeType based rasterized rendering + Растрированный рендеринг на основе FreeType + + + + Rasterized + Растрированная + + + + No hinting + Без уточнения + + + + Light Hinting + Слабое уточнение + + + + Normal Hinting + Обычное уточнение + + + + Freely scalable vector rendering using native toolkit (Qt) + Свободно масштабируемая отрисовка текста + + + + Vector + Векторная + + + + World is wide + Мир велик + + + + Script + Writing system + Письменность + + + + Shaper type + Шейпер: + + + + Use shaper + Использовать шейпер + + + + 1 + 1 + + + + Edit sample text + Изменить текст образца + + + + Edit + Изменить + + + + Sample text rendering options + Параметры отрисовки образца текста + + + + Display settings + Параметры отображения + + + + Enable and disable OpenType features implemented in the font + Включение и отключение функций OpenType, доступных в выбранном шрифте + + + + OpenType features + Функции OpenType + + + + Choose a sample text from your collection + Выбор образцов текста из коллекции + + + + Samples collection + Образцы текста + + + + User + Identify root of user defined sample texts + Добавленный + + + + Print Sample + Печать образца текста + + + ScriptConsole @@ -4425,32 +4804,32 @@ Systray - + &Activate all &Активировать все - + &Deactivate all &Деактивировать все - + Mi&nimize &Свернуть - + &Restore &Развернуть - + E&xit В&ыход - + &Tags &Метки @@ -4552,26 +4931,26 @@ TagsWidget - + Edit followed by a tag name Изменить метку - + Remove tag "%1" from database the %%1 is a tag name Удалить метку «%1» из базы данных - + Please confirm that you want to remove the following tag from database: Подтвердите желание удалить из базы данных следующую метку: - + Please provide a replacement name for the following tag: Укажите новой название следующей метки: @@ -4590,11 +4969,13 @@ Направление строки + e.g. Latin text Например, текст на латыни + Left to right Слева направо @@ -4605,6 +4986,7 @@ Например, арабский текст + Right to left Справа налево @@ -4615,6 +4997,7 @@ Например, текст на традицонном китайском или японском языках + Top to bottom Сверху вниз @@ -4686,11 +5069,15 @@ Мертвые ссылки + + + Select all Выбрать все + Remove Удалить @@ -4744,27 +5131,31 @@ tagsWidget - + Form Form - + Right mouse click on a tag to add it or remove it from TagSet Щелкните правой клавишей мыши метку, чтобы добавить или удалить ее из набора меток - + + Tags + Метки + + Nothing selected - Ничего не выбрано + Ничего не выбрано - + Add a tag Добавить метку - + Add Tag Добавить метку @@ -4772,427 +5163,472 @@ typotek - + default По умолчанию - + Browse Fonts Поиск шрифтов - + Fontmatrix Fontmatrix - + The program will keep running in the system tray. To terminate the program, choose <b>Exit</b> in the context menu of the system tray entry. Программа останется в области уведомления. Для завершения работы с ней выберите команду «Выйти» в контекстном меню программы из области уведомления. - + Add Directory Добавить каталог - + + Importing font files... Импортируются шрифтовые файлы... - + + cancel Отменить - + + Import Импортируются - + Choose the tag for filter exported fonts Выберите метку для фильтрации экспортируемых шрифтов - + Choose Directory Укажите каталог - + &Import... &Импортировать... - + Ctrl+O Ctrl+O - + Import a directory Импортировать шрифты из каталога - + Ctrl+S Ctrl+S - + Export a fontset Экспортировать набор шрифтов - + Print Info... Напечатать сводку... - + Print informations about the current font Напечатать сводку по текущему шрифту - + Print Sample... Напечатать образец... - + Print the sample as a specimen Напечатать образец текста - + Print Chart... Напечатать таблицу символов... - + Print a chart of the current font Напечатать таблицу символов текущего шрифта - + Print Playground... Напечатать песочницу... - + Print the playground Напечатать содержимое песочницы - + Print Family... Напечатать всю гарнитуру... - + Print a specimen of the whole family the current face belongs to Напечатать образец гарнитуры, которой принадлежит выбранное начертание - + Export font book... Создать каталог шрифтов... - + E&xit В&ыход - + Ctrl+Q Ctrl+Q - + Exit the application Завершить работу с программой - + &About &О программе - + About &Qt О &Qt - + Help Справка - + Activate all current Активировать все выбранные - + Deactivate all current Деактивировать все выбранные - + Edit current font Изменить выбранный шрифт - + + Playground + Песочница + + + + Show/Hide Playground + + + + + Close All + + + + + Close all floating windows + + + + + Show All + + + + + Show all floating windows + + + + + Hide All + + + + + Hide all floating windows + + + + Try to run font editor with the selected font as argument Попытаться открыть текущий шрифт в редакторе шрифтов - + You don't seem to have font editor installed. Path to font editor can be set in preferences. Похоже, редактор шрифтов не установлен. Его расположение можно указать в диалоге настройки. - + Preferences Параметры - + Check Database Проверить базу данных - + &File &Файл - + Print Печать - + &Help &Справка - + Ready Готово - + Load settings Загрузка параметров - + Check for Fontmatrix own dir Проверка каталога Fontmatrix - + + Adding Добавляется - + font descriptions imported from network Взятые из сети описания шрифтов - + + Fontmatrix care Fontmatrix заботится о вас - + You are about to activate a bunch of fonts, it is time to cancel if it was not your intent Сейчас будет активирована куча шрифтов, самое время отменить активацию, если вы это нечаянно затеяли. - + You are about to deactivate a bunch of fonts, it is time to cancel if it was not your intent Сейчас будет деактивирована куча шрифтов, самое время отменить деактивацию, если вы это нечаянно затеяли. - + There is no font selected Ни один шрифт не выбран - + Support of DragNDrop over http is sheduled but not yet effective Поддержка перетаскивания с http запланирована, но пока не реализована - - You bring something over me I can’t handle + + You bring something over me I can’t handle Программа не умеет обрабатывать данные такого типа - + Welcome maessage Приветственное сообщение - + Print Infos Печати сводки - + Print Chart Печать таблицы символов - + Print Playground Печать содержимого песочницы - + Print Family Печать гарнитуры - + &Edit &Правка - + + Fonts imported: %1 Импортировано шрифтов: %1 - + Next Family Следующая гарнитура - + Next Face Следующее начертание - + Previous Family Предыдущая гарнитура - + Previous Face Предыдущее начертание - + &Browse Пере&ход - + Not enough text to make a sample Недостаточно текста для создания образца - + &Sync &Синхронизироваться - + Sync with the DB file Синхронизироваться с базой данных - Print Sample - Печать образца текста + Печать образца текста - Tags - Метки + Метки - + Show TrueType tables Показать таблицы TrueType - + Close Закрыть - + &View &Вид - + System Fonts Системные шрифты - + system fonts added. системных шрифтов добавлено. - + + fonts from followed by a directory name шрифтов из - + Execute Last Script Выполнить последний сценарий - + &Scripts С&ценарии - + Python scripts (*.py) Сценарии на Python (*.py) - + Fontmatrix Help Справка по Fontmatrix - + Extract fonts... Извлечь шрифты... - + Cannot import this font because it is broken: Не удалось импортировать этот испорченный шрифт: - + Cannot import this font because it is broken: Не удалось импортировать этот испорченный шрифт: - + Filtered Font(s): %n number of filtererd fonts showed in status bar @@ -5202,233 +5638,230 @@ - + Current Font: followed by currently selected font name (in status bar) Текущий шрифт: - + Show/hide fonts browsing sidebar Показать или скрыть боковую панель для поиска шрифтов - Show/hide tags list sidebar - Показать или скрыть боковую панель со списком меток + Показать или скрыть боковую панель со списком меток - + Fontmatrix Tags Метки Fontmatrix - + Export a PDF document that shows selected fonts Создать шрифтовый альбом в формате PDF - + Show information about Fontmatrix Показывать информацию о Fontmatrix - + Show information about Qt Показывать информацию о Qt - + F1 F1 - + Read documentation on Fontmatrix Открыть документацию по Fontmatrix - + Activate all currently visible fonts Активировать все видимые сейчас в списке шрифты - + Deactivate all currently visible fonts Деактивировать все видимые сейчас в списке шрифты - + Edit currently selected font in a font editor of your choice Изменить выбранный шрифтовый файл в избранном редакторе шрифтов - + You don't seem to have a font editor installed. Path to font editor can be set in Preferences dialog. Похоже, что у вас не установлен или не найден редактор шрифтов. Укажите путь к нему в диалоге настройки программы. - + Setup Fontmatrix Настроить Fontmatrix - + Check Fontmatrix database for dead links to font files Проверить базу данных Fontmatrix на ссылки к несуществующим шрифтам - + Tag all currently visible files Присвоить метки всем видимым сейчас в списке шрифтам - + View hexadecimal values of TrueType tables for currently selected font file Просмотреть шестнадцатиричные значения таблиц TrueType для выбранного шрифтового файла - + Edit PANOSE metadata Изменить метаданные PANOSE... - + Edit PANOSE metadata without saving changes to font files Изменить метаданные PANOSE, не сохраняя изменения в сами шрифтовые файлы - + Switch to the next font family in the list Перейти к следующей в списке гарнитуре - + Switch to the next font face in the list Перейти к следующему в списке начертанию - + Switch to the previous font family in the list Перейти к предыдущей в списке гарнитуре - + Switch to the previous font face in the list Перейти к предыдущему в списке начертанию - + Extract fonts from documents like PDF to PFM file format Извлечь встроенные в PDF грифты в файлы формата PFM - + Execute Script... Исполнить сценарий... - + Execute a Python script Исполнить сценарий на языке Python - + Execute the last chosen Python script Исполнить последний выбранный сценарий на языке Python - + Script Console... Консоль... - + Open Python scripting console Открыть консоль для тестирования сценариев на языке Python - + Fill a template file with metadata for packaging currently selected font to a Linux distribution Заполнить метаданными шаблон для упаковки выбранного шрифта в дистрибутив Linux - + Find a font using raster sample... Найти шрифты по растровому образцу... - + Find a font using a raster sample of a letter Найти шрифты по растровому образцу одного символа - Text layout engine options - Параметры текстового движка + Параметры текстового движка - View and edit text layout engine variables - Просмотреть и изменить переменные текстового движка + Просмотреть и изменить переменные текстового движка - + confirmation Подтверждение - + Do you confirm you want to import these %1 fonts? Вы действительно хотите импортировать %1 шрифтов? - + Loading System Fonts Загружаются системные шрифты - + Export &fonts &Экспортировать шрифты... - + Export font info for packaging... Экспортировать данные для упаковки... - + Tag All Filtered... Метки для всех отфильтрованных... - + &Service С&ервис - + Reload Filtered Повторно загрузить отфильтрованные - + Reload informations for filtered fonts from the font files they belong to Повторно загрузить информацию об отфильтрованных шрифтах из их файлов - + Reload Selected Повторно загрузить выбранный - + Reload informations for selected font from the font file Повторно загрузить информацию о текущем выбранном шрифте из его файла - + Failed to reload %n fonts Не удалось загрузить %n шрифт diff -Nru fontmatrix-0.6.0+svn20100107/src/metawidget.cpp fontmatrix-0.6.0+svn20110930/src/metawidget.cpp --- fontmatrix-0.6.0+svn20100107/src/metawidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/metawidget.cpp 2010-09-14 10:45:17.000000000 +0000 @@ -0,0 +1,150 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "metawidget.h" +#include "ui_metawidget.h" +#include "fmfontstrings.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QStringListModel * MetaWidget::mModel = 0; +QStringList MetaWidget::mList = QStringList(); + +MetaWidget::MetaWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::MetaWidget) +{ + ui->setupUi(this); + if(mModel == 0) + { + mModel = new QStringListModel; + mModel->setStringList(mList); + } +// QGridLayout * ui->grid(new QGridLayout(this)); + QCompleter * completer(new QCompleter(mModel)); + + // dont know why but it doesn't want to be placed in the ui->grid ### +// QLabel *lab(new QLabel(tr("
Fill-in a text field and press enter.
"), this)); +// ui->grid->addWidget(lab,0,0,0,-1); + + QList ln; + ln << FMFontDb::FontFamily + << FMFontDb::FontSubfamily + << FMFontDb::Designer + << FMFontDb::Description + << FMFontDb::Copyright + << FMFontDb::Trademark + << FMFontDb::ManufacturerName + << FMFontDb::LicenseDescription + << FMFontDb::AllInfo; + + int limit(qRound((ln.count() + 1) / 2) - 1); + + for(int gIdx(0); gIdx < ln.count() ; ++gIdx) + { + FMFontDb::InfoItem k(ln[gIdx]); +// if((k != FMFontDb::AllInfo)) + { + QString fieldname(FontStrings::Names().value(k)); + if(k == FMFontDb::AllInfo) + fieldname = QString("
%1
").arg(fieldname); + QLabel *label(new QLabel(fieldname,this)); + QLineEdit *line(new QLineEdit(this)); + metFields[line] = k; + line->setCompleter(completer); + label->setBuddy(line); + connect(line,SIGNAL(returnPressed()), this, SLOT(addFilter())); + if((gIdx) < limit) + { + ui->grid->addWidget(label,gIdx,0); + ui->grid->addWidget(line,gIdx ,1); + } + else + { + int row(gIdx - limit); + ui->grid->addWidget(label, row, 3); + ui->grid->addWidget(line, row , 4); + } + } + } + + connect(ui->cancelButton, SIGNAL(clicked()), this, SIGNAL(Close())); + connect(ui->filterButton, SIGNAL(clicked()), this, SLOT(addFilter())); +} + +MetaWidget::~MetaWidget() +{ + delete ui; +} + +void MetaWidget::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void MetaWidget::addFilter() +{ +// if(QString(sender()->metaObject()->className()) == QString("QLineEdit")) +// { +// QLineEdit *l(reinterpret_cast(sender())); +// FMFontDb::InfoItem it(metFields[l]); +// QString t(l->text()); +// if(!mList.contains(t)) +// { +// mList.append(t); +// mModel->setStringList(mList); +// } +// resultMap[it] = t; +// } +// else + { + foreach(QLineEdit *l, metFields.keys()) + { + QString t(l->text()); + FMFontDb::InfoItem it(metFields[l]); + if(!t.isEmpty()) + { + if(!mList.contains(t)) + { + mList.append(t); + mModel->setStringList(mList); + } + resultMap[it] = t; + } + } + } + emit filterAdded(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/metawidget.h fontmatrix-0.6.0+svn20110930/src/metawidget.h --- fontmatrix-0.6.0+svn20100107/src/metawidget.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/metawidget.h 2010-09-14 10:45:17.000000000 +0000 @@ -0,0 +1,73 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef METAWIDGET_H +#define METAWIDGET_H + +#include +#include +#include +#include + +#include "fmfontstrings.h" + +class QStringListModel; +class QPushButton; +class QLineEdit; +class QComboBox; +class QHBoxLayout; + +namespace Ui { + class MetaWidget; +} + +class MetaWidget : public QWidget +{ + Q_OBJECT + +public: + explicit MetaWidget(QWidget *parent = 0); + ~MetaWidget(); + + QMap resultMap; + +protected: + void changeEvent(QEvent *e); + +private: + Ui::MetaWidget *ui; + + static QStringListModel *mModel; + static QStringList mList; + QWidget *filterWidget; + QComboBox *filterCombo; + QLineEdit *filterLine; + QPushButton *filterButton; + QMap metFields; + +signals: + void filterAdded(); + void Close(); + +private slots: + void addFilter(); +}; + +#endif // METAWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/metawidget.ui fontmatrix-0.6.0+svn20110930/src/metawidget.ui --- fontmatrix-0.6.0+svn20100107/src/metawidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/metawidget.ui 2010-09-14 10:45:17.000000000 +0000 @@ -0,0 +1,81 @@ + + + MetaWidget + + + + 0 + 0 + 476 + 89 + + + + Form + + + + + + + 75 + true + + + + Fill-in text fields and press enter key or click "Add Filters" button to process filters. + + + true + + + + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Add Filters + + + + + + + Cancel + + + + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/openclosearrow.cpp fontmatrix-0.6.0+svn20110930/src/openclosearrow.cpp --- fontmatrix-0.6.0+svn20100107/src/openclosearrow.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/openclosearrow.cpp 2011-01-10 15:36:51.000000000 +0000 @@ -0,0 +1,49 @@ +#include "openclosearrow.h" + +OpenCloseArrow::OpenCloseArrow(QWidget *parent, bool open) : + QLabel(parent), + openingState(open) +{ +// setOpText(); +} + +OpenCloseArrow::~OpenCloseArrow() +{ + +} + + +void OpenCloseArrow::mouseReleaseEvent(QMouseEvent *ev) +{ + openingState = !openingState; + setOpText(); + emit openChanged(openingState); + +} + + +void OpenCloseArrow::changeOpen(bool t) +{ + openingState = t; + setOpText(); + emit openChanged(openingState); +} + +void OpenCloseArrow::setOpText() +{ + if(baseText.isEmpty()) + baseText = text(); + QFont f(font()); + if(openingState) + { + f.setBold(true); + setFont(f); + setText(QString("%1").arg(baseText)); + } + else + { + f.setBold(false); + setFont(f); + setText(QString("%1").arg(baseText)); + } +} diff -Nru fontmatrix-0.6.0+svn20100107/src/openclosearrow.h fontmatrix-0.6.0+svn20110930/src/openclosearrow.h --- fontmatrix-0.6.0+svn20100107/src/openclosearrow.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/openclosearrow.h 2011-01-10 15:36:51.000000000 +0000 @@ -0,0 +1,34 @@ +#ifndef OPENCLOSEARROW_H +#define OPENCLOSEARROW_H + +#include + + +class OpenCloseArrow : public QLabel +{ + Q_OBJECT + + QString baseText; + +public: + explicit OpenCloseArrow(QWidget *parent = 0, bool open = true); + ~OpenCloseArrow(); + + bool isOpen() const {return openingState;} + +private: + bool openingState; + void setOpText(); + +protected: + void mouseReleaseEvent( QMouseEvent * ev ); + +signals: + void openChanged(bool); + +public slots: + void changeOpen(bool t); + +}; + +#endif // OPENCLOSEARROW_H diff -Nru fontmatrix-0.6.0+svn20100107/src/panosewidget.cpp fontmatrix-0.6.0+svn20110930/src/panosewidget.cpp --- fontmatrix-0.6.0+svn20100107/src/panosewidget.cpp 2009-10-15 17:19:19.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/panosewidget.cpp 2011-02-17 10:42:06.000000000 +0000 @@ -22,111 +22,94 @@ #include "ui_panosewidget.h" #include "panosemodel.h" #include "fmfontstrings.h" +#include "fmpaths.h" #include +#include +#include +#include +#include +#include -PanoseWidget * PanoseWidget::instance = 0; PanoseWidget::PanoseWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::PanoseWidget) { m_ui->setupUi(this); - attributeModel = new PanoseAttributeModel( this); - valueModel = new PanoseValueModel( this); - m_ui->attributeView->setModel(attributeModel); - m_ui->valueView->setModel(valueModel); m_filter.clear(); m_filterKey = 0; - connect(m_ui->attributeView, SIGNAL(activated (const QModelIndex&)), this, SLOT(slotChangeAtrr(const QModelIndex&))); - connect(m_ui->valueView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotUpdateFilter(const QItemSelection & , const QItemSelection &))); - connect(m_ui->pTree, SIGNAL(activated(QModelIndex)), this, SLOT(slotSelectAttr(QModelIndex))); -} -PanoseWidget::~PanoseWidget() -{ - delete m_ui; -} + QPalette palette(m_ui->pTree->palette()); + palette.setBrush(QPalette::Base, Qt::transparent); + m_ui->pTree->setPalette(palette); + + const QMap< FontStrings::PanoseKey, QMap >& p(FontStrings::Panose()); + QSettings settings; + QString defaultDir(FMPaths::ResourcesDir() + "Panose/Icons"); + QString pDir(settings.value("Panose/IconDir", defaultDir).toString() + QDir::separator()); -PanoseWidget * PanoseWidget::getInstance() -{ - if(!instance) + foreach(const FontStrings::PanoseKey& k, p.keys()) { - instance = new PanoseWidget(); - Q_ASSERT(instance); - } - return instance; -} + QString fn(pDir + QString::number(k) + QDir::separator() + "attribute.png"); + QTreeWidgetItem * pItem(new QTreeWidgetItem(m_ui->pTree)); + pItem->setText(0, FontStrings::PanoseKeyName(k)); + pItem->setData(0,Qt::UserRole,k); + if(QFile::exists(fn)) + pItem->setIcon(0, QIcon(fn)); -void PanoseWidget::slotChangeAtrr(const QModelIndex& index) -{ - if(index.isValid()) - { - m_filterKey = index.row(); - valueModel->setCat(m_filterKey); - disconnect(m_ui->valueView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotUpdateFilter(const QItemSelection & , const QItemSelection &))); - m_ui->valueView->clearSelection(); - if(m_filter.contains(m_filterKey) && !m_filter[m_filterKey].isEmpty()) + foreach(const int& v, p[k].keys()) { - foreach(const int& r, m_filter[m_filterKey]) + if(v > 1) // We do not want "Any" and "No Fit" { - m_ui->valueView->selectionModel()->select(valueModel->index(r), QItemSelectionModel::Select); + QString fn2(pDir + QString::number(k) + QDir::separator() + QString::number(v) +".png"); + + QTreeWidgetItem * item(new QTreeWidgetItem(pItem)); + item->setText(0, p[k][v]); + item->setData(0,Qt::UserRole,v); +// item->setForeground(0, QColor(qrand() % 255, qrand() % 255, qrand() % 255)); + if(QFile::exists(fn2)) + item->setIcon(0, QIcon(fn2)); } } - connect(m_ui->valueView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotUpdateFilter(const QItemSelection & , const QItemSelection &))); } + + connect(m_ui->pTree, SIGNAL(itemClicked(QTreeWidgetItem * , int )), this, SLOT(slotSelect(QTreeWidgetItem * , int ))); +} + +PanoseWidget::~PanoseWidget() +{ + delete m_ui; } -void PanoseWidget::slotUpdateFilter(const QItemSelection & selected, const QItemSelection & deselected) + +void PanoseWidget::doConnect(const bool &c) { - QList ns; - foreach(const QModelIndex& i, m_ui->valueView->selectionModel()->selectedIndexes()) + if(c) { - ns << i.row() + 2; // since "0" and "1" has been removed from the list + connect(m_ui->pTree, SIGNAL(clicked(QTreeWidgetItem * , int )), this, SLOT(slotSelect(QTreeWidgetItem * , int ))); } - if(ns.count()) - m_filter[m_filterKey] = ns; else - m_filter.remove(m_filterKey); - - m_ui->pTree->clear(); - foreach(const int& k, m_filter.keys()) { - QTreeWidgetItem *pItem(new QTreeWidgetItem(m_ui->pTree)); - pItem->setText(0, FontStrings::PanoseKeyName(FontStrings::PanoseKey(k))); - foreach(const int& v, m_filter[k]) - { - QTreeWidgetItem *item(new QTreeWidgetItem(pItem)); - item->setText(0, FontStrings::Panose().value( FontStrings::PanoseKey(k) )[v]); - } - pItem->setExpanded(true); + disconnect(m_ui->pTree, SIGNAL(clicked(QTreeWidgetItem * , int )), this, SLOT(slotSelect(QTreeWidgetItem * , int ))); } - - - - emit filterChanged(m_filter); } -void PanoseWidget::slotSelectAttr(const QModelIndex& idx) +void PanoseWidget::slotSelect(QTreeWidgetItem *item, int column) { - QModelIndex tmpIdx(idx); - while(tmpIdx.parent().isValid()) - tmpIdx = tmpIdx.parent(); + if(column > 0 ) + return; + if(item->childCount() > 0) + return; + int pValue(item->parent()->data(0,Qt::UserRole).toInt()); + int cValue(item->data(0,Qt::UserRole).toInt()); - const QString cs(tmpIdx.data(Qt::DisplayRole).toString()); - for(int i(0); i < m_ui->attributeView->model()->rowCount(); ++i) - { - const QModelIndex &cIdx(m_ui->attributeView->model()->index(i,0)); - if(cs == cIdx.data(Qt::DisplayRole).toString()) - { - m_ui->attributeView->setCurrentIndex(cIdx); - slotChangeAtrr(cIdx); - return; - } - } + m_filter.clear(); + m_filter.insert(pValue,QList() << cValue); + emit filterChanged(); } void PanoseWidget::setFilter(const QMap >& filter) @@ -145,3 +128,8 @@ // break; // } //} + +void PanoseWidget::closeEvent(QCloseEvent *) +{ + hide(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/panosewidget.h fontmatrix-0.6.0+svn20110930/src/panosewidget.h --- fontmatrix-0.6.0+svn20100107/src/panosewidget.h 2009-10-15 17:19:19.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/panosewidget.h 2011-01-10 15:36:51.000000000 +0000 @@ -22,11 +22,9 @@ #define PANOSEWIDGET_H #include -#include #include -class PanoseValueModel; -class PanoseAttributeModel; +class QTreeWidgetItem; namespace Ui { class PanoseWidget; @@ -36,33 +34,30 @@ class PanoseWidget : public QWidget { Q_OBJECT - PanoseWidget(QWidget *parent = 0); - static PanoseWidget * instance; public: - static PanoseWidget * getInstance(); - + PanoseWidget(QWidget *parent = 0); ~PanoseWidget(); void setFilter(const QMap >& filter); + QMap > getFilter() const{return m_filter;} protected: // void changeEvent(QEvent *e); + void closeEvent(QCloseEvent *); private: Ui::PanoseWidget *m_ui; - PanoseAttributeModel * attributeModel; - PanoseValueModel * valueModel; int m_filterKey; QMap > m_filter; + void doConnect(const bool& c); + private slots: - void slotChangeAtrr(const QModelIndex& idx); - void slotUpdateFilter(const QItemSelection & selected, const QItemSelection & deselected); - void slotSelectAttr(const QModelIndex& idx); + void slotSelect(QTreeWidgetItem * item, int column); signals: - void filterChanged(const QMap >&); + void filterChanged(); }; diff -Nru fontmatrix-0.6.0+svn20100107/src/panosewidget.ui fontmatrix-0.6.0+svn20110930/src/panosewidget.ui --- fontmatrix-0.6.0+svn20100107/src/panosewidget.ui 2009-10-15 12:32:07.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/panosewidget.ui 2011-01-10 17:25:20.000000000 +0000 @@ -11,139 +11,52 @@ - Form + Panose Metadata + + 0 + - - - Qt::Vertical - - - - - 0 - 2 - - - - - 0 - - - 0 - - - - - - 1 - 0 - - - - QFrame::NoFrame - - - Qt::ScrollBarAlwaysOff - - - Qt::ElideNone - - - QListView::Static - - - QListView::TopToBottom - - - QListView::Adjust - - - QListView::ListMode - - - 0 - - - false - - - true - - - - - - - - 2 - 0 - - - - QFrame::NoFrame - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::NoDragDrop - - - QAbstractItemView::ExtendedSelection - - - - 64 - 64 - - - - Qt::ElideNone - - - QListView::Static - - - QListView::TopToBottom - - - QListView::Adjust - - - QListView::IconMode - - - 0 - - - true - - - - - - - Qt::Vertical - - - - - - - - - 0 - 1 - + + + + 0 + 1 + + + + Qt::NoFocus + + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SingleSelection + + + 12 + + + true + + + true + + + false + + + + Panose Attributes - - - Panose Attributes - - - + diff -Nru fontmatrix-0.6.0+svn20100107/src/playwidget.cpp fontmatrix-0.6.0+svn20110930/src/playwidget.cpp --- fontmatrix-0.6.0+svn20100107/src/playwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/playwidget.cpp 2010-06-30 10:44:12.000000000 +0000 @@ -0,0 +1,121 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "playwidget.h" +#include "ui_playwidget.h" + +#include +#include +#include +#include +#include + +PlayWidget* PlayWidget::instance = 0; +PlayWidget::PlayWidget() : + ui(new Ui::PlayWidget) +{ + ui->setupUi(this); + setWindowTitle(tr("Playground")); + ui->toolbar->setDetached(); + ui->toolbar->setNoClose(true); + playScene = new QGraphicsScene; + playScene->setSceneRect ( 0,0,10000,10000 ); + ui->playView->setScene( playScene ); + + connect ( ui->playView, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); + connect(ui->toolbar, SIGNAL(Hide()), this, SLOT(hide())); + connect(ui->toolbar, SIGNAL(Print()), this, SLOT(print())); +} + +PlayWidget::~PlayWidget() +{ + delete ui; +} + +PlayWidget* PlayWidget::getInstance() +{ + if(instance == 0) + { + instance = new PlayWidget; + Q_ASSERT(instance); + } + return instance; +} + +void PlayWidget::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void PlayWidget::closeEvent(QCloseEvent *) +{ + hide(); +} + + +void PlayWidget::slotZoom ( int z ) +{ + double delta = 1.0 + ( z/1000.0 ) ; + QTransform trans; + trans.scale ( delta,delta ); + ui->playView->setTransform ( trans, ( z == 0 ) ? false : true ); +} + +double PlayWidget::playFontSize() +{ + return ui->playFontSize->value(); +} + +QRectF PlayWidget::getMaxRect() +{ + return ui->playView->getMaxRect(); +} + +void PlayWidget::clearSelection() +{ + ui->playView->deselectAll(); +} + +void PlayWidget::print() +{ + QPrinter thePrinter ( QPrinter::HighResolution ); + QPrintDialog dialog(&thePrinter, this); + dialog.setWindowTitle("Fontmatrix - " + tr("Print Playground") ); + + if ( dialog.exec() != QDialog::Accepted ) + return; + thePrinter.setFullPage ( true ); + QPainter aPainter ( &thePrinter ); + + double pWidth(thePrinter.paperRect().width()); + double pHeight(thePrinter.paperRect().height()); + + QRectF targetR( pWidth * 0.1, pHeight * 0.1, pWidth * 0.8, pHeight * 0.8 ); + QRectF sourceR( PlayWidget::getInstance()->getMaxRect()); + PlayWidget::getInstance()->clearSelection(); + PlayWidget::getInstance()->getPlayScene()->render(&aPainter, targetR ,sourceR, Qt::KeepAspectRatio ); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/playwidget.h fontmatrix-0.6.0+svn20110930/src/playwidget.h --- fontmatrix-0.6.0+svn20100107/src/playwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/playwidget.h 2010-06-28 09:52:59.000000000 +0000 @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef PLAYWIDGET_H +#define PLAYWIDGET_H + +#include +#include + +class QGraphicsScene; + +namespace Ui { + class PlayWidget; +} + +class PlayWidget : public QWidget +{ + Q_OBJECT + + static PlayWidget* instance; + explicit PlayWidget(); +public: + ~PlayWidget(); + static PlayWidget* getInstance(); + double playFontSize(); + QRectF getMaxRect(); + void clearSelection(); + QGraphicsScene* getPlayScene(){return playScene;} + +protected: + void changeEvent(QEvent *e); + void closeEvent(QCloseEvent *); + +private: + Ui::PlayWidget *ui; + QGraphicsScene *playScene; + +private slots: + void slotZoom ( int z ); + void print(); +}; + +#endif // PLAYWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/playwidget.ui fontmatrix-0.6.0+svn20110930/src/playwidget.ui --- fontmatrix-0.6.0+svn20100107/src/playwidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/playwidget.ui 2010-06-28 09:52:59.000000000 +0000 @@ -0,0 +1,89 @@ + + + PlayWidget + + + + 0 + 0 + 662 + 524 + + + + Form + + + + 2 + + + 2 + + + + + + + + QFrame::NoFrame + + + + + + + Qt::Horizontal + + + + 497 + 20 + + + + + + + + Font Size: + + + playFontSize + + + + + + + pt + + + 1.000000000000000 + + + 999.990000000000009 + + + 24.000000000000000 + + + + + + + + FloatingWidgetToolBar + QWidget +
floatingwidgettoolbar.h
+ 1 +
+ + FMPlayGround + QGraphicsView +
fmplayground.h
+
+
+ + +
diff -Nru fontmatrix-0.6.0+svn20100107/src/progressbarduo.cpp fontmatrix-0.6.0+svn20110930/src/progressbarduo.cpp --- fontmatrix-0.6.0+svn20100107/src/progressbarduo.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/progressbarduo.cpp 2010-09-22 15:31:04.000000000 +0000 @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "progressbarduo.h" +#include "ui_progressbarduo.h" + +ProgressBarDuo::ProgressBarDuo(QWidget *parent) : + QDialog(parent), + ui(new Ui::ProgressBarDuo) +{ + ui->setupUi(this); + connect(ui->cancelButton, SIGNAL(Canceled()), this, SIGNAL(Canceled())); +} + +ProgressBarDuo::~ProgressBarDuo() +{ + delete ui; +} + +void ProgressBarDuo::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + + +void ProgressBarDuo::setLabel(const QString &s, int n) +{ + QLabel *l = 0; + + switch(n) + { + case 0: l = ui->Label0; + break; + case 1: l = ui->Label1; + break; + default: break; + } + if(l) + l->setText(s); +} + + +void ProgressBarDuo::setValue(int value, int n) +{ + QProgressBar *p = 0; + switch(n) + { + case 0: p = ui->Bar0; + break; + case 1: p = ui->Bar1; + break; + default: break; + } + if(p) + p->setValue(value); +} + +void ProgressBarDuo::setMax(int max, int n) +{ + QProgressBar *p = 0; + switch(n) + { + case 0: p = ui->Bar0; + break; + case 1: p = ui->Bar1; + break; + default: break; + } + if(p) + p->setMaximum(max); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/progressbarduo.h fontmatrix-0.6.0+svn20110930/src/progressbarduo.h --- fontmatrix-0.6.0+svn20100107/src/progressbarduo.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/progressbarduo.h 2010-09-22 15:31:04.000000000 +0000 @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef PROGRESSBARDUO_H +#define PROGRESSBARDUO_H + +#include + +namespace Ui { + class ProgressBarDuo; +} + +class ProgressBarDuo : public QDialog +{ + Q_OBJECT + +public: + explicit ProgressBarDuo(QWidget *parent = 0); + ~ProgressBarDuo(); + + void setLabel(const QString& s, int n); + void setValue(int value, int n); + void setMax(int max, int n); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::ProgressBarDuo *ui; + +signals: + void Canceled(); +}; + +#endif // PROGRESSBARDUO_H diff -Nru fontmatrix-0.6.0+svn20100107/src/progressbarduo.ui fontmatrix-0.6.0+svn20110930/src/progressbarduo.ui --- fontmatrix-0.6.0+svn20100107/src/progressbarduo.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/progressbarduo.ui 2010-09-22 15:31:04.000000000 +0000 @@ -0,0 +1,69 @@ + + + ProgressBarDuo + + + + 0 + 0 + 298 + 134 + + + + Dialog + + + + + + TextLabel + + + + + + + 24 + + + + + + + TextLabel + + + + + + + 24 + + + + + + + Qt::Horizontal + + + + 204 + 20 + + + + + + + + Cancel + + + + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/remotedir.cpp fontmatrix-0.6.0+svn20110930/src/remotedir.cpp --- fontmatrix-0.6.0+svn20100107/src/remotedir.cpp 2008-02-14 17:10:05.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/remotedir.cpp 2011-01-12 15:05:44.000000000 +0000 @@ -266,7 +266,7 @@ } /// FontInfo ********************************************** -QString FontInfo::dump() +QString RemoteDir::FontInfo::dump() { QString sep(" | "); return file + sep + family + sep + variant + sep + type + sep +tags.join(sep); diff -Nru fontmatrix-0.6.0+svn20100107/src/remotedir.h fontmatrix-0.6.0+svn20110930/src/remotedir.h --- fontmatrix-0.6.0+svn20100107/src/remotedir.h 2008-02-14 08:48:34.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/remotedir.h 2011-01-12 15:05:44.000000000 +0000 @@ -22,17 +22,6 @@ class QByteArray; class QHttp; -struct FontInfo -{ - QString file; - QString family; - QString variant; - QString type; - QString info; - QStringList tags; - QPixmap pix; - QString dump(); -}; /** @author Pierre Marchand @@ -41,6 +30,18 @@ { Q_OBJECT public: + struct FontInfo + { + QString file; + QString family; + QString variant; + QString type; + QString info; + QStringList tags; + QPixmap pix; + QString dump(); + }; + RemoteDir ( const QStringList &dirs ); ~RemoteDir(); diff -Nru fontmatrix-0.6.0+svn20100107/src/sampletoolbar.cpp fontmatrix-0.6.0+svn20110930/src/sampletoolbar.cpp --- fontmatrix-0.6.0+svn20100107/src/sampletoolbar.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/sampletoolbar.cpp 2010-09-20 16:51:54.000000000 +0000 @@ -0,0 +1,107 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "sampletoolbar.h" +#include "ui_sampletoolbar.h" +#include "fmfontstrings.h" + +SampleToolBar::SampleToolBar(QWidget *parent) : + QWidget(parent), + ui(new Ui::SampleToolBar) +{ + ui->setupUi(this); +// setAutoFillBackground(true); + + connect(ui->liveSize, SIGNAL(valueChanged(double)), this, SIGNAL(SizeChanged(double))); + connect(ui->sampleButton, SIGNAL(toggled(bool)), this, SIGNAL(SampleToggled(bool))); + connect(ui->opentypeButton, SIGNAL(toggled(bool)), this, SIGNAL(OpenTypeToggled(bool))); + connect(ui->languageCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(ScriptSelected())); +} + +SampleToolBar::~SampleToolBar() +{ + delete ui; +} + +void SampleToolBar::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +double SampleToolBar::getFontSize() const +{ + return ui->liveSize->value(); +} + +void SampleToolBar::setFontSize(double fs) +{ + ui->liveSize->setValue(fs); +} + +bool SampleToolBar::isChecked(Button b) +{ + if(b == SampleButton) + return ui->sampleButton->isChecked(); + else if(b == OpenTypeButton) + return ui->opentypeButton->isChecked(); + return false; +} + +void SampleToolBar::toggle(Button b, bool c) +{ + if(b == SampleButton) + ui->sampleButton->setChecked(c); + else if(b == OpenTypeButton) + ui->opentypeButton->setChecked(c); +} + +void SampleToolBar::enableButton(Button b, bool c) +{ + if(b == SampleButton) + ui->sampleButton->setEnabled(c); + else if(b == OpenTypeButton) + ui->opentypeButton->setEnabled(c); +} + +void SampleToolBar::setScripts(const QStringList &ll) +{ + ui->languageCombo->addItem(tr("Select language"), QString("NOSHAPER")); + foreach(QString l, ll) + { + ui->languageCombo->addItem(FontStrings::scriptTagName(l), l); + } + if(ll.isEmpty()) + ui->languageCombo->setEnabled(false); +} + +QString SampleToolBar::getScript() +{ + QString ret(ui->languageCombo->itemData(ui->languageCombo->currentIndex()).toString()); + if(ret != QString("NOSHAPER")) + return ret; + return QString(); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/sampletoolbar.h fontmatrix-0.6.0+svn20110930/src/sampletoolbar.h --- fontmatrix-0.6.0+svn20100107/src/sampletoolbar.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/sampletoolbar.h 2010-09-20 16:51:54.000000000 +0000 @@ -0,0 +1,68 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef SAMPLETOOLBAR_H +#define SAMPLETOOLBAR_H + +#include +#include + +namespace Ui { + class SampleToolBar; +} + +class SampleToolBar : public QWidget +{ + Q_OBJECT + +public: + explicit SampleToolBar(QWidget *parent = 0); + ~SampleToolBar(); + + enum Button{ + SampleButton, + OpenTypeButton + }; + + double getFontSize() const; + void setFontSize(double fs); + + bool isChecked(Button b); + void toggle(Button b, bool c); + + void enableButton(Button b, bool c); + + void setScripts(const QStringList& ll); + QString getScript(); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::SampleToolBar *ui; + +signals: + void SizeChanged(double); + void SampleToggled(bool); + void OpenTypeToggled(bool); + void ScriptSelected(); +}; + +#endif // SAMPLETOOLBAR_H diff -Nru fontmatrix-0.6.0+svn20100107/src/sampletoolbar.ui fontmatrix-0.6.0+svn20110930/src/sampletoolbar.ui --- fontmatrix-0.6.0+svn20100107/src/sampletoolbar.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/sampletoolbar.ui 2010-09-29 11:05:22.000000000 +0000 @@ -0,0 +1,95 @@ + + + SampleToolBar + + + + 0 + 0 + 511 + 37 + + + + Form + + + + + + Font Size: + + + liveSize + + + + + + + 999.990000000000009 + + + + + + + Samples + + + true + + + Qt::ToolButtonTextBesideIcon + + + true + + + Qt::UpArrow + + + + + + + OpenType + + + true + + + Qt::ToolButtonTextBesideIcon + + + true + + + Qt::UpArrow + + + + + + + Depending of the font, some scripts +are especially supported if processed +through some logic (ICU here). + + + + + + + Shaping: + + + languageCombo + + + + + + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/samplewidget.cpp fontmatrix-0.6.0+svn20110930/src/samplewidget.cpp --- fontmatrix-0.6.0+svn20100107/src/samplewidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/samplewidget.cpp 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,996 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "samplewidget.h" +#include "sampletoolbar.h" +#include "ui_samplewidget.h" +#include "typotek.h" +#include "fmbaseshaper.h" +#include "fmfontdb.h" +#include "fontitem.h" +#include "fmlayout.h" +#include "textprogression.h" +#include "opentypetags.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +QByteArray SampleWidget::State::toByteArray() const +{ + QByteArray b; + QDataStream ds(&b, QIODevice::WriteOnly); + ds << sampleName; + ds << fontSize; + ds << renderHinting; + ds << shaper; + ds << script; + return b; +} + + +void FMLayoutThread::setLayout(FMLayout * l, const QList& spec , double fs, FontItem* f, unsigned int hinting) +{ + pLayout = l; + pLayout->setContext(false); + gl = spec; + fontSize = fs; + font = f; + fHinting = hinting; +} + +void FMLayoutThread::run() +{ + FontItem * tf(new FontItem(font->path(),font->family(),font->variant(),font->type(), font->isActivated())); + tf->setFTHintMode(fHinting); + pLayout->doLayout(gl, fontSize, tf); + delete tf; +} + +SampleWidget::State SampleWidget::State::fromByteArray(QByteArray b) +{ + QDataStream ds(&b, QIODevice::ReadOnly); + QString sn; + double fs; + unsigned int rh; + QString sh; + QString sc; + ds >> sn; + ds >> fs; + ds >> rh; + ds >> sh; + ds >> sc; +// State* pState(new State(sn,fs,rh,sh,sc)); +// State rState(*pState); + sampleName = sn; + fontSize = fs; + renderHinting = rh; + shaper = sh; + script = sc; +// return State(sn,fs,rh,sh,sc); + return *this; +} + +const QString SampleWidget::Name = QObject::tr("Sample"); + +SampleWidget::SampleWidget(const QString& fid, QWidget *parent) : + FloatingWidget(fid, Name, parent), + ui(new Ui::SampleWidget), + fontIdentifier(fid) +{ + layoutTimer = new QTimer(this); + layoutWait = 1000; + layoutForPrint = false; + layoutSwitch = false; + ui->setupUi(this); +// ui->textProgression->setVisible(false); + + sampleToolBar = new SampleToolBar(this); + ui->sampleGridLayout->addWidget(sampleToolBar, 1,0, Qt::AlignRight | Qt::AlignBottom); + + + sampleNameEditor = new QStyledItemDelegate(ui->sampleTextTree); + ui->sampleTextTree->setItemDelegate(sampleNameEditor); + refillSampleList(); + fillOTTree(); + +#ifdef PLATFORM_APPLE + fileInfo.setFile(fid); + fileLastModified = fileInfo.lastModified().toMSecsSinceEpoch(); +#endif + sysWatcher = new QFileSystemWatcher(this); + sysWatcher->addPath(fid); + reloadTimer = new QTimer(this); + reloadTimer->setInterval(1000); + + loremScene = new QGraphicsScene; + ftScene = new QGraphicsScene; + QRectF pageRect ( 0,0,597.6,842.4 ); //TODO find means to smartly decide of page size (here, iso A4) + + loremScene->setSceneRect ( pageRect ); + + ftScene->setSceneRect ( 0,0, 597.6 * typotek::getInstance()->getDpiX() / 72.0, 842.4 * typotek::getInstance()->getDpiX() / 72.0); + ui->loremView->setScene ( loremScene ); + ui->loremView->locker = false; + double horiScaleT (typotek::getInstance()->getDpiX() / 72.0); + double vertScaleT ( typotek::getInstance()->getDpiY() / 72.0); + QTransform adjustAbsoluteViewT( horiScaleT , 0, 0,vertScaleT, 0, 0 ); + ui->loremView->setTransform ( adjustAbsoluteViewT , false ); + + ui->loremView_FT->setScene ( ftScene ); + ui->loremView_FT->locker = false; + ui->loremView_FT->fakePage(); + + layoutThread = new FMLayoutThread; + + FontItem * cf(FMFontDb::DB()->Font(fid)); + textLayoutVect = new FMLayout(loremScene, cf); + textLayoutFT = new FMLayout(ftScene); + + + QSettings settings; + State s; + s.fontSize = 14; + QByteArray bs = settings.value("Sample/state", s.toByteArray()).toByteArray(); + setState(s.fromByteArray(bs)); + sampleRatio = 1.2; + sampleInterSize = sampleFontSize * sampleRatio; + + createConnections(); + slotView(); +} + +SampleWidget::~SampleWidget() +{ + removeConnections(); + delete ui; + delete loremScene; + delete ftScene; + delete textLayoutFT; + delete textLayoutVect; +} + +void SampleWidget::createConnections() +{ + // connections + + connect ( ui->loremView, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateSView())); + connect ( ui->loremView, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); + + connect ( ui->loremView_FT, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); + connect ( ui->loremView_FT, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateRView())); + + connect ( textLayoutVect, SIGNAL(updateLayout()),this, SLOT(slotView())); + connect ( this, SIGNAL(stopLayout()), textLayoutVect,SLOT(stopLayout())); + connect ( textLayoutFT, SIGNAL(updateLayout()),this, SLOT(slotView())); + connect ( this, SIGNAL(stopLayout()), textLayoutFT,SLOT(stopLayout())); + + connect ( ui->sampleTextTree,SIGNAL ( itemSelectionChanged ()),this,SLOT ( slotSampleChanged() ) ); + connect ( ui->sampleTextTree,SIGNAL ( itemSelectionChanged ()),this,SLOT ( slotEditSample() ) ); + connect ( sampleToolBar, SIGNAL( SizeChanged(double) ),this,SLOT(slotLiveFontSize(double))); + + connect ( ui->OpenTypeTree, SIGNAL ( itemClicked ( QTreeWidgetItem*, int ) ), this, SLOT ( slotFeatureChanged() ) ); + connect ( ui->saveDefOTFBut, SIGNAL(released()),this,SLOT(slotDefaultOTF())); + connect ( ui->resetDefOTFBut, SIGNAL(released()),this,SLOT(slotResetOTF())); + +// connect ( ui->textProgression, SIGNAL ( stateChanged ( ) ),this ,SLOT(slotProgressionChanged())); + + connect(ui->toolbar, SIGNAL(Print()), this, SLOT(slotPrint())); + connect(ui->toolbar, SIGNAL(Close()), this, SLOT(close())); + connect(ui->toolbar, SIGNAL(Hide()), this, SLOT(hide())); + connect(ui->toolbar, SIGNAL(Detach()), this, SLOT(ddetach())); + + connect(sysWatcher, SIGNAL(fileChanged(QString)),this, SLOT(slotFileChanged(QString))); + connect(reloadTimer,SIGNAL(timeout()), this, SLOT(slotReload())); + + connect(this, SIGNAL(stateChanged()), this, SLOT(saveState())); + + connect(sampleToolBar, SIGNAL(OpenTypeToggled(bool)), this, SLOT(slotShowOpenType(bool))); + connect(sampleToolBar, SIGNAL(SampleToggled(bool)), this, SLOT(slotShowSamples(bool))); + connect(sampleToolBar, SIGNAL(ScriptSelected()), this, SLOT(slotScriptChange())); + + connect(ui->addSampleButton, SIGNAL(clicked()), this, SLOT(slotAddSample())); + connect(ui->removeSampleButton, SIGNAL(clicked()), this, SLOT(slotRemoveSample())); + connect(sampleNameEditor, SIGNAL(closeEditor(QWidget*)), this, SLOT(slotSampleNameEdited(QWidget*))); + connect(ui->sampleEdit, SIGNAL(textChanged()), this, SLOT(slotUpdateSample())); + + + connect(textLayoutFT, SIGNAL(clearScene()), this, SLOT(clearFTScene())); +} + + +void SampleWidget::removeConnections() +{ + + disconnect ( ui->loremView, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateSView())); + disconnect ( ui->loremView, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); + + disconnect ( ui->loremView_FT, SIGNAL(pleaseZoom(int)),this,SLOT(slotZoom(int))); + disconnect ( ui->loremView_FT, SIGNAL(pleaseUpdateMe()), this, SLOT(slotUpdateRView())); + + disconnect ( textLayoutVect, SIGNAL(updateLayout()),this, SLOT(slotView())); + disconnect ( this, SIGNAL(stopLayout()), textLayoutVect,SLOT(stopLayout())); + disconnect ( textLayoutFT, SIGNAL(updateLayout()),this, SLOT(slotView())); + disconnect ( this, SIGNAL(stopLayout()), textLayoutFT,SLOT(stopLayout())); + + disconnect ( ui->sampleTextTree,SIGNAL ( itemSelectionChanged ()),this,SLOT ( slotSampleChanged() ) ); + disconnect ( sampleToolBar, SIGNAL( SizeChanged(double) ),this,SLOT(slotLiveFontSize(double))); + + disconnect ( ui->OpenTypeTree, SIGNAL ( itemClicked ( QTreeWidgetItem*, int ) ), this, SLOT ( slotFeatureChanged() ) ); + disconnect ( ui->saveDefOTFBut, SIGNAL(released()),this,SLOT(slotDefaultOTF())); + disconnect ( ui->resetDefOTFBut, SIGNAL(released()),this,SLOT(slotResetOTF())); + +// disconnect ( ui->textProgression, SIGNAL ( stateChanged ( ) ),this ,SLOT(slotProgressionChanged())); + + disconnect(ui->toolbar, SIGNAL(Print()), this, SLOT(slotPrint())); + disconnect(ui->toolbar, SIGNAL(Close()), this, SLOT(close())); + disconnect(ui->toolbar, SIGNAL(Hide()), this, SLOT(hide())); + disconnect(ui->toolbar, SIGNAL(Detach()), this, SLOT(ddetach())); + + disconnect(sysWatcher, SIGNAL(fileChanged(QString)),this, SLOT(slotFileChanged(QString))); + + disconnect(this, SIGNAL(stateChanged()), this, SLOT(saveState())); +} + +void SampleWidget::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + + +QGraphicsScene * SampleWidget::textScene() const +{ + return loremScene; +} + +SampleWidget::State SampleWidget::state() const +{ + State ret; + ret.set = true; + ret.fontSize = sampleToolBar->getFontSize(); +// ret.renderRaster = ui->freetypeRadio->isChecked(); + ret.renderHinting = 0; +// if(ui->normalHinting->isChecked()) +// ret.renderHinting = 1; +// else if(ui->lightHinting->isChecked()) +// ret.renderHinting = 2; + ret.sampleName = ui->sampleTextTree->currentItem()->data(0, Qt::UserRole).toString(); + if(ui->useShaperCheck->isChecked()) + { + ret.script = ui->langCombo->currentText(); + ret.shaper = ui->shaperTypeCombo->currentText(); + } + return ret; +} + +void SampleWidget::setState(const SampleWidget::State &s) +{ + if(!s.set) + return; + sampleToolBar->setFontSize( s.fontSize ); + reSize( s.fontSize, s.fontSize * sampleRatio ); + +// { +// switch(s.renderHinting) +// { +// case 0: ui->noHinting->setChecked(true); +// break; +// case 1: ui->normalHinting->setChecked(true); +// break; +// case 2: ui->lightHinting->setChecked(true); +// break; +// default:break; +// } +// } + + QTreeWidgetItem * targetItem = 0; + for(int i(0); i < ui->sampleTextTree->topLevelItemCount(); ++i) + { + QTreeWidgetItem * tli(ui->sampleTextTree->topLevelItem(i)); + for(int ii(0); ii < tli->childCount(); ++ii) + { + if(tli->child(ii)->data(0, Qt::UserRole).toString() == s.sampleName) + { + targetItem = tli->child(ii); + typotek::getInstance()->namedSample(s.sampleName); + break; + } + } + if(targetItem != 0) + break; + } +// qDebug()<<"TI"<sampleTextTree->setCurrentItem(targetItem, 0, QItemSelectionModel::SelectCurrent); + +// if(!s.shaper.isEmpty()) +// { +// ui->useShaperCheck->setChecked(true); +// ui->shaperTypeCombo->setCurrentIndex(ui->shaperTypeCombo->findText(s.shaper)); +// ui->langCombo->setCurrentIndex(ui->langCombo->findText(s.script)); +// } + + slotView(); + slotEditSample(); +} + +void SampleWidget::slotView() +{ + qDebug()<<"SampleWidget::slotView "<< fontIdentifier; +// disconnect(textLayoutFT, SIGNAL(drawBaselineForMe(double)), this, SLOT(drawBaseline(double))); + QTime t; + t.start(); + FontItem *f(FMFontDb::DB()->Font( fontIdentifier )); + if ( !f ) + return; + + bool wantDeviceDependant = !layoutForPrint; + if(wantDeviceDependant) + { + f->setFTHintMode(hinting()); + } + +// if(ui->textProgression->inLine() == TextProgression::INLINE_LTR ) + f->setProgression(PROGRESSION_LTR ); +// else if(ui->textProgression->inLine() == TextProgression::INLINE_RTL ) +// f->setProgression(PROGRESSION_RTL); +// else if(ui->textProgression->inLine() == TextProgression::INLINE_TTB ) +// f->setProgression(PROGRESSION_TTB ); +// else if(ui->textProgression->inLine() == TextProgression::INLINE_BTT ) +// f->setProgression(PROGRESSION_BTT); + + f->setFTRaster ( wantDeviceDependant ); + +// if ( ui->loremView->isVisible() || ui->loremView_FT->isVisible() || layoutForPrint) + { + if(!layoutForPrint && !textLayoutFT->isLayoutFinished()) + { + connect(textLayoutFT, SIGNAL(layoutFinished()), this, SLOT(slotView())); + textLayoutFT->stopLayout(); + qDebug()<<"\tLayout stopped"; + layoutSwitch = false; + return; + } + else + { + disconnect(textLayoutFT, SIGNAL(layoutFinished()), this, SLOT(slotView())); + } +// else if(textLayoutVect->isRunning()) +// textLayoutVect->stopLayout(); +// else + { + qDebug()<<"\tStart layout"; + ui->loremView_FT->unSheduleUpdate(); + ui->loremView->unSheduleUpdate(); + FMLayout * textLayout; + if(layoutForPrint) + textLayout = textLayoutVect; + else + textLayout = textLayoutFT; + + bool processFeatures = f->isOpenType() && !deFillOTTree().isEmpty(); + QString script(sampleToolBar->getScript()); + bool processScript( !script.isEmpty() ); + textLayout->setDeviceIndy(!wantDeviceDependant); + textLayout->setAdjustedSampleInter( sampleInterSize ); + + double fSize(sampleFontSize); + + QList list; + QStringList stl( typotek::getInstance()->namedSample().split("\n")); +// qDebug()<<"Sample:\n\t"<glyphs( stl[p] , fSize, script ); + } + } + else if(processFeatures) + { + for(int p(0);pglyphs( stl[p] , fSize, deFillOTTree()); + } + } + else + { + for(int p(0);pglyphs( stl[p] , fSize ); + } + if(!layoutForPrint) + { + layoutThread->setLayout(textLayout, list, fSize, f, hinting()); + connect(textLayout, SIGNAL(drawPixmapForMe(int,double,double,double)), this, SLOT(drawPixmap(int,double,double,double))); +// connect(textLayoutFT, SIGNAL(drawBaselineForMe(double)), this, SLOT(drawBaseline(double))); + connect(textLayout, SIGNAL(layoutFinished()), this, SLOT(endLayout())); + layoutSwitch = true; + pixmapDrawn = 0; + layoutThread->start(); + } + else + { + textLayout->doLayout(list, fSize); + } + } + } + +} + +void SampleWidget::drawPixmap(int index, double fontsize, double x, double y) +{ +// qDebug()<<"SampleWidget::drawPixmap index:"<Font( fontIdentifier ) ); + if(!f) + return; + ++pixmapDrawn; + QGraphicsPixmapItem *glyph = f->itemFromGindexPix ( index , fontsize ); +// qDebug()<<"SampleWidget::drawPixmap index:"<data(GLYPH_DATA_BITMAPTOP).toDouble(); + ftScene->addItem ( glyph ); + glyph->setZValue ( 100.0 ); + glyph->setPos ( x,y ); +// QGraphicsLineItem * l = ftScene->addLine(x,y,x,y + glyph->data(GLYPH_DATA_BITMAPTOP).toDouble()); +// l->setData(GLYPH_DATA_GLYPH, 1); +// glyph->pixmap().toImage().save(QString("/tmp/%1.png").arg(index)); +} + +void SampleWidget::drawBaseline(double y) +{ + QGraphicsLineItem * l = ftScene->addLine(0,y,ftScene->width(),y); + l->setData(GLYPH_DATA_GLYPH, 1); +} + +void SampleWidget::clearFTScene() +{ + qDebug()<<"SampleWidget::clearFTScene"<< layoutSwitch; +// if(layoutSwitch) +// return; + foreach(QGraphicsItem* gi, ftScene->items()) + { + if(gi->data(GLYPH_DATA_GLYPH).toInt() > 0) + delete gi; + } +} + +void SampleWidget::endLayout() +{ + QPointF texttopLeft(ui->loremView_FT->mapFromScene(textLayoutFT->getRect().topLeft())); + ui->loremView_FT->translate( 10 -texttopLeft.x(), 10 -texttopLeft.y()); + ui->loremView_FT->update(); +// qDebug()<<"Pixmaps:"<OpenTypeTree->clear(); + ui->langCombo->clear(); + ui->langCombo->setEnabled ( false ); + ui->useShaperCheck->setCheckState ( Qt::Unchecked ); + ui->useShaperCheck->setEnabled ( false ); + typotek * typo(typotek::getInstance()); + QStringList scripts; + FontItem * theVeryFont(FMFontDb::DB()->Font( fontIdentifier )); + if ( theVeryFont && theVeryFont->isOpenType() ) + { + FMOtf * otf = theVeryFont->takeOTFInstance(); + foreach ( QString table, otf->get_tables() ) + { + otf->set_table ( table ); + QTreeWidgetItem *tab_item = new QTreeWidgetItem ( ui->OpenTypeTree,QStringList ( table ) ); + tab_item->setExpanded ( true ); + foreach ( QString script, otf->get_scripts() ) + { + scripts << script; + otf->set_script ( script ); + QTreeWidgetItem *script_item = new QTreeWidgetItem ( tab_item, QStringList ( script ) ); + script_item->setExpanded ( true ); + foreach ( QString lang, otf->get_langs() ) + { + otf->set_lang ( lang ); + QTreeWidgetItem *lang_item = new QTreeWidgetItem ( script_item, QStringList ( lang ) ); + lang_item->setExpanded ( true ); + foreach ( QString feature, otf->get_features() ) + { + QStringList f ( feature ); + f << OTTagMeans ( feature ); + QTreeWidgetItem *feature_item = new QTreeWidgetItem ( lang_item, f ); + feature_item->setCheckState ( 0, Qt::Unchecked ); + if(table == "GPOS") + { + if(typo->getDefaultOTFScript() == script && typo->getDefaultOTFLang() == lang && typo->getDefaultOTFGPOS().contains(feature) ) + { + feature_item->setCheckState ( 0, Qt::Checked ); + } + } + else if(table == "GSUB") + { + if(typo->getDefaultOTFScript() == script && typo->getDefaultOTFLang() == lang && typo->getDefaultOTFGSUB().contains(feature) ) + { + feature_item->setCheckState ( 0, Qt::Checked ); + } + } + } + } + } + } + ui->OpenTypeTree->resizeColumnToContents ( 0 ) ; + theVeryFont->releaseOTFInstance ( otf ); + } + scripts = scripts.toSet().toList(); + // scripts.removeAll ( "latn" ); +// if ( !scripts.isEmpty() ) + { +// ui->langCombo->setEnabled ( true ); +// ui->useShaperCheck->setEnabled ( true ); +// ui->langCombo->addItems ( scripts ); + sampleToolBar->setScripts(scripts); + } +} + +OTFSet SampleWidget::deFillOTTree() +{ + // qDebug() << "MainViewWidget::deFillOTTree()"; + OTFSet ret; + // qDebug() << ui->OpenTypeTree->topLevelItemCount(); + for ( int table_index = 0; table_index < ui->OpenTypeTree->topLevelItemCount(); ++table_index ) //tables + { + // qDebug() << "table_index = " << table_index; + QTreeWidgetItem * table_item = ui->OpenTypeTree->topLevelItem ( table_index ) ; + // qDebug() << table_item->text(0); + for ( int script_index = 0; script_index < table_item->childCount();++script_index ) //scripts + { + QTreeWidgetItem * script_item = table_item->child ( script_index ); + // qDebug() << "\tscript_index = " << script_index << script_item->text(0); + for ( int lang_index = 0; lang_index < script_item->childCount(); ++lang_index ) //langs + { + QTreeWidgetItem * lang_item = script_item->child ( lang_index ); + // qDebug() << "\t\tlang_index = "<< lang_index << lang_item->text(0); + for ( int feature_index = 0; feature_index < lang_item->childCount(); ++feature_index ) //features + { + // qDebug() << lang_item->childCount() <<" / "<< feature_index; + QTreeWidgetItem * feature_item = lang_item->child ( feature_index ); + // qDebug() << "\t\t\tfeature_item -> "<< feature_item->text(0); + if ( feature_item->checkState ( 0 ) == Qt::Checked ) + { + if ( table_item->text ( 0 ) == "GPOS" ) + { + ret.script = script_item->text ( 0 ); + ret.lang = lang_item->text ( 0 ); + ret.gpos_features.append ( feature_item->text ( 0 ) ); + } + if ( table_item->text ( 0 ) == "GSUB" ) + { + ret.script = script_item->text ( 0 ); + ret.lang = lang_item->text ( 0 ); + ret.gsub_features.append ( feature_item->text ( 0 ) ); + } + } + } + } + } + } + // qDebug() << "endOf"; + return ret; + +} + +//void SampleWidget::slotChangeViewPage(QAbstractButton* but) +//{ +// QString radioName( but->objectName() ); + +// if(radioName == "freetypeRadio" ) +// { +// ui->stackedViews->setCurrentIndex(VIEW_PAGE_FREETYPE); +// ui->hintingSelect->setEnabled(true); +// } +// else if(radioName == "nativeRadio" ) +// { +// ui->stackedViews->setCurrentIndex(VIEW_PAGE_ABSOLUTE); +// ui->hintingSelect->setEnabled(false); +// } + +// slotView(true); +//} + +//void SampleWidget::slotHintChanged(int ) +//{ +// slotView(true); +// emit stateChanged(); +//} + + +//void SampleWidget::slotChangeViewPageSetting ( bool ch ) +//{ +// // qDebug() <<"MainViewWidget::slotChangeViewPageSetting("<objectName() ); +// if ( !ch ) +// { +// toolPanelWidth = ui->splitter_2->sizes().at ( 1 ) ; +// ui->stackedTools->hide(); +// } +// else +// { +// ui->stackedTools->show(); +// if ( ui->splitter_2->sizes().at ( 1 ) == 0 ) +// { +// QList li; +// li << ui->splitter_2->width() - toolPanelWidth << toolPanelWidth; +// ui->splitter_2->setSizes ( li ); +// } +// } + +// QMap bmap; +// QMap pmap; +// bmap[ "settingsButton" ] = ui->settingsButton; +// bmap[ "openTypeButton" ] = ui->openTypeButton; +// bmap[ "sampleButton" ] = ui->sampleButton; +// pmap[ "settingsButton" ] = VIEW_PAGE_SETTINGS; +// pmap[ "openTypeButton" ] = VIEW_PAGE_OPENTYPE; +// pmap[ "sampleButton" ] = VIEW_PAGE_SAMPLES; + +// foreach(QString pk, bmap.keys()) +// { +// if(butName == pk) +// { +// ui->stackedTools->setCurrentIndex(pmap[pk]); +// } +// else +// { +// bmap[pk]->setChecked ( false ); +// } +// } +//} + + +void SampleWidget::slotUpdateSView() +{ + if(ui->loremView->isVisible()) + slotView(); +} + + +void SampleWidget::slotZoom ( int z ) +{ + double delta = 1.0 + ( z/1000.0 ) ; + QTransform trans; + trans.scale ( delta,delta ); + + QGraphicsView * concernedView; + if ( ui->loremView_FT->isVisible() ) + concernedView = ui->loremView_FT; + else if ( ui->loremView->isVisible() ) + { + concernedView = ui->loremView; + if ( delta == 1.0 ) + { + double horiScaleT (typotek::getInstance()->getDpiX() / 72.0); + double vertScaleT ( typotek::getInstance()->getDpiY() / 72.0); + QTransform adjustAbsoluteViewT( horiScaleT , 0, 0,vertScaleT, 0, 0 ); + trans = adjustAbsoluteViewT; + } + } + concernedView->setTransform ( trans, ( z == 0 ) ? false : true ); + +} + + +void SampleWidget::slotUpdateRView() +{ + if(ui->loremView_FT->isVisible()) + slotView(); +} + +void SampleWidget::slotSampleChanged() +{ + typotek::getInstance()->namedSample( ui->sampleTextTree->currentItem()->data(0, Qt::UserRole).toString() ); + ui->removeSampleButton->setEnabled(ui->sampleTextTree->currentItem()->parent() == uRoot); + slotView ( ); + emit stateChanged(); +} + + + +void SampleWidget::slotLiveFontSize(double fs) +{ +// double fs( sampleToolBar->getFontSize() ); + reSize(fs, fs * sampleRatio); + slotView(); + emit stateChanged(); +} + +void SampleWidget::slotFeatureChanged() +{ + // OTFSet ret = deFillOTTree(); + slotView ( ); + emit stateChanged(); +} + +void SampleWidget::slotDefaultOTF() +{ + OTFSet ots(deFillOTTree()); + typotek* typo(typotek::getInstance()); + typo->setDefaultOTFScript(ots.script); + typo->setDefaultOTFLang(ots.lang); + typo->setDefaultOTFGPOS(ots.gpos_features); + typo->setDefaultOTFGSUB(ots.gsub_features); +} + +void SampleWidget::slotResetOTF() +{ + typotek* typo(typotek::getInstance()); + typo->setDefaultOTFScript(QString()); + typo->setDefaultOTFLang(QString()); + typo->setDefaultOTFGPOS(QStringList()); + typo->setDefaultOTFGSUB(QStringList()); +} + + +void SampleWidget::slotChangeScript() +{ + if ( ui->useShaperCheck->checkState() == Qt::Checked ) + { + slotView ( ); + } + emit stateChanged(); +} + +void SampleWidget::slotProgressionChanged() +{ + slotView(); +} + +void SampleWidget::slotWantShape() +{ + slotView ( ); + emit stateChanged(); +} + + +void SampleWidget::refillSampleList() +{ + ui->sampleTextTree->clear(); + + QTreeWidgetItem * curIt = 0; + QMap > sl = typotek::getInstance()->namedSamplesNames(); + QList ul( sl.take(QString("User")) ); + uRoot = new QTreeWidgetItem(ui->sampleTextTree); + //: Identify root of user defined sample texts + uRoot->setText(0, tr("User")); + if(ul.count()) + { + + bool first(true); + foreach(QString uk, ul) + { + if(first) + { + first = false; + uRoot->setData(0, Qt::UserRole , QString("User::") + uk); + curIt = uRoot; + } + QTreeWidgetItem * it = new QTreeWidgetItem(); + it->setText(0, uk); + it->setData(0, Qt::UserRole , QString("User::") + uk); + uRoot->addChild(it); + } + } + foreach(QString k, sl.keys()) + { + QTreeWidgetItem * kRoot = new QTreeWidgetItem(ui->sampleTextTree); + kRoot->setText(0, k); + bool first(true); + foreach(QString n, sl[k]) + { + if(first) + { + first = false; + kRoot->setData(0, Qt::UserRole , k + QString("::") + n); + if(!curIt) + curIt = kRoot; + } + QTreeWidgetItem * it = new QTreeWidgetItem(); + it->setText(0, n); + it->setData(0, Qt::UserRole, k + QString("::") + n); + kRoot->addChild(it); + } + } + + ui->sampleTextTree->setCurrentItem(curIt); +} + +unsigned int SampleWidget::hinting() +{ +// if(ui->lightHinting->isChecked()) +// return FT_LOAD_TARGET_LIGHT; +// else if(ui->normalHinting->isChecked()) +// return FT_LOAD_TARGET_NORMAL; + + return FT_LOAD_NO_HINTING ; +} + + +void SampleWidget::slotPrint() +{ + FontItem * font(FMFontDb::DB()->Font( fontIdentifier )); + if(!font) + return; + + if(printer == 0) + printer = new QPrinter(QPrinter::HighResolution); + if(printDialog == 0) + printDialog = new QPrintDialog(printer, this); + + printDialog->setWindowTitle("Fontmatrix - " + tr("Print Sample") +" - " + font->fancyName() ); + printDialog->open(this, SLOT(slotDoPrinting())); +} + + +void SampleWidget::slotDoPrinting() +{ + layoutForPrint = true; + slotView(); + printer->setFullPage ( true ); + QPainter aPainter ( printer ); + loremScene->render(&aPainter); + layoutForPrint = false; +} + +void SampleWidget::slotFileChanged(const QString &) +{ +#ifdef PLATFORM_APPLE + if(fileInfo.lastModified().toMSecsSinceEpoch() == fileLastModified) + return; + fileLastModified = fileInfo.lastModified().toMSecsSinceEpoch(); +#endif + if(reloadTimer->isActive()) + reloadTimer->start(); + else + { + reloadTimer->start(); + } +} + +void SampleWidget::slotReload() +{ +// reloadTimer->stop(); + slotView(); +} + +void SampleWidget::slotScriptChange() +{ + slotView(); +} + +void SampleWidget::saveState() +{ + QSettings settings; + State s(state()); + QByteArray bs(s.toByteArray()); + settings.setValue("Sample/state", bs); +} + +void SampleWidget::slotShowSamples(bool b) +{ + if(b) + { + if(sampleToolBar->isChecked(SampleToolBar::OpenTypeButton)) + { + ui->sampleGridLayout->removeWidget(ui->opentypeWidget); + ui->opentypeWidget->setParent(ui->stackedViews->widget(VIEW_PAGE_OPENTYPE)); + sampleToolBar->toggle(SampleToolBar::OpenTypeButton, false); + } + ui->sampleEditWidget->setAutoFillBackground(true); + ui->sampleEditWidget->resize(ui->sampleGridLayout->geometry().width() / 2, ui->sampleGridLayout->geometry().height()); + ui->sampleGridLayout->addWidget(ui->sampleEditWidget, 0,0, Qt::AlignRight); + } + else + { + ui->sampleGridLayout->removeWidget(ui->sampleEditWidget); + ui->sampleEditWidget->setParent(ui->stackedViews->widget(VIEW_PAGE_SAMPLES)); + } +} + +void SampleWidget::slotShowOpenType(bool b) +{ + if(b) + { + if(sampleToolBar->isChecked(SampleToolBar::SampleButton)) + { + ui->sampleGridLayout->removeWidget(ui->sampleEditWidget); + ui->sampleEditWidget->setParent(ui->stackedViews->widget(VIEW_PAGE_SAMPLES)); + sampleToolBar->toggle(SampleToolBar::SampleButton, false); + } + ui->opentypeWidget->setAutoFillBackground(true); + ui->opentypeWidget->resize(ui->sampleGridLayout->geometry().width() / 2, ui->sampleGridLayout->geometry().height()); + ui->sampleGridLayout->addWidget(ui->opentypeWidget, 0,0, Qt::AlignRight); + } + else + { + ui->sampleGridLayout->removeWidget(ui->opentypeWidget); + ui->opentypeWidget->setParent(ui->stackedViews->widget(VIEW_PAGE_OPENTYPE)); + } +} + +void SampleWidget::slotAddSample() +{ + QString nu( tr("New Sample") ); + newSampleName = new QTreeWidgetItem(); + newSampleName->setText(0,nu); + newSampleName->setData(0, Qt::UserRole , QString("NEW_SAMPLE")); + newSampleName->setFlags(newSampleName->flags() | Qt::ItemIsEditable); + uRoot->addChild(newSampleName); + ui->sampleTextTree->openPersistentEditor(newSampleName); + if(!uRoot->isExpanded()) + uRoot->setExpanded(true); + ui->sampleTextTree->setCurrentItem(newSampleName); +} + +void SampleWidget::slotSampleNameEdited(QWidget *w) +{ + ui->sampleTextTree->closePersistentEditor(newSampleName); + newSampleName->setData(0, Qt::UserRole , QString("User::") + newSampleName->text(0)); + typotek::getInstance()->changeSample(newSampleName->text(0), ui->sampleEdit->toPlainText() ); +} + +void SampleWidget::slotRemoveSample() +{ + QString name(ui->sampleTextTree->currentItem()->text(0)); + QTreeWidgetItem * currentItem = ui->sampleTextTree->currentItem(); + uRoot->removeChild(currentItem); + typotek::getInstance()->removeNamedSample(name); +} + +void SampleWidget::slotEditSample() +{ + disconnect(ui->sampleEdit, SIGNAL(textChanged()), this, SLOT(slotUpdateSample())); + QTreeWidgetItem * currentItem = ui->sampleTextTree->currentItem(); + ui->sampleEdit->setPlainText(typotek::getInstance()->namedSample( currentItem->data(0, Qt::UserRole).toString() )); + ui->sampleEdit->setReadOnly(currentItem->parent() != uRoot); + connect(ui->sampleEdit, SIGNAL(textChanged()), this, SLOT(slotUpdateSample())); +} + +void SampleWidget::slotUpdateSample() +{ + typotek::getInstance()->changeSample(ui->sampleTextTree->currentItem()->text(0), ui->sampleEdit->toPlainText()); + slotView(); +} + diff -Nru fontmatrix-0.6.0+svn20100107/src/samplewidget.h fontmatrix-0.6.0+svn20110930/src/samplewidget.h --- fontmatrix-0.6.0+svn20100107/src/samplewidget.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/samplewidget.h 2011-02-08 14:43:38.000000000 +0000 @@ -0,0 +1,206 @@ +/*************************************************************************** + * Copyright (C) 2010 by Pierre Marchand * + * pierre@oep-h.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 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef SAMPLEWIDGET_H +#define SAMPLEWIDGET_H + +#include "floatingwidget.h" +#include "fmotf.h" + +#include +#include +#include +#include +#include + +class QGraphicsScene; +class FMLayout; +class QButtonGroup; +class QAbstractButton; +class QFileSystemWatcher; +class QTimer; +class SampleToolBar; +class QTreeWidgetItem; +class QStyledItemDelegate; +class FontItem; + +namespace Ui { + class SampleWidget; +} + +#define VIEW_PAGE_FREETYPE 0 +#define VIEW_PAGE_ABSOLUTE 1 +#define VIEW_PAGE_OPENTYPE 3 +//#define VIEW_PAGE_SETTINGS 1 +#define VIEW_PAGE_SAMPLES 4 + +class FMLayoutThread : public QThread +{ + FMLayout * pLayout; + QList gl; + double fontSize; + FontItem * font; + unsigned int fHinting; + +public: + void setLayout(FMLayout * l, const QList& spec , double fs, FontItem * f, unsigned int hinting); + void run(); +}; + +class SampleWidget : public FloatingWidget +{ + Q_OBJECT + +public: + struct State + { + bool set; + State() : set(false) {} + State(const QString& sn, double fs, unsigned int rh, const QString& sh, const QString& sc): + set(true), + sampleName(sn), + fontSize(fs), + renderHinting(rh), + shaper(sh), + script(sc) + {} + State(const State& other) + : set(true) + { + sampleName = other.sampleName; + fontSize = other.fontSize; + renderHinting = other.renderHinting; + shaper = other.shaper; + script = other.script; + } + QString sampleName; + double fontSize; + unsigned int renderHinting; // 0 = No; 1 = Normal; 2 = Light + QString shaper; + QString script; + QByteArray toByteArray() const; + State fromByteArray(QByteArray b); + + private: + State operator= (const State&){} + }; + + static const QString Name; + explicit SampleWidget(const QString& fid, QWidget *parent = 0); + ~SampleWidget(); + + QGraphicsScene* textScene() const; + State state() const; + void setState(const State& s); + +protected: + void changeEvent(QEvent *e); + void refillSampleList(); + unsigned int hinting(); + +private: + Ui::SampleWidget *ui; + SampleToolBar * sampleToolBar; + QTreeWidgetItem * uRoot; + QTreeWidgetItem * newSampleName; + QStyledItemDelegate * sampleNameEditor; + + const QString fontIdentifier; + QGraphicsScene *loremScene; + QGraphicsScene *ftScene; + FMLayout *textLayoutVect; + FMLayout *textLayoutFT; + // QButtonGroup *radioRenderGroup; + QButtonGroup *radioFTHintingGroup; + double sampleFontSize; + double sampleInterSize; + double sampleRatio; + int toolPanelWidth; + QFileSystemWatcher *sysWatcher; + QTimer *reloadTimer; + + void createConnections(); + void removeConnections(); + + void fillOTTree(); + OTFSet deFillOTTree(); + + bool layoutForPrint; + bool firstUpdateRequest; + int firstUpdateRequestTimeStamp; + QTime layoutTime; + QTimer *layoutTimer; + int layoutWait; + FMLayoutThread * layoutThread; + bool layoutSwitch; + int pixmapDrawn; +#ifdef PLATFORM_APPLE + QFileInfo fileInfo; + qint64 fileLastModified; +#endif + void reSize(double fSize, double lSize){sampleFontSize = fSize; sampleInterSize = lSize;} + +private slots: + void slotView(); + void drawPixmap(int index, double fontsize, double x, double y); + void drawBaseline(double y); + void clearFTScene(); + void endLayout(); + // void slotChangeViewPage(QAbstractButton* ); + // void slotHintChanged(int); + // void slotChangeViewPageSetting(bool); + void slotUpdateSView(); + void slotZoom(int z); + void slotUpdateRView(); + void slotSampleChanged(); + void slotLiveFontSize(double); + void slotFeatureChanged(); + void slotDefaultOTF(); + void slotResetOTF(); + void slotChangeScript(); + void slotProgressionChanged(); + void slotWantShape(); + void slotFileChanged(const QString&); + void slotReload(); + void slotScriptChange(); + + void slotAddSample(); + void slotSampleNameEdited(QWidget* w); + void slotRemoveSample(); + void slotEditSample(); + void slotUpdateSample(); + + void slotShowSamples(bool); + void slotShowOpenType(bool); + + void slotPrint(); + void slotDoPrinting(); + + void saveState(); + +signals: + void stopLayout(); + void stateChanged(); + + + +}; + +#endif // SAMPLEWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/samplewidget.ui fontmatrix-0.6.0+svn20110930/src/samplewidget.ui --- fontmatrix-0.6.0+svn20100107/src/samplewidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/samplewidget.ui 2010-09-20 16:51:54.000000000 +0000 @@ -0,0 +1,326 @@ + + + SampleWidget + + + + 0 + 0 + 663 + 620 + + + + Form + + + + + + + + + + 5 + 0 + + + + 0 + + + + + 0 + + + + + + + Qt::NoFocus + + + QFrame::NoFrame + + + + + + + + + + + 0 + + + + + Qt::NoFocus + + + QFrame::NoFrame + + + + + + + + + + 100 + 70 + 260 + 131 + + + + World is wide + + + + 2 + + + 3 + + + + + + 2 + 0 + + + + + + + + + 2 + 0 + + + + + + + + + 1 + 0 + + + + Script + + + langCombo + + + + + + + + 1 + 0 + + + + Shaper type + + + shaperTypeCombo + + + + + + + + 0 + 0 + + + + Use shaper + + + + + + + + + + + 40 + 0 + 321 + 591 + + + + + + + + + Qt::Vertical + + + + + 0 + 0 + + + + Qt::NoFocus + + + true + + + 2 + + + + OpenType Features + + + + + Friendly Name + + + + + + + + + Save as default + + + + + + + Reset Default + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 60 + 80 + 451 + 381 + + + + + + + + 1 + 0 + + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + + 1 + + + + + + + + Add + + + + + + + Remove + + + + + + + + + + + 3 + 0 + + + + + + + + + + + + + + FloatingWidget + QWidget +
floatingwidget.h
+ 1 +
+ + FMSampleTextView + QGraphicsView +
fmsampletextview.h
+
+ + FloatingWidgetToolBar + QWidget +
floatingwidgettoolbar.h
+ 1 +
+
+ + +
diff -Nru fontmatrix-0.6.0+svn20100107/src/systray.cpp fontmatrix-0.6.0+svn20110930/src/systray.cpp --- fontmatrix-0.6.0+svn20100107/src/systray.cpp 2009-08-09 18:03:55.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/systray.cpp 2010-09-13 16:56:48.000000000 +0000 @@ -110,80 +110,81 @@ void Systray::slotActivateAll() { - ttek->theMainView->slotViewAll(); - if (showAllConfirmation) { - bool wasVisible = ttek->isVisible(); - if (!wasVisible) - ttek->show(); - ttek->slotActivateCurrents(); - if (!wasVisible) - ttek->hide(); - } else - ttek->theMainView->slotActivateAll(); - - disconnect(tagMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotTagMenuClicked(QAction*))); - QList tags = tagActions.values(); - foreach (QAction* a, tags) { - a->setChecked(true); - } - connect(tagMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotTagMenuClicked(QAction*))); +// ttek->theMainView->slotViewAll(); +// if (showAllConfirmation) { +// bool wasVisible = ttek->isVisible(); +// if (!wasVisible) +// ttek->show(); +// ttek->slotActivateCurrents(); +// if (!wasVisible) +// ttek->hide(); +// } else +// ttek->theMainView->slotActivateAll(); + +// disconnect(tagMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotTagMenuClicked(QAction*))); +// QList tags = tagActions.values(); +// foreach (QAction* a, tags) { +// a->setChecked(true); +// } +// connect(tagMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotTagMenuClicked(QAction*))); } void Systray::slotDeactivateAll() { - ttek->theMainView->slotViewAll(); - if (showAllConfirmation) { - bool wasVisible = ttek->isVisible(); - if (!wasVisible) - ttek->show(); - ttek->slotDeactivateCurrents(); - if (!wasVisible) - ttek->hide(); - } else - ttek->theMainView->slotDesactivateAll(); - disconnect(tagMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotTagMenuClicked(QAction*))); - QList tags = tagActions.values(); - foreach (QAction* a, tags) { - a->setChecked(false); - } - connect(tagMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotTagMenuClicked(QAction*))); +// ttek->theMainView->slotViewAll(); +// if (showAllConfirmation) { +// bool wasVisible = ttek->isVisible(); +// if (!wasVisible) +// ttek->show(); +// ttek->slotDeactivateCurrents(); +// if (!wasVisible) +// ttek->hide(); +// } else +// ttek->theMainView->slotDesactivateAll(); +// disconnect(tagMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotTagMenuClicked(QAction*))); +// QList tags = tagActions.values(); +// foreach (QAction* a, tags) { +// a->setChecked(false); +// } +// connect(tagMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotTagMenuClicked(QAction*))); } void Systray::slotTagMenuClicked(QAction *action) { - action->setIcon(QIcon ()); - QString name = action->text(); - if (name.isEmpty()) - return; - if (!action->isChecked()) { // deactivate based on the tag name - ttek->theMainView->slotFilterTag(name); - if (showTagsConfirmation) { - bool wasVisible = ttek->isVisible(); - if (!wasVisible) - ttek->show(); - ttek->slotDeactivateCurrents(); - if (!wasVisible) - ttek->hide(); - } else - ttek->theMainView->slotDesactivateAll(); - } else { // activate based on the tag name - ttek->theMainView->slotFilterTag(name); - if (showTagsConfirmation) { - bool wasVisible = ttek->isVisible(); - if (!wasVisible) - ttek->show(); - ttek->slotActivateCurrents(); - if (!wasVisible) - ttek->hide(); - } else - ttek->theMainView->slotActivateAll(); - } + // Deactivate the feature atm +// action->setIcon(QIcon ()); +// QString name = action->text(); +// if (name.isEmpty()) +// return; + +// if (!action->isChecked()) { // deactivate based on the tag name +// ttek->theMainView->slotFilterTag(name); +// if (showTagsConfirmation) { +// bool wasVisible = ttek->isVisible(); +// if (!wasVisible) +// ttek->show(); +// ttek->slotDeactivateCurrents(); +// if (!wasVisible) +// ttek->hide(); +// } else +// ttek->theMainView->slotDesactivateAll(); +// } else { // activate based on the tag name +// ttek->theMainView->slotFilterTag(name); +// if (showTagsConfirmation) { +// bool wasVisible = ttek->isVisible(); +// if (!wasVisible) +// ttek->show(); +// ttek->slotActivateCurrents(); +// if (!wasVisible) +// ttek->hide(); +// } else +// ttek->theMainView->slotActivateAll(); +// } } void Systray::slotQuit() { - ttek->save(); ttek->writeSettings(); qApp->quit(); } @@ -208,10 +209,7 @@ QAction *tmp = tagMenu->addAction(name); tmp->setCheckable(true); - if(!ttek) - ttek = typotek::getInstance(); QList taggedFonts = FMFontDb::DB()->Fonts( name , FMFontDb::Tags ); - ttek->resetFilter(); int nActivated(0); int nFonts(taggedFonts.count()); for(int i = 0; i < nFonts ; ++i) diff -Nru fontmatrix-0.6.0+svn20100107/src/tagswidget.cpp fontmatrix-0.6.0+svn20110930/src/tagswidget.cpp --- fontmatrix-0.6.0+svn20100107/src/tagswidget.cpp 2009-06-20 09:05:36.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/tagswidget.cpp 2011-01-11 18:24:33.000000000 +0000 @@ -12,231 +12,58 @@ #include #include +#include #include +#include +#include #include "typotek.h" #include "tagswidget.h" #include "fontitem.h" #include "fmfontdb.h" -#include "listdockwidget.h" +#include "tagswidget_listmodel.h" + -TagsWidget * TagsWidget::instance = 0; TagsWidget::TagsWidget ( QWidget * parent ) :QWidget ( parent ) { setupUi ( this ); - tagsListWidget->setContextMenuPolicy ( Qt::CustomContextMenu ); - + model = new TagsWidget_ListModel(this); + tagsListView->setModel(model); - connect ( tagsListWidget,SIGNAL ( itemClicked ( QListWidgetItem* ) ),this,SLOT ( slotSwitchCheckState ( QListWidgetItem* ) ) ); connect ( newTagButton,SIGNAL ( clicked ( bool ) ),this,SLOT ( slotNewTag() ) ); - connect ( newTagName, SIGNAL ( editingFinished() ), this, SLOT ( slotNewTag() ) ); - connect ( tagsListWidget,SIGNAL ( customContextMenuRequested ( const QPoint & ) ), this, SLOT ( slotContextMenu ( QPoint ) ) ); -} + connect( removeTagButton, SIGNAL(clicked()), this, SLOT(slotActRemovetag())); -TagsWidget::~ TagsWidget() -{ } -TagsWidget * TagsWidget::getInstance() +TagsWidget::~ TagsWidget() { - if ( !instance ) - { - instance = new TagsWidget ( 0 ); - Q_ASSERT ( instance ); - } - return instance; } -void TagsWidget::slotSwitchCheckState ( QListWidgetItem * item ) +void TagsWidget::prepare(QList fonts) { - slotFinalize(); + model->setFonts(fonts); } void TagsWidget::slotNewTag() { - QString nTag ( newTagName->text() ); - newTagName->clear(); - bool ok; -// nTag = QInputDialog::getText(this,"Fontmatrix",tr("Add new tag"),QLineEdit::Normal, QString() , &ok ); - if ( nTag.isEmpty() || FMFontDb::DB()->getTags().contains ( nTag ) ) + QModelIndex idx(model->addTag()); + if(!idx.isValid()) return; - - FMFontDb::DB()->addTagToDB ( nTag ); - QListWidgetItem *lit = new QListWidgetItem ( nTag ); - lit->setCheckState ( Qt::Checked ); - tagsListWidget->addItem ( lit ); - slotFinalize(); - - ListDockWidget::getInstance()->reloadTagsCombo(); -} - -void TagsWidget::slotFinalize() -{ - QStringList plusTags; - QStringList noTags; - for ( int i=0;i< tagsListWidget->count();++i ) - { - if ( tagsListWidget->item ( i )->checkState() == Qt::Checked ) - plusTags.append ( tagsListWidget->item ( i )->text() ); - if ( tagsListWidget->item ( i )->checkState() == Qt::Unchecked ) - noTags.append ( tagsListWidget->item ( i )->text() ); - } - - QStringList sourceTags; - - QMap refTagLists; - for ( int i=0;ipath()] = theTaggedFonts[i]->tags(); - } - FMFontDb::DB()->TransactionBegin(); - for ( int i=0;ipath()]; -// qDebug() <setTags ( sourceTags ); - } - FMFontDb::DB()->TransactionEnd(); -} - -void TagsWidget::prepare ( QList< FontItem * > fonts ) -{ - theTaggedFonts.clear(); - theTaggedFonts = fonts; - - bool readOnly ( false ); -// for ( int i ( 0 ); i < theTaggedFonts.count() ; ++i ) -// { -// if ( theTaggedFonts[i]->isLocked() ) -// { -// readOnly = true; -// break; -// } -// } - tagsListWidget->clear(); - QString tot; - for ( int i=0;ifancyName() + "\n" ); - } - if ( theTaggedFonts.count() > 1 ) - { - titleLabel->setText ( theTaggedFonts[0]->family() + " (family)" ); - } - else - { - titleLabel->setText ( theTaggedFonts[0]->fancyName() ); - } - titleLabel->setToolTip ( tot ); - QStringList tagsList ( FMFontDb::DB()->getTags() ); - - QString sysTag(typotek::getInstance()->getSysTagName()); - tagsList.removeAll(sysTag); - - QMap tmap; - foreach(FontItem* fi, theTaggedFonts) - { - if(fi) - tmap[fi] = FMFontDb::DB()->getValue(fi->path(), FMFontDb::Tags, false).toStringList(); - } - for ( int i=0; i < tagsList.count(); ++i ) - { - QString cur_tag = tagsList[i]; - - if ( (cur_tag.isEmpty()) || (cur_tag == sysTag) ) - continue; - - QListWidgetItem *lit; - - { - lit = new QListWidgetItem ( cur_tag ); - lit->setCheckState ( Qt::Unchecked ); - int YesState = 0; - for ( int i=0;isetCheckState ( Qt::Checked ); - else if ( YesState > 0 && YesState < theTaggedFonts.count() ) - lit->setCheckState ( Qt::PartiallyChecked ); - - tagsListWidget->addItem ( lit ); - if ( readOnly ) - lit->setFlags ( 0 );// No NoItemFlags in Qt < 4.4 - } - } + tagsListView->setCurrentIndex(idx); + tagsListView->edit(idx); } -void TagsWidget::newTag() -{ - slotNewTag(); -} - -void TagsWidget::slotContextMenu ( QPoint pos ) -{ -// if(theTaggedFonts.isEmpty()) -// return; - - if(!tagsListWidget->selectedItems().count()) - return; - currentTag = tagsListWidget->selectedItems().first()->text(); - if ( currentTag.isEmpty() ) - return; -// QString fs(theTaggedFonts.first()->fancyName() + ((theTaggedFonts.count() > 1) ? "…" :"")); - - foreach ( QAction* a, contAction ) - { - delete a; - } - contAction.clear(); - -// contAction << new QAction(tr("Untag") + " " + fs, this); -// connect(contAction.last(),SIGNAL(triggered()), this, SLOT(slotActUntag())); - - contAction << new QAction ( tr ( "Edit", "followed by a tag name" ) + QString ( " \""+currentTag+"\"" ), this ); - connect ( contAction.last(),SIGNAL ( triggered() ), this, SLOT ( slotActEditTag() ) ); -// - contAction << new QAction ( tr ( "Remove tag \"%1\" from database", "the %%1 is a tag name" ).arg ( currentTag ), this ); - connect ( contAction.last(),SIGNAL ( triggered() ), this, SLOT ( slotActRemovetag() ) ); - QMenu menu ( tagsListWidget ); - foreach ( QAction* a, contAction ) - { - menu.addAction ( a ); - } - menu.exec ( QCursor::pos() ); -} void TagsWidget::slotActRemovetag() { -// qDebug() <<"TagsWidget::slotActRemovetag"; + QModelIndex idx(tagsListView->currentIndex()); + if(!idx.isValid()) + return; + QString currentTag(model->data(idx, Qt::DisplayRole).toString()); QString message; message = tr ( "Please confirm that you want to remove\nthe following tag from database:" ) + " " + currentTag; if ( QMessageBox::question ( typotek::getInstance(), @@ -247,30 +74,8 @@ == QMessageBox::Ok ) { FMFontDb::DB()->removeTagFromDB ( currentTag ); - prepare(theTaggedFonts); } } -void TagsWidget::slotActEditTag() -{ -// qDebug()<<"TagsWidget::slotActEditTag"; - QString fromT(currentTag); - QString message; - message = tr ( "Please provide a replacement name for\nthe following tag:") + " " + currentTag ; - QString nt = QInputDialog::getText ( typotek::getInstance(), - "Fontmatrix", - message, - QLineEdit::Normal, - currentTag ) ; - if ( ( nt != currentTag ) && ( !nt.isEmpty() ) ) - { - FMFontDb::DB()->editTag ( currentTag, nt ); - prepare(theTaggedFonts); - ListDockWidget::getInstance()->reloadTagsCombo(); - } - -} - - diff -Nru fontmatrix-0.6.0+svn20100107/src/tagswidget.h fontmatrix-0.6.0+svn20110930/src/tagswidget.h --- fontmatrix-0.6.0+svn20100107/src/tagswidget.h 2008-11-20 16:48:02.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/tagswidget.h 2011-01-11 17:50:04.000000000 +0000 @@ -16,34 +16,25 @@ #include "ui_tagswidget.h" class FontItem; +class TagsWidget_ListModel; class TagsWidget : public QWidget , private Ui::tagsWidget { Q_OBJECT - TagsWidget(QWidget * parent); - ~TagsWidget(); - static TagsWidget * instance; - - QList theTaggedFonts; - - QList contAction; - - QString currentTag; - - public: - static TagsWidget *getInstance(); - void prepare(QList fonts); - void newTag(); - void removeFromTagged(FontItem* f){theTaggedFonts.removeAll(f);} - - private slots: - void slotSwitchCheckState( QListWidgetItem * item ); - void slotNewTag(); - void slotFinalize(); - - void slotContextMenu( QPoint pos ); - void slotActRemovetag(); - void slotActEditTag(); + + + TagsWidget_ListModel * model; + +public: + TagsWidget(QWidget * parent); + ~TagsWidget(); + + void prepare(QList fonts); + +private slots: + void slotNewTag(); + void slotActRemovetag(); + }; #endif //TAGSWIDGET_H diff -Nru fontmatrix-0.6.0+svn20100107/src/tagswidget_listmodel.cpp fontmatrix-0.6.0+svn20110930/src/tagswidget_listmodel.cpp --- fontmatrix-0.6.0+svn20100107/src/tagswidget_listmodel.cpp 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/tagswidget_listmodel.cpp 2011-01-11 18:24:33.000000000 +0000 @@ -0,0 +1,170 @@ +// Author: Pierre Marchand , (C) 2011 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "tagswidget_listmodel.h" + +#include "fontitem.h" +#include "fmfontdb.h" + +#include +#include +#include + + + +TagsWidget_ListModel::TagsWidget_ListModel(QObject *parent) + :QAbstractListModel(parent), + newTagString(tr("New Tag")) +{ + connect(FMFontDb::DB(), SIGNAL(tagsChanged()), this, SLOT(updateTags())); +} + +void TagsWidget_ListModel::updateTags() +{ + emit dataChanged(index(0), index(rowCount() - 1)); +} + +int TagsWidget_ListModel::rowCount(const QModelIndex &parent) const +{ + if(parent.isValid()) + return 0; + return FMFontDb::DB()->getTags().count(); +} + +int TagsWidget_ListModel::columnCount(const QModelIndex &parent) const +{ + if(parent.isValid()) + return 0; + return 1; +} + +QVariant TagsWidget_ListModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid() && index.column() != 0) + return QVariant(); + QStringList tl_tmp = FMFontDb::DB()->getTags(); + tl_tmp.sort(); + + QString tag(tl_tmp.at(index.row())); + if(role == Qt::DisplayRole) + { + return tag; + } + else if(role == Qt::EditRole) + return tag; + else if(role == Qt::CheckStateRole) + { + if(tags.contains(tag)) + return Qt::Checked; + return Qt::Unchecked; + } + else if(role == Qt::FontRole) + { + QFont dfont; + if(tags.contains(tag)) + { + dfont.setBold(true); + return dfont; + } + return dfont; + } + + return QVariant(); + +} + +bool TagsWidget_ListModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if(!index.isValid()) + return false; + if(value.toString().isEmpty()) + return false; + + if(role == Qt::CheckStateRole) + { + QStringList tl_tmp = FMFontDb::DB()->getTags(); + tl_tmp.sort(); + QString tag(tl_tmp.at(index.row())); + if(Qt::CheckState(value.toInt()) == Qt::Checked) + { + if(!tags.contains(tag)) + { + FMFontDb::DB()->TransactionBegin(); + foreach(FontItem* f, fonts) + f->addTag(tag); + FMFontDb::DB()->TransactionEnd(); + tags.append(tag); + emit dataChanged(index, index); + return true; + } + else + return false; + } + else if(Qt::CheckState(value.toInt()) == Qt::Unchecked) + { + if(tags.contains(tag)) + { + FMFontDb::DB()->TransactionBegin(); + foreach(FontItem* f, fonts) + FMFontDb::DB()->removeTag(f->path(), tag); + FMFontDb::DB()->TransactionEnd(); + tags.removeAll(tag); + emit dataChanged(index, index); + return true; + } + else + return false; + } + } + else if(role == Qt::EditRole || role == Qt::DisplayRole) + { + QStringList tl_tmp = FMFontDb::DB()->getTags(); + tl_tmp.sort(); + if(value.toString() == tl_tmp.at(index.row())) + return false; + FMFontDb::DB()->editTag ( tl_tmp.at(index.row()), value.toString()); + emit dataChanged(index, index); + return true; + } + return false; +} + +Qt::ItemFlags TagsWidget_ListModel::flags(const QModelIndex &index) const +{ + return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable; +} + +void TagsWidget_ListModel::setFonts(const QList &flist) +{ + fonts.clear(); + fonts = flist; + if(fonts.count() > 0) + tags = fonts.first()->tags(); + updateTags(); +} + + +QModelIndex TagsWidget_ListModel::addTag() +{ + if(FMFontDb::DB()->getTags().contains(newTagString)) + return QModelIndex(); + + FMFontDb::DB()->addTagToDB(newTagString); + updateTags(); + + QStringList tl_tmp = FMFontDb::DB()->getTags(); + tl_tmp.sort(); + + for(int i(0); i < tl_tmp.count(); ++i) + { + if(tl_tmp.at(i) == newTagString) + return index(i); + } + +} + + + diff -Nru fontmatrix-0.6.0+svn20100107/src/tagswidget_listmodel.h fontmatrix-0.6.0+svn20110930/src/tagswidget_listmodel.h --- fontmatrix-0.6.0+svn20100107/src/tagswidget_listmodel.h 1970-01-01 00:00:00.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/tagswidget_listmodel.h 2011-01-11 18:24:33.000000000 +0000 @@ -0,0 +1,43 @@ +// Author: Pierre Marchand , (C) 2011 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef TAGSWIDGET_LISTMODEL_H +#define TAGSWIDGET_LISTMODEL_H + +#include +#include +#include +#include +#include + +class FontItem; + +class TagsWidget_ListModel : public QAbstractListModel +{ + Q_OBJECT + + QList fonts; + QStringList tags; + const QString newTagString; + +private slots: + void updateTags(); + +public: + + TagsWidget_ListModel(QObject * parent); + int rowCount ( const QModelIndex & parent = QModelIndex() ) const; + int columnCount ( const QModelIndex & parent = QModelIndex() ) const; + QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; + bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); + Qt::ItemFlags flags ( const QModelIndex & index ) const; + + void setFonts(const QList& flist); + QModelIndex addTag(); + +}; + +#endif // TAGSWIDGET_LISTMODEL_H diff -Nru fontmatrix-0.6.0+svn20100107/src/tagswidget.ui fontmatrix-0.6.0+svn20110930/src/tagswidget.ui --- fontmatrix-0.6.0+svn20100107/src/tagswidget.ui 2008-11-20 11:58:20.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/tagswidget.ui 2011-01-11 17:50:04.000000000 +0000 @@ -1,105 +1,89 @@ - + + tagsWidget - - + + 0 0 305 - 391 + 177 - + + + 0 + 1 + + + Form - - + + 0 - - - - + + + + 1 1 - - - - - + + + 2 + + + + + Tags + + + + + + + 0 0 - - - 0 - 64 - - - - - 10 - - - - QFrame::NoFrame - - - Nothing selected + + Add a tag - - Qt::PlainText + + Add Tag - + false - - Qt::AlignCenter - - - true - - - tagsListWidget - - - - - true - - - Right mouse click on a tag to add it or remove it from TagSet + + + + Remove Tag - - - - + + + + true - - - - - - - 0 - 0 - + + Right mouse click on a tag to add it or remove it from TagSet - - Add a tag + + QListView::Adjust - - Add Tag + + 0 - - false + + true @@ -108,8 +92,6 @@ - - - + diff -Nru fontmatrix-0.6.0+svn20100107/src/textprogression.cpp fontmatrix-0.6.0+svn20110930/src/textprogression.cpp --- fontmatrix-0.6.0+svn20100107/src/textprogression.cpp 2008-06-03 09:58:26.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/textprogression.cpp 2010-09-20 16:51:54.000000000 +0000 @@ -12,48 +12,47 @@ #include "textprogression.h" TextProgression *TextProgression::instance = 0; -TextProgression::TextProgression(QWidget * parent) - :QWidget(parent) +TextProgression::TextProgression() { instance = this; - setupUi(this); +// setupUi(this); - connect(inlineBTT,SIGNAL(released()),this,SLOT(forwardStateChanged())); - connect(inlineRTL,SIGNAL(released()),this,SLOT(forwardStateChanged())); - connect(inlineLTR,SIGNAL(released()),this,SLOT(forwardStateChanged())); - connect(inlineTTB,SIGNAL(released()),this,SLOT(forwardStateChanged())); - connect(blockTTB,SIGNAL(released()),this,SLOT(forwardStateChanged())); - connect(blockRTL,SIGNAL(released()),this,SLOT(forwardStateChanged())); - connect(blockLTR,SIGNAL(released()),this,SLOT(forwardStateChanged())); +// connect(inlineBTT,SIGNAL(released()),this,SLOT(forwardStateChanged())); +// connect(inlineRTL,SIGNAL(released()),this,SLOT(forwardStateChanged())); +// connect(inlineLTR,SIGNAL(released()),this,SLOT(forwardStateChanged())); +// connect(inlineTTB,SIGNAL(released()),this,SLOT(forwardStateChanged())); +// connect(blockTTB,SIGNAL(released()),this,SLOT(forwardStateChanged())); +// connect(blockRTL,SIGNAL(released()),this,SLOT(forwardStateChanged())); +// connect(blockLTR,SIGNAL(released()),this,SLOT(forwardStateChanged())); } TextProgression::Progression TextProgression::inBlock() { - if(blockTTB->isChecked()) - return BLOCK_TTB; - else if(blockRTL->isChecked()) - return BLOCK_RTL; - else if(blockLTR->isChecked()) - return BLOCK_LTR; +// if(blockTTB->isChecked()) +// return BLOCK_TTB; +// else if(blockRTL->isChecked()) +// return BLOCK_RTL; +// else if(blockLTR->isChecked()) +// return BLOCK_LTR; - return UNDEFINED; + return BLOCK_TTB; } TextProgression::Progression TextProgression::inLine() { - if(inlineLTR->isChecked()) - return INLINE_LTR; - else if(inlineRTL->isChecked()) - return INLINE_RTL; - else if(inlineTTB->isChecked()) - return INLINE_TTB; - else if(inlineBTT->isChecked()) - return INLINE_BTT; +// if(inlineLTR->isChecked()) +// return INLINE_LTR; +// else if(inlineRTL->isChecked()) +// return INLINE_RTL; +// else if(inlineTTB->isChecked()) +// return INLINE_TTB; +// else if(inlineBTT->isChecked()) +// return INLINE_BTT; - return UNDEFINED; + return INLINE_LTR; } -void TextProgression::forwardStateChanged( ) -{ - emit stateChanged(); -} +//void TextProgression::forwardStateChanged( ) +//{ +// emit stateChanged(); +//} diff -Nru fontmatrix-0.6.0+svn20100107/src/textprogression.h fontmatrix-0.6.0+svn20110930/src/textprogression.h --- fontmatrix-0.6.0+svn20100107/src/textprogression.h 2008-06-03 09:58:26.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/textprogression.h 2010-09-20 16:51:54.000000000 +0000 @@ -12,15 +12,15 @@ #ifndef TEXTPROGRESSION_H #define TEXTPROGRESSION_H -#include "ui_textprogression.h" +//#include "ui_textprogression.h" -class TextProgression : public QWidget, private Ui::TextProgressionWidget +class TextProgression { - Q_OBJECT + public: enum Progression {INLINE_LTR, INLINE_RTL, INLINE_TTB, INLINE_BTT, BLOCK_TTB, BLOCK_LTR, BLOCK_RTL, UNDEFINED}; - TextProgression(QWidget *parent); + TextProgression(); Progression inBlock(); Progression inLine(); @@ -28,10 +28,10 @@ static TextProgression* getInstance(){return instance;} private: static TextProgression *instance; - signals: - void stateChanged(); - private slots: - void forwardStateChanged(); +// signals: +// void stateChanged(); +// private slots: +// void forwardStateChanged(); }; #endif diff -Nru fontmatrix-0.6.0+svn20100107/src/typotek.cpp fontmatrix-0.6.0+svn20110930/src/typotek.cpp --- fontmatrix-0.6.0+svn20100107/src/typotek.cpp 2009-08-14 15:07:30.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/typotek.cpp 2011-02-08 14:43:38.000000000 +0000 @@ -21,9 +21,12 @@ #include "aboutwidget.h" +#include "browserwidget.h" #include "dataexport.h" #include "dataloader.h" #include "dumpdialog.h" +#include "floatingwidget.h" +#include "floatingwidgetsregister.h" #include "fmactivate.h" #include "fmfontdb.h" #include "fmfontextract.h" @@ -32,16 +35,18 @@ #include "fmpaths.h" #include "fmrepair.h" #include "fontbook.h" +#include "fontcomparewidget.h" #include "fontitem.h" // #include "helpwidget.h" #include "helpbrowser.h" #include "hyphenate/fmhyphenator.h" #include "importedfontsdialog.h" #include "importtags.h" -#include "listdockwidget.h" +//#include "listdockwidget.h" #include "mainviewwidget.h" #include "panosedialog.h" #include "panosewidget.h" +#include "playwidget.h" #include "prefspaneldialog.h" #include "remotedir.h" //#include "savedata.h" @@ -64,6 +69,7 @@ #include #include #include +#include #ifdef HAVE_FONTCONFIG #include @@ -76,6 +82,9 @@ #define MAX_RECENT_PYSCRIPTS 10 #endif // HAVE_PYTHONQT +#ifdef Q_WS_MAC +#include +#endif typotek* typotek::instance = 0; bool typotek::matrix = false; @@ -149,13 +158,30 @@ hyphenator = 0; theHelp = 0; dataLoader = 0; + playVisible = false; m_dpiX = ( double ) QApplication::desktop()->physicalDpiX(); m_dpiY = ( double ) QApplication::desktop()->physicalDpiY(); +#ifdef Q_WS_MAC + CGDirectDisplayID macDId = CGMainDisplayID(); + CGRect macDRect = CGDisplayBounds(macDId); + CGSize macDSize = CGDisplayScreenSize(macDId); + + double macDisplayPxWidth(macDRect.size.width); + double macDisplayPxHeight(macDRect.size.height); + double macDisplayPhysicalWidth(double(macDSize.width) / 25.4); + double macDisplayPhysicalHeight(double(macDSize.height) / 25.4); + + m_dpiX = macDisplayPxWidth / macDisplayPhysicalWidth; + m_dpiY = macDisplayPxHeight / macDisplayPhysicalHeight; +#endif + + qDebug()<< m_dpiX << m_dpiY; } void typotek::initMatrix() { + qDebug()<<"Main Thread:"<addWidget(theMainView); + mainStack->addWidget(theBrowser); + setCentralWidget ( mainStack ); if ( QSystemTrayIcon::isSystemTrayAvailable() ) systray = new Systray(); @@ -176,31 +207,31 @@ setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::ForceTabbedDocks); - installDock("Main", tr ( "Browse Fonts" ), ListDockWidget::getInstance() , tr ( "Show/hide fonts browsing sidebar" )); - installDock("Tags", tr ( "Tags" ), TagsWidget::getInstance() , tr ( "Show/hide tags list sidebar" ) ); - installDock("Panose", tr ( "Panose"), PanoseWidget::getInstance(), tr ( "Browse fonts by means of Panose attributes" ) ); +// installDock("Main", tr ( "Browse Fonts" ), ListDockWidget::getInstance() , tr ( "Show/hide fonts browsing sidebar" )); +// installDock("Tags", tr ( "Tags" ), TagsWidget::getInstance() , tr ( "Show/hide tags list sidebar" ) ); +// installDock("Panose", tr ( "Panose"), PanoseWidget::getInstance(), tr ( "Browse fonts by means of Panose attributes" ) ); // force tabifyication - QStringList dl; - dl << "Tags" << "Panose" << "Main"; - for(int i(1); i < dl.count(); ++i) - { - if(dockArea[dl[i]] != "Float") - { - for(int j(i-1); j >=0 ; --j) - { - if(dockArea[dl[j]] == dockArea[dl[i]]) - tabifyDockWidget(dockWidget[dl[j]], dockWidget[dl[i]]); - } - } - } +// QStringList dl; +// dl << "Tags" << "Panose" << "Main"; +// for(int i(1); i < dl.count(); ++i) +// { +// if(dockArea[dl[i]] != "Float") +// { +// for(int j(i-1); j >=0 ; --j) +// { +// if(dockArea[dl[j]] == dockArea[dl[i]]) +// tabifyDockWidget(dockWidget[dl[j]], dockWidget[dl[i]]); +// } +// } +// } createActions(); createMenus(); createStatusBar(); doConnect(); - theMainView->setCrumb(); + showToltalFilteredFonts(); if(!hyphenator) { @@ -247,17 +278,17 @@ void typotek::postInit() { // TODO restore last filter - theMainView->slotViewAll(); +// theMainView->slotViewAll(); QSettings st; QString cname(st.value("CurrentFont", QString()).toString()); - if(!cname.isEmpty()) - { - if(!ListDockWidget::getInstance()->fontTree->slotSetCurrent(cname)) - theMainView->displayWelcomeMessage(); - } - else - theMainView->displayWelcomeMessage(); +// if(!cname.isEmpty()) +// { +// if(!ListDockWidget::getInstance()->fontTree->slotSetCurrent(cname)) +// theMainView->displayWelcomeMessage(); +// } +// else +// theMainView->displayWelcomeMessage(); } void typotek::doConnect() @@ -265,13 +296,11 @@ if(getSystray()) connect ( FMActivate::getInstance() ,SIGNAL ( activationEvent ( const QStringList& ) ), getSystray(),SLOT ( updateTagMenu ( const QStringList& ) ) ); - connect(FMLayout::getLayout()->optionDialog,SIGNAL(finished( int )),this,SLOT(slotUpdateLayOptStatus())); +// connect(FMLayout::getLayout()->optionDialog,SIGNAL(finished( int )),this,SLOT(slotUpdateLayOptStatus())); #ifdef HAVE_PYTHONQT connect(FMScriptConsole::getInstance(),SIGNAL(finished()), this, SLOT(slotUpdateScriptConsoleStatus())); #endif - - - + connect(toggleMainViewButton, SIGNAL(toggled(bool)), this, SLOT(toggleMainView(bool))); } void typotek::closeEvent ( QCloseEvent *event ) @@ -296,8 +325,16 @@ } } -// save(); + foreach(FloatingWidget *f, FloatingWidgetsRegister::AllWidgets()) + { + f->close(); + } writeSettings(); + + delete PlayWidget::getInstance(); + delete FontCompareWidget::getInstance(); + delete theMainView; + event->accept(); } @@ -306,7 +343,7 @@ // if announce == true user will be shown a dialog of imported fonts // if announce == false and collect == true all fonts imported will be // collected and announced next time announce == true -void typotek::open ( QString path, bool announce, bool collect ) +void typotek::open ( QString path, bool recursive, bool announce, bool collect ) { static QStringList nameList; static QStringList tali; // tali gets reseted when announce = true then the shouldAskTali is also set to true @@ -335,10 +372,12 @@ dir = tmpdir; // only set dir if importing wasn't cancelled settings.setValue ( "Places/LastUsedFolder", dir ); - QDir theDir ( dir ); - // addFcDirItem(theDir.absolutePath()); - QStringList dirList ( fontmatrix::exploreDirs ( dir,0 ) ); + QStringList dirList; + if(recursive) + dirList = fontmatrix::exploreDirs ( dir,0 ) ; + else + dirList.append(dir); // qDebug() << dirList.join ( "\n" ); QStringList yetHereFonts; @@ -376,8 +415,8 @@ // It can happen that you wrongly select a dir, it is time to let the user cancel the import. // I want it :) - pm - if ( ( pathList.count() > 1 ) - && ( QMessageBox::question ( this, + if ( /*( pathList.count() > 1 ) + &&*/ ( QMessageBox::question ( this, QString ( "Fontmatrix - %1" ).arg ( tr ( "confirmation" ) ) , tr ( "Do you confirm you want to import these %1 fonts?" ).arg ( pathList.count() ), QMessageBox::Yes | QMessageBox::No, @@ -476,9 +515,17 @@ tali.clear(); shouldAskTali = true; } - theMainView->slotReloadFontList(); - ListDockWidget::getInstance()->reloadTagsCombo(); + emit newFontsArrived(); +} +void typotek::importFiles() +{ + QStringList flist = QFileDialog::getOpenFileNames(this, + tr("Select Files to Import"), + QDir::homePath(), + QString("%1 (*.otf *.ttf *.pfb)").arg(tr("Font Files"))); + if(!flist.isEmpty()) + openList(flist); } /// Import files in a drop event. @@ -542,7 +589,7 @@ else { QString errorFont ( tr ( "Cannot import this font because it is broken: " ) +" "+fi.fileName() ); - statusBar()->showMessage ( errorFont ); +// statusBar()->showMessage ( errorFont ); nameList << "__FAILEDTOLOAD__" + fi.fileName(); } } @@ -570,42 +617,33 @@ { statusBar()->showMessage ( tr ( "Fonts imported: %1" ).arg ( nameList.count() ), 3000 ); } - - theMainView->slotReloadFontList(); - ListDockWidget::getInstance()->reloadTagsCombo(); + emit newFontsArrived(); } /// EXPORT void typotek::slotExportFontSet() { - QStringList tagsList(FMFontDb::DB()->getTags()); - QStringList items ( tagsList ); -// items.removeAll ( "Activated_On" ); -// items.removeAll ( "Activated_Off" ); - bool ok; - QString item = QInputDialog::getItem ( this, tr ( "Fontmatrix Tags" ), - tr ( "Choose the tag for filter exported fonts" ), items, 0, false, &ok ); - if ( ok && !item.isEmpty() ) - { - - - QString dir( QDir::homePath() ); - dir = QFileDialog::getExistingDirectory ( this, tr ( "Choose Directory" ), dir , QFileDialog::ShowDirsOnly ); - if ( dir.isEmpty() ) - return; - - DataExport dx(dir,item); - dx.doExport(); - } - +// QStringList tagsList(FMFontDb::DB()->getTags()); +// QStringList items ( tagsList ); +// bool ok; +// QString item = QInputDialog::getItem ( this, tr ( "Fontmatrix Tags" ), +// tr ( "Choose the tag for filter exported fonts" ), items, 0, false, &ok ); +// if ( ok && !item.isEmpty() ) +// { + + +// QString dir( QDir::homePath() ); +// dir = QFileDialog::getExistingDirectory ( this, tr ( "Choose Directory" ), dir , QFileDialog::ShowDirsOnly ); +// if ( dir.isEmpty() ) +// return; + +// DataExport dx(dir,item); +// dx.doExport(); +// } + new DataExport(this); } -bool typotek::save() -{ - return true; - -} void typotek::about() { @@ -617,47 +655,23 @@ { Shortcuts *scuts = Shortcuts::getInstance(); - openAct = new QAction ( QIcon ( ":/fontmatrix_import_icon" ), tr ( "&Import..." ), this ); - openAct->setShortcut ( tr ( "Ctrl+O" ) ); - openAct->setStatusTip ( tr ( "Import a directory" ) ); + openAct = new QAction ( QIcon ( ":/fontmatrix_import_icon" ), tr ( "&Import Directory..." ), this ); + openAct->setShortcut ( Qt::CTRL + Qt::Key_O ); + openAct->setToolTip( tr ( "Import a directory" ) ); scuts->add(openAct); connect ( openAct, SIGNAL ( triggered() ), this, SLOT ( open() ) ); - saveAct = new QAction ( tr ( "&Sync" ), this ); - saveAct->setShortcut ( tr ( "Ctrl+S" ) ); - saveAct->setStatusTip ( tr ( "Sync with the DB file" ) ); - scuts->add(saveAct); - connect ( saveAct, SIGNAL ( triggered() ), this, SLOT ( save()) ); + importFilesAction = new QAction(QIcon ( ":/fontmatrix_import_icon" ), tr ( "Import &Files..." ), this ); + importFilesAction->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_O ); + importFilesAction->setToolTip(tr("Import Files")); + scuts->add(importFilesAction); + connect(importFilesAction, SIGNAL(triggered()), this, SLOT(importFiles())); exportFontSetAct = new QAction(tr("Export &fonts"),this); exportFontSetAct->setStatusTip(tr("Export a fontset")); scuts->add(exportFontSetAct); connect( exportFontSetAct,SIGNAL(triggered( )),this,SLOT(slotExportFontSet())); - printInfoAct = new QAction ( tr ( "Print Info..." ),this ); - printInfoAct->setStatusTip ( tr ( "Print informations about the current font" ) ); - scuts->add(printInfoAct); - connect ( printInfoAct, SIGNAL ( triggered() ), this, SLOT ( printInfo() ) ); - - printSampleAct = new QAction ( tr ( "Print Sample..." ),this ); - printSampleAct->setStatusTip( tr("Print the sample as a specimen")); - scuts->add(printSampleAct); - connect (printSampleAct,SIGNAL( triggered() ), this, SLOT ( printSample()) ); - - printChartAct = new QAction ( tr ( "Print Chart..." ),this ); - printChartAct->setStatusTip( tr("Print a chart of the current font")); - scuts->add(printChartAct); - connect (printChartAct,SIGNAL( triggered() ), this, SLOT ( printChart()) ); - - printPlaygroundAct = new QAction ( tr ( "Print Playground..." ),this ); - printPlaygroundAct->setStatusTip( tr("Print the playground")); - scuts->add(printPlaygroundAct); - connect (printPlaygroundAct,SIGNAL( triggered() ), this, SLOT ( printPlayground()) ); - - printFamilyAct = new QAction ( tr ( "Print Family..." ),this ); - printFamilyAct->setStatusTip( tr("Print a specimen of the whole family the current face belongs to")); - scuts->add(printFamilyAct); - connect (printFamilyAct,SIGNAL( triggered() ), this, SLOT ( printFamily()) ); fontBookAct = new QAction ( QIcon ( ":/fontmatrix_fontbookexport_icon.png" ), tr ( "Export font book..." ),this ); fontBookAct->setStatusTip ( tr ( "Export a PDF document that shows selected fonts" ) ); @@ -669,7 +683,7 @@ connect(dumpInfoAct, SIGNAL(triggered()), this, SLOT(slotDumpInfo())); exitAct = new QAction ( tr ( "E&xit" ), this ); - exitAct->setShortcut ( tr ( "Ctrl+Q" ) ); + exitAct->setShortcut ( Qt::CTRL + Qt::Key_Q ); exitAct->setStatusTip ( tr ( "Exit the application" ) ); exitAct->setMenuRole(QAction::QuitRole); scuts->add(exitAct); @@ -689,7 +703,7 @@ connect (aboutQtAct,SIGNAL(triggered()), QApplication::instance(),SLOT(aboutQt())); helpAct = new QAction ( tr ( "Help" ), this ); - helpAct->setShortcut ( tr ( "F1" ) ); + helpAct->setShortcut ( Qt::Key_F1 ); helpAct->setStatusTip ( tr ( "Read documentation on Fontmatrix" ) ); helpAct->setCheckable(true); helpAct->setChecked(false); @@ -745,8 +759,8 @@ scuts->add(repairAct); connect( repairAct, SIGNAL ( triggered() ),this,SLOT (slotRepair())); - if ( systray ) - connect ( theMainView, SIGNAL ( newTag ( QString ) ), systray, SLOT ( newTag ( QString ) ) ); +// if ( systray ) +// connect ( theMainView, SIGNAL ( newTag ( QString ) ), systray, SLOT ( newTag ( QString ) ) ); tagAll = new QAction(tr("Tag All Filtered..."), this); tagAll->setStatusTip ( tr ( "Tag all currently visible files" ) ); @@ -763,36 +777,41 @@ scuts->add(editPanoseAct); connect(editPanoseAct, SIGNAL(triggered()), this, SLOT(slotEditPanose())); - nextFamily = new QAction(tr("Next Family"), this); - nextFamily->setShortcut(Qt::Key_PageDown); - nextFamily->setStatusTip ( tr ( "Switch to the next font family in the list" ) ); - scuts->add(nextFamily); - connect(nextFamily, SIGNAL(triggered()), ListDockWidget::getInstance()->fontTree, SLOT(slotNextFamily())); - - nextFont = new QAction(tr("Next Face"), this); - nextFont->setShortcut(Qt::Key_Down); - nextFont->setStatusTip ( tr ( "Switch to the next font face in the list" ) ); - scuts->add(nextFont); - connect(nextFont, SIGNAL(triggered()), ListDockWidget::getInstance()->fontTree, SLOT(slotNextFont())); - - previousFamily = new QAction(tr("Previous Family"), this); - previousFamily->setShortcut(Qt::Key_PageUp); - previousFamily->setStatusTip ( tr ( "Switch to the previous font family in the list" ) ); - scuts->add(previousFamily); - connect(previousFamily, SIGNAL(triggered()), ListDockWidget::getInstance()->fontTree, SLOT(slotPreviousFamily())); - - - previousFont = new QAction(tr("Previous Face"), this); - previousFont->setShortcut(Qt::Key_Up); - previousFont->setStatusTip ( tr ( "Switch to the previous font face in the list" ) ); - scuts->add(previousFont); - connect(previousFont, SIGNAL(triggered()), ListDockWidget::getInstance()->fontTree, SLOT(slotPreviousFont())); - - layOptAct = new QAction(tr("Text layout engine options"),this); - layOptAct->setStatusTip ( tr ( "View and edit text layout engine variables" ) ); - layOptAct->setCheckable(true); - scuts->add(layOptAct); - connect(layOptAct,SIGNAL(triggered()),this,SLOT(slotSwitchLayOptVisible())); + + playAction = new QAction(tr("Playground"), this); + playAction->setShortcut(Qt::CTRL + Qt::Key_G); + playAction->setToolTip(tr("Show/Hide Playground")); + playAction->setCheckable(true); + playAction->setChecked(false); + scuts->add(playAction); + connect(playAction, SIGNAL(triggered(bool)), PlayWidget::getInstance(), SLOT(setVisible(bool))); + + compareAction = new QAction(tr("Compare"), this); + compareAction->setShortcut(Qt::CTRL + Qt::Key_R); + compareAction->setToolTip(tr("Show/Hide Compare glyphs")); + compareAction->setCheckable(true); + compareAction->setChecked(false); + scuts->add(compareAction); + connect(compareAction, SIGNAL(triggered(bool)), FontCompareWidget::getInstance(), SLOT(setVisible(bool))); + + closeAllFloat = new QAction(tr("Close All"), this); + closeAllFloat->setToolTip(tr("Close all floating windows")); + scuts->add(closeAllFloat); + connect(closeAllFloat, SIGNAL(triggered()), this, SLOT(closeAllFloatings())); + + showAllFloat = new QAction(tr("Show All"), this); + showAllFloat->setToolTip(tr("Show all floating windows")); + scuts->add(showAllFloat); + connect(showAllFloat, SIGNAL(triggered()), this, SLOT(showAllFloatings())); + + hideAllFloat = new QAction(tr("Hide All"), this); + hideAllFloat->setToolTip(tr("Hide all floating windows")); + scuts->add(hideAllFloat); + connect(hideAllFloat, SIGNAL(triggered()), this, SLOT(hideAllFloatings())); + + floatSep = new QAction(this); + floatSep->setSeparator(true); + extractFontAction = new QAction(tr("Extract fonts..."),this); extractFontAction->setStatusTip ( tr ( "Extract fonts from documents like PDF to PFM file format" ) ); @@ -830,17 +849,10 @@ fileMenu = menuBar()->addMenu ( tr ( "&File" ) ); fileMenu->addAction ( openAct ); - fileMenu->addAction ( saveAct ); + fileMenu->addAction ( importFilesAction ); fileMenu->addAction ( exportFontSetAct ); fileMenu->addSeparator(); - printMenu = fileMenu->addMenu(tr("Print")); - printMenu->addAction(printInfoAct); - printMenu->addAction(printSampleAct); - printMenu->addAction(printChartAct); - printMenu->addAction(printPlaygroundAct); - printMenu->addAction(printFamilyAct); - fileMenu->addAction ( fontBookAct ); fileMenu->addAction ( dumpInfoAct ); fileMenu->addSeparator(); @@ -861,15 +873,11 @@ editMenu->addSeparator(); editMenu->addAction ( prefsAct ); - browseMenu = menuBar()->addMenu(tr("&Browse")); - browseMenu->addAction(nextFamily); - browseMenu->addAction(previousFamily); - browseMenu->addAction(nextFont); - browseMenu->addAction(previousFont); - - viewMenu = createPopupMenu(); - viewMenu->setTitle(tr("&View")); - menuBar()->addMenu(viewMenu); + viewMenu = menuBar()->addMenu(tr("&View")); + viewMenu->addAction(playAction); + viewMenu->addAction(compareAction); + viewMenu->addSeparator(); + connect(viewMenu, SIGNAL(aboutToShow()), this,SLOT(updateFloatingStatus())); #ifdef HAVE_PYTHONQT scriptMenu = menuBar()->addMenu ( tr ( "&Scripts" ) );; @@ -890,7 +898,7 @@ #endif servicesMenu->addAction(showTTTAct); servicesMenu->addSeparator(); - servicesMenu->addAction(layOptAct); +// servicesMenu->addAction(layOptAct); helpMenu = menuBar()->addMenu ( tr ( "&Help" ) ); helpMenu->addAction ( helpAct ); @@ -901,7 +909,7 @@ void typotek::createStatusBar() { - statusBar()->showMessage ( tr ( "Ready" ) ); +// statusBar()->showMessage ( tr ( "Ready" ) ); statusProgressBar = new QProgressBar(this); statusProgressBar->setMaximumSize(200,20); @@ -913,13 +921,19 @@ curFontPresentation->setFrameShape(QFrame::StyledPanel); curFontPresentation->setAlignment ( Qt::AlignRight ); curFontPresentation->setFont ( statusFontFont ); - statusBar()->addPermanentWidget ( curFontPresentation ); + statusBar()->insertWidget ( 0, curFontPresentation ); countFilteredFonts = new QLabel ( "" ); countFilteredFonts->setFrameShape(QFrame::StyledPanel); countFilteredFonts->setAlignment ( Qt::AlignRight ); countFilteredFonts->setFont ( statusFontFont ); statusBar()->addPermanentWidget ( countFilteredFonts ); + + toggleMainViewButton = new QToolButton(this); + toggleMainViewButton->setText(tr("Browse Directories")); + toggleMainViewButton->setCheckable(true); + toggleMainViewButton->setToolTip(tr("Toggle Files/Collection view")); + statusBar()->addPermanentWidget(toggleMainViewButton); } void typotek::readSettings() @@ -939,21 +953,21 @@ previewSubtitled = settings.value("Preview/Subtitled", false).toBool(); m_theWord = settings.value("Preview/Word", "" ).toString(); - QStringList dl; - dl << "Main" << "Tags" << "Panose"; - foreach(const QString & ds, dl) - { - dockArea[ds] = settings.value("Docks/"+ds+"Pos", "Left").toString(); - dockVisible[ds] = settings.value("Docks/"+ds+"Visible", true).toBool(); - dockGeometry[ds] = settings.value("Docks/"+ds+"Geometry", QRect()).toRect(); - qDebug()<saveSplitterState(); - QStringList dl; - dl << "Main" << "Tags" << "Panose"; - foreach(const QString & ds, dl) - { - if(dockWidget[ds]->isFloating()) - { - dockArea[ds] = "Float"; - } - settings.setValue( "Docks/"+ds+"Pos", dockArea[ds] ); - settings.setValue( "Docks/"+ds+"Visible", dockWidget[ds]->isVisible()); - settings.setValue( "Docks/"+ds+"Geometry", dockWidget[ds]->geometry()); - } +// QStringList dl; +// dl << "Main" << "Tags" << "Panose"; +// foreach(const QString & ds, dl) +// { +// if(dockWidget[ds]->isFloating()) +// { +// dockArea[ds] = "Float"; +// } +// settings.setValue( "Docks/"+ds+"Pos", dockArea[ds] ); +// settings.setValue( "Docks/"+ds+"Visible", dockWidget[ds]->isVisible()); +// settings.setValue( "Docks/"+ds+"Geometry", dockWidget[ds]->geometry()); +// } settings.setValue("Info/PreviewSize", previewInfoFontSize ); @@ -1018,7 +1032,6 @@ if(theMainView->selectedFont()) settings.setValue("CurrentFont", theMainView->selectedFont()->path()); - save(); } @@ -1030,7 +1043,6 @@ typotek::~typotek() { - } void typotek::fillTagsList() @@ -1293,7 +1305,7 @@ QStringList tagsList(FMFontDb::DB()->getTags()); // qDebug()<<"typotek::slotRemoteIsReady()"; - QList listInfo(remoteDir->rFonts()); + QList listInfo(remoteDir->rFonts()); // qDebug()<< "Have got "<< listInfo.count() <<"remote font descriptions"; for(int rf(0) ;rf < listInfo.count(); ++rf) { @@ -1313,31 +1325,22 @@ if(!tag.isEmpty() && !tagsList.contains(tag)) { tagsList << tag; - theMainView->slotAppendTag(tag); } } } - theMainView->slotReloadFontList(); +// theMainView->slotReloadFontList(); showStatusMessage( QString::number(listInfo.count())+ " " + tr("font descriptions imported from network")); // qDebug()<<"END OF slotRemoteIsReady()"; } -void typotek::resetFilter() -{ - theMainView->setCrumb(); -} - void typotek::fontBook() { FontBook fontbook; - fontbook.doBook(); + fontbook.doBook(FontBook::Full); } -QList typotek::getCurrentFonts() -{ - return theMainView->curFonts(); -} + FontItem * typotek::getSelectedFont() { @@ -1391,7 +1394,7 @@ FontItem *item = theMainView->selectedFont(); if ( !item ) { - statusBar()->showMessage ( tr ( "There is no font selected" ), 5000 ); + statusBar()->showMessage ( tr ( "There is no font selected" ), 3000 ); return; } @@ -1418,25 +1421,6 @@ QStringList uris = event->mimeData()->text().split ( "\n" ); QStringList ret; - // Internal drag & drop - if(event->source() && event->source()->objectName() == "folderView" ) - { - QString fP(ListDockWidget::getInstance()->getFolderCurrentIndex().data(QDirModel::FilePathRole).toString()); - - if(QFileInfo(fP).isDir()) - { - open(fP); - return; - } - else - { - { - uris << "file://" + fP; - } - } - - } - for ( int i = 0; i < uris.count() ; ++i ) { qDebug() << "dropped uri["<< i <<"] -> "<< uris[i]; @@ -1465,7 +1449,7 @@ { // TODO Get fonts over http qDebug() << "Support of DragNDrop over http is sheduled"; - statusBar()->showMessage ( tr ( "Support of DragNDrop over http is sheduled but not yet effective" ), 5000 ); + statusBar()->showMessage ( tr ( "Support of DragNDrop over http is sheduled but not yet effective" ), 3000 ); } else { @@ -1490,7 +1474,7 @@ else { qDebug() << "dragEnterEvent refused"; - statusBar()->showMessage ( tr ( "You bring something over me I can’t handle" ), 2000 ); + statusBar()->showMessage ( tr ( "You bring something over me I can’t handle" ), 3000 ); } } @@ -1521,7 +1505,7 @@ void typotek::forwardUpdateView() { - theMainView->slotView ( true ); +// theMainView->slotView ( true ); } void typotek::setSystrayVisible ( bool isVisible ) @@ -1560,17 +1544,23 @@ QString typotek::namedSample ( QString name ) { + QString cn(name); + if(cn == QString("NEW_SAMPLE")) + return tr("Edit me!"); + if(cn.isEmpty()) + cn = currentNamedSample; + else + currentNamedSample = cn; + if(!dataLoader) dataLoader = new DataLoader(); -// qDebug()<<"typotek::namedSample"<& us(dataLoader->userSamples()); foreach(const QString& k, us.keys()) { QString id(QString("User::") + k); // qDebug()<<"\t"< > typotek::namedSamplesNames() @@ -1614,7 +1604,7 @@ dataLoader = new DataLoader(); dataLoader->update(name, sample); - theMainView->refillSampleList(); +// theMainView->refillSampleList(); } void typotek::removeNamedSample(const QString& key) @@ -1623,7 +1613,7 @@ dataLoader = new DataLoader(); dataLoader->remove(key); - theMainView->refillSampleList(); +// theMainView->refillSampleList(); } void typotek::changeSample ( QString name, QString text ) @@ -1632,7 +1622,7 @@ dataLoader = new DataLoader(); dataLoader->update(name, text); - theMainView->refillSampleList(); +// theMainView->refillSampleList(); } QString typotek::defaultSampleName() @@ -1644,19 +1634,19 @@ if(us.contains(tr("default"))) return QString("User::") + QString("default"); else if(us.count() > 0) - return us[us.keys().first()]; + return QString("User::") + us.keys().first(); else { const QMap >& ss(dataLoader->systemSamples()); QString l(QLocale::system().language()); if((ss.contains(l)) && (ss[l].count() > 0)) - return ss[l][ss[l].keys().first()]; + return l + QString("::") + ss[l].keys().first(); else { foreach(QString k, ss.keys()) { if(ss[k].count() > 0) - return ss[k][ss[k].keys().first()]; + return k + QString("::") +ss[k].keys().first(); } } } @@ -1680,9 +1670,9 @@ if(previewSize == d) return; - previewSize = d; - if(previewSize != ListDockWidget::getInstance()->previewSize->value()) - ListDockWidget::getInstance()->previewSize->setValue(previewSize); +// previewSize = d; +// if(previewSize != ListDockWidget::getInstance()->previewSize->value()) +// ListDockWidget::getInstance()->previewSize->setValue(previewSize); QList fontMap(FMFontDb::DB()->AllFonts()); for(int i(0); i < fontMap.count(); ++i) fontMap[i]->clearPreview() ; @@ -1763,7 +1753,7 @@ QSettings settings; settings.setValue("Sample/FontSize", fSize); settings.setValue("Sample/Interline", lSize); - theMainView->reSize(fSize,lSize); +// theMainView->reSize(fSize,lSize); } void typotek::relayStartingStepIn(QString s) @@ -1795,7 +1785,7 @@ void typotek::showStatusMessage(const QString & message) { - statusBar()->showMessage(message, 2500); + statusBar()->showMessage(message, 3000); } void typotek::setRemoteTmpDir(const QString & s) @@ -1829,7 +1819,6 @@ if(!tagsList.contains(tali[t])) { tagsList.append(tali[t]); - emit tagAdded(tali[t]); } } @@ -1844,272 +1833,136 @@ } FMFontDb::DB()->TransactionEnd(); - TagsWidget::getInstance()->newTag(); -} - -void typotek::printInfo() -{ - FontItem * font(theMainView->selectedFont()); - QString fontname(tr("Welcome maessage")); - if(font) - fontname =font->fancyName(); - - QPrinter thePrinter ( QPrinter::HighResolution ); - QPrintDialog dialog(&thePrinter, this); - dialog.setWindowTitle("Fontmatrix - " + tr("Print Infos") +" - " + fontname ); - - if ( dialog.exec() != QDialog::Accepted ) - return; - thePrinter.setFullPage ( true ); - theMainView->info()->print(&thePrinter); -} - -void typotek::printSample() -{ - FontItem * font(theMainView->selectedFont()); - if(!font) - return; - QGraphicsScene *ls (theMainView->currentSampleScene()); - if( FMLayout::getLayout()->isRunning() ) - { - connect(FMLayout::getLayout(), SIGNAL(paintFinished()), this,SLOT(printSample())); -// waitLayoutForPrint = false; - return; - } - else - { - disconnect(FMLayout::getLayout(), SIGNAL(paintFinished()), this,SLOT(printSample())); -// waitLayoutForPrint = true; - } - - QPrinter thePrinter ( QPrinter::HighResolution ); - QPrintDialog dialog(&thePrinter, this); - dialog.setWindowTitle("Fontmatrix - " + tr("Print Sample") +" - " + font->fancyName() ); - - if ( dialog.exec() != QDialog::Accepted ) - return; - thePrinter.setFullPage ( true ); - QPainter aPainter ( &thePrinter ); - - ls->render(&aPainter); - -} - -void typotek::printChart() -{ - FontItem * font(theMainView->selectedFont()); - if(!font) - return; - - QPrinter thePrinter ( QPrinter::HighResolution ); - QPrintDialog dialog(&thePrinter, this); - dialog.setWindowTitle("Fontmatrix - " + tr("Print Chart") +" - " + font->fancyName() ); - - if ( dialog.exec() != QDialog::Accepted ) - return; - thePrinter.setFullPage ( true ); - QPainter aPainter ( &thePrinter ); - - - double pWidth(thePrinter.paperRect().width()); - double pHeight(thePrinter.paperRect().height()); - double pFactor( thePrinter.resolution() ); - - qDebug()<<"Paper :"<"< lgit(pScene.items()); - foreach(QGraphicsItem* git, lgit) - { - pScene.removeItem(git); - delete git; - } - - int controlN(maxCharcode - beginCharcode); - int stopAtCode( font->renderChart(&pScene, beginCharcode, maxCharcode, sourceR.width(),sourceR.height() ) ); - qDebug()<< "Control"<fancyName()+"[U"+QString::number(beginCharcode ,16).toUpper()+", U"+QString::number(stopAtCode ,16).toUpper()+"]"); - pScene.render(&aPainter,targetR, sourceR, Qt::KeepAspectRatio); - - beginCharcode = stopAtCode; - } - - -} - -void typotek::printPlayground() -{ - FontItem * font(theMainView->selectedFont()); - QPrinter thePrinter ( QPrinter::HighResolution ); - QPrintDialog dialog(&thePrinter, this); - dialog.setWindowTitle("Fontmatrix - " + tr("Print Playground") ); - - if ( dialog.exec() != QDialog::Accepted ) - return; - thePrinter.setFullPage ( true ); - QPainter aPainter ( &thePrinter ); - - double pWidth(thePrinter.paperRect().width()); - double pHeight(thePrinter.paperRect().height()); - - QRectF targetR( pWidth * 0.1, pHeight * 0.1, pWidth * 0.8, pHeight * 0.8 ); - QRectF sourceR( theMainView->getPlayground()->getMaxRect() ); - theMainView->getPlayground()->deselectAll(); - theMainView->getPlayground()->scene()->render(&aPainter, targetR ,sourceR, Qt::KeepAspectRatio ); +// TagsWidget::getInstance()->newTag(); } -void typotek::printFamily() -{ - FontItem * font(theMainView->selectedFont()); - if(!font) - return; - QPrinter thePrinter ( QPrinter::HighResolution ); - QPrintDialog dialog(&thePrinter, this); - dialog.setWindowTitle("Fontmatrix - " + tr("Print Family") +" - " + font->family()); - - if ( dialog.exec() != QDialog::Accepted ) - return; - - thePrinter.setFullPage ( true ); - QPainter aPainter ( &thePrinter ); - - QGraphicsScene tmpScene(thePrinter.paperRect()); - QGraphicsScene pScene(thePrinter.paperRect()); - - qDebug()< logWidth; - QMap logAscend; - QMap logDescend; - QMap sampleString; - QMap sampleFont; - - QStringList stl1(namedSample ( theMainView->sampleName() ).split ( QRegExp("\\W") )); - if(stl1.count() < 10 ) - { - QMessageBox::information(this,"Fontmatrix",tr("Not enough text to make a sample")); - return; - } - QStringList stl; - int idxS(0); - int idxE( qrand() % 9 ); - while((idxS + idxE) < stl1.count()) - { - QString t(QStringList(stl1.mid(idxS,idxE)).join( " " )); - qDebug()<<"s e T"< familyFonts(FMFontDb::DB()->Fonts(theMainView->selectedFont()->family(), FMFontDb::Family )); -// if(familyFonts.count() > stl.count()) - { - int diff ( familyFonts.count() ); - for (int i(0); i < diff; ++i) - { - sampleString[i] = stl[ i % stl.count() ]; - } - } +//void typotek::printFamily() +//{ +// FontItem * font(theMainView->selectedFont()); +// if(!font) +// return; +// QPrinter thePrinter ( QPrinter::HighResolution ); +// QPrintDialog dialog(&thePrinter, this); +// dialog.setWindowTitle("Fontmatrix - " + tr("Print Family") +" - " + font->family()); + +// if ( dialog.exec() != QDialog::Accepted ) +// return; + +// thePrinter.setFullPage ( true ); +// QPainter aPainter ( &thePrinter ); + +// QGraphicsScene tmpScene(thePrinter.paperRect()); +// QGraphicsScene pScene(thePrinter.paperRect()); + +// qDebug()< logWidth; +// QMap logAscend; +// QMap logDescend; +// QMap sampleString; +// QMap sampleFont; + +// QStringList stl1(namedSample ( theMainView->sampleName() ).split ( QRegExp("\\W") )); +// if(stl1.count() < 10 ) +// { +// QMessageBox::information(this,"Fontmatrix",tr("Not enough text to make a sample")); +// return; +// } +// QStringList stl; +// int idxS(0); +// int idxE( qrand() % 9 ); +// while((idxS + idxE) < stl1.count()) +// { +// QString t(QStringList(stl1.mid(idxS,idxE)).join( " " )); +// qDebug()<<"s e T"< familyFonts(FMFontDb::DB()->Fonts(theMainView->selectedFont()->family(), FMFontDb::Family )); + +//// if(familyFonts.count() > stl.count()) +// { +// int diff ( familyFonts.count() ); +// for (int i(0); i < diff; ++i) +// { +// sampleString[i] = stl[ i % stl.count() ]; +// } +// } + +// // first we’ll get widths for font size 1000 +// for(int fidx(0); fidx < familyFonts.count(); ++fidx) +// { +// sampleFont[fidx] = familyFonts[fidx]; +// bool rasterState(sampleFont[fidx]->rasterFreetype()); +// sampleFont[fidx]->setFTRaster(false); +// sampleFont[fidx]->setRenderReturnWidth(true); +// logWidth[fidx] = familyFonts[fidx]->renderLine(&tmpScene, sampleString[fidx], QPointF(0.0, 1000.0) , 999999.0, 1000.0, 1) ; +// sampleFont[fidx]->setRenderReturnWidth(false); +// sampleFont[fidx]->setFTRaster(rasterState); +// logAscend[fidx] = 1000.0 - tmpScene.itemsBoundingRect().top(); +// logDescend[fidx] = tmpScene.itemsBoundingRect().bottom() - 1000.0; +// qDebug()<< sampleString[fidx] << logWidth[fidx]; +// QList lgit(tmpScene.items()); +// foreach(QGraphicsItem* git, lgit) +// { +// tmpScene.removeItem(git); +// delete git; +// } +// } +// double defWidth(0.8 * pScene.width() ); +// double defHeight(0.9 * pScene.height() ); +// double xOff( 0.1 * pScene.width() ); +// double yPos(0.1 * pScene.height() ); + +// QFont nameFont; +// nameFont.setPointSizeF(100.0); +// nameFont.setItalic(true); + +// for(int fidx(0); fidx < familyFonts.count(); ++fidx) +// { +// double scaleFactor(1000.0 / logWidth[fidx] ); +// double fSize( defWidth * scaleFactor ); +// double fAscend(logAscend[fidx] * fSize / 1000.0); +// double fDescend(logDescend[fidx] * fSize / 1000.0 ); +// if( yPos + fAscend + fDescend > defHeight) +// { +// pScene.render(&aPainter); +// thePrinter.newPage(); +// QList lgit(pScene.items()); +// foreach(QGraphicsItem* git, lgit) +// { +// pScene.removeItem(git); +// delete git; +// } +// yPos = 0.1 * pScene.height(); + +// } + +// yPos += fAscend; +// QPointF origine(xOff, yPos ); + +// qDebug()<< sampleString[fidx] << fSize; + +// bool rasterState(sampleFont[fidx]->rasterFreetype()); +// sampleFont[fidx]->setFTRaster(false); +// sampleFont[fidx]->renderLine(&pScene, sampleString[fidx], origine, pScene.width(), fSize, 100); +// pScene.addLine(QLineF(origine, QPointF(xOff + defWidth, yPos))); +// sampleFont[fidx]->setFTRaster(rasterState); + +// yPos += fDescend ; + +// QGraphicsSimpleTextItem * nameText = pScene.addSimpleText( familyFonts[fidx]->fancyName(), nameFont) ; +// nameText->setPos(xOff, yPos); +//// nameText->setBrush(Qt::gray); +// yPos += nameText->boundingRect().height(); +// } - // first we’ll get widths for font size 1000 - for(int fidx(0); fidx < familyFonts.count(); ++fidx) - { - sampleFont[fidx] = familyFonts[fidx]; - bool rasterState(sampleFont[fidx]->rasterFreetype()); - sampleFont[fidx]->setFTRaster(false); - sampleFont[fidx]->setRenderReturnWidth(true); - logWidth[fidx] = familyFonts[fidx]->renderLine(&tmpScene, sampleString[fidx], QPointF(0.0, 1000.0) , 999999.0, 1000.0, 1, false) ; - sampleFont[fidx]->setRenderReturnWidth(false); - sampleFont[fidx]->setFTRaster(rasterState); - logAscend[fidx] = 1000.0 - tmpScene.itemsBoundingRect().top(); - logDescend[fidx] = tmpScene.itemsBoundingRect().bottom() - 1000.0; - qDebug()<< sampleString[fidx] << logWidth[fidx]; - QList lgit(tmpScene.items()); - foreach(QGraphicsItem* git, lgit) - { - tmpScene.removeItem(git); - delete git; - } - } - double defWidth(0.8 * pScene.width() ); - double defHeight(0.9 * pScene.height() ); - double xOff( 0.1 * pScene.width() ); - double yPos(0.1 * pScene.height() ); - - QFont nameFont; - nameFont.setPointSizeF(100.0); - nameFont.setItalic(true); - - for(int fidx(0); fidx < familyFonts.count(); ++fidx) - { - double scaleFactor(1000.0 / logWidth[fidx] ); - double fSize( defWidth * scaleFactor ); - double fAscend(logAscend[fidx] * fSize / 1000.0); - double fDescend(logDescend[fidx] * fSize / 1000.0 ); - if( yPos + fAscend + fDescend > defHeight) - { - pScene.render(&aPainter); - thePrinter.newPage(); - QList lgit(pScene.items()); - foreach(QGraphicsItem* git, lgit) - { - pScene.removeItem(git); - delete git; - } - yPos = 0.1 * pScene.height(); - - } - - yPos += fAscend; - QPointF origine(xOff, yPos ); - - qDebug()<< sampleString[fidx] << fSize; - - bool rasterState(sampleFont[fidx]->rasterFreetype()); - sampleFont[fidx]->setFTRaster(false); - sampleFont[fidx]->renderLine(&pScene, sampleString[fidx], origine, pScene.width(), fSize, 100, false); - pScene.addLine(QLineF(origine, QPointF(xOff + defWidth, yPos))); - sampleFont[fidx]->setFTRaster(rasterState); - - yPos += fDescend ; - - QGraphicsSimpleTextItem * nameText = pScene.addSimpleText( familyFonts[fidx]->fancyName(), nameFont) ; - nameText->setPos(xOff, yPos); -// nameText->setBrush(Qt::gray); - yPos += nameText->boundingRect().height(); - } - - pScene.render(&aPainter); -} +// pScene.render(&aPainter); +//} void typotek::showEvent(QShowEvent * event) { @@ -2140,22 +1993,22 @@ return hyphenator; } -void typotek::slotSwitchLayOptVisible() -{ - if(FMLayout::getLayout()->optionDialog->isVisible()) - FMLayout::getLayout()->optionDialog->setVisible(false); - else - FMLayout::getLayout()->optionDialog->setVisible(true); - slotUpdateLayOptStatus(); -} - -void typotek::slotUpdateLayOptStatus() -{ - if(FMLayout::getLayout()->optionDialog->isVisible()) - layOptAct->setChecked(true); - else - layOptAct->setChecked(false); -} +//void typotek::slotSwitchLayOptVisible() +//{ +// if(FMLayout::getLayout()->optionDialog->isVisible()) +// FMLayout::getLayout()->optionDialog->setVisible(false); +// else +// FMLayout::getLayout()->optionDialog->setVisible(true); +// slotUpdateLayOptStatus(); +//} + +//void typotek::slotUpdateLayOptStatus() +//{ +// if(FMLayout::getLayout()->optionDialog->isVisible()) +// layOptAct->setChecked(true); +// else +// layOptAct->setChecked(false); +//} #ifdef HAVE_PYTHONQT void typotek::slotSwitchScriptConsole() @@ -2299,7 +2152,7 @@ { // qDebug()<< "Update Panose"<selectedFont()->path(); FMFontDb::DB()->setValue(theMainView->selectedFont()->path(), FMFontDb::Panose, dia.getTargetPanose()); - theMainView->slotInfoFont(); +// theMainView->slotInfoFont(); } } } @@ -2354,11 +2207,11 @@ { //! Number of fonts we failed to reload showStatusMessage(tr("Failed to reload %n fonts", "", toReload.count() - renewedFonts.count())); - theMainView->slotReloadFontList(); +// theMainView->slotReloadFontList(); } if(!cfName.isEmpty()) { - theMainView->forceReloadSelection(); +// theMainView->forceReloadSelection(); theMainView->slotFontSelectedByName(cfName); } @@ -2378,7 +2231,7 @@ if(cf) { cf->setTags(t); - theMainView->forceReloadSelection(); +// theMainView->forceReloadSelection(); theMainView->slotFontSelectedByName(curName); } } @@ -2448,12 +2301,14 @@ void typotek::showToltalFilteredFonts() { - countFilteredFonts->setText( tr( "Filtered Font(s): %n", "number of filtererd fonts showed in status bar", theMainView->curFonts().count() ) ); + countFilteredFonts->setText( tr( "Filtered Font(s): %n", "number of filtererd fonts showed in status bar", FMFontDb::DB()->countFilteredFonts() ) ); } void typotek::presentFontName(QString s) { - curFontPresentation->setText(tr("Current Font:", "followed by currently selected font name (in status bar)") +s); + curFontPresentation->setText(QString("%1 : %2") + .arg(tr("Current Font", "followed by currently selected font name (in status bar)")) + .arg(s)); } @@ -2499,6 +2354,15 @@ dockVisible[k] = dockWidget[k]->isVisible(); dockWidget[k]->hide(); } + visibleFloatingWidgets.clear(); + foreach(FloatingWidget* f, FloatingWidgetsRegister::AllWidgets()) + { + visibleFloatingWidgets[f] = f->isVisible(); + f->setVisible(false); + } + + playVisible = PlayWidget::getInstance()->isVisible(); + QMainWindow::hide(); } @@ -2508,6 +2372,13 @@ { dockWidget[k]->setVisible(dockVisible[k]); } + foreach(FloatingWidget *f, visibleFloatingWidgets.keys()) + { + f->setVisible(visibleFloatingWidgets[f]); + } + + PlayWidget::getInstance()->setVisible(playVisible); + QMainWindow::show(); } @@ -2516,11 +2387,13 @@ infoStyle = theValue; } -QString typotek::word(FontItem * item) +QString typotek::word(FontItem * item, const QString& alt) { if(item) { - QString word = m_theWord; + QString word(m_theWord); + if(!alt.isEmpty()) + word = alt; word.replace("", item->fancyName()); word.replace("", item->family()); word.replace("", item->variant()); @@ -2529,3 +2402,92 @@ return m_theWord; } + + +void typotek::updateFloatingStatus() +{ + playAction->setChecked( PlayWidget::getInstance()->isVisible() ); + compareAction->setChecked(FontCompareWidget::getInstance()->isVisible()); + + viewMenu->removeAction(closeAllFloat); + viewMenu->removeAction(showAllFloat); + viewMenu->removeAction(hideAllFloat); + viewMenu->removeAction(floatSep); + + QList fwl(FloatingWidgetsRegister::AllWidgets()); + foreach(FloatingWidget* f, floatingWidgets.keys()) + { + if(!fwl.contains(f)) + { + viewMenu->removeAction(floatingWidgets[f]); + floatingWidgets.remove(f); + } + } + + foreach(FloatingWidget* f, fwl) + { + if(floatingWidgets.contains(f)) + { + floatingWidgets[f]->setChecked(f->isVisible()); + } + else + { + QAction *wa(new QAction(f->getActionName(),this)); + wa->setCheckable(true); + connect(f, SIGNAL(visibilityChange()), this, SLOT(updateFloatingStatus())); + connect(wa, SIGNAL(triggered(bool)), f, SLOT(activate(bool))); + floatingWidgets.insert(f, wa); + floatingWidgets[f]->setChecked(f->isVisible()); + viewMenu->addAction(wa); + } + } + if(floatingWidgets.count() > 0) + { + viewMenu->addAction(floatSep); + viewMenu->addAction(closeAllFloat); + } + if(floatingWidgets.count() > 1) + { + viewMenu->addAction(showAllFloat); + viewMenu->addAction(hideAllFloat); + } +} + + +void typotek::closeAllFloatings() +{ + foreach(FloatingWidget* f, floatingWidgets.keys()) + { + f->close(); + } +} + +void typotek::showAllFloatings() +{ + foreach(FloatingWidget* f, floatingWidgets.keys()) + { + f->setVisible(true); + } +} + +void typotek::hideAllFloatings() +{ + foreach(FloatingWidget* f, floatingWidgets.keys()) + { + f->setVisible(false); + } +} + + +void typotek::toggleMainView(bool v) +{ + if(v) + mainStack->setCurrentWidget(theBrowser); + else + mainStack->setCurrentWidget(theMainView); +} + +void typotek::pushObject(QObject *o) +{ + o->moveToThread(sender()->thread()); +} diff -Nru fontmatrix-0.6.0+svn20100107/src/typotek.h fontmatrix-0.6.0+svn20110930/src/typotek.h --- fontmatrix-0.6.0+svn20100107/src/typotek.h 2009-08-14 15:07:30.000000000 +0000 +++ fontmatrix-0.6.0+svn20110930/src/typotek.h 2011-02-08 14:43:38.000000000 +0000 @@ -38,6 +38,7 @@ class QMenu; class QTextEdit; class MainViewWidget; +class BrowserWidget; class FontItem; // class TypotekAdaptator; class QDockWidget; @@ -48,6 +49,8 @@ // class HelpWidget; class HelpBrowser; class DataLoader; +class FloatingWidget; +class QStackedWidget; class typotek:public QMainWindow { @@ -67,12 +70,6 @@ void keyPressEvent ( QKeyEvent * event ) ; private slots: - void printInfo(); - void printSample(); - void printChart(); - void printPlayground(); - void printFamily(); - void fontBook(); void slotActivateCurrents(); void slotDeactivateCurrents(); @@ -85,8 +82,8 @@ void slotRepair(); void slotTagAll(); void slotDockAreaChanged(Qt::DockWidgetArea area); - void slotSwitchLayOptVisible(); - void slotUpdateLayOptStatus(); +// void slotSwitchLayOptVisible(); +// void slotUpdateLayOptStatus(); void slotShowTTTables(); void slotEditPanose(); void slotDumpInfo(); @@ -103,9 +100,9 @@ void slotMatchRaster(); public slots: - void open( QString path = QString(), bool announce = true, bool collect = false ); + void open( QString path = QString(), bool recursive = true, bool announce = true, bool collect = false ); + void importFiles(); void openList( QStringList files ); - bool save(); void slotCloseToSystray(bool isEnabled); void slotSystrayStart(bool isEnabled); void slotUseInitialTags(bool isEnabled); @@ -115,14 +112,20 @@ void slotPrefsPanel(PrefsPanelDialog::PAGE page); void relayStartingStepIn(QString s); void showToltalFilteredFonts(); + void updateFloatingStatus(); + void closeAllFloatings(); + void showAllFloatings(); + void hideAllFloatings(); + void toggleMainView(bool v); + void pushObject(QObject* o); void hide(); void show(); signals: - void tagAdded(QString); void relayStartingStepOut(QString, int, QColor); void previewHasChanged(); + void newFontsArrived(); private: void installDock(const QString& id, const QString& name, QWidget *w, const QString& tip=QString() ); @@ -146,7 +149,6 @@ QMenu *fileMenu; QMenu *editMenu; QMenu *servicesMenu; - QMenu *browseMenu; QMenu *viewMenu; #ifdef HAVE_PYTHONQT QMenu *scriptMenu; @@ -156,8 +158,7 @@ QToolBar *editToolBar; QAction *newAct; QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; + QAction *importFilesAction; QAction *exitAct; QAction *cutAct; QAction *copyAct; @@ -189,26 +190,23 @@ QAction *extractFontAction; QAction *matchRasterAct; - QAction *nextFamily; - QAction *previousFamily; - QAction *nextFont; - QAction *previousFont; - - QMenu *printMenu; - QAction *printInfoAct; - QAction *printSampleAct; - QAction *printChartAct; - QAction *printPlaygroundAct; - QAction *printFamilyAct; + QAction *playAction; + QAction *compareAction; + QAction *closeAllFloat; + QAction *showAllFloat; + QAction *hideAllFloat; + QAction *floatSep; // HelpWidget *theHelp; HelpBrowser *theHelp; - QAction *layOptAct; +// QAction *layOptAct; QProgressBar *statusProgressBar; + QStackedWidget * mainStack; MainViewWidget *theMainView; + BrowserWidget * theBrowser; QFile ResourceFile; QDir ownDir; @@ -274,12 +272,20 @@ double m_dpiX; double m_dpiY; + QMap floatingWidgets; + QMap visibleFloatingWidgets; + bool playVisible; + + QString currentNamedSample; + + QToolButton * toggleMainViewButton; + public: bool isSysFont(FontItem* f); - QList getCurrentFonts(); FontItem* getSelectedFont(); void resetFilter(); + QString getManagedDir(){return managedDir.absolutePath();} QFile* getResourceFile(){ return &ResourceFile; } @@ -299,7 +305,7 @@ void systrayTagsConfirmation(bool); // Samples - QString namedSample(QString name); + QString namedSample(QString name = QString()); QMap > namedSamplesNames(); void addNamedSample(QString name, QString sample); void removeNamedSample(const QString& key); @@ -315,7 +321,7 @@ QString getTemplatesDir() {return templatesDir;} void setWord(QString s, bool updateView); - QString word(FontItem * item = 0); + QString word(FontItem * item = 0, const QString& alt = QString()); void setPreviewSize(double d); double getPreviewSize(){ return previewSize; } void setPreviewRTL(bool d);