📄 typo.java
字号:
import java.io.*;import javax.servlet.*;import javax.servlet.http.*;
import Acme.JPM.Encoders.GifEncoder;/** * Typo. * @version 1.0 * @author S.H. * @company JavaZOOM. * @date 01/2000. * * Use of this source and binary code is permitted only for non-commercial purposes. * Modification is allowed with this copyright notice and the following disclaimer. *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. */public class typo extends HttpServlet{ public static final String PATH="";
private fontgrabber _fg = null; private fontinfo _fi = null;
private GifEncoder _gifEncoder = null;
/** * Service * Handles GET request-response * @param HttpServletRequest, HttpServletResponse */ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("image/gif"); ServletOutputStream out=res.getOutputStream(); String fontName = req.getParameter("font");
String text = req.getParameter("text");
if ((text != null) && (fontName != null) && (!fontName.equals("")) && (!text.equals("")))
{
String Error = null;
Error = readBitmap(PATH+fontName+".ffi");
if (Error == null)
{
//Transparent => color < 0x08000000
_fg = new fontgrabber(_fi, text.toUpperCase(), 0x07000000);
_gifEncoder=new GifEncoder(_fg.getImageProd(),out);
_gifEncoder.encode(); }
else out.println();
}
else out.println();
}
/** * Reads Bitmap and font descriptor.
*/
private String readBitmap(String fn) {
/*-- Load font descriptor --*/
FileInputStream fis = null;
ObjectInputStream ois = null;
try
{
fis = new FileInputStream(fn);
ois = new ObjectInputStream(fis);
_fi = (fontinfo)ois.readObject();
ois.close();
fis.close();
} catch (Exception e)
{
return "Cannot load font descriptor !";
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -