View | Details | Raw Unified | Return to issue 18285
Collapse All | Expand All

(-)SRC680_m130.orig/vcl/source/glyphs/gcach_ftyp.cxx (-7 / +183 lines)
Lines 107-112 Link Here
107
#endif
107
#endif
108
108
109
// -----------------------------------------------------------------------
109
// -----------------------------------------------------------------------
110
// Add by Firefly(firefly@firefly.idv.tw)
111
#define M_MAX  255
112
#define M_X    128
113
#define M_Y    208
114
bool isgamma_init = false;
115
static unsigned char  gamma_table[257];
116
117
static void GammaInit(void)
118
{
119
    unsigned int  x, a;
120
    for (x = 0; x < 256; x++)
121
    {
122
        if ( x <= M_X )
123
            a = ( x * M_Y + M_X / 2) / M_X;
124
        else
125
            a = M_Y + ( ( x - M_X ) * ( M_MAX - M_Y ) +
126
                ( M_MAX - M_X ) / 2 ) / ( M_MAX - M_X );
127
    
128
        gamma_table[x] = (unsigned char)a;
129
    }
130
    isgamma_init = true;
131
}
132
// -----------------------------------------------------------------------
110
133
111
static FT_Library aLibFT = 0;
134
static FT_Library aLibFT = 0;
112
135
Lines 782-787 FreetypeServerFont::FreetypeServerFont( Link Here
782
    // TODO: query GASP table for load flags
805
    // TODO: query GASP table for load flags
783
    mnLoadFlags = FT_LOAD_DEFAULT;
806
    mnLoadFlags = FT_LOAD_DEFAULT;
784
807
808
    // Add by Firefly(firefly@firefly.idv.tw)
809
    mbArtItalic = (rFSD.meItalic != ITALIC_NONE && rFSD.mpFontData->GetSlant() == ITALIC_NONE);
810
    mbArtBold = (rFSD.meWeight > WEIGHT_MEDIUM && rFSD.mpFontData->GetWeight() <= WEIGHT_MEDIUM);
811
    if (!isgamma_init)
812
	GammaInit();
813
814
#define TT_CODEPAGE_RANGE_874    (1L << 16) /* Thai */
815
#define TT_CODEPAGE_RANGE_932    (1L << 17) /* JIS/Japan */
816
#define TT_CODEPAGE_RANGE_936    (1L << 18) /* Chinese: Simplified */
817
#define TT_CODEPAGE_RANGE_949    (1L << 19) /* Korean Wansung */
818
#define TT_CODEPAGE_RANGE_950    (1L << 20) /* Chinese: Traditional */
819
#define TT_CODEPAGE_RANGE_1361   (1L << 21) /* Korean Johab */
820
    const TT_OS2* os2 = (const TT_OS2*)FT_Get_Sfnt_Table(maFaceFT, ft_sfnt_os2);
821
    if ((os2) && ( os2->ulCodePageRange1 & TT_CODEPAGE_RANGE_874  ||
822
		   os2->ulCodePageRange1 & TT_CODEPAGE_RANGE_932  ||
823
		   os2->ulCodePageRange1 & TT_CODEPAGE_RANGE_936  ||
824
		   os2->ulCodePageRange1 & TT_CODEPAGE_RANGE_949  ||
825
		   os2->ulCodePageRange1 & TT_CODEPAGE_RANGE_950  ||
826
		   os2->ulCodePageRange1 & TT_CODEPAGE_RANGE_1361)
827
	      && rFSD.mnHeight < 20)
828
	mbUseGamma = true;
829
    else
830
	mbUseGamma = false;
831
832
    if (mbUseGamma)
833
	mnLoadFlags |= FT_LOAD_FORCE_AUTOHINT;
834
    //---------------------------------------
835
785
    if( (mnSin != 0) && (mnCos != 0) ) // hinting for 0/90/180/270 degrees only
836
    if( (mnSin != 0) && (mnCos != 0) ) // hinting for 0/90/180/270 degrees only
786
        mnLoadFlags |= FT_LOAD_NO_HINTING;
837
        mnLoadFlags |= FT_LOAD_NO_HINTING;
787
    mnLoadFlags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; //#88334#
838
    mnLoadFlags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; //#88334#
Lines 1090-1095 int FreetypeServerFont::FixupGlyphIndex( Link Here
1090
        }
1141
        }
1091
    }
1142
    }
