示例#1
0
int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        if (n == 0) {
            break;
        }
        int **p = malloc(sizeof(int *) * n);
        int i, j;
        for (i = 0; i != n; i++) {
            p[i] = malloc(sizeof(int) * n);
            for (j = 0; j != n; j++) {
                scanf("%d", &p[i][j]);
            }
        }
        if (isLatin(p, n)) {
            if (isStdLatin(p, n)) {
                printf("%d\n", 2);
            } else {
                printf("%d\n", 1);
            }
        } else {
            printf("%d\n", 0);
        }
        for (i = 0; i != n; i++) {
            free(p[i]);
        }
        free(p);
    }
    return 0;
}
void TransliterateNameVisitor::visit(const shared_ptr<Element>& e)
{
  QStringList names = e->getTags().getNames();

  for (int i = 0; i < names.size(); i++)
  {
    // we found a latin name, no need to do any more work.
    if (isLatin(names[i]))
    {
      return;
    }
  }

  if (names.size() > 0)
  {
    e->getTags().addNote("Transliterated Name: " + Translator::getInstance().toEnglish(names[0]));
  }
}
示例#3
0
void MsgSMS::textChanged()
{
    if (btnSend == NULL)
        return;
    QString msgText = m_edit->m_edit->text();
    if (btnTranslit->isOn())
        msgText = toTranslit(msgText);
    btnSend->setEnabled(!lineEdit()->text().isEmpty() && !msgText.isEmpty());
    unsigned size = msgText.length();
    unsigned max_size = MAX_SMS_LEN_UNICODE;
    if (isLatin(msgText))
        max_size = MAX_SMS_LEN_LATIN1;
    QString status = i18n("Size: %1 / Max. size: %2")
                     .arg(size) .arg(max_size);
    if (size > max_size){
        status += " ! ";
        status += i18n("Message will be split");
    }
    m_edit->m_userWnd->setStatus(status);
}
示例#4
0
int PalFont_RenderText( void         *aContext,
                        unsigned int *aBitmap,
                        int           aBitmapWidth,
                        int           aBitmapHeight,
                        const char   *text,
                        int           textIndex,
                        int           textLength,
                        int          *aPen_x,
                        int          *aPen_y,
                        PalFont_BBox_t*aBBox,
                        int           resetBox ) {
   ft_Context_t *ftContext = FT_CONTEXT( aContext );
   HarfBuzz_t    aHarfBuzz;
   int           err       = 0;
   uint16_t      str[ MAX_CHARS ];
   int           i;
   int           nChars;
   int           isArabic  = 0;
   int           savePenX, savePenY;

   /* firstly convert to UTF-16 in str */
   for ( i = 0; i < MAX_CHARS; i++ ) {
      int aCharCode = getNextUnicodeFromUTF8( ( unsigned char ** )&text );
      if ( aCharCode == 0 ) {
         break;
      }
      str[ i ] = aCharCode;
   }

   /* we cant handle more than MAX_CHARS */
   if ( i == MAX_CHARS ) {
      return -1;
   }

   /* add termination, not sure if needed */
   str[ i ] = '\0';
   nChars   = i;

   /* do we have any Arabic? */
   for ( i = 0; i < nChars; i++ ) {
      if ( code_point_to_script( str[ i ] ) == HB_Script_Arabic ) {
         isArabic = 1;
         break;
      }
   }

   /* if we do then reverse any runs of Latin */
   if ( isArabic != 0 ) {
      int j;
      for ( j = 0 ; j < nChars; ) {
        /* set i to the start of latin */
        for ( i = j; i < nChars; i++ ) {
           if ( isLatin( str[ i ] ) != 0 ) {
              break;
           }
        }
        /* set j to the end of latin + 1 */
        for ( j = i; j < nChars; j++ ) {
           if ( isLatin( str[ j ] ) == 0 ) {
               break;
            }
         }
         reverse_text( str, i, j - i );
      }
   }

   err = Utf16_To_Harfbuzz( aContext, str, nChars, &aHarfBuzz );
   if ( err != 0 ) {
      return err;
   }

   if ( aPen_x != NULL ) {
      savePenX = *aPen_x;
   }

   if ( aPen_y != NULL ) {
      savePenY = *aPen_y;
   }

   err = PalFont_RenderHarfBuzz( ftContext,
                                 aBitmap,
                                 aBitmapWidth,
                                 aBitmapHeight,
                                &aHarfBuzz,
                                 textIndex,
                                 textLength,
                                 aPen_x,
                                 aPen_y,
                                 aBBox,
                                 resetBox,
                                 isArabic,
                                 0 );
   if ( err != 0 ) {
      return err;
   }

   if ( ( ftContext->m_Synth & SynthTwoColor ) != 0 ) {
      resetBox = 0;

      if ( aPen_x != NULL ) {
         *aPen_x = savePenX;
      }

      if ( aPen_y != NULL ) {
         *aPen_y = savePenY;
      }

      err = PalFont_RenderHarfBuzz( ftContext,
                                    aBitmap,
                                    aBitmapWidth,
                                    aBitmapHeight,
                                    &aHarfBuzz,
                                    textIndex,
                                    textLength,
                                    aPen_x,
                                    aPen_y,
                                    aBBox,
                                    resetBox,
                                    isArabic,
                                    1 );
      if ( err != 0 ) {
         return err;
      }
   }
   return 0;
}