Java Code Examples for com.lowagie.text.pdf.BaseFont#TIMES_BOLD

The following examples show how to use com.lowagie.text.pdf.BaseFont#TIMES_BOLD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Font.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Gets the <CODE>BaseFont</CODE> this class represents. For the built-in
 * fonts a <CODE>BaseFont</CODE> is calculated.
 * 
 * @param specialEncoding
 *            <CODE>true</CODE> to use the special encoding for Symbol and
 *            ZapfDingbats, <CODE>false</CODE> to always use <CODE>Cp1252
 *            </CODE>
 * @return the <CODE>BaseFont</CODE> this class represents
 */
public BaseFont getCalculatedBaseFont(boolean specialEncoding) {
	if (baseFont != null)
		return baseFont;
	int style = this.style;
	if (style == UNDEFINED) {
		style = NORMAL;
	}
	String fontName = BaseFont.HELVETICA;
	String encoding = BaseFont.WINANSI;
	BaseFont cfont = null;
	switch (family) {
	case COURIER:
		switch (style & BOLDITALIC) {
		case BOLD:
			fontName = BaseFont.COURIER_BOLD;
			break;
		case ITALIC:
			fontName = BaseFont.COURIER_OBLIQUE;
			break;
		case BOLDITALIC:
			fontName = BaseFont.COURIER_BOLDOBLIQUE;
			break;
		default:
			//case NORMAL:
			fontName = BaseFont.COURIER;
			break;
		}
		break;
	case TIMES_ROMAN:
		switch (style & BOLDITALIC) {
		case BOLD:
			fontName = BaseFont.TIMES_BOLD;
			break;
		case ITALIC:
			fontName = BaseFont.TIMES_ITALIC;
			break;
		case BOLDITALIC:
			fontName = BaseFont.TIMES_BOLDITALIC;
			break;
		default:
		case NORMAL:
			fontName = BaseFont.TIMES_ROMAN;
			break;
		}
		break;
	case SYMBOL:
		fontName = BaseFont.SYMBOL;
		if (specialEncoding)
			encoding = BaseFont.SYMBOL;
		break;
	case ZAPFDINGBATS:
		fontName = BaseFont.ZAPFDINGBATS;
		if (specialEncoding)
			encoding = BaseFont.ZAPFDINGBATS;
		break;
	default:
	case Font.HELVETICA:
		switch (style & BOLDITALIC) {
		case BOLD:
			fontName = BaseFont.HELVETICA_BOLD;
			break;
		case ITALIC:
			fontName = BaseFont.HELVETICA_OBLIQUE;
			break;
		case BOLDITALIC:
			fontName = BaseFont.HELVETICA_BOLDOBLIQUE;
			break;
		default:
		case NORMAL:
			fontName = BaseFont.HELVETICA;
			break;
		}
		break;
	}
	try {
		cfont = BaseFont.createFont(fontName, encoding, false);
	} catch (Exception ee) {
		throw new ExceptionConverter(ee);
	}
	return cfont;
}
 
Example 2
Source File: Font.java    From itext2 with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Gets the <CODE>BaseFont</CODE> this class represents. For the built-in
 * fonts a <CODE>BaseFont</CODE> is calculated.
 * 
 * @param specialEncoding
 *            <CODE>true</CODE> to use the special encoding for Symbol and
 *            ZapfDingbats, <CODE>false</CODE> to always use <CODE>Cp1252
 *            </CODE>
 * @return the <CODE>BaseFont</CODE> this class represents
 */
