diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 22c0a88..a2abba5 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -885,6 +885,18 @@ _cairo_pdf_operators_emit_glyph_string (cairo_pdf_operators_t   *pdf_operators,
 {
     int i;
 
+    if (getenv ("CAIRO_PSFRAG_HACK")) {
+	_cairo_output_stream_printf (stream, "(");
+	for (i = 0; i < pdf_operators->num_glyphs; i++) {
+	    _cairo_output_stream_printf (stream,
+					 "%c",
+					 pdf_operators->glyphs[i].glyph_index);
+	    pdf_operators->cur_x += pdf_operators->glyphs[i].x_advance;
+	}
+	_cairo_output_stream_printf (stream, ") show\n");
+	return _cairo_output_stream_get_status (stream);
+    }
+
     _cairo_output_stream_printf (stream, "<");
     for (i = 0; i < pdf_operators->num_glyphs; i++) {
 	_cairo_output_stream_printf (stream,
@@ -976,7 +988,7 @@ _cairo_pdf_operators_flush_glyphs (cairo_pdf_operators_t    *pdf_operators)
 	    break;
 	x += pdf_operators->glyphs[i].x_advance;
     }
-    if (i == pdf_operators->num_glyphs) {
+    if (getenv ("CAIRO_PSFRAG_HACK") || i == pdf_operators->num_glyphs) {
 	status = _cairo_pdf_operators_emit_glyph_string (pdf_operators,
 							 word_wrap_stream);
     } else {
@@ -1005,6 +1017,10 @@ _cairo_pdf_operators_add_glyph (cairo_pdf_operators_t             *pdf_operators
 	cairo_matrix_transform_distance (&pdf_operators->font_matrix_inverse, &x, &y);
 
     pdf_operators->glyphs[pdf_operators->num_glyphs].x_position = x_position;
+    if (getenv ("CAIRO_PSFRAG_HACK")) {
+	pdf_operators->glyphs[pdf_operators->num_glyphs].glyph_index = glyph->unicode;
+    }
+    else
     pdf_operators->glyphs[pdf_operators->num_glyphs].glyph_index = glyph->subset_glyph_index;
     pdf_operators->glyphs[pdf_operators->num_glyphs].x_advance = x;
     pdf_operators->num_glyphs++;
@@ -1107,7 +1123,7 @@ _cairo_pdf_operators_set_font_subset (cairo_pdf_operators_t             *pdf_ope
     cairo_status_t status;
 
     _cairo_output_stream_printf (pdf_operators->stream,
-				 "/f-%d-%d 1 Tf\n",
+				 getenv ("CAIRO_PSFRAG_HACK") ? "/Helvetica 1 Tf\n" : "/f-%d-%d 1 Tf\n",
 				 subset_glyph->font_id,
 				 subset_glyph->subset_id);
     if (pdf_operators->use_font_subset) {