Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp

    r561 r769  
    11081108#ifndef NO_OPENTYPE
    11091109static const HB_OpenTypeFeature indic_features[] = {
     1110    { HB_MAKE_TAG('l', 'o', 'c', 'a'), LocaProperty },
    11101111    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
    11111112    { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },
     
    11161117    { HB_MAKE_TAG('h', 'a', 'l', 'f'), HalfFormProperty },
    11171118    { HB_MAKE_TAG('p', 's', 't', 'f'), PostFormProperty },
     1119    { HB_MAKE_TAG('c', 'j', 'c', 't'), ConjunctFormProperty },
    11181120    { HB_MAKE_TAG('v', 'a', 't', 'u'), VattuProperty },
    11191121    { HB_MAKE_TAG('p', 'r', 'e', 's'), PreSubstProperty },
     
    11221124    { HB_MAKE_TAG('p', 's', 't', 's'), PostSubstProperty },
    11231125    { HB_MAKE_TAG('h', 'a', 'l', 'n'), HalantProperty },
     1126    { HB_MAKE_TAG('c', 'a', 'l', 't'), IndicCaltProperty },
    11241127    { 0, 0 }
    11251128};
     
    11491152    QString res;
    11501153    properties = ~properties;
     1154    if (properties & LocaProperty)
     1155        res += "Loca ";
    11511156    if (properties & CcmpProperty)
    11521157        res += "Ccmp ";
     
    11691174    if (properties & PostFormProperty)
    11701175        res += "PostForm ";
     1176    if (properties & ConjunctFormProperty)
     1177        res += "PostForm ";
    11711178    if (properties & VattuProperty)
    11721179        res += "Vattu ";
     
    11831190    if (properties & CligProperty)
    11841191        res += "Clig ";
     1192    if (properties & IndicCaltProperty)
     1193        res += "Calt ";
    11851194    return res;
    11861195}
     
    12971306            int skipped = 0;
    12981307            Position pos = Post;
    1299             for (i = len-1; i > base; i--) {
     1308            for (i = len-1; i >= base; i--) {
    13001309                if (position[i] != Consonant && (position[i] != Control || script == HB_Script_Kannada))
    13011310                    continue;
     1311
     1312                if (i < len-1 && position[i] == Control && position[i+1] == Consonant) {
     1313                    base = i+1;
     1314                    break;
     1315                }
    13021316
    13031317                Position charPosition = indic_position(uc[i]);
     
    15461560        // features we should always apply
    15471561        for (i = 0; i < len; ++i)
    1548             properties[i] = ~(CcmpProperty
     1562            properties[i] = ~(LocaProperty
     1563                              | CcmpProperty
    15491564                              | NuktaProperty
    15501565                              | VattuProperty
     1566                              | ConjunctFormProperty
    15511567                              | PreSubstProperty
    15521568                              | BelowSubstProperty
     
    15541570                              | PostSubstProperty
    15551571                              | HalantProperty
     1572                              | IndicCaltProperty
    15561573                              | PositioningProperties);
    15571574
     1575        // Loca always applies
    15581576        // Ccmp always applies
    15591577        // Init
     
    16121630        // psts always applies
    16131631        // halant always applies
     1632        // calt always applies
    16141633
    16151634#ifdef INDIC_DEBUG
  • trunk/src/3rdparty/harfbuzz/src/harfbuzz-shaper-private.h

    r2 r769  
    5858
    5959typedef enum {
    60     CcmpProperty = 0x1,
    61     InitProperty = 0x2,
    62     IsolProperty = 0x4,
    63     FinaProperty = 0x8,
    64     MediProperty = 0x10,
    65     RligProperty = 0x20,
    66     CaltProperty = 0x40,
    67     LigaProperty = 0x80,
    68     DligProperty = 0x100,
    69     CswhProperty = 0x200,
    70     MsetProperty = 0x400,
     60    LocaProperty = 0x1,
     61    CcmpProperty = 0x2,
     62    InitProperty = 0x4,
     63    IsolProperty = 0x8,
     64    FinaProperty = 0x10,
     65    MediProperty = 0x20,
     66    RligProperty = 0x40,
     67    CaltProperty = 0x80,
     68    LigaProperty = 0x100,
     69    DligProperty = 0x200,
     70    CswhProperty = 0x400,
     71    MsetProperty = 0x800,
    7172
    7273    /* used by indic and myanmar shaper */
    73     NuktaProperty = 0x4,
    74     AkhantProperty = 0x8,
    75     RephProperty = 0x10,
    76     PreFormProperty = 0x20,
    77     BelowFormProperty = 0x40,
    78     AboveFormProperty = 0x80,
    79     HalfFormProperty = 0x100,
    80     PostFormProperty = 0x200,
    81     VattuProperty = 0x400,
    82     PreSubstProperty = 0x800,
    83     BelowSubstProperty = 0x1000,
    84     AboveSubstProperty = 0x2000,
    85     PostSubstProperty = 0x4000,
    86     HalantProperty = 0x8000,
    87     CligProperty = 0x10000
     74    NuktaProperty = 0x8,
     75    AkhantProperty = 0x10,
     76    RephProperty = 0x20,
     77    PreFormProperty = 0x40,
     78    BelowFormProperty = 0x80,
     79    AboveFormProperty = 0x100,
     80    HalfFormProperty = 0x200,
     81    PostFormProperty = 0x400,
     82    ConjunctFormProperty = 0x800,
     83    VattuProperty = 0x1000,
     84    PreSubstProperty = 0x2000,
     85    BelowSubstProperty = 0x4000,
     86    AboveSubstProperty = 0x8000,
     87    PostSubstProperty = 0x10000,
     88    HalantProperty = 0x20000,
     89    CligProperty = 0x40000,
     90    IndicCaltProperty = 0x80000
    8891
    8992} HB_OpenTypeProperty;
  • trunk/src/3rdparty/harfbuzz/tests/shaping/main.cpp

    r561 r769  
    137137}
    138138
    139 void hb_getGlyphMetrics(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics)
     139void hb_getGlyphMetrics(HB_Font, HB_Glyph, HB_GlyphMetrics *metrics)
    140140{
    141141    // ###
     
    143143}
    144144
    145 HB_Fixed hb_getFontMetric(HB_Font font, HB_FontMetric metric)
     145HB_Fixed hb_getFontMetric(HB_Font, HB_FontMetric )
    146146{
    147147    return 0; // ####
     
    170170    void cleanupTestCase();
    171171private slots:
     172    void greek();
     173
    172174    void devanagari();
    173175    void bengali();
     
    204206}
    205207
    206 struct ShapeTable {
    207     unsigned short unicode[16];
    208     unsigned short glyphs[16];
     208class Shaper
     209{
     210public:
     211    Shaper(FT_Face face, HB_Script script, const QString &str);
     212
     213    HB_FontRec hbFont;
     214    HB_ShaperItem shaper_item;
     215    QVarLengthArray<HB_Glyph> hb_glyphs;
     216    QVarLengthArray<HB_GlyphAttributes> hb_attributes;
     217    QVarLengthArray<HB_Fixed> hb_advances;
     218    QVarLengthArray<HB_FixedPoint> hb_offsets;
     219    QVarLengthArray<unsigned short> hb_logClusters;
     220
    209221};
    210222
    211 static bool shaping(FT_Face face, const ShapeTable *s, HB_Script script)
    212 {
    213     QString str = QString::fromUtf16( s->unicode );
    214 
     223Shaper::Shaper(FT_Face face, HB_Script script, const QString &str)
     224{
    215225    HB_Face hbFace = HB_NewFace(face, hb_getSFntTable);
    216226
    217     HB_FontRec hbFont;
    218227    hbFont.klass = &hb_fontClass;
    219228    hbFont.userData = face;
     
    223232    hbFont.y_scale = face->size->metrics.y_scale;
    224233
    225     HB_ShaperItem shaper_item;
    226234    shaper_item.kerning_applied = false;
    227235    shaper_item.string = reinterpret_cast<const HB_UChar16 *>(str.constData());
     
    238246    shaper_item.initialGlyphCount = 0;
    239247
    240     QVarLengthArray<HB_Glyph> hb_glyphs(shaper_item.num_glyphs);
    241     QVarLengthArray<HB_GlyphAttributes> hb_attributes(shaper_item.num_glyphs);
    242     QVarLengthArray<HB_Fixed> hb_advances(shaper_item.num_glyphs);
    243     QVarLengthArray<HB_FixedPoint> hb_offsets(shaper_item.num_glyphs);
    244     QVarLengthArray<unsigned short> hb_logClusters(shaper_item.num_glyphs);
    245248
    246249    while (1) {
     
    264267        if (HB_ShapeItem(&shaper_item))
    265268            break;
    266 
    267269    }
    268270
    269271    HB_FreeFace(hbFace);
     272}
     273
     274
     275static bool decomposedShaping(FT_Face face, HB_Script script, const QChar &ch)
     276{
     277    QString uc = QString().append(ch);
     278    Shaper shaper(face, script, uc);
     279
     280    uc = uc.normalized(QString::NormalizationForm_D);
     281    Shaper decomposed(face, script, uc);
     282
     283    if( shaper.shaper_item.num_glyphs != decomposed.shaper_item.num_glyphs )
     284        goto error;
     285
     286    for (unsigned int i = 0; i < shaper.shaper_item.num_glyphs; ++i) {
     287        if ((shaper.shaper_item.glyphs[i]&0xffffff) != (decomposed.shaper_item.glyphs[i]&0xffffff))
     288            goto error;
     289    }
     290    return true;
     291 error:
     292    QString str = "";
     293    int i = 0;
     294    while (i < uc.length()) {
     295        str += QString("%1 ").arg(uc[i].unicode(), 4, 16);
     296        ++i;
     297    }
     298    qDebug("%s: decomposedShaping of char %4x failed\n    decomposedString: %s\n   nglyphs=%d, decomposed nglyphs %d",
     299           face->family_name,
     300           ch.unicode(), str.toLatin1().data(),
     301           shaper.shaper_item.num_glyphs,
     302           decomposed.shaper_item.num_glyphs);
     303
     304    str = "";
     305    i = 0;
     306    while (i < shaper.shaper_item.num_glyphs) {
     307        str += QString("%1 ").arg(shaper.shaper_item.glyphs[i], 4, 16);
     308        ++i;
     309    }
     310    qDebug("    composed glyph result   = %s", str.toLatin1().constData());
     311    str = "";
     312    i = 0;
     313    while (i < decomposed.shaper_item.num_glyphs) {
     314        str += QString("%1 ").arg(decomposed.shaper_item.glyphs[i], 4, 16);
     315        ++i;
     316    }
     317    qDebug("    decomposed glyph result = %s", str.toLatin1().constData());
     318    return false;
     319}
     320
     321struct ShapeTable {
     322    unsigned short unicode[16];
     323    unsigned short glyphs[16];
     324};
     325
     326static bool shaping(FT_Face face, const ShapeTable *s, HB_Script script)
     327{
     328    Shaper shaper(face, script, QString::fromUtf16( s->unicode ));
    270329
    271330    hb_uint32 nglyphs = 0;
     
    276335    }
    277336
    278     if( nglyphs != shaper_item.num_glyphs )
     337    if( nglyphs != shaper.shaper_item.num_glyphs )
    279338        goto error;
    280339
    281340    for (hb_uint32 i = 0; i < nglyphs; ++i) {
    282         if ((shaper_item.glyphs[i]&0xffffff) != s->glyphs[i])
     341        if ((shaper.shaper_item.glyphs[i]&0xffffff) != s->glyphs[i])
    283342            goto error;
    284343    }
    285344    return true;
    286345 error:
    287     str = "";
     346    QString str = "";
    288347    const unsigned short *uc = s->unicode;
    289348    while (*uc) {
     
    294353           face->family_name,
    295354           str.toLatin1().constData(),
    296            shaper_item.num_glyphs, nglyphs);
     355           shaper.shaper_item.num_glyphs, nglyphs);
    297356
    298357    str = "";
    299358    hb_uint32 i = 0;
    300     while (i < shaper_item.num_glyphs) {
    301         str += QString("%1 ").arg(shaper_item.glyphs[i], 4, 16);
     359    while (i < shaper.shaper_item.num_glyphs) {
     360        str += QString("%1 ").arg(shaper.shaper_item.glyphs[i], 4, 16);
    302361        ++i;
    303362    }
     
    305364    return false;
    306365}
     366
     367
     368void tst_QScriptEngine::greek()
     369{
     370    FT_Face face = loadFace("DejaVuSans.ttf");
     371    if (face) {
     372        for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
     373            QString str;
     374            str.append(uc);
     375            if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) {
     376                //qDebug() << "skipping" << hex << uc;
     377                continue;
     378            }
     379            if (uc == 0x1fc1 || uc == 0x1fed)
     380                continue;
     381            QVERIFY( decomposedShaping(face, HB_Script_Greek, QChar(uc)) );
     382        }
     383        FT_Done_Face(face);
     384    } else {
     385        QSKIP("couln't find DejaVu Sans", SkipAll);
     386    }
     387
     388
     389    face = loadFace("SBL_grk.ttf");
     390    if (face) {
     391        for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
     392            QString str;
     393            str.append(uc);
     394            if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) {
     395                //qDebug() << "skipping" << hex << uc;
     396                continue;
     397            }
     398            if (uc == 0x1fc1 || uc == 0x1fed)
     399                continue;
     400            QVERIFY( decomposedShaping(face, HB_Script_Greek, QChar(uc)) );
     401
     402        }
     403
     404        const ShapeTable shape_table [] = {
     405            { { 0x3b1, 0x300, 0x313, 0x0 },
     406              { 0xb8, 0x3d3, 0x3c7, 0x0 } },
     407            { { 0x3b1, 0x313, 0x300, 0x0 },
     408              { 0xd4, 0x0 } },
     409
     410            { {0}, {0} }
     411        };
     412
     413
     414        const ShapeTable *s = shape_table;
     415        while (s->unicode[0]) {
     416            QVERIFY( shaping(face, s, HB_Script_Greek) );
     417            ++s;
     418        }
     419
     420        FT_Done_Face(face);
     421    } else {
     422        QSKIP("couln't find DejaVu Sans", SkipAll);
     423    }
     424}
     425
    307426
    308427void tst_QScriptEngine::devanagari()
     
    10121131                { { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0x0 },
    10131132                  { 0x2ff, 0x0 } },
     1133                { { 0xd30, 0xd4d, 0x200d, 0xd35, 0xd4d, 0xd35, 0x0 },
     1134                  { 0xf3, 0x350, 0x0 } },
    10141135
    10151136                { {0}, {0} }
Note: See TracChangeset for help on using the changeset viewer.