]> git.donarmstrong.com Git - xournal.git/commitdiff
Print via gtk-print instead of libgnomeprint
authorauroux <auroux>
Wed, 16 Sep 2009 20:26:03 +0000 (20:26 +0000)
committerauroux <auroux>
Wed, 16 Sep 2009 20:26:03 +0000 (20:26 +0000)
configure.in
src/Makefile.am
src/TODO
src/sft.h [deleted file]
src/xo-callbacks.c
src/xo-file.c
src/xo-misc.c
src/xo-misc.h
src/xo-print.c
src/xo-print.h
src/xournal.h

index a83f7d3c8316cd5afbc2806514e650b478436b95..bfef4b42dce9f0599ccce36d6587e0fec37fbb5b 100644 (file)
@@ -1,16 +1,17 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT(configure.in)
-AM_INIT_AUTOMAKE(xournal, 0.4.2.9)
+AM_INIT_AUTOMAKE(xournal, 0.4.3)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 
 AC_ISC_POSIX
 AC_PROG_CC
 AM_PROG_CC_STDC
+AC_PROG_RANLIB
 AC_HEADER_STDC
 
-pkg_modules="gtk+-2.0 >= 2.4.0 libgnomecanvas-2.0 >= 2.4.0 libgnomeprintui-2.2 >= 2.0.0 poppler-glib >= 0.6.1"
+pkg_modules="gtk+-2.0 >= 2.10.0 libgnomecanvas-2.0 >= 2.4.0 poppler-glib >= 0.6.1"
 PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
 AC_SUBST(PACKAGE_CFLAGS)
 AC_SUBST(PACKAGE_LIBS)
@@ -26,6 +27,7 @@ AM_GLIB_GNU_GETTEXT
 AC_OUTPUT([
 Makefile
 src/Makefile
+src/ttsubset/Makefile
 po/Makefile.in
 ])
 
index 2fd92b53195af9d87c008dfecf9baafa4fa42b34..aef9a77ad7ebd3ce3734145293816c8f899306db 100644 (file)
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+SUBDIRS = ttsubset
+
 INCLUDES = \
        -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
        -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
@@ -18,5 +20,5 @@ xournal_SOURCES = \
        xo-callbacks.c xo-callbacks.h \
        xo-shapes.c xo-shapes.h
 
-xournal_LDADD = @PACKAGE_LIBS@ $(INTLLIBS)
+xournal_LDADD = ttsubset/libttsubset.a @PACKAGE_LIBS@ $(INTLLIBS)
 
index 594cf493a01ffaeec9db0466957a099f8f0a0fe7..4468be7ea378efd3519e0fb73443409077b5d080 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -33,20 +33,25 @@ DONE: use poppler to render PDF backgrounds (after patches contributed
       by Mike Ter Louw and Bob McElrath)
 DONE: gettext internationalization (contributed by David Planella)
 DONE: Catalan translation (by David Planella); French translation
+DONE: fix unresponsiveness to button events in text edition box (GTK+ 2.17)
+      and segfaults when dragging text or using Layers combobox (GTK+ 2.17)
+DONE: Esc leaves text box if editing; and leaves fullscreen mode
+DONE: package our own copy of the ttsubset library (to remove a dependency
+      on libgnomeprint), and create TT subfonts in memory
+DONE: use gtk-print instead of libgnomeprint
 
-****** URGENT: gtkprint; new release by November end for Debian!
-  nb: libgnomeprint produces many warnings (spinbutton; gpa assertions)
-  nb: gtkprint includes sft.c or not?? see font generation...
+** update: include ttsubset/(Makefile.am, *.c, *.h, README) in cvs
+           also revised configure.in, src/Makefile.am
+           remove src/sft.h
 
-- get GTK+ 2.17 events while editing text to work.
 - prerelease: update help file (remove references to pdftoppm/libgnomeprint
-  to poppler/gtkprint
+  & update to poppler/gtkprint)
 - remove "antialias bg" flag, useless... see McElrath
 - PDF bg memory usage throttling / delete oldest pdf backgrounds
+- replace ttsubset by something more modern? (eg. from cairo ?)
 - fix fix_xinput_coords so it works ok without ENABLE_XINPUT_BUGFIX ?
    (with both old and new GTK+)
   (need to shift by (sx,sy), + shift between canvas->window vs canvas in 2.17)
-- Esc should leave text box if editing; and fullscreen if fullscreen?
 - color chooser button (patch tracker?)
 - option to have buttons *toggle* the tool rather than act as tool
    (ie button 2 causes button 1 to map to tool 2) [Dylan Thurston]
@@ -97,6 +102,8 @@ DONE: Catalan translation (by David Planella); French translation
 - navigation sidebar with bitmap page previews
 - bitmap preview for document icon in desktop environments?
 - "organizer" side panel (hierarchy of notes), cf. gjots