1092
1143
1144
// Modify by Firefly(firefly@firefly.idv.tw)
1145
// ¨S¦³©w¸q BYTECODE_INTERPRETER ÁÙ¬O­n hinting
1146
#if 0
1093
#if !defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
1147
#if !defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
1094
    // #95556# autohinting not yet optimized for non-western glyph styles
1148
    // #95556# autohinting not yet optimized for non-western glyph styles
1095
    if( !(mnLoadFlags & FT_LOAD_NO_HINTING)
1149
    if( !(mnLoadFlags & FT_LOAD_NO_HINTING)
Lines 1098-1103 int FreetypeServerFont::FixupGlyphIndex( Link Here
1098
        ||(aChar >= 0xF800) ) )                 // presentation + symbols
1152
        ||(aChar >= 0xF800) ) )                 // presentation + symbols
1099
        nGlyphFlags |= GF_UNHINTED;
1153
        nGlyphFlags |= GF_UNHINTED;
1100
#endif
1154
#endif
1155
#endif
1101
1156
1102
    if( nGlyphIndex != 0 )
1157
    if( nGlyphIndex != 0 )
1103
        nGlyphIndex |= nGlyphFlags;
1158
        nGlyphIndex |= nGlyphFlags;
Lines 1126-1133 void FreetypeServerFont::InitGlyphData( Link Here
1126
    SplitGlyphFlags( *this, nGlyphIndex, nGlyphFlags );
1181
    SplitGlyphFlags( *this, nGlyphIndex, nGlyphFlags );
1127
1182
1128
    int nLoadFlags = mnLoadFlags;
1183
    int nLoadFlags = mnLoadFlags;
1129
    if( nGlyphFlags & GF_UNHINTED )
1184
1130
        nLoadFlags |= FT_LOAD_NO_HINTING;
1185
    // Add by Firefly(firefly@firefly.idv.tw)
1186
//    if (mbArtItalic)
1187
//	nLoadFlags |= FT_LOAD_NO_BITMAP;    
1131
1188
1132
    FT_Error rc = -1;
1189
    FT_Error rc = -1;
1133
#if (FTVERSION <= 2008)
1190
#if (FTVERSION <= 2008)
Lines 1156-1161 void FreetypeServerFont::InitGlyphData( Link Here
1156
    }
1213
    }
1157
1214
1158
    int nCharWidth = maFaceFT->glyph->metrics.horiAdvance;
1215
    int nCharWidth = maFaceFT->glyph->metrics.horiAdvance;
