Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 33069 | Differences between
and this patch

Collapse All | Expand All

(-)qt-x11-free-3.2.3-fix/src/kernel/qpsprinter.cpp (-4 / +258 lines)
Lines 98-103 Link Here
98
#include "qtextlayout_p.h"
98
#include "qtextlayout_p.h"
99
#include "qtextengine_p.h"
99
#include "qtextengine_p.h"
100
extern bool qt_has_xft;
100
extern bool qt_has_xft;
101
102
#ifndef QT_NO_XFTFREETYPE
103
#include <ft2build.h>
104
#include FT_OUTLINE_H
105
#endif
106
101
#endif
107
#endif
102
108
103
static bool qt_gen_epsf = FALSE;
109
static bool qt_gen_epsf = FALSE;
Lines 2076-2081 Link Here
2076
2082
2077
// ================== TTF ====================
2083
// ================== TTF ====================
2078
2084
2085
#ifndef QT_NO_XFTFREETYPE
2086
2087
static void
2088
getXftData( const QFontEngine *engine,
2089
	    int &index, int &weight, int &slant, XftMatrix &matrix )
2090
{
2091
    XftPattern*  font = static_cast<const QFontEngineXft *>( engine )->pattern();
2092
    XftMatrix    unit = { 1.0, 0, 0, 1.0 };
2093
    XftMatrix*   mat;
2094
2095
    index  = 0;
2096
    weight = XFT_WEIGHT_MEDIUM;
2097
    slant  = XFT_SLANT_ROMAN;
2098
    matrix = unit;
2099
2100
    XftPatternGetInteger( font, XFT_INDEX, 0, &index );
2101
    XftPatternGetInteger( font, XFT_WEIGHT, 0, &weight );
2102
    XftPatternGetInteger( font, XFT_SLANT, 0, &slant );
2103
2104
    if ( XftPatternGetMatrix( font, XFT_MATRIX, 0, &mat ) == XftResultMatch )
2105
	matrix = *mat;
2106
}
2107
2108
#endif // QT_NO_XFTFREETYPE
2109
2110
2079
typedef Q_UINT8  BYTE;
2111
typedef Q_UINT8  BYTE;
2080
typedef Q_UINT16 USHORT;
2112
typedef Q_UINT16 USHORT;
2081
typedef Q_UINT16 uFWord;
2113
typedef Q_UINT16 uFWord;
Lines 2184-2189 Link Here
2184
2216
2185
    int indexToLocFormat;         /* short or long offsets */
2217
    int indexToLocFormat;         /* short or long offsets */
2186
2218
2219
#ifndef QT_NO_XFTFREETYPE
2220
    FT_Face face;
2221
    int index;
2222
    int weight;
2223
    int slant;
2224
    XftMatrix matrix;
2225
2226
    QString StyleName_Extension;
2227
#endif // QT_NO_XFTFREETYPE
2228
2187
};
2229
};
2188
2230
2189
2231
Lines 2293-2298 Link Here
2293
#endif
2335
#endif
2294
  offset_table = (unsigned char*) data.data(); /* first 12 bytes */
2336
  offset_table = (unsigned char*) data.data(); /* first 12 bytes */
2295
2337
2338
#ifndef QT_NO_XFTFREETYPE
2339
  if ( target_type == 42 ) {
2340
    if ( !( d[0] == '0' && d[1] == '1' && d[2] == '0' && d[3] == '0' ) ) {
2341
      defective = TRUE;
2342
      return;
2343
    }
2344
  }
2345
2346
  face = 0;
2347
  StyleName_Extension = "";
2348
  getXftData( f, index, weight, slant, matrix );
2349
2350
  if ( qt_has_xft && f->type() == QFontEngine::Xft ) {
2351
    extern FT_Library  _XftFTlibrary;
2352
2353
    if ( FT_New_Memory_Face( _XftFTlibrary,
2354
                             (const FT_Byte*)data.data(),
2355
                             data.size(), index, &face ) ||
2356
         ( face->face_flags & FT_FACE_FLAG_SCALABLE ) == 0 ) {
2357
      defective = TRUE;
2358
      return;
2359
    }
2360
2361
    FT_Set_Pixel_Sizes( face, 1000, 1000 );
2362
2363
    bool bold   = ( face->style_flags & FT_STYLE_FLAG_BOLD   ) != 0;
2364
    bool italic = ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0;
2365
2366
    if ( weight > XFT_WEIGHT_MEDIUM && !bold )
2367
      StyleName_Extension += "Bold";
2368
    if ( slant > XFT_SLANT_ROMAN && !italic )
2369
      StyleName_Extension += "Oblique";
2370
2371
    if ( !StyleName_Extension.isEmpty() )
2372
      StyleName_Extension = "-" + StyleName_Extension;
2373
2374
    if ( matrix.xx != 1.0 || matrix.xy != 0.0 ||
2375
         matrix.yx != 0.0 || matrix.yy != 1.0 )
2376
      StyleName_Extension += QString( "-%1-%2-%3-%4" )
2377
                                     .arg( matrix.xx, 0, 'f' )
2378
                                     .arg( matrix.yx, 0, 'f' )
2379
                                     .arg( matrix.xy, 0, 'f' )
2380
                                     .arg( matrix.yy, 0, 'f' );
2381
2382
    StyleName_Extension.replace( '.', '_' );
2383
  }
