Skip to content

Commit 767be4c

Browse files
author
Yuuki Harano
committed
revert my ftfont.c changes.
1 parent 74d6780 commit 767be4c

File tree

2 files changed

+11
-73
lines changed

2 files changed

+11
-73
lines changed

src/ftfont.c

Lines changed: 11 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots
768768
if (scalable >= 0
769769
&& ! FcPatternAddBool (pattern, FC_SCALABLE, scalable ? FcTrue : FcFalse))
770770
goto err;
771-
#if (defined HAVE_XFT || defined USE_CAIRO) && defined FC_COLOR
771+
#if defined HAVE_XFT && defined FC_COLOR
772772
/* We really don't like color fonts, they cause Xft crashes. See
773773
Bug#30874. */
774774
if (Vxft_ignore_color_fonts
@@ -1266,19 +1266,6 @@ ftfont_entity_pattern (Lisp_Object entity, int pixel_size)
12661266

12671267
#ifndef USE_CAIRO
12681268

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-
12821269
Lisp_Object
12831270
ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
12841271
{
@@ -1293,8 +1280,6 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
12931280
int spacing;
12941281
int i;
12951282
double upEM;
1296-
bool color;
1297-
double scale = 1.0;
12981283

12991284
val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX));
13001285
if (! CONSP (val))
@@ -1321,33 +1306,15 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
13211306
size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX));
13221307
if (size == 0)
13231308
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)
13271310
{
1328-
if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0)
1311+
if (cache_data->face_refcount == 0)
13291312
{
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;
13361315
}
1316+
return Qnil;
13371317
}
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-
13511318
cache_data->face_refcount++;
13521319

13531320
font_object = font_build_object (VECSIZE (struct font_info),
@@ -1366,7 +1333,6 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
13661333
#endif /* HAVE_HARFBUZZ */
13671334
/* This means that there's no need of transformation. */
13681335
ftfont_info->matrix.xx = 0;
1369-
ftfont_info->is_color_font = color;
13701336
font->pixel_size = size;
13711337
#ifdef HAVE_HARFBUZZ
13721338
if (EQ (AREF (font_object, FONT_TYPE_INDEX), Qfreetypehb))
@@ -1418,22 +1384,12 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
14181384
&& spacing != FC_DUAL
14191385
#endif /* FC_DUAL */
14201386
)
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);
14301390
else
14311391
{
14321392
int n;
1433-
int load_flag = FT_LOAD_DEFAULT;
1434-
1435-
if (color)
1436-
load_flag |= FT_LOAD_COLOR;
14371393

14381394
font->min_width = font->average_width = font->space_width = 0;
14391395
for (i = 32, n = 0; i < 127; i++)
@@ -1457,7 +1413,7 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
14571413
font->relative_compose = 0;
14581414
font->default_ascent = 0;
14591415
font->vertical_centering = 0;
1460-
if (scalable && upEM != 0)
1416+
if (scalable)
14611417
{
14621418
font->underline_position = (-ft_face->underline_position * size / upEM
14631419
+ 0.5);
@@ -1470,8 +1426,6 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
14701426
font->underline_thickness = 0;
14711427
}
14721428

1473-
ftfont_info->scale = scale;
1474-
14751429
return font_object;
14761430
}
14771431

@@ -1578,15 +1532,10 @@ ftfont_text_extents (struct font *font, const unsigned int *code,
15781532
FT_Face ft_face = ftfont_info->ft_size->face;
15791533
int i, width = 0;
15801534
bool first;
1581-
int load_flag;
15821535

15831536
if (ftfont_info->ft_size != ft_face->size)
15841537
FT_Activate_Size (ftfont_info->ft_size);
15851538

1586-
load_flag = FT_LOAD_DEFAULT;
1587-
if (ftfont_info->is_color_font)
1588-
load_flag |= FT_LOAD_COLOR;
1589-
15901539
for (i = 0, first = 1; i < nglyphs; i++)
15911540
{
15921541
int advance, lbearing, rbearing, ascent, descent;
@@ -1615,10 +1564,6 @@ ftfont_text_extents (struct font *font, const unsigned int *code,
16151564
width += font->space_width;
16161565
}
16171566
metrics->width = width;
1618-
1619-
metrics->width *= ftfont_info->scale;
1620-
metrics->lbearing *= ftfont_info->scale;
1621-
metrics->rbearing *= ftfont_info->scale;
16221567
}
16231568

16241569
#endif /* !USE_CAIRO */
@@ -1672,15 +1617,10 @@ ftfont_anchor_point (struct font *font, unsigned int code, int idx,
16721617
{
16731618
struct font_info *ftfont_info = (struct font_info *) font;
16741619
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;
16801620

16811621
if (ftfont_info->ft_size != ft_face->size)
16821622
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)
16841624
return -1;
16851625
if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
16861626
return -1;

src/ftfont.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ struct font_info
6262
#ifdef HAVE_HARFBUZZ
6363
hb_font_t *hb_font;
6464
#endif /* HAVE_HARFBUZZ */
65-
bool is_color_font;
66-
double scale;
6765

6866
#ifdef USE_CAIRO
6967
cairo_scaled_font_t *cr_scaled_font;

0 commit comments

Comments
 (0)