+- see iRex code for generic viewer + PDF plugin including caching,
+  throttling etc. (Marcel Hendrickx email of Sep 11 '09) 
 
 - allow toolbar to go vertical
 - toolbar buttons should react to button 2/3 click to modify settings
diff --git a/src/sft.h b/src/sft.h
deleted file mode 100644 (file)
index bcb3d90..0000000
--- a/src/sft.h
+++ /dev/null
@@ -1,678 +0,0 @@
-/* modified from sft.h in libgnomeprint */
-
-/*
- * Copyright © 2002, 2003 Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of Sun Microsystems, Inc. nor the names of 
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind.
- *
- * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
- * SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES OR
- * LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR RELATING TO USE,
- * MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS DERIVATIVES.
- * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
- * PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
- * THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
- * SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-/* $Id$ */
-
-/* @(#)sft.h 1.17 03/01/08 SMI */
-
-/*
- * @file sft.h
- * @brief Sun Font Tools
- * @author Alexander Gelfenbain <adg@sun.com>
- * @version 1.0
- */
-
-/*
- *        Generated fonts contain an XUID entry in the form of:
- *
- *                  103 0 T C1 N C2 C3
- *
- *        103 - Sun's Adobe assigned XUID number. Contact person: Alexander Gelfenbain <gelf@eng.sun.com>
- *
- *        T  - font type. 0: Type 3, 1: Type 42
- *        C1 - CRC-32 of the entire source TrueType font
- *        N  - number of glyphs in the subset
- *        C2 - CRC-32 of the array of glyph IDs used to generate the subset
- *        C3 - CRC-32 of the array of encoding numbers used to generate the subset
- *
- */
-
-#ifndef __SUBFONT_H
-#define __SUBFONT_H
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#define false 0               /**< standard false value */
-#define true  1               /**< standard true value */
-
-/* glib already deals with different compilers */
-#include <glibconfig.h>
-
-/*@{*/
-    typedef gint16       F2Dot14;            /**< fixed: 2.14 */
-    typedef gint32       F16Dot16;           /**< fixed: 16.16 */
-/*@}*/
-
-    typedef struct {
-        guint16 s;
-        guint16 d;
-    } uint16pair;
-
-/** Return value of OpenTTFont() and CreateT3FromTTGlyphs() */
-    enum SFErrCodes {
-        SF_OK,                              /**< no error                                     */
-        SF_BADFILE,                         /**< file not found                               */
-        SF_FILEIO,                          /**< file I/O error                               */
-        SF_MEMORY,                          /**< memory allocation error                      */
-        SF_GLYPHNUM,                        /**< incorrect number of glyphs                   */
-        SF_BADARG,                          /**< incorrect arguments                          */
-        SF_TTFORMAT,                        /**< incorrect TrueType font format               */
-        SF_TABLEFORMAT,                     /**< incorrect format of a TrueType table         */
-        SF_FONTNO                           /**< incorrect logical font number of a TTC font  */
-    };
-
-#ifndef FW_THIN /* WIN32 compilation would conflict */
-/** Value of the weight member of the TTGlobalFontInfo struct */
-    enum WeightClass {
-        FW_THIN = 100,                      /**< Thin                               */
-        FW_EXTRALIGHT = 200,                /**< Extra-light (Ultra-light)          */
-        FW_LIGHT = 300,                     /**< Light                              */
-        FW_NORMAL = 400,                    /**< Normal (Regular)                   */
-        FW_MEDIUM = 500,                    /**< Medium                             */
-        FW_SEMIBOLD = 600,                  /**< Semi-bold (Demi-bold)              */
-        FW_BOLD = 700,                      /**< Bold                               */
-        FW_EXTRABOLD = 800,                 /**< Extra-bold (Ultra-bold)            */
-        FW_BLACK = 900                      /**< Black (Heavy)                      */
-    };
-
-/** Value of the width member of the TTGlobalFontInfo struct */
-    enum WidthClass {
-        FWIDTH_ULTRA_CONDENSED = 1,         /**< 50% of normal                      */
-        FWIDTH_EXTRA_CONDENSED = 2,         /**< 62.5% of normal                    */
-        FWIDTH_CONDENSED = 3,               /**< 75% of normal                      */
-        FWIDTH_SEMI_CONDENSED = 4,          /**< 87.5% of normal                    */
-        FWIDTH_NORMAL = 5,                  /**< Medium, 100%                       */
-        FWIDTH_SEMI_EXPANDED = 6,           /**< 112.5% of normal                   */
-        FWIDTH_EXPANDED = 7,                /**< 125% of normal                     */
-        FWIDTH_EXTRA_EXPANDED = 8,          /**< 150% of normal                     */
-        FWIDTH_ULTRA_EXPANDED = 9           /**< 200% of normal                     */
-    };
-#endif /* FW_THIN */
-
-/** Type of the 'kern' table, stored in _TrueTypeFont::kerntype */
-    enum KernType {
-
-        KT_NONE         = 0,                /**< no kern table                      */
-        KT_APPLE_NEW    = 1,                /**< new Apple kern table               */
-        KT_MICROSOFT    = 2                 /**< Microsoft table                    */
-    };
-
-/* Composite glyph flags definition */
-    enum CompositeFlags {
-        ARG_1_AND_2_ARE_WORDS     = 1,
-        ARGS_ARE_XY_VALUES        = 1<<1,
-        ROUND_XY_TO_GRID          = 1<<2,
-        WE_HAVE_A_SCALE           = 1<<3,
-        MORE_COMPONENTS           = 1<<5,
-        WE_HAVE_AN_X_AND_Y_SCALE  = 1<<6,
-        WE_HAVE_A_TWO_BY_TWO      = 1<<7,
-        WE_HAVE_INSTRUCTIONS      = 1<<8,
-        USE_MY_METRICS            = 1<<9,
-        OVERLAP_COMPOUND          = 1<<10
-    };
-
-/** Flags for TrueType generation */
-    enum TTCreationFlags {
-        TTCF_AutoName = 1,                  /**< Automatically generate a compact 'name' table.
-                                               If this flag is not set, name table is generated
-                                               either from an array of NameRecord structs passed as
-                                               arguments or if the array is NULL, 'name' table
-                                               of the generated TrueType file will be a copy
-                                               of the name table of the original file.
-                                               If this flag is set the array of NameRecord structs
-                                               is ignored and a very compact 'name' table is automatically
-                                               generated. */
-
-        TTCF_IncludeOS2 = 2                 /** If this flag is set OS/2 table from the original font will be
-                                                copied to the subset */
-    };
-
-    /** Structure used by GetTTGlyphMetrics() */
-    /*- In horisontal writing mode right sidebearing is calculated using this formula
-     *- rsb = aw - (lsb + xMax - xMin) -*/
-     typedef struct {
-         gint16  xMin;
-         gint16  yMin;
-         gint16  xMax;
-         gint16  yMax;
-         guint16 aw;                /*- Advance Width (horisontal writing mode)    */
-         gint16  lsb;               /*- Left sidebearing (horisontal writing mode) */
-         guint16 ah;                /*- advance height (vertical writing mode)     */
-         gint16  tsb;               /*- top sidebearing (vertical writing mode)    */
-     } TTGlyphMetrics;
-
-
-    /** Structure used by GetTTSimpleGlyphMetrics() and GetTTSimpleCharMetrics() functions */
-    typedef struct {
-        guint16 adv;                         /**< advance width or height            */
-        gint16 sb;                           /**< left or top sidebearing            */
-    } TTSimpleGlyphMetrics;
-
-    /** Structure returned by ReadGlyphMetrics() */
-    typedef struct {
-        guint16 aw, ah;
-        gint16 lsb, tsb;
-    } TTFullSimpleGlyphMetrics;
-
-
-/** Structure used by the TrueType Creator and GetRawGlyphData() */
-
-    typedef struct {
-        guint32 glyphID;                     /**< glyph ID                           */
-        guint16 nbytes;                      /**< number of bytes in glyph data      */
-        guint8  *ptr;                         /**< pointer to glyph data              */
-        guint16 aw;                          /**< advance width                      */
-        gint16  lsb;                         /**< left sidebearing                   */
-        guint16 compflag;                    /**< 0- if non-composite, 1- otherwise  */
-        guint16 npoints;                     /**< number of points                   */
-        guint16 ncontours;                   /**< number of contours                 */
-        /* */
-        guint32 newID;                       /**< used internally by the TTCR        */
-    } GlyphData;
-
-
-    /* STSF defines NameRecord and FUnitBBox structures in its own include file sttypes.h */
-
-    typedef struct {
-        gint16 xMin;
-        gint16 yMin;
-        gint16 xMax;
-        gint16 yMax;
-    } FUnitBBox;
-
-/** Structure used by the TrueType Creator and CreateTTFromTTGlyphs() */
-    typedef struct {
-        guint16 platformID;                  /**< Platform ID                                            */
-        guint16 encodingID;                  /**< Platform-specific encoding ID                          */
-        guint16 languageID;                  /**< Language ID                                            */
-        guint16 nameID;                      /**< Name ID                                                */
-        guint16 slen;                        /**< String length in bytes                                 */
-        guint8  *sptr;                        /**< Pointer to string data (not zero-terminated!)          */
-    } NameRecord;
-
-
-/** Return value of GetTTGlobalFontInfo() */
-
-    typedef struct {
-        char *family;             /**< family name                                             */
-        guint16 *ufamily;                /**< family name UCS2                                         */
-        char *subfamily;          /**< subfamily name                                          */
-        char *psname;             /**< PostScript name                                         */
-        int   weight;             /**< value of WeightClass or 0 if can't be determined        */
-        int   width;              /**< value of WidthClass or 0 if can't be determined         */
-        int   pitch;              /**< 0: proportianal font, otherwise: monospaced             */
-        int   italicAngle;        /**< in counter-clockwise degrees * 65536                    */
-        guint16 fsSelection;       /**< fsSelection field of OS/2 table                         */
-        int   xMin;               /**< global bounding box: xMin                               */
-        int   yMin;               /**< global bounding box: yMin                               */
-        int   xMax;               /**< global bounding box: xMax                               */
-        int   yMax;               /**< global bounding box: yMax                               */
-        int   ascender;           /**< typographic ascent.                                     */
-        int   descender;          /**< typographic descent.                                    */
-        int   linegap;            /**< typographic line gap.\ Negative values are treated as
-                                     zero in Win 3.1, System 6 and System 7.                 */
-        int   vascent;            /**< typographic ascent for vertical writing mode            */
-        int   vdescent;           /**< typographic descent for vertical writing mode           */
-        int   typoAscender;       /**< OS/2 portable typographic ascender                      */
-        int   typoDescender;      /**< OS/2 portable typographic descender                     */
-        int   typoLineGap;        /**< OS/2 portable typographc line gap                       */
-        int   winAscent;          /**< ascender metric for Windows                             */
-        int   winDescent;         /**< descender metric for Windows                            */
-        int   symbolEncoded;      /**< 1: MS symbol encoded 0: not symbol encoded              */
-        int   rangeFlag;          /**< if set to 1 Unicode Range flags are applicable          */
-        guint32 ur1;               /**< bits 0 - 31 of Unicode Range flags                      */
-        guint32 ur2;               /**< bits 32 - 63 of Unicode Range flags                     */
-        guint32 ur3;               /**< bits 64 - 95 of Unicode Range flags                     */
-        guint32 ur4;               /**< bits 96 - 127 of Unicode Range flags                    */
-        guint8   panose[10];        /**< PANOSE classification number                            */
-        guint16 typeFlags;               /**< type flags (copyright information)                      */
-    } TTGlobalFontInfo;
-
-/** Structure used by KernGlyphs()      */
-    typedef struct {
-        int x;                    /**< positive: right, negative: left                        */
-        int y;                    /**< positive: up, negative: down                           */
-    } KernData;
-
-
-/** ControlPoint structure used by GetTTGlyphPoints() */
-    typedef struct {
-        guint32 flags;             /**< 00000000 00000000 e0000000 bbbbbbbb */
-        /**< b - guint8 flags from the glyf array  */
-        /**< e == 0 - regular point              */
-        /**< e == 1 - end contour                */
-        gint16 x;                  /**< X coordinate in EmSquare units      */
-        gint16 y;                  /**< Y coordinate in EmSquare units      */
-    } ControlPoint;
-
-    typedef struct _TrueTypeFont TrueTypeFont;
-
-/*
- * @defgroup sft Sun Font Tools Exported Functions
- */
-
-
-/*
- * Get the number of fonts contained in a TrueType collection
- * @param  fname - file name
- * @return number of fonts or zero, if file is not a TTC file.
- * @ingroup sft
- */
-    int CountTTCFonts(const char* fname);
-
-
-/*
- * TrueTypeFont constructor. 
- * Reads the font file and allocates the memory for the structure.
- * @param  facenum - logical font number within a TTC file. This value is ignored
- *                   for TrueType fonts
- * @return value of SFErrCodes enum
- * @ingroup sft
- */
-    int  OpenTTFont(const char *fname, guint32 facenum, TrueTypeFont**);
-
-/*
- * TrueTypeFont destructor. Deallocates the memory.
- * @ingroup sft
- */
-    void CloseTTFont(TrueTypeFont *);
-
-/*
- * Extracts TrueType control points, and stores them in an allocated array pointed to
- * by *pointArray. This function returns the number of extracted points.
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param glyphID     Glyph ID
- * @param pointArray  Return value - address of the pointer to the first element of the array
- *                    of points allocated by the function
- * @return            Returns the number of points in *pointArray or -1 if glyphID is
- *                    invalid.
- * @ingroup sft
- *
- */
-int GetTTGlyphPoints(TrueTypeFont *ttf, guint32 glyphID, ControlPoint **pointArray);
-
-/*
- * Extracts bounding boxes in normalized FUnits (1000/em) for all glyphs in the
- * font and allocates an array of FUnitBBox structures. There are ttf->nglyphs
- * elements in the array.
- *
- * @param ttf     pointer to the TrueTypeFont structure
- *
- * @return        an array of FUnitBBox structures with values normalized to 1000 UPEm
- *
- * @ingroup sft
- */
-FUnitBBox *GetTTGlyphBoundingBoxes(TrueTypeFont *ttf);
-
-/*
- * Extracts raw glyph data from the 'glyf' table and returns it in an allocated
- * GlyphData structure.
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param glyphID     Glyph ID
- *
- * @return            pointer to an allocated GlyphData structure or NULL if
- *                    glyphID is not present in the font
- * @ingroup sft
- *
- */
-    GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, guint32 glyphID);
-
-/*
- * Extracts all Name Records from the font and stores them in an allocated
- * array of NameRecord structs
- *
- * @param ttf       pointer to the TrueTypeFont struct
- * @param nr        pointer to the array of NameRecord structs
- *
- * @return          number of NameRecord structs
- * @ingroup sft
- */
-
-    int GetTTNameRecords(TrueTypeFont *ttf, NameRecord **nr);
-
-/*
- * Deallocates previously allocated array of NameRecords.
- *
- * @param nr        array of NameRecord structs
- * @param n         number of elements in the array
- *
- * @ingroup sft
- */
-    void DisposeNameRecords(NameRecord* nr, int n);
-
-
-#ifndef NO_TYPE3
-/*
- * Generates a new PostScript Type 3 font and dumps it to <b>outf</b> file.
- * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
- * @param ttf         pointer to the TrueTypeFont structure
- * @param outf        the resulting font is written to this stream
- * @param fname       font name for the new font. If it is NULL the PostScript name of the
- *                    original font will be used
- * @param glyphArray  pointer to an array of glyphs that are to be extracted from ttf
- * @param encoding    array of encoding values. encoding[i] specifies the position of the glyph
- *                    glyphArray[i] in the encoding vector of the resulting Type3 font
- * @param nGlyphs     number of glyph IDs in glyphArray and encoding values in encoding
- * @param wmode       writing mode for the output file: 0 - horizontal, 1 - vertical
- * @return            return the value of SFErrCodes enum
- * @see               SFErrCodes
- * @ingroup sft
- *
- */
-    int  CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, guint16 *glyphArray, guint8 *encoding, int nGlyphs, int wmode);
-#endif
-
-#ifndef NO_TTCR
-/*
- * Generates a new TrueType font and dumps it to <b>outf</b> file.
- * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
- * @param ttf         pointer to the TrueTypeFont structure
- * @param fname       file name for the output TrueType font file
- * @param glyphArray  pointer to an array of glyphs that are to be extracted from ttf. The first
- *                    element of this array has to be glyph 0 (default glyph)
- * @param encoding    array of encoding values. encoding[i] specifies character code for
- *                    the glyphID glyphArray[i]. Character code 0 usually points to a default
- *                    glyph (glyphID 0)
- * @param nGlyphs     number of glyph IDs in glyphArray and encoding values in encoding
- * @param nNameRecs   number of NameRecords for the font, if 0 the name table from the
- *                    original font will be used
- * @param nr          array of NameRecords
- * @param flags       or'ed TTCreationFlags
- * @return            return the value of SFErrCodes enum
- * @see               SFErrCodes
- * @ingroup sft
- *
- */
-    int  CreateTTFromTTGlyphs(TrueTypeFont  *ttf,
-                              const char    *fname,
-                              guint16        *glyphArray,
-                              guint8          *encoding,
-                              int            nGlyphs,
-                              int            nNameRecs,
-                              NameRecord    *nr,
-                              guint32        flags);
-#endif
-
-#ifndef NO_TYPE42
-/*
- * Generates a new PostScript Type42 font and dumps it to <b>outf</b> file.
- * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
- * @param ttf         pointer to the TrueTypeFont structure
- * @param outf        output stream for a resulting font
- * @param psname      PostScript name of the resulting font
- * @param glyphArray  pointer to an array of glyphs that are to be extracted from ttf. The first
- *                    element of this array has to be glyph 0 (default glyph)
- * @param encoding    array of encoding values. encoding[i] specifies character code for
- *                    the glyphID glyphArray[i]. Character code 0 usually points to a default
- *                    glyph (glyphID 0)
- * @param nGlyphs     number of glyph IDs in glyphArray and encoding values in encoding
- * @return            SF_OK - no errors
- *                    SF_GLYPHNUM - too many glyphs (> 255)
- *                    SF_TTFORMAT - corrupted TrueType fonts
- *
- * @see               SFErrCodes
- * @ingroup sft
- *
- */
-    int  CreateT42FromTTGlyphs(TrueTypeFont  *ttf,
-                               FILE          *outf,
-                               const char    *psname,
-                               guint16        *glyphArray,
-                               guint8          *encoding,
-                               int            nGlyphs);
-#endif
-
-/*
- * Queries full glyph metrics for one glyph
- */
-void GetTTGlyphMetrics(TrueTypeFont *ttf, guint32 glyphID, TTGlyphMetrics *metrics);
-
-
-/*
- * Queries glyph metrics. Allocates an array of TTSimpleGlyphMetrics structs and returns it.
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param glyphArray  pointer to an array of glyphs that are to be extracted from ttf
- * @param nGlyphs     number of glyph IDs in glyphArray and encoding values in encoding
- * @param mode        writing mode: 0 - horizontal, 1 - vertical
- * @ingroup sft
- *
- */
-TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, guint16 *glyphArray, int nGlyphs, int mode);
-
-#ifndef NO_MAPPERS
-/*
- * Queries character metrics. Allocates an array of TTSimpleGlyphMetrics structs and returns it.
- * This function behaves just like GetTTSimpleGlyphMetrics() but it takes a range of Unicode
- * characters instead of an array of glyphs.
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param firstChar   Unicode value of the first character in the range
- * @param nChars      number of Unicode characters in the range
- * @param mode        writing mode: 0 - horizontal, 1 - vertical
- *
- * @see GetTTSimpleGlyphMetrics
- * @ingroup sft
- *
- */
-    TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont *ttf, guint16 firstChar, int nChars, int mode);
-
-/*
- * Maps a Unicode (UCS-2) string to a glyph array. Returns the number of glyphs in the array,
- * which for TrueType fonts is always the same as the number of input characters.
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param str         pointer to a UCS-2 string
- * @param nchars      number of characters in <b>str</b>
- * @param glyphArray  pointer to the glyph array where glyph IDs are to be recorded.
- *
- * @return MapString() returns -1 if the TrueType font has no usable 'cmap' tables.
- *         Otherwise it returns the number of characters processed: <b>nChars</b>
- *
- * glyphIDs of TrueType fonts are 2 guint8 positive numbers. glyphID of 0 denotes a missing
- * glyph and traditionally defaults to an empty square.
- * glyphArray should be at least sizeof(guint16) * nchars bytes long. If glyphArray is NULL
- * MapString() replaces the UCS-2 characters in str with glyphIDs.
- * @ingroup sft
- */
-#ifdef USE_GSUB
-    int MapString(TrueTypeFont *ttf, guint16 *str, int nchars, guint16 *glyphArray, int bvertical);
-#else
-    int MapString(TrueTypeFont *ttf, guint16 *str, int nchars, guint16 *glyphArray);
-#endif
-
-/*
- * Maps a Unicode (UCS-2) character to a glyph ID and returns it. Missing glyph has
- * a glyphID of 0 so this function can be used to test if a character is encoded in the font.
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param ch          Unicode (UCS-2) character
- * @return glyph ID, if the character is missing in the font, the return value is 0.
- * @ingroup sft
- */
-#ifdef USE_GSUB
-    guint16 MapChar(TrueTypeFont *ttf, guint16 ch, int bvertical);
-#else
-    guint16 MapChar(TrueTypeFont *ttf, guint16 ch);
-#endif
-#endif
-
-/*
- * Returns global font information about the TrueType font.
- * @see TTGlobalFontInfo
- *
- * @param ttf         pointer to a TrueTypeFont structure
- * @param info        pointer to a TTGlobalFontInfo structure
- * @ingroup sft
- *
- */
-    void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info);
-
-/*
- * Returns kerning information for an array of glyphs.
- * Kerning is not cumulative.
- * kern[i] contains kerning information for a pair of glyphs at positions i and i+1
- *
- * @param ttf         pointer to a TrueTypeFont structure
- * @param glyphs      array of source glyphs
- * @param nglyphs     number of glyphs in the array
- * @param wmode       writing mode: 0 - horizontal, 1 - vertical
- * @param kern        array of KernData structures. It should contain nglyphs-1 elements
- * @see KernData
- * @ingroup sft
- *
- */
-void KernGlyphs(TrueTypeFont *ttf, guint16 *glyphs, int nglyphs, int wmode, KernData *kern);
-
-/*
- * Returns nonzero if font is a symbol encoded font
- */
-int CheckSymbolEncoding(TrueTypeFont* ttf);
-
-/*
- * Extracts a 'cmap' table from a font, allocates memory for it and returns a pointer to it.
- * DEPRECATED - use ExtractTable instead
- */
-#if 0
-guint8 *ExtractCmap(TrueTypeFont *ttf);
-#endif
-
-/*
- * Extracts a table from a font, allocates memort for it and returns a pointer to it.
- */
-guint8 *ExtractTable(TrueTypeFont *ttf, guint32 tag);
-
-/*
- * Returns a pointer to the table but does not allocate memory for it.
- */
-const guint8 *GetTable(TrueTypeFont *ttf, guint32 tag);
-
-/*
- * Functions that do not use TrueTypeFont structure
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-/*
- * Reads full (vertical and horisontal) glyph metrics for an array of glyphs from hmtx and vmtx tables
- *
- * @param hmtx       TrueType hmtx table
- * @param vmtx       TrueType vmtx table
- * @param hcount     numberOfHMetrics value
- * @param vcount     numOfLongVerMetrics value
- * @param gcount     total number of glyphs in the font
- * @param UPEm       units per Em value
- * @param glyphArray array of source glyph IDs
- * @param nGlyphs    number of glyphs in the glyphArray array
- *
- * @return           array of TTFullSimpleGlyphMetrics data structures
- *
- */
-
-TTFullSimpleGlyphMetrics *ReadGlyphMetrics(guint8 *hmtx, guint8 *vmtx, int hcount, int vcount, int gcount, int UPEm, guint16 *glyphArray, int nGlyphs);
-
-void ReadSingleGlyphMetrics(guint8 *hmtx, guint8 *vmtx, int hcount, int vcount, int gcount, int UPEm, guint16 glyphID, TTFullSimpleGlyphMetrics *metrics);
-
-
-/*
- * Returns the length of the 'kern' subtable
- *
- * @param kern       pointer to the 'kern' subtable
- *
- * @return           number of bytes in it
- */
-guint32 GetKernSubtableLength(guint8 *kern);
-
-/*
- *  Kerns a pair of glyphs.
- *
- * @param kerntype   type of the kern table
- * @param nkern      number of kern subtables
- * @param kern       array of pointers to kern subtables
- * @pram unitsPerEm  units per Em value
- * @param wmode      writing mode: 0 - horizontal, 1 - vertical
- * @param a          ID of the first glyoh
- * @param b          ID of the second glyoh
- * @param x          X-axis kerning value is returned here
- * @param y          Y-axis kerning value is returned here
- */
-void KernGlyphPair(int kerntype, guint32 nkern, guint8 **kern, int unitsPerEm, int wmode, guint32 a, guint32 b, int *x, int *y);
-
-
-
-/*- private definitions */ /*FOLD00*/
-
-struct _TrueTypeFont {
-    guint32 tag;
-
-    char   *fname;
-    off_t  fsize;
-    guint8   *ptr;
-
-    char   *psname;
-    char   *family;
-    guint16  *ufamily;
-    char   *subfamily;
-
-    guint32 ntables;
-    guint32 tdoffset;                              /* offset to the table directory (!= 0 for TrueType collections)      */
-    guint32 *goffsets;
-    int    nglyphs;
-    int    unitsPerEm;
-    int    numberOfHMetrics;
-    int    numOfLongVerMetrics;                   /* if this number is not 0, font has vertical metrics information */
-    guint8   *cmap;
-    int    cmapType;
-    guint16 (*mapper)(const guint8 *, guint16);       /* character to glyphID translation function                          */
-    void   **tables;                              /* array of pointers to tables                                        */
-    guint32 *tlens;                                /* array of table lengths                                             */
-    int    kerntype;                              /* Defined in the KernType enum                                       */
-    guint32 nkern;                                 /* number of kern subtables                                           */
-    guint8   **kerntables;                          /* array of pointers to kern subtables                                */
-#ifdef USE_GSUB
-    void   *pGSubstitution;                       /* info provided by GSUB for UseGSUB()                                */
-#endif
-#if 0
-    GnomePrintBuffer gp_buf;
-#endif
-};
-
-#endif /* __SUBFONT_H */
index 6d38176e20afed678de470fee2602c5994b229ba..34a7c89b86cf5306b1c79764a2a92b60e680f23f 100644 (file)
@@ -7,7 +7,6 @@
 #include <gtk/gtk.h>
 #include <libgnomecanvas/libgnomecanvas.h>
 #include <time.h>