1216
1159
    if( nGlyphFlags & GF_ROTMASK ) {  // for bVertical rotated glyphs
1217
    if( nGlyphFlags & GF_ROTMASK ) {  // for bVertical rotated glyphs
1160
        const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics;
1218
        const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics;
1161
#if (FTVERSION < 2000)
1219
#if (FTVERSION < 2000)
Lines 1178-1183 void FreetypeServerFont::InitGlyphData( Link Here
1178
    {
1236
    {
1179
        int t=aBbox.yMin; aBbox.yMin=aBbox.yMax, aBbox.yMax=t;
1237
        int t=aBbox.yMin; aBbox.yMin=aBbox.yMax, aBbox.yMax=t;
1180
    }
1238
    }
1239
1181
    rGD.SetOffset( aBbox.xMin, -aBbox.yMax );
1240
    rGD.SetOffset( aBbox.xMin, -aBbox.yMax );
1182
    rGD.SetSize( Size( (aBbox.xMax-aBbox.xMin+1), (aBbox.yMax-aBbox.yMin) ) );
1241
    rGD.SetSize( Size( (aBbox.xMax-aBbox.xMin+1), (aBbox.yMax-aBbox.yMin) ) );
1183
1242
Lines 1207-1212 bool FreetypeServerFont::GetGlyphBitmap1 Link Here
1207
1266
1208
    FT_Int nLoadFlags = mnLoadFlags;
1267
    FT_Int nLoadFlags = mnLoadFlags;
1209
1268
1269
    // Add by Firefly(firefly@firefly.idv.tw)
1270
    if (mbArtItalic)
1271
	nLoadFlags |= FT_LOAD_NO_BITMAP;    
1272
1210
#if (FTVERSION >= 2002)
1273
#if (FTVERSION >= 2002)
1211
    // for 0/90/180/270 degree fonts enable autohinting even if not advisable
1274
    // for 0/90/180/270 degree fonts enable autohinting even if not advisable
1212
    // non-hinted and non-antialiased bitmaps just look too ugly
1275
    // non-hinted and non-antialiased bitmaps just look too ugly
Lines 1242-1247 bool FreetypeServerFont::GetGlyphBitmap1 Link Here
1242
1305
1243
    int nAngle = ApplyGlyphTransform( nGlyphFlags, pGlyphFT, true );
1306
    int nAngle = ApplyGlyphTransform( nGlyphFlags, pGlyphFT, true );
1244
1307
1308
    // Add by Firefly(firefly@firefly.idv.tw)
1309
    // ¼ÒÀÀ±×Åé
1310
    if (mbArtItalic)
1311
    {
1312
	FT_Matrix matrix;
1313
	matrix.xx = matrix.yy = 0x10000L;
1314
	matrix.xy = 0x6000L;
1315
	matrix.yx = 0;
1316
	FT_Glyph_Transform( pGlyphFT, &matrix, NULL );
1317
    }
1318
1245
    if( pGlyphFT->format != ft_glyph_format_bitmap )
1319
    if( pGlyphFT->format != ft_glyph_format_bitmap )
1246
    {
1320
    {
1247
        if( pGlyphFT->format == ft_glyph_format_outline )
1321
        if( pGlyphFT->format == ft_glyph_format_outline )
Lines 1263-1270 bool FreetypeServerFont::GetGlyphBitmap1 Link Here
1263
1337
1264
    const FT_Bitmap& rBitmapFT  = rBmpGlyphFT->bitmap;
1338
    const FT_Bitmap& rBitmapFT  = rBmpGlyphFT->bitmap;
1265
    rRawBitmap.mnHeight         = rBitmapFT.rows;
1339
    rRawBitmap.mnHeight         = rBitmapFT.rows;
1266
    rRawBitmap.mnWidth          = rBitmapFT.width;
1340
    // Modify by Firefly(firefly.idv.tw)
1267
    rRawBitmap.mnScanlineSize   = rBitmapFT.pitch;
1341
    if (mbArtBold)
1342
    {
1343
	rRawBitmap.mnWidth = rBitmapFT.width + 1;
1344
	int lineBytes = (rRawBitmap.mnWidth + 7) >> 3;
1345
        rRawBitmap.mnScanlineSize   = (lineBytes > rBitmapFT.pitch) ? lineBytes : rBitmapFT.pitch;
1346
    }
1347
    else
1348
    {
1349
	rRawBitmap.mnWidth          = rBitmapFT.width;
1350
	rRawBitmap.mnScanlineSize   = rBitmapFT.pitch;
1351
    }
1268
    rRawBitmap.mnBitCount       = 1;
1352
    rRawBitmap.mnBitCount       = 1;
1269
1353
1270
    const ULONG nNeededSize = rRawBitmap.mnScanlineSize * rRawBitmap.mnHeight;
1354
    const ULONG nNeededSize = rRawBitmap.mnScanlineSize * rRawBitmap.mnHeight;
Lines 1276-1282 bool FreetypeServerFont::GetGlyphBitmap1 Link Here
1276
        rRawBitmap.mpBits = new unsigned char[ rRawBitmap.mnAllocated ];
1360
        rRawBitmap.mpBits = new unsigned char[ rRawBitmap.mnAllocated ];
1277
    }
1361
    }
1278
1362
1279
    memcpy( rRawBitmap.mpBits, rBitmapFT.buffer, nNeededSize );
1363
    // Add by Firefly(firefly@firefly.idv.tw)
1364
    // ¼ÒÀÀ²ÊÅé
1365
    if (!mbArtBold)
1366
    {
1367
	memcpy( rRawBitmap.mpBits, rBitmapFT.buffer, nNeededSize );
1368
    }
1369
    else
1370
    {
1371
        memset (rRawBitmap.mpBits, 0, nNeededSize);
1372
	unsigned char *srcLine = rBitmapFT.buffer;
1373
	unsigned char *dstLine = rRawBitmap.mpBits;
1374
	int h = rRawBitmap.mnHeight;
1375
	while (h--)
1376
	{
1377
	    memcpy (dstLine, srcLine, rBitmapFT.pitch);
1378
	    dstLine += rRawBitmap.mnScanlineSize;
1379
	    srcLine += rBitmapFT.pitch;
1380
	}
1381
1382
	unsigned char *p = rRawBitmap.mpBits;
1383
	unsigned char lsb, tmp;
1384
	int x, y;
1385
	for (y=0; y < rRawBitmap.mnHeight; y++)
1386
	{
1387
	    lsb = 0;
1388
	    for (x=0; x < rRawBitmap.mnScanlineSize; x++)
1389
	    {
1390
		tmp = p[x] << 7;
1391
		p[x] |= (p[x] >> 1) | lsb;
1392
		lsb = tmp;
1393
	    }
1394
	    p += rRawBitmap.mnScanlineSize;
1395
	}
1396
    }
1280
1397
1281
    FT_Done_Glyph( pGlyphFT );
1398
    FT_Done_Glyph( pGlyphFT );
1282
1399
Lines 1306-1311 bool FreetypeServerFont::GetGlyphBitmap8 Link Here
1306
1423
1307
    FT_Int nLoadFlags = mnLoadFlags;
1424
    FT_Int nLoadFlags = mnLoadFlags;
1308
1425
1426
    // Add by Firefly(firefly@firefly.idv.tw)
1427
    if (mbArtItalic)
1428
	nLoadFlags |= FT_LOAD_NO_BITMAP;    
1429
1309
#if (FTVERSION <= 2004) && !defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
1430
#if (FTVERSION <= 2004) && !defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
1310
    // autohinting in FT<=2.0.4 makes antialiased glyphs look worse
1431
    // autohinting in FT<=2.0.4 makes antialiased glyphs look worse
1311
    nLoadFlags |= FT_LOAD_NO_HINTING;
1432
    nLoadFlags |= FT_LOAD_NO_HINTING;
Lines 1343-1348 bool FreetypeServerFont::GetGlyphBitmap8 Link Here
1343
1464
1344
    int nAngle = ApplyGlyphTransform( nGlyphFlags, pGlyphFT, true );
1465
    int nAngle = ApplyGlyphTransform( nGlyphFlags, pGlyphFT, true );
1345
1466
1467
    // Add by Firefly(firefly@firefly.idv.tw)
1468
    if (mbArtItalic)
1469
    {
1470
	FT_Matrix matrix;
1471
	matrix.xx = matrix.yy = 0x10000L;
1472
	matrix.xy = 0x6000L;
1473
	matrix.yx = 0;
1474
	FT_Glyph_Transform( pGlyphFT, &matrix, NULL );
1475
    }
1476
1346
    if( pGlyphFT->format == ft_glyph_format_outline )
1477
    if( pGlyphFT->format == ft_glyph_format_outline )
1347
        ((FT_OutlineGlyph)pGlyphFT)->outline.flags |= ft_outline_high_precision;
1478
        ((FT_OutlineGlyph)pGlyphFT)->outline.flags |= ft_outline_high_precision;
1348
1479
Lines 1361-1367 bool FreetypeServerFont::GetGlyphBitmap8 Link Here
1361
    const FT_Bitmap& rBitmapFT  = rBmpGlyphFT->bitmap;
1492
    const FT_Bitmap& rBitmapFT  = rBmpGlyphFT->bitmap;
1362
    rRawBitmap.mnHeight         = rBitmapFT.rows;
1493
    rRawBitmap.mnHeight         = rBitmapFT.rows;
1363
    rRawBitmap.mnWidth          = rBitmapFT.width;
1494
    rRawBitmap.mnWidth          = rBitmapFT.width;
1364
    rRawBitmap.mnScanlineSize   = ((bEmbedded?rBitmapFT.width:rBitmapFT.pitch) + 3) & -4;
1495
    // Add by Firefly(firefly@firefly.idv.tw)
1496
    if (mbArtBold)
1497
    {
1498
	rRawBitmap.mnWidth++;
1499
	rRawBitmap.mnScanlineSize = ((bEmbedded?rRawBitmap.mnWidth:rBitmapFT.pitch+1) + 3) & -4;
1500
    }
1501
    else
1502
    {
1503
	rRawBitmap.mnScanlineSize = ((bEmbedded?rBitmapFT.width:rBitmapFT.pitch) + 3) & -4;
1504
    }
1365
    rRawBitmap.mnBitCount       = 8;
1505
    rRawBitmap.mnBitCount       = 8;
1366
1506
1367
    const ULONG nNeededSize = rRawBitmap.mnScanlineSize * rRawBitmap.mnHeight;
1507
    const ULONG nNeededSize = rRawBitmap.mnScanlineSize * rRawBitmap.mnHeight;
Lines 1400-1405 bool FreetypeServerFont::GetGlyphBitmap8 Link Here
1400
        }
1540
        }
1401
    }
