Arrays.sort(sourceFiles);
for (int i = 0; i < sourceFiles.length; i++)
{
final String sourceFile = sourceFiles[i];
final FontRecord fontRecord = records.get(sourceFile);
final FontMetrics metrics = metricsFactory.createMetrics(fontRecord.getIdentifier(), context);
writer.writeTag(null, "font-source", "source", sourceFile, false);
/*
<global-metrics ascent="0" descent="0" italic-angle="0" leading="0"
max-ascent="0" max-char-advance="0" max-descent="0" max-height="0"
overline-position="0" strike-through-position="0" underline-position="0" x-height="0"
uniform="false"/>
*/
final AttributeList globalAttrs = new AttributeList();
globalAttrs.setAttribute(null, "ascent", formatText(metrics.getAscent()));
globalAttrs.setAttribute(null, "descent", formatText(metrics.getDescent()));
globalAttrs.setAttribute(null, "italic-angle", formatText(metrics.getItalicAngle()));
globalAttrs.setAttribute(null, "leading", formatText(metrics.getLeading()));
globalAttrs.setAttribute(null, "max-ascent", formatText(metrics.getMaxAscent()));
globalAttrs.setAttribute(null, "max-char-advance", formatText(metrics.getMaxCharAdvance()));
globalAttrs.setAttribute(null, "max-descent", formatText(metrics.getMaxDescent()));
globalAttrs.setAttribute(null, "max-height", formatText(metrics.getMaxHeight()));
globalAttrs.setAttribute(null, "overline-position", formatText(metrics.getOverlinePosition()));
globalAttrs.setAttribute(null, "strike-through-position", formatText(metrics.getStrikeThroughPosition()));
globalAttrs.setAttribute(null, "underline-position", formatText(metrics.getUnderlinePosition()));
globalAttrs.setAttribute(null, "x-height", formatText(metrics.getXHeight()));
globalAttrs.setAttribute(null, "uniform", String.valueOf(metrics.isUniformFontMetrics()));
writer.writeTag(null, "global-metrics", globalAttrs, true);
for (int c = 0; c < 65536; c++)
{
if (c >= 0xD800 && c <= 0xDFFF)
{
// surrogate range is not valid in unicode
continue;
}
final long width = metrics.getCharWidth(c);
if (width == 0)
{
continue;
}
final AttributeList cwList = new AttributeList();
cwList.setAttribute(null, "codepoint", String.valueOf(c));
cwList.setAttribute(null, "value", String.valueOf(width));
writer.writeTag(null, "char-width", cwList, true);
}
for (int c = 0; c < 65536; c++)
{
if (c >= 0xD800 && c <= 0xDFFF)
{
// surrogate range is not valid in unicode
continue;
}
final long width = metrics.getCharWidth(c);
if (width == 0)
{
// if there is no metrics, there is no kerning info
continue;
}
for (int cPrev = 0; cPrev < 65536; cPrev++)
{
if (cPrev >= 0xD800 && cPrev <= 0xDFFF)
{
// surrogate range is not valid in unicode
continue;
}
final long kerning = metrics.getKerning(cPrev, c);
if (kerning == 0)
{
continue;
}
final AttributeList cwList = new AttributeList();