Java Code Examples for sun.font.FontUtilities#getFont2D()

The following examples show how to use sun.font.FontUtilities#getFont2D() . 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: NotoSans.java    From java-9-wtf with Apache License 2.0 6 votes vote down vote up
public static Object createScaler() throws ReflectiveOperationException {
	// these APIs are used to reproduce the specific case I encountered
	// as closely as possible
	Font2D font = FontUtilities.getFont2D(new Font("Noto Sans CJK JP Black", 0, 12));

	// this is a reconstruction of what happens at the end of a call stack like:
	//  - BasicListUI.updateLayoutState()
	//  - JComponent.getPreferredSize()
	//  - JComponent.getFontMetrics(Font)
	//  - TrueTypeFont.getScaler
	Constructor<?> constructor = Class
			.forName("sun.font.T2KFontScaler")
			.getConstructor(Font2D.class, int.class, boolean.class, int.class);
	constructor.setAccessible(true);
	return constructor.newInstance(font, 0, true, 18604592);
}
 
Example 2
Source File: WPathGraphics.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 3
Source File: WPathGraphics.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 4
Source File: WPathGraphics.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 5
Source File: WPathGraphics.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 6
Source File: WPathGraphics.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 7
Source File: WPathGraphics.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 8
Source File: WPathGraphics.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 9
Source File: WPathGraphics.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 10
Source File: WPathGraphics.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 11
Source File: WPathGraphics.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 12
Source File: WPathGraphics.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 13
Source File: WPathGraphics.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}
 
Example 14
Source File: WPathGraphics.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected int platformFontCount(Font font, String str) {

    AffineTransform deviceTransform = getTransform();
    AffineTransform fontTransform = new AffineTransform(deviceTransform);
    fontTransform.concatenate(getFont().getTransform());
    int transformType = fontTransform.getType();

    /* Test if GDI can handle the transform */
    boolean directToGDI = ((transformType !=
                           AffineTransform.TYPE_GENERAL_TRANSFORM)
                           && ((transformType & AffineTransform.TYPE_FLIP)
                               == 0));

    if (!directToGDI) {
        return 0;
    }

    /* Since all windows fonts are available, and the JRE fonts
     * are also registered. Only the Font.createFont() case is presently
     * unknown to GDI. Those can be registered too, although that
     * code does not exist yet, it can be added too, so we should not
     * fail that case. Just do a quick check whether its a TrueTypeFont
     * - ie not a Type1 font etc, and let drawString() resolve the rest.
     */
    Font2D font2D = FontUtilities.getFont2D(font);
    if (font2D instanceof CompositeFont ||
        font2D instanceof TrueTypeFont) {
        return 1;
    } else {
        return 0;
    }
}