Java Code Examples for java.awt.Font#ITALIC

The following examples show how to use java.awt.Font#ITALIC . 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: Typeface.java    From jdk8u-jdk with GNU General Public License v2.0 7 votes vote down vote up
public String write() {
    if (isAbsolute()) {
        int style = Font.PLAIN;
        if (bold == DeriveStyle.On) {
            style = style | Font.BOLD;
        }
        if (italic == DeriveStyle.On) {
            style = style | Font.ITALIC;
        }

        return String.format(
                "new javax.swing.plaf.FontUIResource(\"%s\", %d, %d)",
                name, style, size);
    } else {
        return String.format(
                "new DerivedFont(\"%s\", %sf, %s, %s)",
                uiDefaultParentName, String.valueOf(sizeOffset), bold, italic);
    }
}
 
Example 2
Source File: Typeface.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public String write() {
    if (isAbsolute()) {
        int style = Font.PLAIN;
        if (bold == DeriveStyle.On) {
            style = style | Font.BOLD;
        }
        if (italic == DeriveStyle.On) {
            style = style | Font.ITALIC;
        }

        return String.format(
                "new javax.swing.plaf.FontUIResource(\"%s\", %d, %d)",
                name, style, size);
    } else {
        return String.format(
                "new DerivedFont(\"%s\", %sf, %s, %s)",
                uiDefaultParentName, String.valueOf(sizeOffset), bold, italic);
    }
}
 
Example 3
Source File: Typeface.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public String write() {
    if (isAbsolute()) {
        int style = Font.PLAIN;
        if (bold == DeriveStyle.On) {
            style = style | Font.BOLD;
        }
        if (italic == DeriveStyle.On) {
            style = style | Font.ITALIC;
        }

        return String.format(
                "new javax.swing.plaf.FontUIResource(\"%s\", %d, %d)",
                name, style, size);
    } else {
        return String.format(
                "new DerivedFont(\"%s\", %sf, %s, %s)",
                uiDefaultParentName, String.valueOf(sizeOffset), bold, italic);
    }
}
 
Example 4
Source File: FontConfiguration.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected static int getStyleIndex(int style) {
    switch (style) {
        case Font.PLAIN:
            return 0;
        case Font.BOLD:
            return 1;
        case Font.ITALIC:
            return 2;
        case Font.BOLD | Font.ITALIC:
            return 3;
        default:
            return 0;
    }
}
 
Example 5
Source File: FileFontStrike.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
long getGlyphImageFromWindows(int glyphCode) {
    String family = fileFont.getFamilyName(null);
    int style = desc.style & Font.BOLD | desc.style & Font.ITALIC
        | fileFont.getStyle();
    int size = intPtSize;
    byte charset = fileFont.getSupportedCharset();
    long ptr = 0;
    if (useDirectWrite) {
        ptr = _getGlyphImageFromWindowsUsingDirectWrite(family, style, size, glyphCode, rotation, 
                dwMeasuringMode, dwRenderingMode, dwClearTypeLevel, dwEnhancedContrast, dwGamma, dwPixelGeometry, 
                charset);
        if (ptr == 0 && FontUtilities.isLogging()) {
            FontUtilities.getLogger().warning("Failed to render glyph via DirectWrite: code=" + glyphCode
                    + ", fontFamily=" + family + ", style=" + style + ", size=" + size + ", rotation=" + rotation);
        }
    }
    if (ptr == 0) {
        ptr = _getGlyphImageFromWindows(family, style, size, glyphCode,
                desc.fmHint == INTVAL_FRACTIONALMETRICS_ON, rotation, charset);
        if (ptr != 0 && (rotation == 0 || rotation == 2)) {
            /* Get the advance from the JDK rasterizer. This is mostly
             * necessary for the fractional metrics case, but there are
             * also some very small number (<0.25%) of marginal cases where
             * there is some rounding difference between windows and JDK.
             * After these are resolved, we can restrict this extra
             * work to the FM case.
             */
            float advance = getGlyphAdvance(glyphCode, false);
            StrikeCache.unsafe.putFloat(ptr + StrikeCache.xAdvanceOffset, advance);
        }
    }
    if (ptr == 0) {
        ptr = fileFont.getGlyphImage(pScalerContext, glyphCode);
    }
    return ptr;
}
 
