/** * Combine pitch and family to native id * * @see <a href="https://msdn.microsoft.com/en-us/library/dd145037.aspx">LOGFONT structure</a> * * @param pitch The pitch-value, cannot be null * @param family The family-value, cannot be null * * @return The resulting combined byte-value with pitch and family encoded into one byte */ public static byte getNativeId(FontPitch pitch, FontFamily family) { return (byte)(pitch.getNativeId() | (family.getFlag() << 4)); }
@Override public byte getPitchAndFamily(){ FontGroup fg = FontGroup.getFontGroupFirst(getRawText()); XSLFFontInfo fontInfo = new XSLFFontInfo(fg); FontPitch pitch = fontInfo.getPitch(); if (pitch == null) { pitch = FontPitch.VARIABLE; } FontFamily family = fontInfo.getFamily(); if (family == null) { family = FontFamily.FF_SWISS; } return FontPitch.getNativeId(pitch, family); }
@Override public void setFamily(FontFamily family) { CTTextFont tf = getXmlObject(true); if (tf == null || (family == null && !tf.isSetPitchFamily())) { return; } FontPitch pitch = (tf.isSetPitchFamily()) ? FontPitch.valueOfPitchFamily(tf.getPitchFamily()) : FontPitch.VARIABLE; byte pitchFamily = FontPitch.getNativeId(pitch, family != null ? family : FontFamily.FF_SWISS); tf.setPitchFamily(pitchFamily); }
@Override public void setPitch(FontPitch pitch) { CTTextFont tf = getXmlObject(true); if (tf == null || (pitch == null && !tf.isSetPitchFamily())) { return; } FontFamily family = (tf.isSetPitchFamily()) ? FontFamily.valueOfPitchFamily(tf.getPitchFamily()) : FontFamily.FF_SWISS; byte pitchFamily = FontPitch.getNativeId(pitch != null ? pitch : FontPitch.VARIABLE, family); tf.setPitchFamily(pitchFamily); }
/** * Combine pitch and family to native id * * @see <a href="https://msdn.microsoft.com/en-us/library/dd145037.aspx">LOGFONT structure</a> * * @param pitch The pitch-value, cannot be null * @param family The family-value, cannot be null * * @return The resulting combined byte-value with pitch and family encoded into one byte */ public static byte getNativeId(FontPitch pitch, FontFamily family) { return (byte)(pitch.getNativeId() | (family.getFlag() << 4)); }
@Override public void setPitch(FontPitch pitch) { CTTextFont tf = getXmlObject(true); if (tf == null || (pitch == null && !tf.isSetPitchFamily())) { return; } FontFamily family = (tf.isSetPitchFamily()) ? FontFamily.valueOfPitchFamily(tf.getPitchFamily()) : FontFamily.FF_SWISS; byte pitchFamily = FontPitch.getNativeId(pitch != null ? pitch : FontPitch.VARIABLE, family); tf.setPitchFamily(pitchFamily); }
@Override public byte getPitchAndFamily(){ FontGroup fg = FontGroup.getFontGroupFirst(getRawText()); XSLFFontInfo fontInfo = new XSLFFontInfo(fg); FontPitch pitch = fontInfo.getPitch(); if (pitch == null) { pitch = FontPitch.VARIABLE; } FontFamily family = fontInfo.getFamily(); if (family == null) { family = FontFamily.FF_SWISS; } return FontPitch.getNativeId(pitch, family); }
@Override public void setFamily(FontFamily family) { CTTextFont tf = getXmlObject(true); if (tf == null || (family == null && !tf.isSetPitchFamily())) { return; } FontPitch pitch = (tf.isSetPitchFamily()) ? FontPitch.valueOfPitchFamily(tf.getPitchFamily()) : FontPitch.VARIABLE; byte pitchFamily = FontPitch.getNativeId(pitch, family != null ? family : FontFamily.FF_SWISS); tf.setPitchFamily(pitchFamily); }
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; } }