summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2018-07-16 13:54:45 +0200
committerBehdad Esfahbod <behdad@behdad.org>2018-07-16 13:55:20 +0200
commit3ec4aa24aa50e271f9b23dd85a77385618e82986 (patch)
tree401888464ec843615f44d82a59fc1d6f1c731ee4
parent61122127943dcaff41501e1b06df2a852c576e9b (diff)
[ft] Implement some more color conversion routines
Makes new COLR/CPAL implementation in FreeType work with cairo now. Ie. Microsoft's Segoe UI Emoji Regular font renders (instead of crashing cairo.)
-rw-r--r--src/cairo-ft-font.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 9e1b3fb6f..325dd61b4 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -976,6 +976,11 @@ _compute_xrender_bitmap_size(FT_Bitmap *target,
pitch = width * 4;
break;
+ case FT_PIXEL_MODE_BGRA:
+ /* each pixel is replicated into a 32-bit ARGB value */
+ pitch = width * 4;
+ break;
+
default: /* unsupported source format */
return -1;
}
@@ -1133,7 +1138,7 @@ _fill_xrender_bitmap(FT_Bitmap *target,
}
break;
- default: /* FT_PIXEL_MODE_LCD_V */
+ case FT_PIXEL_MODE_LCD_V:
/* convert vertical RGB into ARGB32 */
if (!bgr) {
@@ -1170,6 +1175,15 @@ _fill_xrender_bitmap(FT_Bitmap *target,
}
}
}
+ break;
+
+ case FT_PIXEL_MODE_BGRA:
+ for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch)
+ memcpy (dstLine, srcLine, width * 4);
+ break;
+
+ default:
+ assert (0);
}
}
@@ -1275,7 +1289,6 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
component_alpha = TRUE;
}
break;
-#ifdef FT_LOAD_COLOR
case FT_PIXEL_MODE_BGRA:
stride = width * 4;
if (own_buffer) {
@@ -1298,7 +1311,6 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
}
format = CAIRO_FORMAT_ARGB32;
break;
-#endif
case FT_PIXEL_MODE_GRAY2:
case FT_PIXEL_MODE_GRAY4:
convert:
@@ -2475,9 +2487,7 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
vertical_layout = TRUE;
}
-#ifdef FT_LOAD_COLOR
load_flags |= FT_LOAD_COLOR;
-#endif
if (info & CAIRO_SCALED_GLYPH_INFO_METRICS) {
@@ -2638,7 +2648,6 @@ LOAD:
}
}
-#ifdef FT_LOAD_COLOR
if (((info & (CAIRO_SCALED_GLYPH_INFO_SURFACE | CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE)) != 0) &&
((scaled_glyph->has_info & CAIRO_SCALED_GLYPH_INFO_SURFACE) == 0)) {
/*
@@ -2650,7 +2659,6 @@ LOAD:
load_flags &= ~FT_LOAD_COLOR;
goto LOAD;
}
-#endif
if (info & CAIRO_SCALED_GLYPH_INFO_PATH) {
cairo_path_fixed_t *path = NULL; /* hide compiler warning */