1541
    }
1402
1542
1543
    // Add by Firefly(firefly@firefly.idv.tw)
1544
    // ¼ÒÀÀ²ÊÅé
1545
    if (mbArtBold)
1546
    {
1547
	unsigned char *p = rRawBitmap.mpBits;
1548
	unsigned char lsb, tmp;
1549
	int x, y;
1550
	for (y=0; y < rRawBitmap.mnHeight; y++)
1551
	{
1552
	    lsb = 0;
1553
	    for (x=0; x < rRawBitmap.mnWidth; x++)
1554
	    {
1555
	        tmp = p[x];
1556
	        p[x] |= p[x] | lsb;
1557
	        lsb = tmp;
1558
	    }
1559
	    p += rRawBitmap.mnScanlineSize;
1560
	}
1561
    }
1562
1563
    // Add by Firefly(firefly@firefly.idv.tw)
1564
    // ¤p©ó 20 ÂI´N¥[²`ÃC¦â
1565
    if (!bEmbedded && mbUseGamma)
1566
    {
1567
	unsigned char *p = rRawBitmap.mpBits;
1568
	int x, y;
1569
	for (y=0; y < rRawBitmap.mnHeight; y++)
1570
	{
1571
	    for (x=0; x < rRawBitmap.mnWidth; x++)
1572
	    {
1573
	        p[x] = gamma_table[p[x]];
1574
	    }
1575
	    p += rRawBitmap.mnScanlineSize;
1576
	}
1577
    }
