@@ -768,7 +768,7 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots
768
768
if (scalable >= 0
769
769
&& ! FcPatternAddBool (pattern , FC_SCALABLE , scalable ? FcTrue : FcFalse ))
770
770
goto err ;
771
- #if ( defined HAVE_XFT || defined USE_CAIRO ) && defined FC_COLOR
771
+ #if defined HAVE_XFT && defined FC_COLOR
772
772
/* We really don't like color fonts, they cause Xft crashes. See
773
773
Bug#30874. */
774
774
if (Vxft_ignore_color_fonts
@@ -1266,19 +1266,6 @@ ftfont_entity_pattern (Lisp_Object entity, int pixel_size)
1266
1266
1267
1267
#ifndef USE_CAIRO
1268
1268
1269
- static bool
1270
- is_color_font (FT_Face face )
1271
- {
1272
- static unsigned int tag = FT_MAKE_TAG ('C' , 'B' , 'D' , 'T' );
1273
- unsigned long length = 0 ;
1274
- FT_Load_Sfnt_Table (face , tag , 0 , NULL , & length );
1275
- if (length )
1276
- {
1277
- return true;
1278
- }
1279
- return false;
1280
- }
1281
-
1282
1269
Lisp_Object
1283
1270
ftfont_open (struct frame * f , Lisp_Object entity , int pixel_size )
1284
1271
{
@@ -1293,8 +1280,6 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1293
1280
int spacing ;
1294
1281
int i ;
1295
1282
double upEM ;
1296
- bool color ;
1297
- double scale = 1.0 ;
1298
1283
1299
1284
val = assq_no_quit (QCfont_entity , AREF (entity , FONT_EXTRA_INDEX ));
1300
1285
if (! CONSP (val ))
@@ -1321,33 +1306,15 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1321
1306
size = XFIXNUM (AREF (entity , FONT_SIZE_INDEX ));
1322
1307
if (size == 0 )
1323
1308
size = pixel_size ;
1324
-
1325
- color = is_color_font (ft_face );
1326
- if (!color )
1309
+ if (FT_Set_Pixel_Sizes (ft_face , size , size ) != 0 )
1327
1310
{
1328
- if (FT_Set_Pixel_Sizes ( ft_face , size , size ) ! = 0 )
1311
+ if (cache_data -> face_refcount = = 0 )
1329
1312
{
1330
- if (cache_data -> face_refcount == 0 )
1331
- {
1332
- FT_Done_Face (ft_face );
1333
- cache_data -> ft_face = NULL ;
1334
- }
1335
- return Qnil ;
1313
+ FT_Done_Face (ft_face );
1314
+ cache_data -> ft_face = NULL ;
1336
1315
}
1316
+ return Qnil ;
1337
1317
}
1338
- else
1339
- {
1340
- if (ft_face -> num_fixed_sizes == 0 || FT_Select_Size (ft_face , 0 ) != 0 )
1341
- {
1342
- if (cache_data -> face_refcount == 0 )
1343
- {
1344
- FT_Done_Face (ft_face );
1345
- cache_data -> ft_face = NULL ;
1346
- }
1347
- return Qnil ;
1348
- }
1349
- }
1350
-
1351
1318
cache_data -> face_refcount ++ ;
1352
1319
1353
1320
font_object = font_build_object (VECSIZE (struct font_info ),
@@ -1366,7 +1333,6 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1366
1333
#endif /* HAVE_HARFBUZZ */
1367
1334
/* This means that there's no need of transformation. */
1368
1335
ftfont_info -> matrix .xx = 0 ;
1369
- ftfont_info -> is_color_font = color ;
1370
1336
font -> pixel_size = size ;
1371
1337
#ifdef HAVE_HARFBUZZ
1372
1338
if (EQ (AREF (font_object , FONT_TYPE_INDEX ), Qfreetypehb ))
@@ -1418,22 +1384,12 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1418
1384
&& spacing != FC_DUAL
1419
1385
#endif /* FC_DUAL */
1420
1386
)
1421
- {
1422
- int adv = 0 ;
1423
- if (scalable && upEM != 0 )
1424
- adv = ft_face -> max_advance_width * size / upEM + 0.5 ;
1425
- if (adv == 0 )
1426
- adv = ft_face -> size -> metrics .max_advance >> 6 ;
1427
- adv *= scale ;
1428
- font -> min_width = font -> average_width = font -> space_width = adv ;
1429
- }
1387
+ font -> min_width = font -> average_width = font -> space_width
1388
+ = (scalable ? ft_face -> max_advance_width * size / upEM + 0.5
1389
+ : ft_face -> size -> metrics .max_advance >> 6 );
1430
1390
else
1431
1391
{
1432
1392
int n ;
1433
- int load_flag = FT_LOAD_DEFAULT ;
1434
-
1435
- if (color )
1436
- load_flag |= FT_LOAD_COLOR ;
1437
1393
1438
1394
font -> min_width = font -> average_width = font -> space_width = 0 ;
1439
1395
for (i = 32 , n = 0 ; i < 127 ; i ++ )
@@ -1457,7 +1413,7 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1457
1413
font -> relative_compose = 0 ;
1458
1414
font -> default_ascent = 0 ;
1459
1415
font -> vertical_centering = 0 ;
1460
- if (scalable && upEM != 0 )
1416
+ if (scalable )
1461
1417
{
1462
1418
font -> underline_position = (- ft_face -> underline_position * size / upEM
1463
1419
+ 0.5 );
@@ -1470,8 +1426,6 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1470
1426
font -> underline_thickness = 0 ;
1471
1427
}
1472
1428
1473
- ftfont_info -> scale = scale ;
1474
-
1475
1429
return font_object ;
1476
1430
}
1477
1431
@@ -1578,15 +1532,10 @@ ftfont_text_extents (struct font *font, const unsigned int *code,
1578
1532
FT_Face ft_face = ftfont_info -> ft_size -> face ;
1579
1533
int i , width = 0 ;
1580
1534
bool first ;
1581
- int load_flag ;
1582
1535
1583
1536
if (ftfont_info -> ft_size != ft_face -> size )
1584
1537
FT_Activate_Size (ftfont_info -> ft_size );
1585
1538
1586
- load_flag = FT_LOAD_DEFAULT ;
1587
- if (ftfont_info -> is_color_font )
1588
- load_flag |= FT_LOAD_COLOR ;
1589
-
1590
1539
for (i = 0 , first = 1 ; i < nglyphs ; i ++ )
1591
1540
{
1592
1541
int advance , lbearing , rbearing , ascent , descent ;
@@ -1615,10 +1564,6 @@ ftfont_text_extents (struct font *font, const unsigned int *code,
1615
1564
width += font -> space_width ;
1616
1565
}
1617
1566
metrics -> width = width ;
1618
-
1619
- metrics -> width *= ftfont_info -> scale ;
1620
- metrics -> lbearing *= ftfont_info -> scale ;
1621
- metrics -> rbearing *= ftfont_info -> scale ;
1622
1567
}
1623
1568
1624
1569
#endif /* !USE_CAIRO */
@@ -1672,15 +1617,10 @@ ftfont_anchor_point (struct font *font, unsigned int code, int idx,
1672
1617
{
1673
1618
struct font_info * ftfont_info = (struct font_info * ) font ;
1674
1619
FT_Face ft_face = ftfont_info -> ft_size -> face ;
1675
- int load_flag ;
1676
-
1677
- load_flag = FT_LOAD_DEFAULT ;
1678
- if (ftfont_info -> is_color_font )
1679
- load_flag |= FT_LOAD_COLOR ;
1680
1620
1681
1621
if (ftfont_info -> ft_size != ft_face -> size )
1682
1622
FT_Activate_Size (ftfont_info -> ft_size );
1683
- if (FT_Load_Glyph (ft_face , code , load_flag ) != 0 )
1623
+ if (FT_Load_Glyph (ft_face , code , FT_LOAD_DEFAULT ) != 0 )
1684
1624
return -1 ;
1685
1625
if (ft_face -> glyph -> format != FT_GLYPH_FORMAT_OUTLINE )
1686
1626
return -1 ;
0 commit comments