-#include <libgnomeprintui/gnome-print-dialog.h>
 #include <glib/gstdio.h>
 #include <gdk/gdkkeysyms.h>
 
@@ -287,87 +286,57 @@ on_filePrintOptions_activate           (GtkMenuItem     *menuitem,
 
 }
 
-
 void
 on_filePrint_activate                  (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-  GtkWidget *printDialog;
-  GnomePrintJob *gpj;
+#if GTK_CHECK_VERSION(2, 10, 0)
+  GtkPrintOperation *print;
+  GtkPrintOperationResult res;
+  
   int fromPage, toPage;
   int response;
-  char *in_fn;
-  guchar *s;
-  GnomePrintConfig *config = gnome_print_config_default();
+  char *in_fn, *p;
 
   end_text();
   reset_focus();
-  if (ui.filename!=NULL) {
-    if (g_str_has_suffix(ui.filename, ".xoj")) {
-      in_fn = g_strdup(ui.filename);
-      g_strlcpy(g_strrstr(in_fn, "xoj"), "pdf", 4);
-    } 
-    else
-      in_fn = g_strdup_printf("%s.pdf", ui.filename);
-    gnome_print_config_set(config, (guchar *)"Printer", (guchar *)"PDF");
-    gnome_print_config_set(config, (guchar *)GNOME_PRINT_KEY_OUTPUT_FILENAME, (guchar *)in_fn);
-    gnome_print_config_set(config, (guchar *)"Settings.Transport.Backend.FileName", (guchar *)in_fn);
-    g_strlcpy(g_strrstr(in_fn, "pdf"), "ps", 3);
-    gnome_print_config_set(config, (guchar *)"Printer", (guchar *)"GENERIC");
-    gnome_print_config_set (config, (guchar *)GNOME_PRINT_KEY_OUTPUT_FILENAME, (guchar *)in_fn);
-    s = gnome_print_config_get(config, (guchar *)"Settings.Transport.Backend.FileName");
-    if (s != NULL) {
-      g_free(s);
-      gnome_print_config_set(config, (guchar *)"Settings.Transport.Backend.FileName", (guchar *)in_fn);
-    }
-    g_free(in_fn);
-  }
-  
-  gpj = gnome_print_job_new(config); /* was NULL */
-  gnome_print_config_unref(config);
-/* end */
-  printDialog = gnome_print_dialog_new(gpj, (guchar *) _("Print"), GNOME_PRINT_DIALOG_RANGE);
-  gnome_print_dialog_construct_range_page(GNOME_PRINT_DIALOG(printDialog),
-    GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_RANGE,
-    1, journal.npages, (guchar *) _("Current page"), (guchar *) _("Pages"));
-  /* don't have "Current page" as option, else it becomes the default!! */
-  
-  gtk_dialog_set_response_sensitive(GTK_DIALOG(printDialog),
-                         GNOME_PRINT_DIALOG_RESPONSE_PREVIEW, FALSE);
-  /* the print-job-preview "feature" is completely, hopelessly broken */                       
-
-  response = gtk_dialog_run(GTK_DIALOG(printDialog));
-  if (response <= 0) {
-    gtk_widget_destroy(printDialog);
-    return;
-  }
-
+  if (!gtk_check_version(2, 10, 0)) {
+    print = gtk_print_operation_new();
 /*
-  if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW) {
-    print_job_render(gpj, 0, journal.npages-1);
-    gtk_widget_destroy(printDialog);
-    preview = gnome_print_job_preview_new(gpj, (guchar *)"Preview");
-    try_fix_print_preview_ui(preview);
-    gtk_window_set_modal(GTK_WINDOW(preview), TRUE);
-    gtk_widget_show_all(preview);
-  }
+    if (!ui.print_settings)
+      ui.print_settings = gtk_print_settings_new();
+    if (ui.filename!=NULL) {
+      if (g_str_has_suffix(ui.filename, ".xoj")) {
+        in_fn = g_strdup(ui.filename);
+        g_strlcpy(g_strrstr(in_fn, "xoj"), "pdf", 4);
+      } 
+      else in_fn = g_strdup_printf("%s.pdf", ui.filename);
+      gtk_print_settings_set(ui.print_settings, GTK_PRINT_SETTINGS_OUTPUT_URI,
+         g_filename_to_uri(in_fn, NULL, NULL));
+      g_free(in_fn);
+    }
 */
-
-  if (response == GNOME_PRINT_DIALOG_RESPONSE_PRINT) {
-    switch(gnome_print_dialog_get_range(GNOME_PRINT_DIALOG(printDialog))) {
-      case GNOME_PRINT_RANGE_RANGE: 
-        gnome_print_dialog_get_range_page(GNOME_PRINT_DIALOG(printDialog), &fromPage, &toPage);
-        fromPage--;
-        toPage--;
-        break;
-      default: 
-        fromPage = 0; 
-        toPage = journal.npages-1;
+    if (ui.print_settings!=NULL)
+       gtk_print_operation_set_print_settings (print, ui.print_settings);
+    gtk_print_operation_set_n_pages(print, journal.npages);
+    gtk_print_operation_set_current_page(print, ui.pageno);
+    gtk_print_operation_set_show_progress(print, TRUE);
+    if (ui.filename!=NULL) {
+      p = g_utf8_strrchr(ui.filename, -1, '/');
+      if (p==NULL) p = ui.filename;
+      else p++;
+      gtk_print_operation_set_job_name(print, p);
     }
-
-    gtk_widget_destroy(printDialog);
-    print_job_render(gpj, fromPage, toPage);
+    g_signal_connect (print, "draw_page", G_CALLBACK (print_job_render_page), NULL);
+    res = gtk_print_operation_run(print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+                                  GTK_WINDOW(winMain), NULL);
+    if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
+      if (ui.print_settings!=NULL) g_object_unref(ui.print_settings);
+      ui.print_settings = g_object_ref(gtk_print_operation_get_print_settings(print));
+    }
+    g_object_unref(print);
   }
+#endif
 }
 
 
@@ -2582,6 +2551,12 @@ on_canvas_key_press_event              (GtkWidget       *widget,
                                         GdkEventKey     *event,
                                         gpointer         user_data)
 {
+  // Esc leaves text edition, or leaves fullscreen mode
+  if (event->keyval == GDK_Escape) {
+    if (ui.cur_item_type == ITEM_TEXT) { end_text(); reset_focus(); }
+    else if (ui.fullscreen) do_fullscreen(FALSE);
+  }
+  
   // If zoomed-out and in single page mode, switch pages with PgUp/PgDn.
   if (!ui.view_continuous && 
       (0.96 * ui.zoom * ui.cur_page->height < 
@@ -3014,18 +2989,7 @@ on_viewFullscreen_activate             (GtkMenuItem     *menuitem,
     active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem));
 
   if (active == ui.fullscreen) return;
-  end_text();
-  reset_focus();
-  ui.fullscreen = active;
-  gtk_check_menu_item_set_active(
-    GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewFullscreen")), ui.fullscreen);
-  gtk_toggle_tool_button_set_active(
-    GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), ui.fullscreen);
-
-  if (ui.fullscreen) gtk_window_fullscreen(GTK_WINDOW(winMain));
-  else gtk_window_unfullscreen(GTK_WINDOW(winMain));
-  
-  update_vbox_order(ui.vertical_order[ui.fullscreen?1:0]);
+  do_fullscreen(active);
 }
 
 
index 7d2786036f38feb0e4a1231e176ba97d7f2dcca4..163c2041abb9ef4ed2fc8de93a8ccbc2627a6212 100644 (file)
@@ -1330,6 +1330,11 @@ void init_config_default(void)
   PDFTOPPM_PRINTING_DPI = 150;
   
   ui.hiliter_opacity = 0.5;
+  
+#if GTK_CHECK_VERSION(2,10,0)
+  ui.print_settings = NULL;
+#endif
+  
 }
 
 #if GLIB_CHECK_VERSION(2,6,0)
index 90ff4f59e16c2198b3c143807a3c7e45eda2d87a..5733f5b1ae018e46e39725426913491b0c294200 100644 (file)
@@ -1970,13 +1970,34 @@ void hide_unimplemented(void)
   gtk_widget_hide(GET_COMPONENT("colorOther"));
   gtk_widget_hide(GET_COMPONENT("helpIndex")); 
 
-  /* config file only works with glib 2.6 */
+  /* config file only works with glib 2.6 and beyond */
   if (glib_minor_version<6) {
     gtk_widget_hide(GET_COMPONENT("optionsAutoSavePrefs"));
     gtk_widget_hide(GET_COMPONENT("optionsSavePreferences"));
   }
+  /* gtkprint only works with gtk+ 2.10 and beyond */
+  if (gtk_check_version(2, 10, 0)) {
+    gtk_widget_hide(GET_COMPONENT("filePrint"));
+  }  
 }  
 
