package com.github.googlei18n.tachyfont;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.GZIPOutputStream;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class GetBase extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    // Get the TachyFont base.
    System.out.println("need to get the font parameter");
    String jarFilename = "fonts/noto/sans/NotoSansJP-Thin.TachyFont.jar";
    JarFile jarFile = new JarFile("WEB-INF/" + jarFilename);
    JarEntry base = jarFile.getJarEntry("base");
    InputStream baseStream = jarFile.getInputStream(base);

    // Send the data.
    byte[] buffer = new byte[4096];
    int bytesRead = 0;
    resp.setContentType("application/x-font-otf");
    OutputStream outputStream = resp.getOutputStream();
//    GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream);
//    resp.setHeader("Content-Encoding", "gzip");
    while ((bytesRead = baseStream.read(buffer)) != -1) {
      outputStream.write(buffer, 0, bytesRead);
    }
//    gzipOutputStream.close();
    jarFile.close();
  }
}

@@ -1,790 +1,1119 @@
-package com.github.googlei18n.tachyfont;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.util.jar.JarEntry;%0Aimport java.util.jar.JarFile;%0Aimport java.util.zip.GZIPOutputStream;%0A%0Aimport javax.servlet.http.*;%0A%0A@SuppressWarnings(%22serial%22)%0Apublic class GetBase extends HttpServlet %7B%0A  @Override%0A  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException %7B%0A    // Get the TachyFont base.%0A    System.out.println(%22need to get the font parameter%22);%0A    String jarFilename = %22fonts/noto/sans/NotoSansJP-Thin.TachyFont.jar%22;%0A    JarFile jarFile = new JarFile(%22WEB-INF/%22 + jarFilename);%0A    JarEntry base = jarFile.getJarEntry(%22base%22);%0A    InputStream baseStream = jarFile.getInputStream(base
+/*%0A * Copyright 2015 Google Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except%0A * in compliance with the License. You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software distributed under the License%0A * is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express%0A * or implied. See the License for the specific language governing permissions and limitations under%0A * the License.%0A */%0Apackage com.github.googlei18n.tachyfont;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0A%0Aimport javax.servlet.http.*;%0A%0A@SuppressWarnings(%22serial%22)%0Apublic class GetBase extends HttpServlet %7B%0A  @Override%0A  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException %7B%0A    // Get the TachyFont base.%0A    String pathInfo = req.getPathInfo();%0A    String%5B%5D pathParts = pathInfo.split(%22/%22);%0A    if (!(%22%22.equals(pathParts%5B0%5D)) %7C%7C !(%22base%22.equals(pathParts%5B2%5D))) %7B%0A      throw new IOException(
 );%0A
-%0A
     
-// Send the data.
+%7D
 %0A   
@@ -1133,51 +1133,112 @@
 r = 
-new byte%5B4096%5D;%0A    int bytesRead = 0;
+TachyFontData.getBase(pathParts%5B1%5D);%0A%0A    // TODO(bstell): Check that the transfer is compressed.
 %0A    
+//
 resp
@@ -1288,70 +1288,55 @@
     
-OutputStream outputStream = resp.getOutputStream(
+resp.setContentType(%22application/binary%22
 );%0A
-//
     
-GZIP
 Outp
@@ -1344,21 +1344,17 @@
 tStream 
-gzipO
+o
 utputStr
@@ -1362,257 +1362,62 @@
 am =
- new GZIPOutputStream(outputStream);%0A//   
  resp.
-setHeader(%22Content-Encoding%22, %22gzip%22);%0A    while ((bytesRead = baseStream.read(buffer)) != -1) %7B%0A      outputStream.write(buffer, 0, bytesRead);%0A    %7D%0A//    gzipOutputStream.close();%0A    jarFile.close(
+getOutputStream();%0A    outputStream.write(buffer
 );%0A 

Use TachyFontData to get the base data. Get the fontname from the request. Add copyright.