Esempio n. 1
0
 void processLine(lString16 & line) {
     if (line.lastChar()=='\r' || line.lastChar()=='\n')
         line.erase(line.length()-1, 1);
     if (state == 0) {
         //
         if (line.startsWith(lString16("%"))) {
             fprintf(out, "%s\n", LCSTR(line));
             return;
         }
         if (line.startsWith(lString16("\\patterns{"))) {
             start();
             return;
         }
     } else {
         lString16 word;
         for (int i=0; i<=line.length(); i++) {
             lChar16 ch = (i<line.length()) ? line[i] : 0;
             if (ch == '}')
                 break;
             if (ch==' ' || ch=='\t' || ch=='%' || ch==0) {
                 if (!word.empty()) {
                     addPattern(word);
                     word.clear();
                 }
                 if (ch!=' ' && ch!='\t')
                     break;
             } else {
                 word.append(1, ch);
             }
         }
     }
 }
Esempio n. 2
0
 void addPattern(lString16 pattern) {
     if (pattern[0] == '.')
         pattern[0] = ' ';
     if (pattern[pattern.length()-1] == '.')
         pattern[pattern.length()-1] = ' ';
     fprintf(out, "  <pattern>%s</pattern>\n", LCSTR(pattern));
 }
Esempio n. 3
0
static void splitFName( lString16 pathname, lString16 & path, lString16 & name )
{
    //
    int spos = -1;
    for ( spos=pathname.length()-1; spos>=0; spos-- ) {
        lChar16 ch = pathname[spos];
        if ( ch=='\\' || ch=='/' ) {
            break;
        }
    }
    if ( spos>=0 ) {
        path = pathname.substr( 0, spos+1 );
        name = pathname.substr( spos+1, pathname.length()-spos-1 );
    } else {
        path.clear();
        name = pathname;
    }
}
Esempio n. 4
0
    TexPattern( const lString16 &s ) : next( NULL )
    {
        memset( word, 0, sizeof(word) );
        memset( attr, '0', sizeof(attr) );
        attr[sizeof(attr)-1] = 0;
        int n = 0;
        for ( int i=0; i<(int)s.length() && n<MAX_PATTERN_SIZE; i++ ) {
            lChar16 ch = s[i];
            if ( ch>='0' && ch<='9' ) {
                attr[n] = (char)ch;
//                if (n>0)
//                    attr[n-1] = (char)ch;
            } else {
                word[n++] = ch;
            }
            if (i==(int)s.length()-1)
                attr[n+1] = 0;
        }
    }
Esempio n. 5
0
 bool setManglingKey(lString16 key) {
     if (key.startsWith(lString16(L"urn:uuid:")))
         key = key.substr(9);
     _fontManglingKey.clear();
     _fontManglingKey.reserve(16);
     lUInt8 b = 0;
     int n = 0;
     for (int i=0; i<key.length(); i++) {
         int d = hexDigit(key[i]);
         if (d>=0) {
             b = (b << 4) | d;
             if (++n > 1) {
                 _fontManglingKey.add(b);
                 n = 0;
                 b = 0;
             }
         }
     }
     return _fontManglingKey.length() == 16;
 }