sun.font.FontManagerFactory Java Examples

The following examples show how to use sun.font.FontManagerFactory. 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 jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #2
Source File: Font.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #3
Source File: Font.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #4
Source File: Font.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #5
Source File: Font.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #6
Source File: Font.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #7
Source File: Font.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #8
Source File: Font.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #9
Source File: Font.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #10
Source File: Font.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #11
Source File: Font.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #12
Source File: Font.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #13
Source File: Font.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #14
Source File: Font.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #15
Source File: Font.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private Font(File fontFile, int fontFormat,
             boolean isCopy, CreatedFontTracker tracker)
    throws FontFormatException {
    this.createdFont = true;
    /* Font2D instances created by this method track their font file
     * so that when the Font2D is GC'd it can also remove the file.
     */
    FontManager fm = FontManagerFactory.getInstance();
    Font2D[] fonts =
        fm.createFont2D(fontFile, fontFormat, false, isCopy, tracker);
    this.font2DHandle = fonts[0].handle;
    this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
    this.style = Font.PLAIN;
    this.size = 1;
    this.pointSize = 1f;
}
 
Example #16
Source File: Font.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #17
Source File: Font.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #18
Source File: Font.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Font(File fontFile, int fontFormat,
             boolean isCopy, CreatedFontTracker tracker)
    throws FontFormatException {
    this.createdFont = true;
    /* Font2D instances created by this method track their font file
     * so that when the Font2D is GC'd it can also remove the file.
     */
    FontManager fm = FontManagerFactory.getInstance();
    Font2D[] fonts =
        fm.createFont2D(fontFile, fontFormat, false, isCopy, tracker);
    this.font2DHandle = fonts[0].handle;
    this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
    this.style = Font.PLAIN;
    this.size = 1;
    this.pointSize = 1f;
}
 
Example #19
Source File: Font.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private Font(String name, int style, float sizePts,
             boolean created, Font2DHandle handle) {
    this(name, style, sizePts);
    this.createdFont = created;
    /* Fonts created from a stream will use the same font2D instance
     * as the parent.
     * One exception is that if the derived font is requested to be
     * in a different style, then also check if its a CompositeFont
     * and if so build a new CompositeFont from components of that style.
     * CompositeFonts can only be marked as "created" if they are used
     * to add fall backs to a physical font. And non-composites are
     * always from "Font.createFont()" and shouldn't get this treatment.
     */
    if (created) {
        if (handle.font2D instanceof CompositeFont &&
            handle.font2D.getStyle() != style) {
            FontManager fm = FontManagerFactory.getInstance();
            this.font2DHandle = fm.getNewComposite(null, style, handle);
        } else {
            this.font2DHandle = handle;
        }
    }
}
 
Example #20
Source File: Font.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
Example #21
Source File: Font.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private Font(AttributeValues values, String oldName, int oldStyle,
             boolean created, Font2DHandle handle) {

    this.createdFont = created;
    if (created) {
        this.font2DHandle = handle;

        String newName = null;
        if (oldName != null) {
            newName = values.getFamily();
            if (oldName.equals(newName)) newName = null;
        }
        int newStyle = 0;
        if (oldStyle == -1) {
            newStyle = -1;
        } else {
            if (values.getWeight() >= 2f)   newStyle  = BOLD;
            if (values.getPosture() >= .2f) newStyle |= ITALIC;
            if (oldStyle == newStyle)       newStyle  = -1;
        }
        if (handle.font2D instanceof CompositeFont) {
            if (newStyle != -1 || newName != null) {
                FontManager fm = FontManagerFactory.getInstance();
                this.font2DHandle =
                    fm.getNewComposite(newName, newStyle, handle);
            }
        } else if (newName != null) {
            this.createdFont = false;
            this.font2DHandle = null;
        }
    }
    initFromValues(values);
}
 
Example #22
Source File: Font.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private Font(AttributeValues values, String oldName, int oldStyle,
             boolean created, Font2DHandle handle) {

    this.createdFont = created;
    if (created) {
        this.font2DHandle = handle;

        String newName = null;
        if (oldName != null) {
            newName = values.getFamily();
            if (oldName.equals(newName)) newName = null;
        }
        int newStyle = 0;
        if (oldStyle == -1) {
            newStyle = -1;
        } else {
            if (values.getWeight() >= 2f)   newStyle  = BOLD;
            if (values.getPosture() >= .2f) newStyle |= ITALIC;
            if (oldStyle == newStyle)       newStyle  = -1;
        }
        if (handle.font2D instanceof CompositeFont) {
            if (newStyle != -1 || newName != null) {
                FontManager fm = FontManagerFactory.getInstance();
                this.font2DHandle =
                    fm.getNewComposite(newName, newStyle, handle);
            }
        } else if (newName != null) {
            this.createdFont = false;
            this.font2DHandle = null;
        }
    }
    initFromValues(values);
}
 
Example #23
Source File: Font.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Font(AttributeValues values, String oldName, int oldStyle,
             boolean created, Font2DHandle handle) {

    this.createdFont = created;
    if (created) {
        this.font2DHandle = handle;

        String newName = null;
        if (oldName != null) {
            newName = values.getFamily();
            if (oldName.equals(newName)) newName = null;
        }
        int newStyle = 0;
        if (oldStyle == -1) {
            newStyle = -1;
        } else {
            if (values.getWeight() >= 2f)   newStyle  = BOLD;
            if (values.getPosture() >= .2f) newStyle |= ITALIC;
            if (oldStyle == newStyle)       newStyle  = -1;
        }
        if (handle.font2D instanceof CompositeFont) {
            if (newStyle != -1 || newName != null) {
                FontManager fm = FontManagerFactory.getInstance();
                this.font2DHandle =
                    fm.getNewComposite(newName, newStyle, handle);
            }
        } else if (newName != null) {
            this.createdFont = false;
            this.font2DHandle = null;
        }
    }
    initFromValues(values);
}
 