+// toggle fullscreen mode
+void do_fullscreen(gboolean active)
+{
+  end_text();
+  reset_focus();
+  ui.fullscreen = active;
+  gtk_check_menu_item_set_active(
+    GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewFullscreen")), ui.fullscreen);
+  gtk_toggle_tool_button_set_active(
+    GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), ui.fullscreen);
+
+  if (ui.fullscreen) gtk_window_fullscreen(GTK_WINDOW(winMain));
+  else gtk_window_unfullscreen(GTK_WINDOW(winMain));
+  
+  update_vbox_order(ui.vertical_order[ui.fullscreen?1:0]);
+}
+
 /* attempt to work around GTK+ 2.16/2.17 bugs where random interface
    elements receive XInput events that they can't handle properly    */
 
index 2bfc75334dbbd16b9781a72f57bd02592af04022..fe490ec63f1988b5438e81540eaf693e2bd7fd0c 100644 (file)
@@ -94,6 +94,8 @@ gboolean is_event_within_textview(GdkEventButton *event);
 
 void hide_unimplemented(void);
 
+void do_fullscreen(gboolean active);
+
 // fix GTK+ 2.16/2.17 issues with XInput events
 gboolean filter_extended_events(GtkWidget *widget, GdkEvent *event, gpointer user_data);
 // gboolean fix_extended_events(GtkWidget *widget, GdkEvent *event, gpointer user_data);
