⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtfdestinationfonttable.java

📁 源码包含生成 PDF 和 HTML 的类库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $Id: RtfDestinationFontTable.java 3373 2008-05-12 16:21:24Z xlv $ * * Copyright 2007 by Howard Shank (hgshank@yahoo.com) * * The contents of this file are subject to the Mozilla Public License Version 1.1 * (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the License. * * The Original Code is 'iText, a free JAVA-PDF library'. * * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by * the Initial Developer are Copyright (C) 1999-2006 by Bruno Lowagie. * All Rights Reserved. * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer * are Copyright (C) 2000-2006 by Paulo Soares. All Rights Reserved. * * Contributor(s): all the names of the contributors are added in the source code * where applicable. * * Alternatively, the contents of this file may be used under the terms of the * LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the * provisions of LGPL are applicable instead of those above.  If you wish to * allow use of your version of this file only under the terms of the LGPL * License and not to allow others to use your version of this file under * the MPL, indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by the LGPL. * If you do not delete the provisions above, a recipient may use your version * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. * * This library is free software; you can redistribute it and/or modify it * under the terms of the MPL as stated above or under the terms of the GNU * Library General Public License as published by the Free Software Foundation; * either version 2 of the License, or any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more * details. * * If you didn't download this code from the following link, you should check if * you aren't using an obsolete version: * http://www.lowagie.com/iText/ */ package com.lowagie.text.rtf.parser.destinations;import java.io.BufferedReader;import java.io.InputStreamReader;import java.util.HashMap;import java.util.Properties;import com.lowagie.text.Font;import com.lowagie.text.FontFactory;import com.lowagie.text.rtf.parser.RtfImportMgr;import com.lowagie.text.rtf.parser.RtfParser;import com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordData;/** * <code>RtfDestinationFontTable</code> handles data destined for the font table destination *  * @author Howard Shank (hgshank@yahoo.com) * * @since 2.0.8 */public final class RtfDestinationFontTable extends RtfDestination {	/**	 * The RtfImportHeader to add font mappings to.	 */	private RtfImportMgr importHeader = null;	/**	 * The theme (Office 2007)	 */	private String themeFont = "";	/**	 * The number of the font being parsed.	 */	private String fontNr = "";	/**	 * The family of the font being parsed.	 */	private String fontFamily = "";	/**	 * The \charset value	 */	private String charset = "";	private static final String CHARSET_DEFAULT = "0";	/**	 * The \fprq	 */	private int fprq = 0;	/**	 * The \*\panose font matching value if primary font is not available.	 */	private String panose = "";	/**	 * The \*\fname	 */	private String nontaggedname = "";	/**	 * The name of the font being parsed.	 */	private String fontName = "";	/**	 * The \falt alternate font if primary font is not available.	 */	private String falt = "";	/**	 * The \falt alternate font if primary font is not available.	 */	private String fontemb = "";	/**	 * The \falt alternate font if primary font is not available.	 */	private String fontType = "";	/**	 * The \falt alternate font if primary font is not available.	 */	private String fontFile = "";	/**	 * The \falt alternate font if primary font is not available.	 */	private String fontFileCpg = "";	/**	 * The \fbias value	 */	private int fbias = 0;	/**	 * The \cpg value	 */	private String cpg = "";	/**	 * The \fnil, \fttruetype value	 */	private String trueType = "";	/**	 * state flag to handle different parsing of a font element	 */	private int state = 0;	/* state values */	/** Normal 	 */	private static final int SETTING_NORMAL = 0;	/** \falt 	 */	private static final int SETTING_ALTERNATE = 1;	/** \fname 	 */	private static final int SETTING_FONTNAME = 2;	/** \panose 	 */	private static final int SETTING_PANOSE = 3;	/** \fontemb	*/	private static final int SETTING_FONT_EMBED = 4;	/** \ffile  */	private static final int SETTING_FONT_FILE = 5;		/**	 * Convert font mapping to <code>FontFactory</code> font objects.	 */	private HashMap fontMap = null;		/**	 * Constructor	 */	public RtfDestinationFontTable() {		super(null);	}	/**	 * Constructs a new RtfFontTableParser.	 * 	 * @param parser an RtfParser.	 * 	 * @since 2.0.8	 */	public RtfDestinationFontTable(RtfParser parser) {		super(parser);		this.init(true);	}		/* (non-Javadoc)	 * @see com.lowagie.text.rtf.parser.destinations.RtfDestination#setParser(com.lowagie.text.rtf.parser.RtfParser)	 * 	 * @since 2.0.8	 */	public void setParser(RtfParser parser) {		if(this.rtfParser != null && this.rtfParser.equals(parser)) return;		this.rtfParser = parser;		this.init(true);	}	/**	 * Initialize the object.	 * 	 * @param importFonts true to import the fonts into the FontFactory, false do not load fonts	 * 	 * @since 2.0.8	 */	private void init(boolean importFonts) {		fontMap = new HashMap();		if(this.rtfParser != null) {			this.importHeader = this.rtfParser.getImportManager();		}		this.setToDefaults();		if(importFonts) {			importSystemFonts();		}	}	/* (non-Javadoc)	 * @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleOpenNewGroup()	 * 	 * @since 2.0.8	 */	public boolean handleOpeningSubGroup() {		return true;	}	/* (non-Javadoc)	 * @see com.lowagie.text.rtf.direct.RtfDestination#closeDestination()	 * 	 * @since 2.0.8	 */	public boolean closeDestination() {		return true;	}	/* (non-Javadoc)	 * @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()	 * 	 * @since 2.0.8	 */	public boolean handleCloseGroup() {		if(this.state == SETTING_NORMAL) {			processFont();		}		this.state = SETTING_NORMAL;		return true;	}	/* (non-Javadoc)	 * @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupStart()	 * 	 * @since 2.0.8	 */	public boolean handleOpenGroup() {		return true;	}		/* (non-Javadoc)	 * @see com.lowagie.text.rtf.direct.RtfDestination#handleCharacter(char[])	 * 	 * @since 2.0.8	 */	public boolean handleCharacter(int ch) {		switch(this.state) {		case SETTING_NORMAL:			this.fontName += (char)ch;			break;		case SETTING_ALTERNATE:			this.falt += (char)ch;			break;		case SETTING_PANOSE:			this.panose += (char)ch;			break;		case SETTING_FONT_EMBED:			break;		case SETTING_FONT_FILE:			break;		case SETTING_FONTNAME:			break;					}		return true;	}	/* (non-Javadoc)	 * @see com.lowagie.text.rtf.parser.destinations.RtfDestination#handleControlWord(com.lowagie.text.rtf.parser.ctrlwords.RtfCtrlWordData)	 * 	 * @since 2.0.8	 */	public boolean handleControlWord(RtfCtrlWordData ctrlWordData) {		boolean result = true;		// just let fonttbl fall through and set last ctrl word object.				if(ctrlWordData.ctrlWord.equals("f")) { this.setFontNumber(ctrlWordData.param); result=true;}		if(ctrlWordData.ctrlWord.equals("fcharset")) { this.setCharset(ctrlWordData.param); result=true; }		// font families		if(ctrlWordData.ctrlWord.equals("fnil")) { this.setFontFamily("roman"); result=true; }		if(ctrlWordData.ctrlWord.equals("froman")) { this.setFontFamily("roman"); result=true; }		if(ctrlWordData.ctrlWord.equals("fswiss")) { this.setFontFamily("swiss"); result=true; }		if(ctrlWordData.ctrlWord.equals("fmodern")) { this.setFontFamily("modern"); result=true; }		if(ctrlWordData.ctrlWord.equals("fscript")) { this.setFontFamily("script"); result=true; }		if(ctrlWordData.ctrlWord.equals("fdecor")) { this.setFontFamily("decor"); result=true; }		if(ctrlWordData.ctrlWord.equals("ftech")) { this.setFontFamily("tech"); result=true; }		if(ctrlWordData.ctrlWord.equals("fbidi")) { this.setFontFamily("bidi"); result=true; }		// pitch		if(ctrlWordData.ctrlWord.equals("fprq")) { this.setPitch(ctrlWordData.param); result=true; }		// bias		if(ctrlWordData.ctrlWord.equals("fbias")) { this.setBias(ctrlWordData.param); result=true; }		// theme font information		if(ctrlWordData.ctrlWord.equals("flomajor")) { this.setThemeFont("flomajor"); result= true; }		if(ctrlWordData.ctrlWord.equals("fhimajor")) { this.setThemeFont("fhimajor"); result= true; }		if(ctrlWordData.ctrlWord.equals("fdbmajor")) { this.setThemeFont("fdbmajor"); result= true; }		if(ctrlWordData.ctrlWord.equals("fbimajor")) { this.setThemeFont("fbimajor"); result= true; }		if(ctrlWordData.ctrlWord.equals("flominor")) { this.setThemeFont("flominor"); result= true; }		if(ctrlWordData.ctrlWord.equals("fhiminor")) { this.setThemeFont("fhiminor"); result= true; }		if(ctrlWordData.ctrlWord.equals("fdbminor")) { this.setThemeFont("fdbminor"); result= true; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -