icu.8198.revert.icu5431.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. Index: icu/trunk/source/layout/IndicReordering.cpp
  2. ===================================================================
  3. --- icu/trunk/source/layout/IndicReordering.cpp (revision 25772)
  4. +++ icu/trunk/source/layout/IndicReordering.cpp (revision 26090)
  5. @@ -126,4 +126,8 @@
  6. FeatureMask fSMFeatures;
  7. + LEUnicode fPreBaseConsonant;
  8. + LEUnicode fPreBaseVirama;
  9. + le_int32 fPBCIndex;
  10. + FeatureMask fPBCFeatures;
  11. void saveMatra(LEUnicode matra, le_int32 matraIndex, IndicClassTable::CharClass matraClass)
  12. @@ -172,5 +176,6 @@
  13. fMatraFeatures(0), fMPreOutIndex(-1), fMPreFixups(mpreFixups),
  14. fVMabove(0), fVMpost(0), fVMIndex(0), fVMFeatures(0),
  15. - fSMabove(0), fSMbelow(0), fSMIndex(0), fSMFeatures(0)
  16. + fSMabove(0), fSMbelow(0), fSMIndex(0), fSMFeatures(0),
  17. + fPreBaseConsonant(0), fPreBaseVirama(0), fPBCIndex(0), fPBCFeatures(0)
  18. {
  19. // nothing else to do...
  20. @@ -191,4 +196,6 @@
  21. fVMabove = fVMpost = 0;
  22. fSMabove = fSMbelow = 0;
  23. +
  24. + fPreBaseConsonant = fPreBaseVirama = 0;
  25. }
  26. @@ -386,4 +393,12 @@
  27. }
  28. + void notePreBaseConsonant(le_uint32 index,LEUnicode PBConsonant, LEUnicode PBVirama, FeatureMask features)
  29. + {
  30. + fPBCIndex = index;
  31. + fPreBaseConsonant = PBConsonant;
  32. + fPreBaseVirama = PBVirama;
  33. + fPBCFeatures = features;
  34. + }
  35. +
  36. void noteBaseConsonant()
  37. {
  38. @@ -465,4 +480,20 @@
  39. }
  40. + void writePreBaseConsonant()
  41. + {
  42. + // The TDIL spec says that consonant + virama + RRA should produce a rakar in Malayalam. However,
  43. + // it seems that almost none of the fonts for Malayalam are set up to handle this.
  44. + // So, we're going to force the issue here by using the rakar as defined with RA in most fonts.
  45. +
  46. + if (fPreBaseConsonant == 0x0d31) { // RRA
  47. + fPreBaseConsonant = 0x0d30; // RA
  48. + }
  49. +
  50. + if (fPreBaseConsonant != 0) {
  51. + writeChar(fPreBaseConsonant, fPBCIndex, fPBCFeatures);
  52. + writeChar(fPreBaseVirama,fPBCIndex-1,fPBCFeatures);
  53. + }
  54. + }
  55. +
  56. le_int32 getOutputIndex()
  57. {
  58. @@ -723,4 +754,5 @@
  59. }
  60. +
  61. IndicClassTable::CharClass charClass = CC_RESERVED;
  62. IndicClassTable::CharClass nextClass = CC_RESERVED;
  63. @@ -730,7 +762,9 @@
  64. le_bool seenVattu = FALSE;
  65. le_bool seenBelowBaseForm = FALSE;
  66. + le_bool seenPreBaseForm = FALSE;
  67. le_bool hasNukta = FALSE;
  68. le_bool hasBelowBaseForm = FALSE;
  69. le_bool hasPostBaseForm = FALSE;
  70. + le_bool hasPreBaseForm = FALSE;
  71. if (postBase < markStart && classTable->isNukta(chars[postBase])) {
  72. @@ -746,12 +780,20 @@
  73. hasBelowBaseForm = IndicClassTable::hasBelowBaseForm(charClass) && !hasNukta;
  74. hasPostBaseForm = IndicClassTable::hasPostBaseForm(charClass) && !hasNukta;
  75. + hasPreBaseForm = IndicClassTable::hasPreBaseForm(charClass) && !hasNukta;
  76. if (IndicClassTable::isConsonant(charClass)) {
  77. if (postBaseLimit == 0 || seenVattu ||
  78. (baseConsonant > baseLimit && !classTable->isVirama(chars[baseConsonant - 1])) ||
  79. - !(hasBelowBaseForm || hasPostBaseForm)) {
  80. + !(hasBelowBaseForm || hasPostBaseForm || hasPreBaseForm)) {
  81. break;
  82. }
  83. + // Note any pre-base consonants
  84. + if ( baseConsonant == lastConsonant && lastConsonant > 0 &&
  85. + hasPreBaseForm && classTable->isVirama(chars[baseConsonant - 1])) {
  86. + output.notePreBaseConsonant(lastConsonant,chars[lastConsonant],chars[lastConsonant-1],tagArray2);
  87. + seenPreBaseForm = TRUE;
  88. +
  89. + }
  90. // consonants with nuktas are never vattus
  91. seenVattu = IndicClassTable::isVattu(charClass) && !hasNukta;
  92. @@ -786,10 +828,12 @@
  93. // write any pre-base consonants
  94. + output.writePreBaseConsonant();
  95. +
  96. le_bool supressVattu = TRUE;
  97. for (i = baseLimit; i < baseConsonant; i += 1) {
  98. LEUnicode ch = chars[i];
  99. - // Don't put 'blwf' on first consonant.
  100. - FeatureMask features = (i == baseLimit? tagArray2 : tagArray1);
  101. + // Don't put 'pstf' or 'blwf' on anything before the base consonant.
  102. + FeatureMask features = tagArray1 & ~( pstfFeatureMask | blwfFeatureMask );
  103. charClass = classTable->getCharClass(ch);
  104. @@ -842,5 +886,5 @@
  105. // write below-base consonants
  106. - if (baseConsonant != lastConsonant) {
  107. + if (baseConsonant != lastConsonant && !seenPreBaseForm) {
  108. for (i = bcSpan + 1; i < postBase; i += 1) {
  109. output.writeChar(chars[i], i, tagArray1);
  110. @@ -872,5 +916,5 @@
  111. // write post-base consonants
  112. // FIXME: does this put the right tags on post-base consonants?
  113. - if (baseConsonant != lastConsonant) {
  114. + if (baseConsonant != lastConsonant && !seenPreBaseForm) {
  115. if (postBase <= lastConsonant) {
  116. for (i = postBase; i <= lastConsonant; i += 1) {