2384
2385
  if ( d[0] == 't' && d[1] == 't' && d[2] == 'c' && d[3] == 'f' )
2386
    offset_table += getULONG( offset_table + 12 + 4 * index );
2387
#endif
2388
2389
2296
  /* Determine how many directory entries there are. */
2390
  /* Determine how many directory entries there are. */
2297
  numTables = getUSHORT( offset_table + 4 );
2391
  numTables = getUSHORT( offset_table + 4 );
2298
2392
Lines 2408-2413 Link Here
2408
//  qDebug("number of glyphs is %d", numGlyphs);
2502
//  qDebug("number of glyphs is %d", numGlyphs);
2409
  replacementList = makePSFontNameList( f, psname );
2503
  replacementList = makePSFontNameList( f, psname );
2410
  uni2glyphSetup();
2504
  uni2glyphSetup();
2505
2506
#ifndef QT_NO_XFTFREETYPE
2507
  psname   += StyleName_Extension;
2508
  FullName += StyleName_Extension;
2509
#endif
2411
}
2510
}
2412
2511
2413
2512
Lines 2524-2530 Link Here
2524
    if( target_type == 42 )
2623
    if( target_type == 42 )
2525
        s << "%%Creator: Converted from TrueType to type 42 by Qt\n";
2624
        s << "%%Creator: Converted from TrueType to type 42 by Qt\n";
2526
    else
2625
    else
2527
        s << "%%Creator: Converted from TrueType by Qt\n";
2626
        s << "%%Creator: Converted from TrueType/OpenType by Qt\n";
2528
2627
2529
    /* If VM usage information is available, print it. */
2628
    /* If VM usage information is available, print it. */
2530
    if( target_type == 42 && post_table)
2629
    if( target_type == 42 && post_table)
Lines 2546-2552 Link Here
2546
        s << "/_d{bind def}bind def\n";
2645
        s << "/_d{bind def}bind def\n";
2547
        s << "/_m{moveto}_d\n";
2646
        s << "/_m{moveto}_d\n";
2548
        s << "/_l{lineto}_d\n";
2647
        s << "/_l{lineto}_d\n";
2549
        s << "/_cl{closepath eofill}_d\n";
2648
        s << "/_cl{closepath fill}_d\n";
2550
        s << "/_c{curveto}_d\n";
2649
        s << "/_c{curveto}_d\n";
2551
        s << "/_sc{7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse}_d\n";
2650
        s << "/_sc{7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse}_d\n";
2552
        s << "/_e{exec}_d\n";
2651
        s << "/_e{exec}_d\n";
Lines 2560-2566 Link Here
2560
    if(target_type == 42)
2659
    if(target_type == 42)
2561
        s << "/FontMatrix[1 0 0 1 0 0]def\n";
2660
        s << "/FontMatrix[1 0 0 1 0 0]def\n";
2562
    else
2661
    else
2662
#ifndef QT_NO_XFTFREETYPE
2663
        s << QString( "/FontMatrix[%1 %2 %3 %4 0 0]def\n" )
2664
                     .arg( 0.001 * matrix.xx, 0, 'f', 6 )
2665
                     .arg( 0.001 * matrix.yx, 0, 'f', 6 )
2666
                     .arg( 0.001 * matrix.xy, 0, 'f', 6 )
2667
                     .arg( 0.001 * matrix.yy, 0, 'f', 6 );
2668
#else
2563
        s << "/FontMatrix[.001 0 0 .001 0 0]def\n";
2669
        s << "/FontMatrix[.001 0 0 .001 0 0]def\n";
2670
#endif
2564
2671
2565
    s << "/FontBBox[";
2672
    s << "/FontBBox[";
2566
    s<< llx;
2673
    s<< llx;
Lines 2703-2708 Link Here
2703
2810
2704
    s << "end readonly def\n";
2811
    s << "end readonly def\n";
2705
2812
2813
    if ( face ) {
2814
      FT_Done_Face( face );
2815
      face = 0;
2816
    }
2817
2706
    // === trailer ===
2818
    // === trailer ===
2707
2819
2708
    /* If we are generating a type 3 font, we need to provide */
2820
    /* If we are generating a type 3 font, we need to provide */
Lines 2845-2851 Link Here
2845
            offset = getULONG( ptr + 8 );
2957
            offset = getULONG( ptr + 8 );
2846
            //length = getULONG( ptr + 12 );
2958
            //length = getULONG( ptr + 12 );
2847
2959
2848
            table = offset_table + offset;
2960
            table = (BYTE*)data.data() + offset;
2849
            return table;
2961
            return table;
2850
        }
2962
        }
2851
2963
Lines 3348-3353 Link Here
3348
  }
3460
  }
3349
}
3461
}
3350
3462
3463
3464
#ifndef QT_NO_XFTFREETYPE
3465
3466
#undef DOWNSCALE
3467
#define DOWNSCALE( x ) ( ( (x) + 32 ) >> 6 )
3468
3469
extern "C" {
3470
3471
static FT_Vector  from;
3472
3473
  static FT_Error
3474
  PSMovetoFT( FT_Vector*  to, QTextStream *s )
3475
  {
3476
    if ( !to ) {
3477
      stack( 100, 1, *s );
3478
      (*s) << " _cl";
3479
    } else {
3480
      stack( 100, 3, *s );
3481
      (*s) << DOWNSCALE( to->x ) << " "
3482
           << DOWNSCALE( to->y ) << " _m\n";
3483
      from = *to;
3484
    }
3485
3486
    return FT_Err_Ok;
3487
  }
3488
3489
  static FT_Error
3490
  PSLinetoFT( FT_Vector*  to,
3491
              QTextStream *s )
3492
  {
3493
    stack( 100, 3, *s );
3494
    (*s) << DOWNSCALE( to->x ) << " "
3495
         << DOWNSCALE( to->y ) << " _l\n";
3496
    from = *to;
3497
    return FT_Err_Ok;
3498
  }
3499
3500
  static FT_Error
3501
  PSCubictoFT( FT_Vector*  ctrl1, FT_Vector*  ctrl2, FT_Vector*  to,
3502
               QTextStream *s )
3503
  {
3504
    stack( 100, 7, *s );
3505
    (*s) << DOWNSCALE( ctrl1->x ) << " "
3506
         << DOWNSCALE( ctrl1->y ) << " "
3507
         << DOWNSCALE( ctrl2->x ) << " "
3508
         << DOWNSCALE( ctrl2->y ) << " "
3509
         << DOWNSCALE( to->x    ) << " "
3510
         << DOWNSCALE( to->y    ) << " _c\n";
3511
    from = *to;
3512
    return FT_Err_Ok;
3513
  }
3514
3515
  static FT_Error
3516
  PSConictoFT( FT_Vector*  ctrl, FT_Vector*  to,
3517
               QTextStream *s )
3518
  {
3519
    FT_Vector  ctrl1, ctrl2;
3520
3521
3522
    ctrl1.x = ( from.x + 2*ctrl->x ) / 3;
3523
    ctrl1.y = ( from.y + 2*ctrl->y ) / 3;
3524
    ctrl2.x = ( to->x  + 2*ctrl->x ) / 3;
3525
    ctrl2.y = ( to->y  + 2*ctrl->y ) / 3;
3526
3527
    return PSCubictoFT( &ctrl1, &ctrl2, to, s );
3528
  }
3529
3530
} // extern "C"
3531
3532
static void
3533
charprocFT( FT_Face  face, FT_UInt  glyph_index,
3534
            int weight, int slant, QTextStream &s )