Example 6
Source File: PAdESVisibleSignatureWithJavaFontTest.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testFontBoldAndItalic() throws IOException {
	SignatureImageParameters imageParameters = new SignatureImageParameters();
	SignatureImageTextParameters textParameters = new SignatureImageTextParameters();
	textParameters.setText("My signature");
	textParameters.setTextColor(Color.RED);
	Font font = new Font(Font.SANS_SERIF, Font.BOLD + Font.ITALIC, 14);
	textParameters.setFont(new DSSJavaFont(font));
	imageParameters.setTextParameters(textParameters);
	signatureParameters.setImageParameters(imageParameters);

	signAndValidate("testFontBoldAndItalic");
}
 
Example 7
Source File: ImageProducer.java    From development with Apache License 2.0 5 votes vote down vote up
protected BufferedImage createImage(Color bgColor) {
    BufferedImage bufferedImage = new BufferedImage(END_X, END_Y,
            BufferedImage.TYPE_INT_RGB);
    // create graphics and graphics2d
    final Graphics graphics = bufferedImage.getGraphics();
    final Graphics2D g2d = (Graphics2D) graphics;

    // set the background color
    g2d.setBackground(bgColor == null ? Color.gray : bgColor);
    g2d.clearRect(START_X, START_Y, END_X, END_Y);
    // create a pattern for the background
    createPattern(g2d);
    // set the fonts and font rendering hints
    Font font = new Font("Helvetica", Font.ITALIC, 30);
    g2d.setFont(font);
    FontRenderContext frc = g2d.getFontRenderContext();
    g2d.translate(10, 24);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setStroke(new BasicStroke(3));

    // sets the foreground color
    g2d.setPaint(Color.DARK_GRAY);
    GlyphVector gv = font.createGlyphVector(frc, message);
    int numGlyphs = gv.getNumGlyphs();
    for (int ii = 0; ii < numGlyphs; ii++) {
        AffineTransform at;
        Point2D p = gv.getGlyphPosition(ii);
        at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
        at.rotate(Math.PI / 8);
        Shape shape = gv.getGlyphOutline(ii);
        Shape sss = at.createTransformedShape(shape);
        g2d.fill(sss);
    }
    return blurImage(bufferedImage);
}
 
Example 8
Source File: Paint.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
private static int getFontStyle(FontStyle fontStyle) {
	switch (fontStyle) {
	case BOLD:
		return Font.BOLD;
	case BOLD_ITALIC:
		return Font.BOLD | Font.ITALIC;
	case ITALIC:
		return Font.ITALIC;
	case NORMAL:
		return Font.PLAIN;
	}

	throw new IllegalArgumentException("unknown fontStyle: " + fontStyle);
}
 
Example 9
Source File: TrueTypeFont.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void setStyle(ByteBuffer os_2Table) {
        /* fsSelection is unsigned short at buffer offset 62 */
        if (os_2Table == null || os_2Table.capacity() < 64) {
            super.setStyle();
            return;
        }
        int fsSelection = os_2Table.getChar(62) & 0xffff;
        int italic  = fsSelection & fsSelectionItalicBit;
        int bold    = fsSelection & fsSelectionBoldBit;
        int regular = fsSelection & fsSelectionRegularBit;
//      System.out.println("platname="+platName+" font="+fullName+
//                         " family="+familyName+
//                         " R="+regular+" I="+italic+" B="+bold);
        if (regular!=0 && ((italic|bold)!=0)) {
            /* This is inconsistent. Try using the font name algorithm */
            super.setStyle();
            return;
        } else if ((regular|italic|bold) == 0) {
            /* No style specified. Try using the font name algorithm */
            super.setStyle();
            return;
        }
        switch (bold|italic) {
        case fsSelectionItalicBit:
            style = Font.ITALIC;
            break;
        case fsSelectionBoldBit:
            if (FontUtilities.isSolaris && platName.endsWith("HG-GothicB.ttf")) {
                /* Workaround for Solaris's use of a JA font that's marked as
                 * being designed bold, but is used as a PLAIN font.
                 */
                style = Font.PLAIN;
            } else {
                style = Font.BOLD;
            }
            break;
        case fsSelectionBoldBit|fsSelectionItalicBit:
            style = Font.BOLD|Font.ITALIC;
        }
    }
 