public BaseFont getCalculatedBaseFont(boolean specialEncoding) {
	if (baseFont != null)
		return baseFont;
	int style = this.style;
	if (style == UNDEFINED) {
		style = NORMAL;
	}
	String fontName = BaseFont.HELVETICA;
	String encoding = BaseFont.WINANSI;
	BaseFont cfont = null;
	switch (family) {
	case COURIER:
		switch (style & BOLDITALIC) {
		case BOLD:
			fontName = BaseFont.COURIER_BOLD;
			break;
		case ITALIC:
			fontName = BaseFont.COURIER_OBLIQUE;
			break;
		case BOLDITALIC:
			fontName = BaseFont.COURIER_BOLDOBLIQUE;
			break;
		default:
			//case NORMAL:
			fontName = BaseFont.COURIER;
			break;
		}
		break;
	case TIMES_ROMAN:
		switch (style & BOLDITALIC) {
		case BOLD:
			fontName = BaseFont.TIMES_BOLD;
			break;
		case ITALIC:
			fontName = BaseFont.TIMES_ITALIC;
			break;
		case BOLDITALIC:
			fontName = BaseFont.TIMES_BOLDITALIC;
			break;
		default:
		case NORMAL:
			fontName = BaseFont.TIMES_ROMAN;
			break;
		}
		break;
	case SYMBOL:
		fontName = BaseFont.SYMBOL;
		if (specialEncoding)
			encoding = BaseFont.SYMBOL;
		break;
	case ZAPFDINGBATS:
		fontName = BaseFont.ZAPFDINGBATS;
		if (specialEncoding)
			encoding = BaseFont.ZAPFDINGBATS;
		break;
	default:
	case Font.HELVETICA:
		switch (style & BOLDITALIC) {
		case BOLD:
			fontName = BaseFont.HELVETICA_BOLD;
			break;
		case ITALIC:
			fontName = BaseFont.HELVETICA_OBLIQUE;
			break;
		case BOLDITALIC:
			fontName = BaseFont.HELVETICA_BOLDOBLIQUE;
			break;
		default:
		case NORMAL:
			fontName = BaseFont.HELVETICA;
			break;
		}
		break;
	}
	try {
		cfont = BaseFont.createFont(fontName, encoding, false);
	} catch (Exception ee) {
		throw new ExceptionConverter(ee);
	}
	return cfont;
}
 
Example 3
Source File: Font.java    From MesquiteCore with GNU Lesser General Public License v3.0 4 votes vote down vote up
/** Gets the <CODE>BaseFont</CODE> this class represents.
 * For the built-in fonts a <CODE>BaseFont</CODE> is calculated.
 * @param specialEncoding <CODE>true</CODE> to use the special encoding for Symbol and ZapfDingbats,
 * <CODE>false</CODE> to always use <CODE>Cp1252</CODE>
 * @return the <CODE>BaseFont</CODE> this class represents
 */    
public BaseFont getCalculatedBaseFont(boolean specialEncoding) {
    if (baseFont != null)
        return baseFont;
    int style = this.style;
    if (style == UNDEFINED) {
        style = NORMAL;
    }
    String fontName = BaseFont.HELVETICA;
    String encoding = BaseFont.WINANSI;
    BaseFont cfont = null;
    switch(family) {
        case COURIER:
            switch(style & BOLDITALIC) {
                case BOLD:
                    fontName = BaseFont.COURIER_BOLD;
                    break;
                case ITALIC:
                    fontName = BaseFont.COURIER_OBLIQUE;
                    break;
                case BOLDITALIC:
                    fontName = BaseFont.COURIER_BOLDOBLIQUE;
                    break;
                default:
                //case NORMAL:
                    fontName = BaseFont.COURIER;
                    break;
            }
            break;
        case TIMES_ROMAN:
            switch(style & BOLDITALIC) {
                case BOLD:
                    fontName = BaseFont.TIMES_BOLD;
                    break;
                case ITALIC:
                    fontName = BaseFont.TIMES_ITALIC;
                    break;
                case BOLDITALIC:
                    fontName = BaseFont.TIMES_BOLDITALIC;
                    break;
                    default:
                case NORMAL:
                    fontName = BaseFont.TIMES_ROMAN;
                    break;
            }
            break;
        case SYMBOL:
            fontName = BaseFont.SYMBOL;
            if (specialEncoding)
                encoding = BaseFont.SYMBOL;
            break;
        case ZAPFDINGBATS:
            fontName = BaseFont.ZAPFDINGBATS;
            if (specialEncoding)
                encoding = BaseFont.ZAPFDINGBATS;
            break;
        default:
        //case Font.HELVETICA:
            switch(style & BOLDITALIC) {
                case BOLD:
                    fontName = BaseFont.HELVETICA_BOLD;
                    break;
                case ITALIC:
                    fontName = BaseFont.HELVETICA_OBLIQUE;
                    break;
                case BOLDITALIC:
                    fontName = BaseFont.HELVETICA_BOLDOBLIQUE;
                    break;
                    default:
                case NORMAL:
                    fontName = BaseFont.HELVETICA;
                    break;
            }
            break;
    }
    try {
        cfont = BaseFont.createFont(fontName, encoding, false);
    }
    catch (Exception ee) {
        throw new ExceptionConverter(ee);
    }
    return cfont;
}