@Override public void setCharset(FontCharset charset) { CTTextFont tf = getXmlObject(true); if (tf == null) { return; } if (charset != null) { tf.setCharset((byte)charset.getNativeId()); } else { if (tf.isSetCharset()) { tf.unsetCharset(); } } }
@Override public FontCharset getCharset() { CTTextFont tf = getXmlObject(false); return (tf != null && tf.isSetCharset()) ? FontCharset.valueOf(tf.getCharset()&0xFF) : null; }
/** * Try to get the code page from various areas of the document. * Start with the DocumentSummaryInformation, back off to the section info, * finally try the charset information from the font table. * * Consider throwing an exception if > 1 unique codepage that is not default, symbol or ansi * appears here. * * @param fontTable * @return The detected Charset from the old font table */ private Charset guessCodePage(OldFontTable fontTable) { // pick the first non-default, non-symbol charset for (OldFfn oldFfn : fontTable.getFontNames()) { FontCharset wmfCharset = FontCharset.valueOf(oldFfn.getChs()& 0xff); if (wmfCharset != null && wmfCharset != FontCharset.ANSI && wmfCharset != FontCharset.DEFAULT && wmfCharset != FontCharset.SYMBOL ) { return wmfCharset.getCharset(); } } logger.log(POILogger.WARN, "Couldn't find a defined charset; backing off to cp1252"); //if all else fails return DEFAULT_CHARSET; }
charset = (font.getCharset() == null || font.getCharset().getCharset() == null) ? LocaleUtil.CHARSET_1252 : font.getCharset().getCharset();
byte chs = buf[offset]; Charset charset = null; FontCharset wmfCharset = FontCharset.valueOf(chs & 0xff); if (wmfCharset == null) { logger.log(POILogger.WARN, "Couldn't find font for type: " + (chs & 0xff)); } else { charset = wmfCharset.getCharset();
Charset charset = (font.getCharset().getCharset() == null)? DEFAULT_CHARSET : font.getCharset().getCharset(); String textString = new String(text, charset); AttributedString as = new AttributedString(textString);
@Override public FontCharset getCharset() { CTTextFont tf = getXmlObject(false); return (tf != null && tf.isSetCharset()) ? FontCharset.valueOf(tf.getCharset()&0xFF) : null; }
@Override public void setCharset(FontCharset charset) { CTTextFont tf = getXmlObject(true); if (tf == null) { return; } if (charset != null) { tf.setCharset((byte)charset.getNativeId()); } else { if (tf.isSetCharset()) { tf.unsetCharset(); } } }
charset = (font.getCharset() == null || font.getCharset().getCharset() == null) ? LocaleUtil.CHARSET_1252 : font.getCharset().getCharset();
public int init(LittleEndianInputStream leis) throws IOException { height = leis.readShort(); width = leis.readShort(); escapement = leis.readShort(); orientation = leis.readShort(); weight = leis.readShort(); italic = leis.readByte() != 0; underline = leis.readByte() != 0; strikeOut = leis.readByte() != 0; charSet = FontCharset.valueOf(leis.readUByte()); outPrecision = WmfOutPrecision.valueOf(leis.readUByte()); clipPrecision = WmfClipPrecision.valueOf(leis.readUByte()); quality = WmfFontQuality.valueOf(leis.readUByte()); pitchAndFamily = leis.readUByte(); byte buf[] = new byte[32], b, readBytes = 0; do { if (readBytes == 32) { throw new IOException("Font facename can't be determined."); } buf[readBytes++] = b = leis.readByte(); } while (b != 0 && b != -1 && readBytes <= 32); facename = new String(buf, 0, readBytes-1, StandardCharsets.ISO_8859_1); return 5*LittleEndianConsts.SHORT_SIZE+8*LittleEndianConsts.BYTE_SIZE+readBytes; }
public FontEntityAtom createRecord() { FontEntityAtom fnt = new FontEntityAtom(); fnt.setFontIndex(getIndex() << 4); fnt.setFontName(getTypeface()); fnt.setCharSet(getCharset().getNativeId()); fnt.setFontFlags((byte)(isEmbedSubsetted() ? 1 : 0)); int typeFlag; switch (renderType) { case device: typeFlag = FLAGS_RENDER_FONTTYPE.setValue(0, 1); break; case raster: typeFlag = FLAGS_RENDER_FONTTYPE.setValue(0, 2); break; default: case truetype: typeFlag = FLAGS_RENDER_FONTTYPE.setValue(0, 4); break; } typeFlag = FLAGS_NO_FONT_SUBSTITUTION.setBoolean(typeFlag, isFontSubstitutable()); fnt.setFontType(typeFlag); fnt.setPitchAndFamily(FontPitch.getNativeId(pitch, family)); return fnt; } }
/** * Creates a new instance of HSLFFontInfo and initialize it from the supplied font atom */ public HSLFFontInfo(FontEntityAtom fontAtom){ setIndex(fontAtom.getFontIndex()); setTypeface(fontAtom.getFontName()); setCharset(FontCharset.valueOf(fontAtom.getCharSet())); // assumption: the render type is exclusive switch (FLAGS_RENDER_FONTTYPE.getValue(fontAtom.getFontType())) { case 1: setRenderType(FontRenderType.raster); break; case 2: setRenderType(FontRenderType.device); break; default: case 4: setRenderType(FontRenderType.truetype); break; } byte pitchAndFamily = (byte)fontAtom.getPitchAndFamily(); setPitch(FontPitch.valueOfPitchFamily(pitchAndFamily)); setFamily(FontFamily.valueOfPitchFamily(pitchAndFamily)); setEmbedSubsetted(FLAGS_EMBED_SUBSETTED.isSet(fontAtom.getFontFlags())); setFontSubstitutable(!FLAGS_NO_FONT_SUBSTITUTION.isSet(fontAtom.getFontType())); }