tokenCount + ", found " + tokens.length);
}
// Use StyleContext to create fonts to get composite fonts for
// Asian glyphs.
StyleContext sc = StyleContext.getDefaultStyleContext();
// Loop through each token style. Format:
// "index,(fg|-),(bg|-),(t|f),((font,style,size)|(-,,))"
for (int i=0; i<tokenTypeCount; i++) {
int pos = i*7 + 1;
int integer = Integer.parseInt(tokens[pos]); // == i
if (integer!=i)
throw new Exception("Expected " + i + ", found " +
integer);
Color fg = null; String temp = tokens[pos+1];
if (!"-".equals(temp)) { // "-" => keep fg as null
fg = stringToColor(temp);
}
Color bg = null; temp = tokens[pos+2];
if (!"-".equals(temp)) { // "-" => keep bg as null
bg = stringToColor(temp);
}
// Check for "true" or "false" since we don't want to
// accidentally suck in an int representing the next
// packed color, and any string != "true" means false.
temp = tokens[pos+3];
if (!"t".equals(temp) && !"f".equals(temp))
throw new Exception("Expected 't' or 'f', found " + temp);
boolean underline = "t".equals(temp);
Font font = null;
String family = tokens[pos+4];
if (!"-".equals(family)) {
font = sc.getFont(family,
Integer.parseInt(tokens[pos+5]), // style
Integer.parseInt(tokens[pos+6])); // size
}
scheme.styles[i] = new Style(fg, bg, font, underline);