+2005-02-25 Richard Williamson <rjw@apple.com>
+
+ Fixed <rdar://problem/4000962> 8A375: Help Viewer displays voiced sound and semi-voiced characters strangely (characters don't seem to be composed)
+
+ Added special case for voiced marks.
+
+ Reviewed by John.
+
+ * WebCoreSupport.subproj/WebTextRenderer.m:
+ (widthForNextCharacter):
+
2005-02-25 Darin Adler <darin@apple.com>
Reviewed by John.
#import <float.h>
#import <unicode/uchar.h>
+#import <unicode/unorm.h>
// FIXME: FATAL_ALWAYS seems like a bad idea; lets stop using it.
return delta;
}
+// According to http://www.unicode.org/Public/UNIDATA/UCD.html#Canonical_Combining_Class_Values
+#define HIRAGANA_KATAKANA_VOICING_MARKS 8
+
// Return INVALID_WIDTH if an error is encountered or we're at the end of the range in the run.
static float widthForNextCharacter(CharacterWidthIterator *iterator, ATSGlyphRef *glyphUsed, NSFont **fontUsed)
{
}
}
}
+
+ // Deal with Hiragana and Katakana voiced and semi-voiced syllables. Normalize into
+ // composed form, and then look for glyph with base + combined mark.
+ if (c >= 0x3041 && c <= 0x30FE) { // Early out to minimize performance impact. Do we have a Hiragana/Katakana character?
+ if (currentCharacter < (unsigned)run->to) {
+ UnicodeChar nextCharacter = run->characters[currentCharacter+1];
+ if (u_getCombiningClass(nextCharacter) == HIRAGANA_KATAKANA_VOICING_MARKS) {
+ UChar normalizedCharacters[2] = { 0, 0 };
+ UErrorCode uStatus = 0;
+ int32_t resultLength;
+
+ // Normalize into composed form using 3.2 rules.
+ resultLength = unorm_normalize(&run->characters[currentCharacter], 2,
+ UNORM_NFC, UNORM_UNICODE_3_2,
+ &normalizedCharacters[0], 2,
+ &uStatus);
+ if (resultLength == 1 && uStatus == 0){
+ c = normalizedCharacters[0];
+ clusterLength = 2;
+ }
+ }
+ }
+ }
if (style->rtl) {
c = u_charMirror(c);
}
+
if (c <= 0xFFFF) {
*glyphUsed = glyphForCharacter(renderer->characterToGlyphMap, c, fontUsed);
if (*glyphUsed == nonGlyphID) {
// Now that we have glyph and font, get its width.
WebGlyphWidth width = widthForGlyph(renderer, *glyphUsed, *fontUsed);
-
+
// We special case spaces in two ways when applying word rounding.
// First, we round spaces to an adjusted width in all fonts.
// Second, in fixed-pitch fonts we ensure that all characters that