index dc14d4ee00a809da2aa2e1bc4c72234f7fc845c8..62e0dce0dc6ffb4f7384b5ed2b0d72ff96afb769 100644 (file)
@@ -6,17 +6,20 @@
 
 #include <gtk/gtk.h>
 #include <libgnomecanvas/libgnomecanvas.h>
-#include <libgnomeprint/gnome-print-job.h>
-#include <libgnomeprint/gnome-print-pango.h>
 #include <zlib.h>
 #include <string.h>
 #include <locale.h>
 #include <pango/pango.h>
 #include <pango/pangofc-font.h>
+#include <pango/pangoft2.h>
 #include <fontconfig/fontconfig.h>
 #include <ft2build.h>
 #include FT_FREETYPE_H
-#include "sft.h" /* Sun Font Tools, embedded in libgnomeprint */
+
+#define NO_MAPPERS
+#define NO_TYPE3
+#define NO_TYPE42
+#include "ttsubset/sft.h"
 
 #include "xournal.h"
 #include "xo-support.h"
@@ -840,7 +843,7 @@ void embed_pdffont(GString *pdfbuf, struct XrefTable *xref, struct PdfFont *font
   int i, j, num, len1, len2;
   gsize len;
   TrueTypeFont *ttfnt;
-  char *tmpfile, *seg1, *seg2;
+  char *seg1, *seg2;
   char *fontdata, *p;
   char prefix[8];
   int nobj_fontprog, nobj_descr, lastchar;
@@ -859,11 +862,8 @@ void embed_pdffont(GString *pdfbuf, struct XrefTable *xref, struct PdfFont *font
       }
     font->num_glyphs_used = num-1;
     if (OpenTTFont(font->filename, 0, &ttfnt) == SF_OK) {
-      tmpfile = mktemp(g_strdup(TMPDIR_TEMPLATE));
-      CreateTTFromTTGlyphs(ttfnt, tmpfile, glyphs, encoding, num, 
-                           0, NULL, TTCF_AutoName | TTCF_IncludeOS2);
-      CloseTTFont(ttfnt);
-      if (g_file_get_contents(tmpfile, &fontdata, &len, NULL) && len>=8) {
+      if (CreateTTFromTTGlyphs_tomemory(ttfnt, (guint8**)&fontdata, &len, glyphs, encoding, num, 
+                   0, NULL, TTCF_AutoName | TTCF_IncludeOS2) == SF_OK) {
         make_xref(xref, xref->last+1, pdfbuf->len);
         nobj_fontprog = xref->last;
         g_string_append_printf(pdfbuf, 
@@ -872,12 +872,11 @@ void embed_pdffont(GString *pdfbuf, struct XrefTable *xref, struct PdfFont *font
         g_string_append_len(pdfbuf, fontdata, len);
         g_string_append(pdfbuf, "endstream\nendobj\n");
         g_free(fontdata);
-      } 
+      }
       else fallback = TRUE;
-      unlink(tmpfile);
-      g_free(tmpfile);
-    }
-    else fallback = TRUE;  
+      CloseTTFont(ttfnt);
+    } 
+    else fallback = TRUE;
   } else {
   // embed the font file: Type1 case
     if (g_file_get_contents(font->filename, &fontdata, &len, NULL) && len>=8) {
@@ -1026,6 +1025,7 @@ void pdf_draw_page(struct Page *pg, GString *str, gboolean *use_hiliter,
   PangoRectangle logical_rect;
   PangoLayoutRun *run;
   PangoFcFont *fcfont;
+  PangoFontMap *fontmap;
   FcPattern *pattern;
   int baseline, advance;
   int glyph_no, glyph_page, current_page;
@@ -1080,8 +1080,11 @@ void pdf_draw_page(struct Page *pg, GString *str, gboolean *use_hiliter,
           g_string_append_printf(str, "%.2f %.2f %.2f rg ",
             RGBA_RGB(item->brush.color_rgba));
         old_text_rgba = item->brush.color_rgba & ~0xff;
-        context = gnome_print_pango_create_context(gnome_print_pango_get_default_font_map());
+        fontmap = pango_ft2_font_map_new();
+        pango_ft2_font_map_set_resolution(PANGO_FT2_FONT_MAP (fontmap), 72, 72);
+        context = pango_font_map_create_context(fontmap);
         layout = pango_layout_new(context);
+        g_object_unref(fontmap);
         g_object_unref(context);
         font_desc = pango_font_description_from_string(item->font_name);
         pango_font_description_set_absolute_size(font_desc,
@@ -1401,84 +1404,79 @@ gboolean print_to_pdf(char *filename)
   return TRUE;
 }
 
-/*********** Printing via libgnomeprint **********/
+/*********** Printing via gtk-print **********/
+
+#if GTK_CHECK_VERSION(2, 10, 0)
 
 // does the same job as update_canvas_bg(), but to a print context
 
-void print_background(GnomePrintContext *gpc, struct Page *pg, gboolean *abort)
+void print_background(cairo_t *cr, struct Page *pg)
 {
   double x, y;
   GdkPixbuf *pix;
   BgPdfPage *pgpdf;
   PopplerPage *pdfpage;
-  int width, height;
+  cairo_surface_t *cr_pixbuf;
   double pgwidth, pgheight;
 
   if (pg->bg->type == BG_SOLID) {
-    gnome_print_setopacity(gpc, 1.0);
-    gnome_print_setrgbcolor(gpc, RGBA_RGB(pg->bg->color_rgba));
-    gnome_print_rect_filled(gpc, 0, 0, pg->width, -pg->height);
-
+    cairo_set_source_rgb(cr, RGBA_RGB(pg->bg->color_rgba));
+    cairo_rectangle(cr, 0, 0, pg->width, pg->height);
+    cairo_fill(cr);
     if (!ui.print_ruling) return;
     if (pg->bg->ruling == RULING_NONE) return;
-    gnome_print_setrgbcolor(gpc, RGBA_RGB(RULING_COLOR));
-    gnome_print_setlinewidth(gpc, RULING_THICKNESS);
-    
+    cairo_set_source_rgb(cr, RGBA_RGB(RULING_COLOR));
+    cairo_set_line_width(cr, RULING_THICKNESS);
+
     if (pg->bg->ruling == RULING_GRAPH) {
       for (x=RULING_GRAPHSPACING; x<pg->width-1; x+=RULING_GRAPHSPACING)
-        gnome_print_line_stroked(gpc, x, 0, x, -pg->height);
+        { cairo_move_to(cr, x, 0); cairo_line_to(cr, x, pg->height); }
       for (y=RULING_GRAPHSPACING; y<pg->height-1; y+=RULING_GRAPHSPACING)
-        gnome_print_line_stroked(gpc, 0, -y, pg->width, -y);
+        { cairo_move_to(cr, 0, y); cairo_line_to(cr, pg->width, y); }
+      cairo_stroke(cr);
       return;
     }
     
     for (y=RULING_TOPMARGIN; y<pg->height-1; y+=RULING_SPACING)
-      gnome_print_line_stroked(gpc, 0, -y, pg->width, -y);
+      { cairo_move_to(cr, 0, y); cairo_line_to(cr, pg->width, y); }
+    cairo_stroke(cr);
     if (pg->bg->ruling == RULING_LINED) {
-      gnome_print_setrgbcolor(gpc, RGBA_RGB(RULING_MARGIN_COLOR));
-      gnome_print_line_stroked(gpc, RULING_LEFTMARGIN, 0, RULING_LEFTMARGIN, -pg->height);
+      cairo_set_source_rgb(cr, RGBA_RGB(RULING_MARGIN_COLOR));
+      cairo_move_to(cr, RULING_LEFTMARGIN, 0);
+      cairo_line_to(cr, RULING_LEFTMARGIN, pg->height);
+      cairo_stroke(cr);
     }
     return;
   }
+  else
+  if (pg->bg->type == BG_PDF) {
+    if (!bgpdf.document) return;
+    pdfpage = poppler_document_get_page(bgpdf.document, pg->bg->file_page_seq-1);
+    if (!pdfpage) return;
+    poppler_page_get_size(pdfpage, &pgwidth, &pgheight);
+    cairo_save(cr);
+    cairo_scale(cr, pg->width/pgwidth, pg->height/pgheight);
+    poppler_page_render(pdfpage, cr);
+    cairo_restore(cr);
+    g_object_unref(pdfpage);
+  }
   else 
-  if (pg->bg->type == BG_PIXMAP || pg->bg->type == BG_PDF) {
-    if (pg->bg->type == BG_PDF) {
-      if (!bgpdf.document) return;
-      pdfpage = poppler_document_get_page(bgpdf.document, pg->bg->file_page_seq-1);
-      if (!pdfpage) return;
-      poppler_page_get_size(pdfpage, &pgwidth, &pgheight);
-      width = (int) (PDFTOPPM_PRINTING_DPI * pgwidth/72.0);
-      height = (int) (PDFTOPPM_PRINTING_DPI * pgheight/72.0);
-      pix = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height);
-      poppler_page_render_to_pixbuf(
-         pdfpage, 0, 0, width, height, PDFTOPPM_PRINTING_DPI/72.0, 0, pix);
-      g_object_unref(pdfpage);
-    }
-    else pix = g_object_ref(pg->bg->pixbuf);
-
-    if (gdk_pixbuf_get_bits_per_sample(pix) != 8 ||
-        gdk_pixbuf_get_colorspace(pix) != GDK_COLORSPACE_RGB)
-      { g_object_unref(pix); return; }
-    gnome_print_gsave(gpc);
-    gnome_print_scale(gpc, pg->width, pg->height);
-    gnome_print_translate(gpc, 0., -1.);
-    if (gdk_pixbuf_get_n_channels(pix) == 3)
-       gnome_print_rgbimage(gpc, gdk_pixbuf_get_pixels(pix),
-         gdk_pixbuf_get_width(pix), gdk_pixbuf_get_height(pix), gdk_pixbuf_get_rowstride(pix));
-    else if (gdk_pixbuf_get_n_channels(pix) == 4)
-       gnome_print_rgbaimage(gpc, gdk_pixbuf_get_pixels(pix),
-         gdk_pixbuf_get_width(pix), gdk_pixbuf_get_height(pix), gdk_pixbuf_get_rowstride(pix));
-    g_object_unref(pix);
-    gnome_print_grestore(gpc);
-    return;
+  if (pg->bg->type == BG_PIXMAP) {
+    cairo_save(cr);
+    cairo_scale(cr, pg->width/gdk_pixbuf_get_width(pg->bg->pixbuf),
+                    pg->height/gdk_pixbuf_get_height(pg->bg->pixbuf));
+    gdk_cairo_set_source_pixbuf(cr, pg->bg->pixbuf, 0, 0);
+    cairo_rectangle(cr, 0, 0, gdk_pixbuf_get_width(pg->bg->pixbuf), gdk_pixbuf_get_height(pg->bg->pixbuf));
+    cairo_fill(cr);
+    cairo_restore(cr);
   }
 }
 
-void print_page(GnomePrintContext *gpc, struct Page *pg, int pageno,
-                double pgwidth, double pgheight, gboolean *abort)
+void print_job_render_page(GtkPrintOperation *print, GtkPrintContext *context, gint pageno, gpointer user_data)
 {
-  char tmp[10];
-  gdouble scale;
+  cairo_t *cr;
+  gdouble width, height, scale;
+  struct Page *pg;
   guint old_rgba;
   double old_thickness;
   GList *layerlist, *itemlist;
@@ -1488,128 +1486,69 @@ void print_page(GnomePrintContext *gpc, struct Page *pg, int pageno,
   double *pt;
   PangoFontDescription *font_desc;
   PangoLayout *layout;
+        
+  pg = (struct Page *)g_list_nth_data(journal.pages, pageno);
+  cr = gtk_print_context_get_cairo_context(context);
+  width = gtk_print_context_get_width(context);
+  height = gtk_print_context_get_height(context);
+  scale = MIN(width/pg->width, height/pg->height);
   
-  if (pg==NULL) return;
-  
-  g_snprintf(tmp, 10, _("Page %d"), pageno);
-  gnome_print_beginpage(gpc, (guchar *)tmp);
-  gnome_print_gsave(gpc);
+  cairo_translate(cr, (width-scale*pg->width)/2, (height-scale*pg->height)/2);
+  cairo_scale(cr, scale, scale);
+  cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
+  cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
   
-  scale = MIN(pgwidth/pg->width, pgheight/pg->height)*0.95;
-  gnome_print_translate(gpc,
-     (pgwidth - scale*pg->width)/2, (pgheight + scale*pg->height)/2);
-  gnome_print_scale(gpc, scale, scale);
-  gnome_print_setlinejoin(gpc, 1); // round
-  gnome_print_setlinecap(gpc, 1); // round
+  print_background(cr, pg);
 
-  print_background(gpc, pg, abort);
-
-  old_rgba = 0x12345678;    // not any values we use, so we'll reset them
+  old_rgba = predef_colors_rgba[COLOR_BLACK];
+  cairo_set_source_rgb(cr, 0, 0, 0);
   old_thickness = 0.0;
 
   for (layerlist = pg->layers; layerlist!=NULL; layerlist = layerlist->next) {
-    if (*abort) break;
     l = (struct Layer *)layerlist->data;
     for (itemlist = l->items; itemlist!=NULL; itemlist = itemlist->next) {
-      if (*abort) break;
       item = (struct Item *)itemlist->data;
       if (item->type == ITEM_STROKE || item->type == ITEM_TEXT) {
-        if ((item->brush.color_rgba & ~0xff) != (old_rgba & ~0xff))
-          gnome_print_setrgbcolor(gpc, RGBA_RGB(item->brush.color_rgba));
-        if ((item->brush.color_rgba & 0xff) != (old_rgba & 0xff))
-          gnome_print_setopacity(gpc, RGBA_ALPHA(item->brush.color_rgba));
+        if (item->brush.color_rgba != old_rgba)
+          cairo_set_source_rgba(cr, RGBA_RGB(item->brush.color_rgba),
+                                    RGBA_ALPHA(item->brush.color_rgba));
         old_rgba = item->brush.color_rgba;
       }
       if (item->type == ITEM_STROKE) {    
         if (item->brush.thickness != old_thickness)
-          gnome_print_setlinewidth(gpc, item->brush.thickness);
-        gnome_print_newpath(gpc);
+          cairo_set_line_width(cr, item->brush.thickness);
         pt = item->path->coords;
         if (!item->brush.variable_width) {
-          gnome_print_moveto(gpc, pt[0], -pt[1]);
+          cairo_move_to(cr, pt[0], pt[1]);
           for (i=1, pt+=2; i<item->path->num_points; i++, pt+=2)
-            gnome_print_lineto(gpc, pt[0], -pt[1]);
-          gnome_print_stroke(gpc);
+            cairo_line_to(cr, pt[0], pt[1]);
+          cairo_stroke(cr);
           old_thickness = item->brush.thickness;
         } else {
           for (i=0; i<item->path->num_points-1; i++, pt+=2) {
-            gnome_print_moveto(gpc, pt[0], -pt[1]);
-            gnome_print_setlinewidth(gpc, item->widths[i]);
-            gnome_print_lineto(gpc, pt[2], -pt[3]);
-            gnome_print_stroke(gpc);
+            cairo_move_to(cr, pt[0], pt[1]);
+            cairo_set_line_width(cr, item->widths[i]);
+            cairo_line_to(cr, pt[2], pt[3]);
+            cairo_stroke(cr);
           }
           old_thickness = 0.0;
         }
       }
       if (item->type == ITEM_TEXT) {
-        layout = gnome_print_pango_create_layout(gpc);
+        layout = gtk_print_context_create_pango_layout(context);
         font_desc = pango_font_description_from_string(item->font_name);
-        pango_font_description_set_absolute_size(font_desc,
-          item->font_size*PANGO_SCALE);
+        if (item->font_size)
+          pango_font_description_set_absolute_size(font_desc,
+            item->font_size*PANGO_SCALE);
         pango_layout_set_font_description(layout, font_desc);
         pango_font_description_free(font_desc);
         pango_layout_set_text(layout, item->text, -1);
-        gnome_print_moveto(gpc, item->bbox.left, -item->bbox.top);
-        gnome_print_pango_layout(gpc, layout);
+        cairo_move_to(cr, item->bbox.left, item->bbox.top);
+        pango_cairo_show_layout(cr, layout);
         g_object_unref(layout);
       }
     }
   }
-  
-  gnome_print_grestore(gpc);
-  gnome_print_showpage(gpc);
-}
-
-void cb_print_abort(GtkDialog *dialog, gint response, gboolean *abort)
-{
-  *abort = TRUE;
 }
 
-void print_job_render(GnomePrintJob *gpj, int fromPage, int toPage)
-{
-  GnomePrintConfig *config;
-  GnomePrintContext *gpc;
-  GtkWidget *wait_dialog;
-  double pgwidth, pgheight;
-  int i;
-  gboolean abort;
-  
-  config = gnome_print_job_get_config(gpj);
-  gnome_print_config_get_page_size(config, &pgwidth, &pgheight);
-  g_object_unref(G_OBJECT(config));
-
-  gpc = gnome_print_job_get_context(gpj);
-
-  abort = FALSE;
-  wait_dialog = gtk_message_dialog_new(GTK_WINDOW(winMain), GTK_DIALOG_MODAL,
-     GTK_MESSAGE_INFO, GTK_BUTTONS_CANCEL, _("Preparing print job"));
-  gtk_widget_show(wait_dialog);
-  g_signal_connect(wait_dialog, "response", G_CALLBACK (cb_print_abort), &abort);
-  
-  for (i = fromPage; i <= toPage; i++) {
-#if GTK_CHECK_VERSION(2,6,0)
-    if (!gtk_check_version(2, 6, 0))
-      gtk_message_dialog_format_secondary_text(
-             GTK_MESSAGE_DIALOG(wait_dialog), _("Page %d"), i+1); 
-#endif
-    while (gtk_events_pending()) gtk_main_iteration();
-    print_page(gpc, (struct Page *)g_list_nth_data(journal.pages, i), i+1,
-                                             pgwidth, pgheight, &abort);
-    if (abort) break;
-  }
-#if GTK_CHECK_VERSION(2,6,0)
-  if (!gtk_check_version(2, 6, 0))
-    gtk_message_dialog_format_secondary_text(
-              GTK_MESSAGE_DIALOG(wait_dialog), _("Finalizing..."));
 #endif
-  while (gtk_events_pending()) gtk_main_iteration();
-
-  gnome_print_context_close(gpc);  
-  g_object_unref(G_OBJECT(gpc));  
-
-  gnome_print_job_close(gpj);
-  if (!abort) gnome_print_job_print(gpj);
-  g_object_unref(G_OBJECT(gpj));
-
-  gtk_widget_destroy(wait_dialog);
-}
index 34e2d6c66ea11904b52e6b4e06f3f1a2b56a4e79..4a7ea31a33b5d570815ca8fbc253877686a94a18 100644 (file)
@@ -67,4 +67,6 @@ gboolean pdf_parse_info(GString *pdfbuf, struct PdfInfo *pdfinfo, struct XrefTab
 
 gboolean print_to_pdf(char *filename);
 
-void print_job_render(GnomePrintJob *gpj, int fromPage, int toPage);
+#if GTK_CHECK_VERSION(2, 10, 0)
+void print_job_render_page(GtkPrintOperation *print, GtkPrintContext *context, gint pageno, gpointer user_data);
+#endif
index 9a387d189b8e3ac16ec61d62f8e96f56d5f1bc11..00ac0ccd23885dba225370d580bb7473b321e2a9 100644 (file)
@@ -275,6 +275,9 @@ typedef struct UIData {
   gchar *shorten_menu_items; // which items to hide
   gboolean is_sel_cursor; // displaying a selection-related cursor
   gboolean need_emergency_disable_xinput; // need to disable xinput to avoid GTK+ 2.17 bug ?
+#if GTK_CHECK_VERSION(2,10,0)
+  GtkPrintSettings *print_settings;
+#endif
 } UIData;
 
 #define BRUSH_LINKED 0