[cairo-commit] src/cairo-ft-font.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Jul 16 11:57:55 UTC 2018
src/cairo-ft-font.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
New commits:
commit 3ec4aa24aa50e271f9b23dd85a77385618e82986
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Jul 16 13:54:45 2018 +0200
[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.)
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 */
More information about the cairo-commit
mailing list