Example 10
Source File: JFontStyleBox.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public int getSelectedStyle() {
  switch ((Style) getSelectedItem()) {
    case PLAIN:
      return Font.PLAIN;
    case BOLD:
      return Font.BOLD;
    case ITALIC:
      return Font.ITALIC;
    case BOLDITALIC:
      return Font.BOLD + Font.ITALIC;
  }
  return Font.PLAIN;
}
 
Example 11
Source File: SyntaxColoringPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Font getFont (AttributeSet category) {
    String name = (String) getValue (currentLanguage, category, StyleConstants.FontFamily);
    assert(name != null);
    Integer size = (Integer) getValue (currentLanguage, category, StyleConstants.FontSize);
    assert(size != null);
    Boolean bold = (Boolean) getValue (currentLanguage, category, StyleConstants.Bold);
    if (bold == null) bold = Boolean.FALSE;
    Boolean italic = (Boolean) getValue (currentLanguage, category, StyleConstants.Italic);
    if (italic == null) italic = Boolean.FALSE;
    int style = bold.booleanValue () ? Font.BOLD : Font.PLAIN;
    if (italic.booleanValue ()) style += Font.ITALIC;
    return new Font (name, style, size.intValue ());
}
 
Example 12
Source File: SyntaxStyle.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public void setItalic(Boolean italic) {
    if (italic) {
        fontStyle |= Font.ITALIC;
    } else {
        fontStyle = (fontStyle & (-1 ^ Font.ITALIC));
    }
}
 
Example 13
Source File: FontFamily.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public Font2D getFont(int style) {

        switch (style) {

        case Font.PLAIN:
            return plain;

        case Font.BOLD:
            if (bold != null) {
                return bold;
            } else if (plain != null && plain.canDoStyle(style)) {
                    return plain;
            } else {
                return null;
            }

        case Font.ITALIC:
            if (italic != null) {
                return italic;
            } else if (plain != null && plain.canDoStyle(style)) {
                    return plain;
            } else {
                return null;
            }

        case Font.BOLD|Font.ITALIC:
            if (bolditalic != null) {
                return bolditalic;
            } else if (italic != null && italic.canDoStyle(style)) {
                    return italic;
            } else if (bold != null && bold.canDoStyle(style)) {
                    return italic;
            } else if (plain != null && plain.canDoStyle(style)) {
                    return plain;
            } else {
                return null;
            }
        default:
            return null;
        }
    }
 
Example 14
Source File: CompositeFont.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public CompositeFont(String name, String[] compFileNames,
                     String[] compNames, int metricsSlotCnt,
                     int[] exclRanges, int[] maxIndexes,
                     boolean defer, SunFontManager fm) {

    handle = new Font2DHandle(this);
    fullName = name;
    componentFileNames = compFileNames;
    componentNames = compNames;
    if (compNames == null) {
        numSlots = componentFileNames.length;
    } else {
        numSlots = componentNames.length;
    }

    /* Only the first "numMetricsSlots" slots are used for font metrics.
     * the rest are considered "fallback" slots".
     */
    numMetricsSlots = metricsSlotCnt;
    exclusionRanges = exclRanges;
    maxIndices = maxIndexes;

    /*
     * See if this is a windows locale which has a system EUDC font.
     * If so add it as the final fallback component of the composite.
     * The caller could be responsible for this, but for now it seems
     * better that it is handled internally to the CompositeFont class.
     */
    if (fm.getEUDCFont() != null) {
        numSlots++;
        if (componentNames != null) {
            componentNames = new String[numSlots];
            System.arraycopy(compNames, 0, componentNames, 0, numSlots-1);
            componentNames[numSlots-1] =
                fm.getEUDCFont().getFontName(null);
        }
        if (componentFileNames != null) {
            componentFileNames = new String[numSlots];
            System.arraycopy(compFileNames, 0,
                              componentFileNames, 0, numSlots-1);
        }
        components = new PhysicalFont[numSlots];
        components[numSlots-1] = fm.getEUDCFont();
        deferredInitialisation = new boolean[numSlots];
        if (defer) {
            for (int i=0; i<numSlots-1; i++) {
                deferredInitialisation[i] = true;
            }
        }
    } else {
        components = new PhysicalFont[numSlots];
        deferredInitialisation = new boolean[numSlots];
        if (defer) {
            for (int i=0; i<numSlots; i++) {
                deferredInitialisation[i] = true;
            }
        }
    }

    fontRank = Font2D.FONT_CONFIG_RANK;

    int index = fullName.indexOf('.');
    if (index>0) {
        familyName = fullName.substring(0, index);
        /* composites don't call setStyle() as parsing the style
         * takes place at the same time as parsing the family name.
         * Do I really have to parse the style from the name?
         * Need to look into having the caller provide this. */
        if (index+1 < fullName.length()) {
            String styleStr = fullName.substring(index+1);
            if ("plain".equals(styleStr)) {
                style = Font.PLAIN;
            } else if ("bold".equals(styleStr)) {
                style = Font.BOLD;
            } else if ("italic".equals(styleStr)) {
                style = Font.ITALIC;
            } else if ("bolditalic".equals(styleStr)) {
                style = Font.BOLD | Font.ITALIC;
            }
        }
    } else {
        familyName = fullName;
    }
}
 