3535
{
3536
  static const FT_Outline_Funcs  funcs =
3537
  {
3538
    (FT_Outline_MoveToFunc)  PSMovetoFT,
3539
    (FT_Outline_LineToFunc)  PSLinetoFT,
3540
    (FT_Outline_ConicToFunc) PSConictoFT,
3541
    (FT_Outline_CubicToFunc) PSCubictoFT,
3542
    0, 0
3543
  };
3544
3545
  FT_Int32  load_flags = FT_LOAD_NO_BITMAP |
3546
                         FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
3547
3548
  Q_UNUSED( weight );
3549
  Q_UNUSED( slant );
3550
3551
  if ( !FT_Load_Glyph( face, glyph_index, load_flags ) ) {
3552
    FT_Glyph_Metrics*  metrics = &face->glyph->metrics;
3553
3554
    stack( 100, 7, s );
3555
    s << ( ( face->glyph->linearHoriAdvance + 0x8000L ) >> 16 );
3556
    s << " 0 ";
3557
    s << DOWNSCALE( metrics->horiBearingX );
3558
    s << " ";
3559
    s << DOWNSCALE( metrics->horiBearingY - metrics->height );
3560
    s << " ";
3561
    s << DOWNSCALE( metrics->horiBearingX + metrics->width );
3562
    s << " ";
3563
    s << DOWNSCALE( metrics->horiBearingY );
3564
    s << " _sc\n";
3565
3566
    FT_Outline_Decompose( &face->glyph->outline, &funcs, &s );
3567
    PSMovetoFT( 0, &s );
3568
3569
  } else {
3570
    stack( 7, 7, s );
3571
    s << "0 0 0 0 0 0 0 _sc\n";
3572
  }
3573
3574
  stack_end( s );
3575
  return;
3576
}
3577
3578
#endif // QT_NO_XFTFREETYPE
3579
3351
// postscript drawing commands
3580
// postscript drawing commands
3352
3581
3353
static void PSMoveto(FWord x, FWord y, QTextStream& ts)
3582
static void PSMoveto(FWord x, FWord y, QTextStream& ts)
Lines 3742-3747 Link Here
3742
  charproc_data cd;
3971
  charproc_data cd;
3743
3972
3744
  glyphset[charindex] = TRUE;
3973
  glyphset[charindex] = TRUE;
3974
3975
#ifndef QT_NO_XFTFREETYPE
3976
  if ( face )
3977
    return;
3978
#endif // QT_NO_XFTFREETYPE
3979
3745
  //printf("subsetting %s ==> ",glyphName(charindex).latin1());
3980
  //printf("subsetting %s ==> ",glyphName(charindex).latin1());
3746
3981
3747
  /* Get a pointer to the data. */
3982
  /* Get a pointer to the data. */
Lines 3943-3948 Link Here
3943
  s << "\n";
4178
  s << "\n";
3944
#endif
4179
#endif
3945
4180
4181
  if ( face ) {
4182
    charprocFT( face, charindex, weight, slant, s );
4183
    return;
4184
  }
4185
3946
  /* Get a pointer to the data. */
4186
  /* Get a pointer to the data. */
3947
  BYTE* glyph = charprocFindGlyphData( charindex );
4187
  BYTE* glyph = charprocFindGlyphData( charindex );
3948
4188
Lines 4889-4897 Link Here
4889
	    char *filename = 0;
5129
	    char *filename = 0;
4890
	    XftPatternGetString (pattern, XFT_FILE, 0, &filename);
5130
	    XftPatternGetString (pattern, XFT_FILE, 0, &filename);
4891
	    //qDebug("filename for font is '%s'", filename);
5131
	    //qDebug("filename for font is '%s'", filename);
5132
	    int index, weight, slant;
5133
	    XftMatrix  matrix;
5134
	    getXftData (engine, index, weight, slant, matrix);
5135
	    QString  style = QString("-I%1-W%2-S%3-M[%4,%5,%6,%7]")
5136
				.arg(index).arg(weight).arg(slant)
5137
				.arg(matrix.xx).arg(matrix.xy)
5138
				.arg(matrix.yx).arg(matrix.yy);
5139
4892
	    if ( filename ) {
5140
	    if ( filename ) {
4893
		fontfilename = QString::fromLocal8Bit( filename );
5141
		fontfilename = QString::fromLocal8Bit( filename );
4894
		xfontname = fontfilename;
5142
		xfontname = fontfilename + style;
4895
	    }
5143
	    }
4896
	} else
5144
	} else
4897
#endif
5145
#endif
Lines 5030-5035 Link Here
5030
            type = PFA;
5278
            type = PFA;
5031
        else if (d[0]==0x00 && d[1]==0x01 && d[2]==0x00 && d[3]==0x00)
5279
        else if (d[0]==0x00 && d[1]==0x01 && d[2]==0x00 && d[3]==0x00)
5032
            type = TTF;
5280
            type = TTF;
5281
#ifndef QT_NO_XFTFREETYPE
5282
        else if (d[0]=='t' && d[1]=='t' && d[2]=='c' && d[3]=='f')
5283
            type = TTF;
5284
        else if (d[0]=='O' && d[1]=='T' && d[2]=='T' && d[3]=='O')
5285
            type = TTF;
5286
#endif // QT_NO_XFTFREETYPE
5033
        else
5287
        else
5034
            type = NONE;
5288
            type = NONE;
5035
    } else
5289
    } else

Return to bug 33069