/** * 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)); }
/** * Get FontFamily from combined native id * * @param pitchAndFamily The PitchFamily to decode. * * @return The resulting FontFamily */ public static FontFamily valueOfPitchFamily(byte pitchAndFamily) { return valueOf(pitchAndFamily >>> 4); } }
@Override public FontFamily getFamily() { CTTextFont tf = getXmlObject(false); return (tf != null && tf.isSetPitchFamily()) ? FontFamily.valueOfPitchFamily(tf.getPitchFamily()) : null; }
public static FontFamily valueOf(int nativeId) { for (FontFamily ff : values()) { if (ff.nativeId == nativeId) { return ff; } } return null; }
public static FontFamily valueOf(int nativeId) { for (FontFamily ff : values()) { if (ff.nativeId == nativeId) { return ff; } } return null; }
@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); }
/** * Get FontFamily from combined native id * * @param pitchAndFamily The PitchFamily to decode. * * @return The resulting FontFamily */ public static FontFamily valueOfPitchFamily(byte pitchAndFamily) { return valueOf(pitchAndFamily >>> 4); } }
/** * 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 FontFamily getFamily() { CTTextFont tf = getXmlObject(false); return (tf != null && tf.isSetPitchFamily()) ? FontFamily.valueOfPitchFamily(tf.getPitchFamily()) : null; }
@Override public FontFamily getFamily() { return FontFamily.valueOf(pitchAndFamily & 0xF); }
@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); }
/** * 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())); }