Example 15
Source File: javax_swing_plaf_FontUIResource.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected FontUIResource getAnotherObject() {
    return new FontUIResource(null, Font.ITALIC, 11);
}
 
Example 16
Source File: javax_swing_plaf_FontUIResource.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected FontUIResource getAnotherObject() {
    return new FontUIResource(null, Font.ITALIC, 11);
}
 
Example 17
Source File: CodeEditor.java    From drmips with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Sets custom colors for the editor.
 */
public final void setColors() {
	SyntaxScheme scheme = getSyntaxScheme();
	boolean dark = DrMIPS.prefs.getBoolean(DrMIPS.DARK_THEME_PREF, DrMIPS.DEFAULT_DARK_THEME);
	
	setBackground(dark ? Color.BLACK : Color.WHITE);
	getScrollPane().getGutter().setBackground(dark ? Color.BLACK : Color.WHITE);
	setCaretColor(dark ? Color.WHITE : Color.BLACK);
	setCurrentLineHighlightColor(dark ? (new Color(32, 32, 32)) : (new Color(255, 255, 170)));
	setSelectionColor(dark ? (new Color(64, 64, 64)) : (new Color(200, 200, 255)));
	setMarginLineColor(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);

	Font keywordFont = new Font(getDefaultFont().getFamily(), Font.BOLD, getDefaultFont().getSize());
	Font commentFont = new Font(getDefaultFont().getFamily(), Font.ITALIC, getDefaultFont().getSize());
	Style identifierStyle = new Style(dark ? Color.WHITE : Color.BLACK);
	Style directiveStyle = new Style(dark ? new Color(0, 160, 160) : new Color(0, 128, 128), null, keywordFont);
	Style errorStyle = new Style(Color.RED);

	scheme.setStyle(Token.IDENTIFIER /* references to labels */,
	                identifierStyle);
	scheme.setStyle(Token.RESERVED_WORD /* instructions */,
	                new Style(dark ? new Color(128, 128, 255) : new Color(0, 0, 255), null, keywordFont));
	scheme.setStyle(Token.RESERVED_WORD_2 /* pseudo-instructions */,
	                new Style(dark ? new Color(255, 128, 255) : new Color(128, 0, 255), null, keywordFont));
	scheme.setStyle(Token.LITERAL_NUMBER_DECIMAL_INT /* integer numeric values */,
	                identifierStyle);
	scheme.setStyle(Token.OPERATOR /* argument separators (commas and parentheses) */,
	                identifierStyle);
	scheme.setStyle(Token.PREPROCESSOR /* .text and .data directives */,
	                directiveStyle);
	scheme.setStyle(Token.DATA_TYPE /* .word and .space directives */,
	                directiveStyle);
	scheme.setStyle(Token.ERROR_CHAR /* invalid characters (like special characters) */,
	                errorStyle);
	scheme.setStyle(Token.ERROR_IDENTIFIER /* invalid directives */,
	                errorStyle);
	scheme.setStyle(Token.ERROR_NUMBER_FORMAT /* invalid integer numeric values */,
	                errorStyle);
	scheme.setStyle(Token.FUNCTION /* labels */,
	                new Style(dark ? new Color(160, 160, 160) : new Color(96, 96, 96), null, commentFont));
	scheme.setStyle(Token.COMMENT_EOL /* comments */,
	                new Style(dark ? new Color(0, 160, 0) : new Color(0, 128, 0), null, commentFont));
	scheme.setStyle(Token.VARIABLE /* registers */,
	                new Style(dark ? new Color(255, 128, 0) : new Color(192, 96, 0), null, keywordFont));
}
 