Example #24
Source File: WToolkit.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FontMetrics getFontMetrics(Font font) {
    // This is an unsupported hack, but left in for a customer.
    // Do not remove.
    FontManager fm = FontManagerFactory.getInstance();
    if (fm instanceof SunFontManager
        && ((SunFontManager) fm).usePlatformFontMetrics()) {
        return WFontMetrics.getFontMetrics(font);
    }
    return super.getFontMetrics(font);
}
 
Example #25
Source File: Font.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Font(File fontFile, int fontFormat,
             boolean isCopy, CreatedFontTracker tracker)
    throws FontFormatException {
    this.createdFont = true;
    /* Font2D instances created by this method track their font file
     * so that when the Font2D is GC'd it can also remove the file.
     */
    FontManager fm = FontManagerFactory.getInstance();
    this.font2DHandle = fm.createFont2D(fontFile, fontFormat, isCopy,
                                        tracker).handle;
    this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
    this.style = Font.PLAIN;
    this.size = 1;
    this.pointSize = 1f;
}
 
Example #26
Source File: Font.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private Font(AttributeValues values, String oldName, int oldStyle,
             boolean created, Font2DHandle handle) {

    this.createdFont = created;
    if (created) {
        this.font2DHandle = handle;

        String newName = null;
        if (oldName != null) {
            newName = values.getFamily();
            if (oldName.equals(newName)) newName = null;
        }
        int newStyle = 0;
        if (oldStyle == -1) {
            newStyle = -1;
        } else {
            if (values.getWeight() >= 2f)   newStyle  = BOLD;
            if (values.getPosture() >= .2f) newStyle |= ITALIC;
            if (oldStyle == newStyle)       newStyle  = -1;
        }
        if (handle.font2D instanceof CompositeFont) {
            if (newStyle != -1 || newName != null) {
                FontManager fm = FontManagerFactory.getInstance();
                this.font2DHandle =
                    fm.getNewComposite(newName, newStyle, handle);
            }
        } else if (newName != null) {
            this.createdFont = false;
            this.font2DHandle = null;
        }
    }
    initFromValues(values);
}
 
Example #27
Source File: Font.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private Font(File fontFile, int fontFormat,
             boolean isCopy, CreatedFontTracker tracker)
    throws FontFormatException {
    this.createdFont = true;
    /* Font2D instances created by this method track their font file
     * so that when the Font2D is GC'd it can also remove the file.
     */
    FontManager fm = FontManagerFactory.getInstance();
    this.font2DHandle = fm.createFont2D(fontFile, fontFormat, isCopy,
                                        tracker).handle;
    this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
    this.style = Font.PLAIN;
    this.size = 1;
    this.pointSize = 1f;
}
 
Example #28
Source File: Font.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private Font(AttributeValues values, String oldName, int oldStyle,
             boolean created, Font2DHandle handle) {

    this.createdFont = created;
    if (created) {
        this.font2DHandle = handle;

        String newName = null;
        if (oldName != null) {
            newName = values.getFamily();
            if (oldName.equals(newName)) newName = null;
        }
        int newStyle = 0;
        if (oldStyle == -1) {
            newStyle = -1;
        } else {
            if (values.getWeight() >= 2f)   newStyle  = BOLD;
            if (values.getPosture() >= .2f) newStyle |= ITALIC;
            if (oldStyle == newStyle)       newStyle  = -1;
        }
        if (handle.font2D instanceof CompositeFont) {
            if (newStyle != -1 || newName != null) {
                FontManager fm = FontManagerFactory.getInstance();
                this.font2DHandle =
                    fm.getNewComposite(newName, newStyle, handle);
            }
        } else if (newName != null) {
            this.createdFont = false;
            this.font2DHandle = null;
        }
    }
    initFromValues(values);
}
 
Example #29
Source File: WToolkit.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FontMetrics getFontMetrics(Font font) {
    // This is an unsupported hack, but left in for a customer.
    // Do not remove.
    FontManager fm = FontManagerFactory.getInstance();
    if (fm instanceof SunFontManager
        && ((SunFontManager) fm).usePlatformFontMetrics()) {
        return WFontMetrics.getFontMetrics(font);
    }
    return super.getFontMetrics(font);
}
 
Example #30
Source File: Font.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private Font(AttributeValues values, String oldName, int oldStyle,
             boolean created, Font2DHandle handle) {

    this.createdFont = created;
    if (created) {
        this.font2DHandle = handle;

        String newName = null;
        if (oldName != null) {
            newName = values.getFamily();
            if (oldName.equals(newName)) newName = null;
        }
        int newStyle = 0;
        if (oldStyle == -1) {
            newStyle = -1;
        } else {
            if (values.getWeight() >= 2f)   newStyle  = BOLD;
            if (values.getPosture() >= .2f) newStyle |= ITALIC;
            if (oldStyle == newStyle)       newStyle  = -1;
        }
        if (handle.font2D instanceof CompositeFont) {
            if (newStyle != -1 || newName != null) {
                FontManager fm = FontManagerFactory.getInstance();
                this.font2DHandle =
                    fm.getNewComposite(newName, newStyle, handle);
            }
        } else if (newName != null) {
            this.createdFont = false;
            this.font2DHandle = null;
        }
    }
    initFromValues(values);
}