=== modified file 'src/com/goldencode/p2j/ui/client/FontManager.java' --- src/com/goldencode/p2j/ui/client/FontManager.java 2015-11-23 20:38:12 +0000 +++ src/com/goldencode/p2j/ui/client/FontManager.java 2016-01-10 12:57:09 +0000 @@ -36,6 +36,7 @@ ** 018 CA 20151123 When dialog-frames are used, their owning window (from where the font-table is ** determined) is different than the drawing window. Thus release/restore the ** drawing state when calling GuiDriver APIs. +** 019 SBI 20160110 Changed to install/upload binary fonts only if they are not detected. */ package com.goldencode.p2j.ui.client; @@ -929,8 +930,33 @@ { GuiDriver driver = (GuiDriver) OutputManager.getDriver(); - fd = driver.createFont(details); - + boolean hasAlias = details.fontAlias != null; + + FontDetails fontAlias = hasAlias ? details.fontAlias : details; + + boolean isInstalled = driver.isFontInstalled(fontAlias.fontName); + + FontDetails detailsCopy = details.copy(); + // Clear the font definition if the target font is installed and restore its style + // if the font has a special font definition for the bold style. + if (isInstalled) + { + FontStyle fontStyle = FontStyle.createStyle(details.boldFontDefinition, + fontAlias.style.isItalic(), fontAlias.style.isUnderline()); + if (hasAlias) + { + detailsCopy.fontAlias.fontDefinition = null; + detailsCopy.fontAlias.style = fontStyle; + } + else + { + detailsCopy.fontDefinition = null; + detailsCopy.style = fontStyle; + } + } + + fd = driver.createFont(detailsCopy); + // this is here to maximize common code driver.scaleFont(fd); === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2015-11-12 16:04:40 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2016-01-10 11:17:40 +0000 @@ -64,6 +64,7 @@ ** 035 CA 20151013 Added support for window resize, z-order operations for the GUI web client. ** 036 CA 20151024 Added support for WINDOW:SENSITIVE attribute. ** EVL 20151106 Adding grey image creation for the given original. +** 037 SBI 20160110 Added new method to query if the target font is installed or not. */ package com.goldencode.p2j.ui.client.gui.driver; @@ -663,6 +664,16 @@ public FontDetails createFont(FontDetails details); /** + * Queries if the target font is installed. + * + * @param fontName + * The target font name. + * + * @return True if the target font is installed, otherwise false. + */ + public boolean isFontInstalled(String fontName); + + /** * Get the width of the specified font. * * @param font === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2015-11-12 16:04:40 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2016-01-10 11:54:13 +0000 @@ -515,4 +515,14 @@ { // not needed for clipboard support in Swing } + + @Override + public boolean isFontInstalled(String fontName) + { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + // Enumerates all physical fonts known to JRE + String[] fontFamilies = ge.getAvailableFontFamilyNames(); + + return (Arrays.asList(fontFamilies).indexOf(fontName) > -1); + } } === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java 2016-01-08 00:16:44 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java 2016-01-10 12:51:34 +0000 @@ -38,7 +38,6 @@ ** in order to fix a mouse cursor type over its scroll bars. ** 011 SBI 20151208 Added new parameters, scroll amount and scroll unit for wheel events and ** a mouse modifiers mask for all mouse events. -** SBI 20160107 Changed to upload binary fonts only if they are not detected. */ package com.goldencode.p2j.ui.client.gui.driver.web; @@ -481,21 +480,12 @@ // get the ID for this font res.font = ++nextFontId; - boolean isInstalled = websock.isFontInstalled(res.fontName); - int fontStyle; - if (isInstalled && details.boldFontDefinition) - { - fontStyle = res.style.toInt() | FontStyle.BOLD.toInt(); - } - else - { - fontStyle = res.style.toInt(); - } + int jsFont = websock.createFont(res.font, res.fontName, res.pointSize, - fontStyle, - isInstalled ? null : res.fontDefinition); + res.style.toInt(), + res.fontDefinition); res = details.copy(); res.font = jsFont; @@ -1502,4 +1492,18 @@ { websock.setSelection(txt); } + + /** + * Returns the boolean value if the target font is installed or not. + * + * @param fontName + * The target font name. + * + * @return True if the target font is installed, otherwise false. + */ + @Override + public boolean isFontInstalled(String fontName) + { + return websock.isFontInstalled(fontName); + } }