Cleanup: minor style, Javadoc and code changes

This commit is contained in:
David Kuettel
2013-04-10 18:25:12 -07:00
parent a9ce166190
commit e617737810
8 changed files with 20 additions and 9 deletions
@@ -15,6 +15,7 @@ import com.google.typography.font.sfntly.table.core.HorizontalMetricsTable;
* @author raph@google.com (Raph Levien)
*/
public class AdvWidth {
public static WritableFontData encode(Font font) {
HorizontalMetricsTable hmtx = font.getTable(Tag.hmtx);
int nMetrics = hmtx.numberOfHMetrics();
@@ -17,11 +17,12 @@ import java.util.List;
import java.util.Map;
/**
* @author raph@google.com (Raph Levien)
*
* Experimental CMap encoder, based primarily on writing the _inverse_ encoding.
*
* @author raph@google.com (Raph Levien)
*/
public class CmapEncoder {
public static byte[] encode(Font font) {
int nGlyphs = font.<MaximumProfileTable>getTable(Tag.maxp).numGlyphs();
CMapTable cmapTable = font.getTable(Tag.cmap);
@@ -257,7 +257,7 @@ public class CompressionRunner {
} else if (lastBase.equals("woff")) {
result = toBytes(new WoffWriter().convert(font));
} else if (lastBase.equals("woff2")) {
result = toBytes(new Woff2Writer(lastArgs).convert(srcFont, font));
result = toBytes(new Woff2Writer(lastArgs).convert(font));
} else if (lastBase.equals("eot")) {
result = toBytes(new EOTWriter(true).convert(font));
} else if (lastBase.equals("uncomp")) {
@@ -21,10 +21,10 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author Raph Levien
*
* Implementation of compression of CTF glyph data, as per sections 5.6-5.10 and 6 of the spec.
* This is a hacked-up version with a number of options, for experimenting.
*
* @author Raph Levien
*/
public class GlyfEncoder {
@@ -11,8 +11,11 @@ import java.util.zip.DeflaterOutputStream;
/**
* Simple utility for GZIP compression
*
* @author Raph Levien
*/
public class GzipUtil {
public static byte[] deflate(byte[] bytes) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -11,13 +11,14 @@ import com.google.typography.font.sfntly.data.WritableFontData;
import com.google.typography.font.sfntly.table.Table;
/**
* @author raph@google.com (Raph Levien)
*
* Encoder for "kern" table. This probably won't go in the spec because an even more
* effective technique would be to do class kerning in the GDEF tables, but, even so, I wanted
* to capture the stats.
*
* @author raph@google.com (Raph Levien)
*/
public class KernEncoder {
public static WritableFontData encode(Font font) {
Table kernTable = font.getTable(Tag.kern);
ReadableFontData data = kernTable.readFontData();
@@ -16,6 +16,7 @@ import java.util.List;
* @author raph@google.com (Raph Levien)
*/
public class StatsCollector {
private final List<Double> values;
public StatsCollector() {
@@ -15,7 +15,11 @@ import com.google.typography.font.sfntly.table.core.FontHeaderTable;
import java.util.List;
import java.util.TreeSet;
/**
* @author raph@google.com (Raph Levien)
*/
public class Woff2Writer {
private static final long SIGNATURE = 0x774f4632;
private static final int WOFF2_HEADER_SIZE = 44;
private static final int TABLE_ENTRY_SIZE = 5 * 4;
@@ -25,7 +29,7 @@ public class Woff2Writer {
private final CompressionType compressionType;
private final boolean longForm;
Woff2Writer(String args) {
public Woff2Writer(String args) {
CompressionType compressionType = CompressionType.NONE;
boolean longForm = false;
for (String arg : args.split(",")) {
@@ -85,7 +89,7 @@ public class Woff2Writer {
.put(Tag.intValue(new byte[] {'G', 'S', 'U', 'B'}), 28)
.build();
public WritableFontData convert(Font srcFont, Font font) {
public WritableFontData convert(Font font) {
List<TableDirectoryEntry> entries = createTableDirectoryEntries(font);
int size = computeCompressedFontSize(entries);
WritableFontData writableFontData = WritableFontData.createWritableFontData(size);