1578
1403
    FT_Done_Glyph( pGlyphFT );
1579
    FT_Done_Glyph( pGlyphFT );
1404
1580
1405
    // special case for 0/90/180/270 degree orientation
1581
    // special case for 0/90/180/270 degree orientation
Lines 1942-1948 bool FreetypeServerFont::GetGlyphOutline Link Here
1942
    int nGlyphFlags;
2118
    int nGlyphFlags;
1943
    SplitGlyphFlags( *this, nGlyphIndex, nGlyphFlags );
2119
    SplitGlyphFlags( *this, nGlyphIndex, nGlyphFlags );
1944
2120
1945
    FT_Int nLoadFlags = FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
2121
    FT_Int nLoadFlags = FT_LOAD_DEFAULT | FT_LOAD_TARGET_LIGHT;
1946
    FT_Error rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
2122
    FT_Error rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
1947
    if( rc != FT_Err_Ok )
2123
    if( rc != FT_Err_Ok )
1948
        return false;
2124
        return false;
(-)SRC680_m130.orig/vcl/source/glyphs/gcach_ftyp.hxx (+5 lines)
Lines 218-223 private: Link Here
218
    rtl_UnicodeToTextConverter  maRecodeConverter;
218
    rtl_UnicodeToTextConverter  maRecodeConverter;
219
219
220
    ServerFontLayoutEngine*     mpLayoutEngine;
220
    ServerFontLayoutEngine*     mpLayoutEngine;
221
    // Add by Firefly(firefly@firefly.idv.tw)
222
    bool			mbArtItalic;
223
    bool			mbArtBold;
224
    bool			mbUseGamma;
225
    //--------------------------------------
221
};
226
};
222
227
223
// -----------------------------------------------------------------------
228
// -----------------------------------------------------------------------
(-)SRC680_m130.orig/vcl/source/glyphs/glyphcache.cxx (+4 lines)
Lines 89-94 size_t GlyphCache::IFSD_Hash::operator() Link Here
89
    nHash   += rFontSelData.mnHeight;
89
    nHash   += rFontSelData.mnHeight;
90
    nHash   += rFontSelData.mnOrientation;
90
    nHash   += rFontSelData.mnOrientation;
91
    nHash   += rFontSelData.mbVertical;
91
    nHash   += rFontSelData.mbVertical;
92
    // Add by Firefly(firefly@firefly.idv.tw)
93
    nHash   += rFontSelData.meItalic;
94
    nHash   += rFontSelData.meWeight;
95
    //---------------------------------------
92
    return nHash;
96
    return nHash;
93
}
97
}
94
98

Return to issue 18285