COSDocument cDoc = this.handler.getDocument().getDocument();
// ---- both elements are an array
if (!COSUtils.isArray(this.fontBBox, cDoc)) {
this.fontContainer
.addError(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
"The FontBBox element isn't an array"));
return false;
}
if (!COSUtils.isArray(this.fontMatrix, cDoc)) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_DICTIONARY_INVALID,
"The FontMatrix element isn't an array"));
return false;
}
// ---- check the content of the FontBBox.
// ---- Should be an array with 4 numbers
COSArray bbox = COSUtils.getAsArray(fontBBox, cDoc);
if (bbox.size() != 4) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_DICTIONARY_INVALID, "The FontBBox element is invalid"));
return false;
} else {
for (int i = 0; i < 4; i++) {
COSBase elt = bbox.get(i);
if (!(COSUtils.isFloat(elt, cDoc) || COSUtils.isInteger(elt, cDoc))) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_DICTIONARY_INVALID,
"An element of FontBBox isn't a number"));
return false;
}
}
}
// ---- check the content of the FontMatrix.
// ---- Should be an array with 6 numbers
COSArray matrix = COSUtils.getAsArray(fontMatrix, cDoc);
if (matrix.size() != 6) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_DICTIONARY_INVALID, "The FontMatrix element is invalid"));
return false;
} else {
for (int i = 0; i < 6; i++) {
COSBase elt = matrix.get(i);
if (!(COSUtils.isFloat(elt, cDoc) || COSUtils.isInteger(elt, cDoc))) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_DICTIONARY_INVALID,
"An element of FontMatrix isn't a number"));
return false;
}
}