Example #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);
             }
         }
     }
 }
Example #2
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;
 }