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

📄 rtfdestinationfonttable.java

📁 源码包含生成 PDF 和 HTML 的类库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		if(ctrlWordData.ctrlWord.equals("fbiminor")) { this.setThemeFont("fbiminor"); result= true; }		// panose		if(ctrlWordData.ctrlWord.equals("panose")) {state = SETTING_PANOSE; result = true; }				// \*\fname		// <font name> #PCDATA		if(ctrlWordData.ctrlWord.equals("fname")) {state = SETTING_FONTNAME; result = true; }		// \*\falt		if(ctrlWordData.ctrlWord.equals("falt")) { state = SETTING_ALTERNATE; result = true; }				// \*\fontemb		if(ctrlWordData.ctrlWord.equals("fontemb")) { state = SETTING_FONT_EMBED; result = true; }		// font type		if(ctrlWordData.ctrlWord.equals("ftnil")) { this.setTrueType("ftnil"); result= true; }		if(ctrlWordData.ctrlWord.equals("fttruetype")) { this.setTrueType("fttruetype"); result= true; }				// \*\fontfile		if(ctrlWordData.ctrlWord.equals("fontemb")) { state = SETTING_FONT_FILE; result = true; }		// codepage		if(ctrlWordData.ctrlWord.equals("cpg")) { this.setCodePage(ctrlWordData.param); result= true; }				this.lastCtrlWord = ctrlWordData;		return result;	}	/**	 * Set the code page	 * @param value The code page value	 * 	 * @since 2.0.8	 */	public void setCodePage(String value) {		this.cpg = value;	}	/**	 * Set the TrueTtype type	 * @param value The type	 * 	 * @since 2.0.8	 */	public void setTrueType(String value) {		this.trueType = value;	}	/**	 * Set the font pitch	 * @param value Pitch value	 * 	 * @since 2.0.8	 */	public void setPitch(String value) {		this.fprq = Integer.parseInt(value);	}	/**	 * Set the font bias	 * @param value Bias value	 * 	 * @since 2.0.8	 */	public void setBias(String value) {		this.fbias = Integer.parseInt(value);	}	/**	 * Set the font theme	 * 	 * @param themeFont Theme value	 * 	 * @since 2.0.8	 */	public void setThemeFont(String themeFont) {		this.themeFont = themeFont;	}	/**	 * Set the font name to the parsed value.	 * 	 * @param fontName The font name.	 * 	 * @since 2.0.8	 */	public void setFontName(String fontName) {		this.fontName = fontName;	}	/**	 * Set the font family to the parsed value.	 * 	 * @param fontFamily The font family.	 * 	 * @since 2.0.8	 */	public void setFontFamily(String fontFamily) {		this.fontFamily = fontFamily;	}	/**	 * Set the font number to the parsed value.	 * This is used for mapping fonts to the new font numbers	 * 	 * @param fontNr The font number.	 * 	 * @since 2.0.8	 */	public void setFontNumber(String fontNr) {		this.fontNr = fontNr;	}	/**	 * Set the alternate font name.	 * 	 * @param fontAlternate The falt font value	 * 	 * @since 2.0.8	 */	public void setFontAlternate(String fontAlternate) {		this.falt = fontAlternate;	}	/**	 * Set the character-set to the parsed value.	 * 	 * @param charset The charset value	 * 	 * @since 2.0.8	 */	public void setCharset(String charset) {		if(charset.length() == 0) {			charset = CHARSET_DEFAULT;		}		this.charset = charset;	}	/* (non-Javadoc)	 * @see com.lowagie.text.rtf.direct.RtfDestination#setDefaults()	 * 	 * @since 2.0.8	 */	public void setToDefaults() {		this.themeFont = "";		this.fontNr = "";		this.fontName = "";		this.fontFamily = "";				this.charset = "";		this.fprq = 0;		this.panose = "";		this.nontaggedname = "";		this.falt = "";		this.fontemb = "";		this.fontType = "";		this.fontFile = "";		this.fontFileCpg = "";		this.fbias = 0;		this.cpg = "";		this.trueType = "";		this.state = SETTING_NORMAL;	}	/**	 * Process the font information that was parsed from the input.	 * 	 * @since 2.0.8	 */	private void processFont() {		this.fontName = this.fontName.trim();		if(fontName.length() == 0) return;		if(fontNr.length() == 0) return;				if(fontName.length()>0 && fontName.indexOf(';') >= 0) {			fontName = fontName.substring(0,fontName.indexOf(';'));		}		if(this.rtfParser.isImport()) {			//TODO: If primary font fails, use the alternate				//TODO: Problem: RtfFont defaults family to \froman and doesn't allow any other family.				// if you set the family, it changes the font name and not the family in the Font.java class.					//			if(this.fontFamily.length() > 0) {	//				if(this.importHeader.importFont(this.fontNr, this.fontName, this.fontFamily, Integer.parseInt(this.charset)) == false) {	//					if(this.falt.length() > 0) {	//						this.importHeader.importFont(this.fontNr, this.falt, this.fontFamily, Integer.parseInt(this.charset));	//					}	//				}	//			} else {					if(!this.importHeader.importFont(this.fontNr, this.fontName, Integer.parseInt("".equals(this.charset)?CHARSET_DEFAULT:this.charset))) {						if(this.falt.length() > 0) {							this.importHeader.importFont(this.fontNr, this.falt, Integer.parseInt("".equals(this.charset)?CHARSET_DEFAULT:this.charset));						}					}	//			}			}		if(this.rtfParser.isConvert()) {			// This could probably be written as a better font matching function						String fName = this.fontName;	// work variable for trimming name if needed.			Font f1 = createfont(fName);			if(f1.getBaseFont() == null && this.falt.length()>0)				f1 = createfont(this.falt);						if(f1.getBaseFont() == null) {				// Did not find a font, let's try a substring of the first name.				if(FontFactory.COURIER.indexOf(fName) > -1 ) {					f1 = FontFactory.getFont(FontFactory.COURIER);				} else if(FontFactory.HELVETICA.indexOf(fName) > -1 ) {					f1 = FontFactory.getFont(FontFactory.HELVETICA);				} else if(FontFactory.TIMES.indexOf(fName) > -1 ) {					f1 = FontFactory.getFont(FontFactory.TIMES);				} else if(FontFactory.SYMBOL.indexOf(fName) > -1 ) {					f1 = FontFactory.getFont(FontFactory.SYMBOL);				} else if(FontFactory.ZAPFDINGBATS.indexOf(fName) > -1 ) {					f1 = FontFactory.getFont(FontFactory.ZAPFDINGBATS);				} else {					// we did not find a matching font in any form.					// default to HELVETICA for now.					f1 = FontFactory.getFont(FontFactory.HELVETICA);				}			}			fontMap.put(this.fontNr, f1);			//System.out.println(f1.getFamilyname());		}		this.setToDefaults();	}	/**	 * Create a font via the <code>FontFactory</code>	 * 	 * @param fontName The font name to create	 * @return The created <code>Font</code> object	 * 	 * @since 2.0.8	 */	private Font createfont(String fontName) {		Font f1 = null;		int pos=-1;		do {			f1 = FontFactory.getFont(fontName);						if(f1.getBaseFont() != null) break;	// found a font, exit the do/while						pos = fontName.lastIndexOf(' ');	// find the last space			if(pos>0) {				fontName = fontName.substring(0, pos );	// truncate it to the last space			}		} while(pos>0);		return f1;	}	/**	 * Get a <code>Font</code> object from the font map object	 * 	 * @param key The font number to get	 * @return The mapped <code>Font</code> object.	 * 	 * @since 2.0.8	 */	public Font getFont(String key) {		return (Font) fontMap.get(key);	}	/**	 * Load system fonts into the static <code>FontFactory</code> object	 * 	 * @since 2.0.8	 */	private void importSystemFonts() {		Properties pr = null;		try {			pr = getEnvironmentVariables();		} catch (Throwable e) {		}		String systemRoot = pr.getProperty("SystemRoot");		Runtime runtime = Runtime.getRuntime();		String fileSeperator = System.getProperty("file.separator");		int r = FontFactory.registerDirectory(systemRoot + fileSeperator + "fonts");	}		/**	 * Utility method to load the environment variables.	 * 	 * @return Properties object with environment variable information	 * @throws Throwable	 * 	 * @since 2.0.8	 */	 private Properties getEnvironmentVariables() throws Throwable {		Properties environmentVariables = new Properties();		String operatingSystem = System.getProperty("os.name").toLowerCase();		Runtime runtime = Runtime.getRuntime();		Process process = null;		if (operatingSystem.indexOf("windows 95") > -1				|| operatingSystem.indexOf("windows 98") > -1				|| operatingSystem.indexOf("me") > -1) {			process = runtime.exec("command.com /c set");		} else if ((operatingSystem.indexOf("nt") > -1)				|| (operatingSystem.indexOf("windows 2000") > -1)				|| (operatingSystem.indexOf("windows xp") > -1)				|| (operatingSystem.indexOf("windows 2003") > -1)) {			process = runtime.exec("cmd.exe /c set");		} else {			process = runtime.exec("env");		}		BufferedReader environmentStream = new BufferedReader(new InputStreamReader(process.getInputStream()));		String inputLine = "";		int idx = -1;		while ((inputLine = environmentStream.readLine()) != null) {			idx = inputLine.indexOf('=');			environmentVariables.setProperty(inputLine.substring(0, idx),					inputLine.substring(idx + 1));		}		return environmentVariables;	}}

⌨️ 快捷键说明

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