Example 18
Source File: CompositeFont.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public CompositeFont(String name, String[] compFileNames,
                     String[] compNames, int metricsSlotCnt,
                     int[] exclRanges, int[] maxIndexes,
                     boolean defer, SunFontManager fm) {

    handle = new Font2DHandle(this);
    fullName = name;
    componentFileNames = compFileNames;
    componentNames = compNames;
    if (compNames == null) {
        numSlots = componentFileNames.length;
    } else {
        numSlots = componentNames.length;
    }
    /* We will limit the number of slots to 254.
     * We store the slot for a glyph id in a byte and we may use one slot
     * for an EUDC font, and we may also create a composite
     * using this composite as a backup for a physical font.
     * So we want to leave space for the two additional slots.
     */
     numSlots = (numSlots <= 254) ? numSlots : 254;

    /* Only the first "numMetricsSlots" slots are used for font metrics.
     * the rest are considered "fallback" slots".
     */
    numMetricsSlots = metricsSlotCnt;
    exclusionRanges = exclRanges;
    maxIndices = maxIndexes;

    /*
     * See if this is a windows locale which has a system EUDC font.
     * If so add it as the final fallback component of the composite.
     * The caller could be responsible for this, but for now it seems
     * better that it is handled internally to the CompositeFont class.
     */
    if (fm.getEUDCFont() != null) {
        int msCnt = numMetricsSlots;
        int fbCnt = numSlots - msCnt;
        numSlots++;
        if (componentNames != null) {
            componentNames = new String[numSlots];
            System.arraycopy(compNames, 0, componentNames, 0, msCnt);
            componentNames[msCnt] = fm.getEUDCFont().getFontName(null);
            System.arraycopy(compNames, msCnt,
                             componentNames, msCnt+1, fbCnt);
        }
        if (componentFileNames != null) {
            componentFileNames = new String[numSlots];
            System.arraycopy(compFileNames, 0,
                              componentFileNames, 0, msCnt);
            System.arraycopy(compFileNames, msCnt,
                              componentFileNames, msCnt+1, fbCnt);
        }
        components = new PhysicalFont[numSlots];
        components[msCnt] = fm.getEUDCFont();
        deferredInitialisation = new boolean[numSlots];
        if (defer) {
            for (int i=0; i<numSlots-1; i++) {
                deferredInitialisation[i] = true;
            }
        }
    } else {
        components = new PhysicalFont[numSlots];
        deferredInitialisation = new boolean[numSlots];
        if (defer) {
            for (int i=0; i<numSlots; i++) {
                deferredInitialisation[i] = true;
            }
        }
    }

    fontRank = Font2D.FONT_CONFIG_RANK;

    int index = fullName.indexOf('.');
    if (index>0) {
        familyName = fullName.substring(0, index);
        /* composites don't call setStyle() as parsing the style
         * takes place at the same time as parsing the family name.
         * Do I really have to parse the style from the name?
         * Need to look into having the caller provide this. */
        if (index+1 < fullName.length()) {
            String styleStr = fullName.substring(index+1);
            if ("plain".equals(styleStr)) {
                style = Font.PLAIN;
            } else if ("bold".equals(styleStr)) {
                style = Font.BOLD;
            } else if ("italic".equals(styleStr)) {
                style = Font.ITALIC;
            } else if ("bolditalic".equals(styleStr)) {
                style = Font.BOLD | Font.ITALIC;
            }
        }
    } else {
        familyName = fullName;
    }
}
 
Example 19
Source File: NativeFont.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void initNames() throws FontFormatException {
        /* Valid XLFD has exactly 14 "-" chars.
         * First run over the string to verify have at least this many
         * At the same time record the locations of the hyphens
         * so we can just pick the right substring later on
         */
        int[] hPos = new int[14];
        int hyphenCnt = 1;
        int pos = 1;

        String xlfd = platName.toLowerCase(Locale.ENGLISH);
        if (xlfd.startsWith("-")) {
            while (pos != -1 && hyphenCnt < 14) {
                pos = xlfd.indexOf('-', pos);
                if (pos != -1) {
                    hPos[hyphenCnt++] = pos;
                    pos++;
                }
            }
        }

        if (hyphenCnt == 14 && pos != -1) {

            /* Capitalise words in the Family name */
            String tmpFamily = xlfd.substring(hPos[1]+1, hPos[2]);
            StringBuilder sBuffer = new StringBuilder(tmpFamily);
            char ch = Character.toUpperCase(sBuffer.charAt(0));
            sBuffer.replace(0, 1, String.valueOf(ch));
            for (int i=1;i<sBuffer.length()-1; i++) {
                if (sBuffer.charAt(i) == ' ') {
                    ch = Character.toUpperCase(sBuffer.charAt(i+1));
                    sBuffer.replace(i+1, i+2, String.valueOf(ch));
                }
            }
            familyName = sBuffer.toString();

            String tmpWeight = xlfd.substring(hPos[2]+1, hPos[3]);
            String tmpSlant = xlfd.substring(hPos[3]+1, hPos[4]);

            String styleStr = null;

            if (tmpWeight.indexOf("bold") >= 0 ||
                tmpWeight.indexOf("demi") >= 0) {
                style |= Font.BOLD;
                styleStr = "Bold";
            }

            if (tmpSlant.equals("i") ||
                tmpSlant.indexOf("italic") >= 0) {
                style |= Font.ITALIC;

                if (styleStr == null) {
                    styleStr = "Italic";
                } else {
                    styleStr = styleStr + " Italic";
                }
            }
            else if (tmpSlant.equals("o") ||
                tmpSlant.indexOf("oblique") >= 0) {
                style |= Font.ITALIC;
                if (styleStr == null) {
                    styleStr = "Oblique";
                } else {
                    styleStr = styleStr + " Oblique";
                }
            }

            if (styleStr == null) {
                fullName = familyName;
            } else {
                fullName = familyName + " " + styleStr;
            }

            encoding = xlfd.substring(hPos[12]+1);
            if (encoding.startsWith("-")) {
                encoding = xlfd.substring(hPos[13]+1);
            }
            if (encoding.indexOf("fontspecific") >= 0) {
                if (tmpFamily.indexOf("dingbats") >= 0) {
                    encoding = "dingbats";
                } else if (tmpFamily.indexOf("symbol") >= 0) {
                    encoding = "symbol";
                } else {
                    encoding = "iso8859-1";
                }
            }
        } else {
            throw new FontFormatException("Bad native name " + platName);
//             familyName = "Unknown";
//             fullName = "Unknown";
//             style = Font.PLAIN;
//             encoding = "iso8859-1";
        }
    }
 
Example 20
Source File: FontFamily.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
Font2D getClosestStyle(int style) {

        switch (style) {
            /* if you ask for a plain font try to return a non-italic one,
             * then a italic one, finally a bold italic one */
        case Font.PLAIN:
            if (bold != null) {
                return bold;
            } else if (italic != null) {
                return italic;
            } else {
                return bolditalic;
            }

            /* if you ask for a bold font try to return a non-italic one,
             * then a bold italic one, finally an italic one */
        case Font.BOLD:
            if (plain != null) {
                return plain;
            } else if (bolditalic != null) {
                return bolditalic;
            } else {
                return italic;
            }

            /* if you ask for a italic font try to return a  bold italic one,
             * then a plain one, finally an bold one */
        case Font.ITALIC:
            if (bolditalic != null) {
                return bolditalic;
            } else if (plain != null) {
                return plain;
            } else {
                return bold;
            }

        case Font.BOLD|Font.ITALIC:
            if (italic != null) {
                return italic;
            } else if (bold != null) {
                return bold;
            } else {
                return plain;
            }
        }
        return null;
    }