Bug 298914 - OS-X svg crash with empty string. r=jhpedemonte, a=bsmedberg.

This commit is contained in:
tor%cs.brown.edu 2005-06-28 18:58:31 +00:00
Родитель 304cbe853b
Коммит 80cb1e6318
3 изменённых файлов: 68 добавлений и 7 удалений

Просмотреть файл

@ -34,3 +34,4 @@ PATCHES:
win32-extents.diff - correct text extents for general tranforms
(upstream patch)
atsui-empty.diff - prevent OS-X crash with empty string

Просмотреть файл

@ -0,0 +1,57 @@
Index: cairo/src/cairo-atsui-font.c
===================================================================
RCS file: /cvsroot/mozilla/gfx/cairo/cairo/src/cairo-atsui-font.c,v
retrieving revision 1.5
diff -u -8 -p -r1.5 cairo-atsui-font.c
--- cairo/src/cairo-atsui-font.c 4 Jun 2005 12:19:44 -0000 1.5
+++ cairo/src/cairo-atsui-font.c 28 Jun 2005 18:53:10 -0000
@@ -248,39 +248,42 @@ _cairo_atsui_font_text_to_glyphs(void *
cairo_atsui_font_t *font = abstract_font;
size_t i;
OSStatus err;
ATSUTextLayout textLayout;
ATSLayoutRecord *layoutRecords;
ItemCount glyphCount, charCount;
UniChar *theText;
- err = ATSUCreateTextLayout(&textLayout);
-
-#if 1
+ // liberal estimate of size
charCount = strlen(utf8);
+ if (charCount == 0) {
+ *glyphs = NULL;
+ *num_glyphs = 0;
+ return CAIRO_STATUS_SUCCESS;
+ }
+
// Set the text in the text layout object, so we can measure it
theText = (UniChar *) malloc(charCount * sizeof(UniChar));
+#if 1
for (i = 0; i < charCount; i++) {
theText[i] = utf8[i];
}
#endif
#if 0
- // Set the text in the text layout object, so we can measure it
- charCount = strlen(utf8);
- theText = (UniChar *) malloc(charCount * sizeof(UniChar));
-
size_t inBytes = charCount, outBytes = charCount;
iconv_t converter = iconv_open("UTF-8", "UTF-16");
charCount = iconv(converter, utf8, &inBytes, theText, &outBytes);
#endif
+ err = ATSUCreateTextLayout(&textLayout);
+
err = ATSUSetTextPointerLocation(textLayout,
theText, 0, charCount, charCount);
// Set the style for all of the text
err = ATSUSetRunStyle(textLayout,
font->unscaled_style, kATSUFromTextBeginning, kATSUToTextEnd);

Просмотреть файл

@ -253,29 +253,32 @@ _cairo_atsui_font_text_to_glyphs(void *abstract_font,
ItemCount glyphCount, charCount;
UniChar *theText;
err = ATSUCreateTextLayout(&textLayout);
#if 1
// liberal estimate of size
charCount = strlen(utf8);
if (charCount == 0) {
*glyphs = NULL;
*num_glyphs = 0;
return CAIRO_STATUS_SUCCESS;
}
// Set the text in the text layout object, so we can measure it
theText = (UniChar *) malloc(charCount * sizeof(UniChar));
#if 1
for (i = 0; i < charCount; i++) {
theText[i] = utf8[i];
}
#endif
#if 0
// Set the text in the text layout object, so we can measure it
charCount = strlen(utf8);
theText = (UniChar *) malloc(charCount * sizeof(UniChar));
size_t inBytes = charCount, outBytes = charCount;
iconv_t converter = iconv_open("UTF-8", "UTF-16");
charCount = iconv(converter, utf8, &inBytes, theText, &outBytes);
#endif
err = ATSUCreateTextLayout(&textLayout);
err = ATSUSetTextPointerLocation(textLayout,
theText, 0, charCount, charCount);