Cherry-pick https://gitlab.freedesktop.org/cairo/cairo/-/commit/f4e43b6822ec73f2fd8046859315e5d2a5709bf5 draft
authorJonathan Kew <jkew@mozilla.com>
Wed, 14 Apr 2021 17:27:34 +0100
changeset 3667303 dcfa64c1b9a07e32389ac627848dbdf26355095a
parent 3667302 6b67f2bade3aac7f77904b719ba1f226f12df48a
child 3667304 402d5260dadf182bca45b103f24d4629d67346af
push id683063
push userjkew@mozilla.com
push dateMon, 19 Apr 2021 13:15:26 +0000
treeherdertry@919daaf50d14 [default view] [failures only]
milestone89.0a1
Cherry-pick https://gitlab.freedesktop.org/cairo/cairo/-/commit/f4e43b6822ec73f2fd8046859315e5d2a5709bf5 pdf font subset: Generate valid font names
gfx/cairo/cairo/src/cairo-pdf-surface.c
--- a/gfx/cairo/cairo/src/cairo-pdf-surface.c
+++ b/gfx/cairo/cairo/src/cairo-pdf-surface.c
@@ -5305,28 +5305,24 @@ static uint32_t
 
 static void
 _create_font_subset_tag (cairo_scaled_font_subset_t	*font_subset,
 			 const char 			*font_name,
 			 char				*tag)
 {
     uint32_t hash;
     int i;
-    long numerator;
-    ldiv_t d;
 
     hash = _hash_data ((unsigned char *) font_name, strlen(font_name), 0);
     hash = _hash_data ((unsigned char *) (font_subset->glyphs),
 		       font_subset->num_glyphs * sizeof(unsigned long), hash);
 
-    numerator = hash;
     for (i = 0; i < 6; i++) {
-	d = ldiv (numerator, 26);
-	numerator = d.quot;
-        tag[i] = 'A' + d.rem;
+	tag[i] = 'A' + (hash % 26);
+	hash /= 26;
     }
     tag[i] = 0;
 }
 
 static cairo_int_status_t
 _cairo_pdf_surface_emit_to_unicode_stream (cairo_pdf_surface_t		*surface,
 					   cairo_scaled_font_subset_t	*font_subset,
 					   cairo_pdf_resource_t         *stream)