+ for(FontList::iterator it = fontlist.begin();
+ it != fontlist.end(); ++it) {
+ if (pos >= (*it).pos && pos <= (*it).pos_end) {
+ // found it
+ // we found a font entry. maybe we have to
+ // split it and create a new one
+
+ if ((*it).pos != (*it).pos_end) {
+ // more than one character
+ if (pos == (*it).pos) {
+ // maybe we could enlarge
+ // the left fonttable
+ for(FontList::iterator fit = fontlist.begin();
+ fit != fontlist.end(); ++fit) {
+ if (pos - 1 >= (*fit).pos
+ && pos - 1 <= (*fit).pos_end
+ && (*fit).font == font) {
+ // put the position
+ // under the font
+ (*fit).pos_end++;
+ (*it).pos++;
+ return;
+ }
+ }
+ // Add a new entry in the
+ // fonttable for the position
+ FontTable tmp;
+ tmp.pos = pos + 1;
+ tmp.pos_end = (*it).pos_end;
+ tmp.font = (*it).font;
+ (*it).pos_end = pos;
+ fontlist.push_back(tmp);
+ } else if (pos == (*it).pos_end) {
+ // Add a new entry in the
+ // fonttable for the position
+ FontTable tmp;
+ tmp.pos = (*it).pos;
+ tmp.pos_end = (*it).pos_end - 1;
+ tmp.font = (*it).font;
+ (*it).pos = (*it).pos_end;
+ fontlist.push_back(tmp);
+ } else {
+ // Add a new entry in the
+ // fonttable for the position
+ FontTable tmp;
+ tmp.pos = (*it).pos;
+ tmp.pos_end = pos - 1;
+ tmp.font = (*it).font;
+ fontlist.push_back(tmp);
+
+ tmp.pos = pos + 1;
+ tmp.pos_end = (*it).pos_end;
+ tmp.font = (*it).font;
+ fontlist.push_back(tmp);
+
+ (*it).pos = pos;
+ (*it).pos_end = pos;
+ }
+ }
+ (*it).font = font;
+ return;
+ }
+ }
+
+ // if we did not find a font entry, but if the font at hand
+ // is the same as default, we just forget it
+ if (font == patternfont) return;
+
+ // ok, we did not find a font entry. But maybe there is exactly
+ // the needed font entry one position left
+ for(FontList::iterator it = fontlist.begin();
+ it != fontlist.end(); ++it) {
+ if (pos - 1 >= (*it).pos && pos - 1 <= (*it).pos_end
+ && (*it).font == font) {
+ (*it).pos_end++;
+ return;
+ }
+ }
+ // Add a new entry in the
+ // fonttable for the position
+ FontTable tmp;
+ tmp.pos = pos;
+ tmp.pos_end = pos;
+ tmp.font = patternfont;
+ fontlist.push_back(tmp);
+#else
+ // Next search font table
+ FontTable * tmp2;