jdk/src/share/native/sun/font/layout/LayoutEngine.cpp
changeset 16889 3df90f344221
parent 8743 1d5b09a99c81
child 16890 36b30720a997
equal deleted inserted replaced
16888:4a32a7e572d1 16889:3df90f344221
    31  */
    31  */
    32 
    32 
    33 #include "LETypes.h"
    33 #include "LETypes.h"
    34 #include "LEScripts.h"
    34 #include "LEScripts.h"
    35 #include "LELanguages.h"
    35 #include "LELanguages.h"
       
    36 #include "LESwaps.h"
    36 
    37 
    37 #include "LayoutEngine.h"
    38 #include "LayoutEngine.h"
    38 #include "ArabicLayoutEngine.h"
    39 #include "ArabicLayoutEngine.h"
    39 #include "CanonShaping.h"
    40 #include "CanonShaping.h"
    40 #include "HanLayoutEngine.h"
    41 #include "HanLayoutEngine.h"
    42 #include "IndicLayoutEngine.h"
    43 #include "IndicLayoutEngine.h"
    43 #include "KhmerLayoutEngine.h"
    44 #include "KhmerLayoutEngine.h"
    44 #include "ThaiLayoutEngine.h"
    45 #include "ThaiLayoutEngine.h"
    45 #include "TibetanLayoutEngine.h"
    46 #include "TibetanLayoutEngine.h"
    46 #include "GXLayoutEngine.h"
    47 #include "GXLayoutEngine.h"
       
    48 #include "GXLayoutEngine2.h"
       
    49 
    47 #include "ScriptAndLanguageTags.h"
    50 #include "ScriptAndLanguageTags.h"
    48 #include "CharSubstitutionFilter.h"
    51 #include "CharSubstitutionFilter.h"
    49 
    52 
    50 #include "LEGlyphStorage.h"
    53 #include "LEGlyphStorage.h"
    51 
    54 
    60 
    63 
    61 U_NAMESPACE_BEGIN
    64 U_NAMESPACE_BEGIN
    62 
    65 
    63 /* Leave this copyright notice here! It needs to go somewhere in this library. */
    66 /* Leave this copyright notice here! It needs to go somewhere in this library. */
    64 static const char copyright[] = U_COPYRIGHT_STRING;
    67 static const char copyright[] = U_COPYRIGHT_STRING;
       
    68 
       
    69 /* TODO: remove these? */
       
    70 const le_int32 LayoutEngine::kTypoFlagKern = LE_Kerning_FEATURE_FLAG;
       
    71 const le_int32 LayoutEngine::kTypoFlagLiga = LE_Ligatures_FEATURE_FLAG;
    65 
    72 
    66 const LEUnicode32 DefaultCharMapper::controlChars[] = {
    73 const LEUnicode32 DefaultCharMapper::controlChars[] = {
    67     0x0009, 0x000A, 0x000D,
    74     0x0009, 0x000A, 0x000D,
    68     /*0x200C, 0x200D,*/ 0x200E, 0x200F,
    75     /*0x200C, 0x200D,*/ 0x200E, 0x200F,
    69     0x2028, 0x2029, 0x202A, 0x202B, 0x202C, 0x202D, 0x202E,
    76     0x2028, 0x2029, 0x202A, 0x202B, 0x202C, 0x202D, 0x202E,
   249     if (offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
   256     if (offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
   250         success = LE_ILLEGAL_ARGUMENT_ERROR;
   257         success = LE_ILLEGAL_ARGUMENT_ERROR;
   251         return 0;
   258         return 0;
   252     }
   259     }
   253 
   260 
   254     if ((fTypoFlags & 0x4) == 0) { // no canonical processing
   261     if ((fTypoFlags & LE_NoCanon_FEATURE_FLAG) == 0) { // no canonical processing
   255       return count;
   262       return count;
   256     }
   263     }
   257 
   264 
   258     const GlyphSubstitutionTableHeader *canonGSUBTable = (GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
   265     const GlyphSubstitutionTableHeader *canonGSUBTable = (GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
   259     LETag scriptTag  = OpenTypeLayoutEngine::getScriptTag(fScriptCode);
   266     LETag scriptTag  = OpenTypeLayoutEngine::getScriptTag(fScriptCode);
   570 
   577 
   571 LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, LEErrorCode &success)
   578 LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, LEErrorCode &success)
   572 {
   579 {
   573     static const le_uint32 gsubTableTag = LE_GSUB_TABLE_TAG;
   580     static const le_uint32 gsubTableTag = LE_GSUB_TABLE_TAG;
   574     static const le_uint32 mortTableTag = LE_MORT_TABLE_TAG;
   581     static const le_uint32 mortTableTag = LE_MORT_TABLE_TAG;
       
   582     static const le_uint32 morxTableTag = LE_MORX_TABLE_TAG;
   575 
   583 
   576     if (LE_FAILURE(success)) {
   584     if (LE_FAILURE(success)) {
   577         return NULL;
   585         return NULL;
   578     }
   586     }
   579 
   587 
   606 
   614 
   607         case arabScriptCode:
   615         case arabScriptCode:
   608             result = new ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success);
   616             result = new ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success);
   609             break;
   617             break;
   610 
   618 
       
   619         case hebrScriptCode:
       
   620             // Disable hebrew ligatures since they have only archaic uses, see ticket #8318
       
   621             result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags & ~kTypoFlagLiga, gsubTable, success);
       
   622             break;
       
   623 
   611         case hangScriptCode:
   624         case hangScriptCode:
   612             result = new HangulOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success);
   625             result = new HangulOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success);
   613             break;
   626             break;
   614 
   627 
   615         case haniScriptCode:
   628         case haniScriptCode:
   644         default:
   657         default:
   645             result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success);
   658             result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success);
   646             break;
   659             break;
   647         }
   660         }
   648     } else {
   661     } else {
   649         const MorphTableHeader *morphTable = (MorphTableHeader *) fontInstance->getFontTable(mortTableTag);
   662         MorphTableHeader2 *morxTable = (MorphTableHeader2 *)fontInstance->getFontTable(morxTableTag);
   650 
   663         if (morxTable != NULL) {
   651         if (morphTable != NULL) {
   664             result = new GXLayoutEngine2(fontInstance, scriptCode, languageCode, morxTable, typoFlags, success);
   652             result = new GXLayoutEngine(fontInstance, scriptCode, languageCode, morphTable, success);
       
   653         } else {
   665         } else {
   654             switch (scriptCode) {
   666             const MorphTableHeader *mortTable = (MorphTableHeader *) fontInstance->getFontTable(mortTableTag);
   655             case bengScriptCode:
   667             if (mortTable != NULL) { // mort
   656             case devaScriptCode:
   668                 result = new GXLayoutEngine(fontInstance, scriptCode, languageCode, mortTable, success);
   657             case gujrScriptCode:
   669             } else {
   658             case kndaScriptCode:
   670                 switch (scriptCode) {
   659             case mlymScriptCode:
   671                     case bengScriptCode:
   660             case oryaScriptCode:
   672                     case devaScriptCode:
   661             case guruScriptCode:
   673                     case gujrScriptCode:
   662             case tamlScriptCode:
   674                     case kndaScriptCode:
   663             case teluScriptCode:
   675                     case mlymScriptCode:
   664             case sinhScriptCode:
   676                     case oryaScriptCode:
   665             {
   677                     case guruScriptCode:
   666                 result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
   678                     case tamlScriptCode:
   667                 break;
   679                     case teluScriptCode:
   668             }
   680                     case sinhScriptCode:
       
   681                     {
       
   682                         result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
       
   683                         break;
       
   684                     }
   669 
   685 
   670             case arabScriptCode:
   686             case arabScriptCode:
   671             //case hebrScriptCode:
   687             //case hebrScriptCode:
   672                 result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
   688                 result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
   673                 break;
   689                 break;
   681 
   697 
   682             case hangScriptCode:
   698             case hangScriptCode:
   683                 result = new HangulOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
   699                 result = new HangulOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
   684                 break;
   700                 break;
   685 
   701 
   686             default:
   702                     default:
   687                 result = new LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
   703                         result = new LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
   688                 break;
   704                         break;
       
   705                 }
   689             }
   706             }
   690         }
   707         }
   691     }
   708     }
   692 
   709 
   693     if (result && LE_FAILURE(success)) {
   710     if (result && LE_FAILURE(success)) {