Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER Copyright 2010 IBM. All rights reserved. Use is subject to license terms. Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0. You can also obtain a copy of the License at http://odftoolkit.org/docs/license.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package org.odftoolkit.simple.style;
 
 
This class represents the font style settings, including font family name, font style, size, front color.

Since:
0.3
 
 public class Font {
 
 	String familyName// svg:font-family
 	String fontName// style:name @ <style:font-face>
 	StyleTypeDefinitions.TextLinePosition textLinePosition//style:text-line-through-style and style:text-underline-style
 	// fo:font-weight
 	double size// fo:font-size
 	// Locale language;
Create a font with specific family name, font style, and size.

Parameters:
fontFamilyName - the family name
simpleFontStyle - the font style
fontSize - the size
 
 	public Font(String fontFamilyNameStyleTypeDefinitions.FontStyle simpleFontStyledouble fontSize) {
 		this. = fontFamilyName;
 		this. = simpleFontStyle;
 		this. = fontSize;
 	}

Create a font with specific family name, font style, size and line position.

Parameters:
fontFamilyName - the family name
simpleFontStyle - the font style
fontSize - the size
textLinePosition - the line position
 
 	public Font(String fontFamilyNameStyleTypeDefinitions.FontStyle simpleFontStyledouble fontSizeStyleTypeDefinitions.TextLinePosition textLinePosition) {
 		this. = fontFamilyName;
 		this. = simpleFontStyle;
 		this. = textLinePosition;
 		this. = fontSize;
 	}

Create a font with specific family name, style, size, and front color.

Parameters:
fontFamilyName - the family name
simpleFontStyle - the font style
fontSize - the size
color - the front color
 
 	public Font(String fontFamilyNameStyleTypeDefinitions.FontStyle simpleFontStyledouble fontSizeColor color) {
 		this. = fontFamilyName;
 		this. = simpleFontStyle;
 		this. = fontSize;
 		this. = color;
 	}

Create a font with specific family name, style, size, front color and line position

Parameters:
fontFamilyName - the family name
simpleFontStyle - the font style
fontSize - the size
color - the front color
textLinePosition - the line position
	public Font(String fontFamilyNameStyleTypeDefinitions.FontStyle simpleFontStyledouble fontSizeColor colorStyleTypeDefinitions.TextLinePosition textLinePosition) {
		this. = fontFamilyName;
		this. = simpleFontStyle;
		this. = textLinePosition;
		this. = fontSize;
		this. = color;
	}

Create a font with specific family name, style, size for a specific character. For example, a font style setting for English character.

Parameters:
fontFamilyName - the family name
simpleFontStyle - the font style
fontSize - the font size
language - the character information
	public Font(String fontFamilyNameStyleTypeDefinitions.FontStyle simpleFontStyledouble fontSizeLocale language) {
		this. = fontFamilyName;
		this. = simpleFontStyle;
		this. = fontSize;
	}

Create a font with specific family name, style, size, and color for a specific character. For example, a font style setting for English character.

Parameters:
fontFamilyName - the family name
simpleFontStyle - the font style
fontSize - the size
color - the front color
language - the character information
	public Font(String fontFamilyNameStyleTypeDefinitions.FontStyle simpleFontStyledouble fontSizeColor colorLocale language) {
		this. = fontFamilyName;
		this. = simpleFontStyle;
		this. = fontSize;
		this. = color;
	}

Create a font with specific family name, style, size, color, and line position for a specific character. For example, a font style setting for English character.

Parameters:
fontFamilyName - the family name
simpleFontStyle - the font style
fontSize - the size
color - the front color
textLinePosition - the line position
language - the character information
	public Font(String fontFamilyNameStyleTypeDefinitions.FontStyle simpleFontStyledouble fontSizeColor colorStyleTypeDefinitions.TextLinePosition textLinePosition,
			Locale language) {
		this. = fontFamilyName;
		this. = simpleFontStyle;
		this. = textLinePosition;
		this. = fontSize;
		this. = color;
	}

Return the font family

Returns:
the font family
	public String getFamilyName() {
		return ;
	}

Set the font family.

Font family name is what you get from the font list in ODF editors.

Parameters:
familyName - the font family name
	public void setFamilyName(String familyName) {
		this. = familyName;
	}

Return the font name

Note the font name might be different from font family name. A font family may have different font name definitions.

Returns:
the font name
	protected String getFontName() {
		return ;
	}

Set the font name

Note the font name might be different from font family name. A font family may have different font name definitions.

Parameters:
fontName - the font name
	protected void setFontName(String fontName) {
		this. = fontName;
	}

Get the font style

Returns:
the font style
	}

Set the font style

Parameters:
simpleFontStyle - the font style
	public void setFontStyle(StyleTypeDefinitions.FontStyle simpleFontStyle) {
		this. = simpleFontStyle;
	}

Get the font text line position

Returns:
the font text line position
	}

Set the font text line position

Parameters:
textLinePosition - the font text line position
	public void setTextLinePosition(StyleTypeDefinitions.TextLinePosition textLinePosition) {
		this. = textLinePosition;
	}

Return the font size in measurement point(PT).

Returns:
- the font size in measurement point(PT)
	public double getSize() {
		return ;
	}

Set the font size. The font size is in measurement point(PT).

Parameters:
size - the font size
	public void setSize(double size) {
		this. = size;
	}
	// /**
	// * Return the character information, which the font setting will affect.
	// *
	// * @return the character information
	// * @deprecated
	// */
	// public Locale getLocale() {
	// return language;
	// }
	//
	// /**
	// * Set the character information, which the font setting will affect.
	// *
	// * @param language
	// * - the character information
	// * @deprecated
	// */
	// public void setLocale(Locale language) {
	// this.language = language;
	// }
Return the font color

Returns:
the font color
	public Color getColor() {
		return ;
	}

Set the font color

Parameters:
color - the font color
	public void setColor(Color color) {
		this. = color;
	}
	public String toString() {
		return "FamilyName:" + getFamilyName() + ";" + "Style:" + getFontStyle() + ";" + "Size:" + getSize();
	}
	public boolean equals(Object o) {
		if (o instanceof Font) {
			Font f = (Fonto;
				return false;
			if (!(Math.abs(this.getSize() - f.getSize()) < 0.005))
				return false;
			if (!(this.getFontStyle() == f.getFontStyle()))
				return false;
			// if ((this.getLocale() != null && f.getLocale() == null)
			// || (this.getLocale() == null && f.getLocale() != null))
			// return false;
			// if ((this.getLocale() != null && f.getLocale() != null)
			// && (!this.getLocale().equals(f.getLocale())))
			// return false;
			if ((this.getColor() != null && f.getColor() == null) || (this.getColor() == null && f.getColor() != null))
				return false;
			if ((this.getColor() != null && f.getColor() != null)
					&& (!this.getColor().toString().equals(f.getColor().toString())))
				return false;
			return true;
		}
		return false;
	}
New to GrepCode? Check out our FAQ X