+ free( psz_node );
+ }
+ break;
+ case XML_READER_STARTELEM:
+ psz_node = xml_ReaderName( p_xml_reader );
+ if( psz_node )
+ {
+ if( !strcasecmp( "font", psz_node ) )
+ rv = HandleFontAttributes( p_xml_reader, &p_fonts, i_scale );
+ else if( !strcasecmp( "b", psz_node ) )
+ b_bold = true;
+ else if( !strcasecmp( "i", psz_node ) )
+ b_italic = true;
+ else if( !strcasecmp( "u", psz_node ) )
+ b_uline = true;
+ else if( !strcasecmp( "br", psz_node ) )
+ {
+ CFMutableAttributedStringRef p_attrnode = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
+ CFAttributedStringReplaceString( p_attrnode, CFRangeMake(0, 0), CFSTR("\n") );
+
+ GetAttrStrFromFontStack( &p_fonts, b_bold, b_italic, b_uline,
+ CFRangeMake( 0, 1 ),
+ p_attrnode );
+ CFAttributedStringReplaceAttributedString( p_attrString,
+ CFRangeMake(CFAttributedStringGetLength(p_attrString), 0),
+ p_attrnode);
+ CFRelease( p_attrnode );
+ }
+ free( psz_node );
+ }
+ break;
+ case XML_READER_TEXT:
+ psz_node = xml_ReaderValue( p_xml_reader );
+ if( psz_node )
+ {
+ CFStringRef p_cfString;
+ int len;
+
+ // Turn any multiple-whitespaces into single spaces
+ char *s = strpbrk( psz_node, "\t\r\n " );
+ while( s )
+ {
+ int i_whitespace = strspn( s, "\t\r\n " );
+
+ if( i_whitespace > 1 )
+ memmove( &s[1],
+ &s[i_whitespace],
+ strlen( s ) - i_whitespace + 1 );
+ *s++ = ' ';
+
+ s = strpbrk( s, "\t\r\n " );
+ }
+
+
+ CFMutableAttributedStringRef p_attrnode = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
+ p_cfString = CFStringCreateWithCString( NULL, psz_node, kCFStringEncodingUTF8 );
+ CFAttributedStringReplaceString( p_attrnode, CFRangeMake(0, 0), p_cfString );
+ CFRelease( p_cfString );
+ len = CFAttributedStringGetLength( p_attrnode );