6795908: Refactor FontManager

Reviewed-by: prr, igor
This commit is contained in:
Roman Kennke 2009-08-07 18:31:11 +02:00
parent 63e666407c
commit eb12553aa3
58 changed files with 1437 additions and 6661 deletions

View File

@ -1,249 +1,250 @@
# #
# Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as # under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this # published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided # particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code. # by Sun in the LICENSE file that accompanied this code.
# #
# This code is distributed in the hope that it will be useful, but WITHOUT # This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that # version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code). # accompanied this code).
# #
# You should have received a copy of the GNU General Public License version # You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation, # 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or # CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions. # have any questions.
# #
# FILES_export definitions for Win32 # FILES_export definitions for Win32
FILES_export = \ FILES_export = \
java/awt/AlphaComposite.java \ java/awt/AlphaComposite.java \
java/awt/MouseInfo.java \ java/awt/MouseInfo.java \
java/awt/Graphics.java \ java/awt/Graphics.java \
java/awt/Color.java \ java/awt/Color.java \
java/awt/Image.java \ java/awt/Image.java \
java/awt/Rectangle.java \ java/awt/Rectangle.java \
java/awt/Event.java \ java/awt/Event.java \
java/awt/Font.java \ java/awt/Font.java \
java/awt/FontMetrics.java \ java/awt/FontMetrics.java \
java/awt/Toolkit.java \ java/awt/Toolkit.java \
java/awt/Component.java \ java/awt/Component.java \
java/awt/Container.java \ java/awt/Container.java \
java/awt/Canvas.java \ java/awt/Canvas.java \
java/awt/Button.java \ java/awt/Button.java \
java/awt/List.java \ java/awt/List.java \
java/awt/Adjustable.java \ java/awt/Adjustable.java \
java/awt/Scrollbar.java \ java/awt/Scrollbar.java \
java/awt/ScrollPane.java \ java/awt/ScrollPane.java \
java/awt/ScrollPaneAdjustable.java \ java/awt/ScrollPaneAdjustable.java \
java/awt/Transparency.java \ java/awt/Transparency.java \
java/awt/Window.java \ java/awt/Window.java \
java/awt/TextField.java \ java/awt/TextField.java \
java/awt/Label.java \ java/awt/Label.java \
java/awt/Choice.java \ java/awt/Choice.java \
java/awt/TextComponent.java \ java/awt/TextComponent.java \
java/awt/TextArea.java \ java/awt/TextArea.java \
java/awt/MenuBar.java \ java/awt/MenuBar.java \
java/awt/Menu.java \ java/awt/Menu.java \
java/awt/Dialog.java \ java/awt/Dialog.java \
java/awt/FileDialog.java \ java/awt/FileDialog.java \
java/awt/MenuItem.java \ java/awt/MenuItem.java \
java/awt/MenuComponent.java \ java/awt/MenuComponent.java \
java/awt/Checkbox.java \ java/awt/Checkbox.java \
java/awt/CheckboxGroup.java \ java/awt/CheckboxGroup.java \
java/awt/CheckboxMenuItem.java \ java/awt/CheckboxMenuItem.java \
java/awt/Frame.java \ java/awt/Frame.java \
java/awt/Insets.java \ java/awt/Insets.java \
java/awt/Cursor.java \ java/awt/Cursor.java \
java/awt/Dimension.java \ java/awt/Dimension.java \
java/awt/PopupMenu.java \ java/awt/PopupMenu.java \
java/awt/AWTEvent.java \ java/awt/AWTEvent.java \
java/awt/AWTException.java \ java/awt/AWTException.java \
java/awt/AWTKeyStroke.java \ java/awt/AWTKeyStroke.java \
java/awt/KeyboardFocusManager.java \ java/awt/KeyboardFocusManager.java \
java/awt/DisplayMode.java \ java/awt/DisplayMode.java \
java/awt/TrayIcon.java \ java/awt/TrayIcon.java \
java/awt/datatransfer/StringSelection.java \ java/awt/datatransfer/StringSelection.java \
java/awt/datatransfer/Transferable.java \ java/awt/datatransfer/Transferable.java \
java/awt/dnd/DnDConstants.java \ java/awt/dnd/DnDConstants.java \
java/awt/event/ActionEvent.java \ java/awt/event/ActionEvent.java \
java/awt/event/AdjustmentEvent.java \ java/awt/event/AdjustmentEvent.java \
java/awt/event/ComponentEvent.java \ java/awt/event/ComponentEvent.java \
java/awt/event/FocusEvent.java \ java/awt/event/FocusEvent.java \
java/awt/event/ItemEvent.java \ java/awt/event/ItemEvent.java \
java/awt/event/InputEvent.java \ java/awt/event/InputEvent.java \
java/awt/event/InvocationEvent.java \ java/awt/event/InvocationEvent.java \
java/awt/event/KeyEvent.java \ java/awt/event/KeyEvent.java \
java/awt/event/MouseEvent.java \ java/awt/event/MouseEvent.java \
java/awt/event/MouseWheelEvent.java \ java/awt/event/MouseWheelEvent.java \
java/awt/event/WindowEvent.java \ java/awt/event/WindowEvent.java \
java/awt/event/InputMethodEvent.java \ java/awt/event/InputMethodEvent.java \
java/awt/im/InputMethodHighlight.java \ java/awt/im/InputMethodHighlight.java \
java/awt/im/spi/InputMethod.java \ java/awt/im/spi/InputMethod.java \
java/awt/font/TextHitInfo.java \ java/awt/font/TextHitInfo.java \
java/text/AttributedCharacterIterator.java \ java/text/AttributedCharacterIterator.java \
java/text/AttributedString.java \ java/text/AttributedString.java \
java/awt/geom/PathIterator.java \ java/awt/geom/PathIterator.java \
java/awt/image/AffineTransformOp.java \ java/awt/image/AffineTransformOp.java \
java/awt/image/ImageConsumer.java \ java/awt/image/ImageConsumer.java \
java/awt/image/ImageObserver.java \ java/awt/image/ImageObserver.java \
java/awt/image/BufferedImage.java \ java/awt/image/BufferedImage.java \
java/awt/image/ColorModel.java \ java/awt/image/ColorModel.java \
java/awt/image/ConvolveOp.java \ java/awt/image/ConvolveOp.java \
java/awt/image/DirectColorModel.java \ java/awt/image/DirectColorModel.java \
java/awt/image/IndexColorModel.java \ java/awt/image/IndexColorModel.java \
java/awt/image/Raster.java \ java/awt/image/Raster.java \
java/awt/color/ColorSpace.java \ java/awt/color/ColorSpace.java \
java/awt/color/ICC_Profile.java \ java/awt/color/ICC_Profile.java \
java/awt/peer/ComponentPeer.java \ java/awt/peer/ComponentPeer.java \
java/awt/peer/MenuComponentPeer.java \ java/awt/peer/MenuComponentPeer.java \
java/io/InputStream.java java/io/InputStream.java
FILES_export2 = \ FILES_export2 = \
sun/awt/im/InputMethodContext.java \ sun/awt/im/InputMethodContext.java \
sun/awt/EmbeddedFrame.java \ sun/awt/EmbeddedFrame.java \
sun/awt/KeyboardFocusManagerPeerImpl.java \ sun/awt/KeyboardFocusManagerPeerImpl.java \
sun/awt/windows/WEmbeddedFrame.java \ sun/awt/windows/WEmbeddedFrame.java \
sun/awt/windows/WEmbeddedFramePeer.java \ sun/awt/windows/WEmbeddedFramePeer.java \
sun/awt/Win32GraphicsEnvironment.java \ sun/awt/Win32FontManager.java \
sun/awt/Win32GraphicsDevice.java \ sun/awt/Win32GraphicsEnvironment.java \
sun/awt/Win32GraphicsConfig.java \ sun/awt/Win32GraphicsDevice.java \
sun/java2d/SunGraphicsEnvironment.java \ sun/awt/Win32GraphicsConfig.java \
sun/java2d/SunGraphics2D.java \ sun/java2d/SunGraphicsEnvironment.java \
sun/java2d/SurfaceData.java \ sun/java2d/SunGraphics2D.java \
sun/awt/image/IntegerComponentRaster.java \ sun/java2d/SurfaceData.java \
sun/awt/image/ImagingLib.java \ sun/awt/image/IntegerComponentRaster.java \
sun/awt/image/BufImgSurfaceData.java \ sun/awt/image/ImagingLib.java \
sun/awt/image/DataBufferNative.java \ sun/awt/image/BufImgSurfaceData.java \
sun/awt/shell/Win32ShellFolder2.java \ sun/awt/image/DataBufferNative.java \
sun/java2d/windows/GDIBlitLoops.java \ sun/awt/shell/Win32ShellFolder2.java \
sun/java2d/windows/GDIRenderer.java \ sun/java2d/windows/GDIBlitLoops.java \
sun/java2d/windows/GDIWindowSurfaceData.java \ sun/java2d/windows/GDIRenderer.java \
sun/java2d/windows/WindowsFlags.java \ sun/java2d/windows/GDIWindowSurfaceData.java \
sun/java2d/loops/Blit.java \ sun/java2d/windows/WindowsFlags.java \
sun/java2d/loops/BlitBg.java \ sun/java2d/loops/Blit.java \
sun/java2d/loops/ScaledBlit.java \ sun/java2d/loops/BlitBg.java \
sun/java2d/loops/FillRect.java \ sun/java2d/loops/ScaledBlit.java \
sun/java2d/loops/FillSpans.java \ sun/java2d/loops/FillRect.java \
sun/java2d/loops/DrawGlyphList.java \ sun/java2d/loops/FillSpans.java \
sun/java2d/loops/DrawGlyphListAA.java \ sun/java2d/loops/DrawGlyphList.java \
sun/java2d/loops/DrawGlyphListLCD.java \ sun/java2d/loops/DrawGlyphListAA.java \
sun/java2d/loops/DrawLine.java \ sun/java2d/loops/DrawGlyphListLCD.java \
sun/java2d/loops/DrawRect.java \ sun/java2d/loops/DrawLine.java \
sun/java2d/loops/DrawPolygons.java \ sun/java2d/loops/DrawRect.java \
sun/java2d/loops/DrawPath.java \ sun/java2d/loops/DrawPolygons.java \
sun/java2d/loops/FillPath.java \ sun/java2d/loops/DrawPath.java \
sun/java2d/loops/MaskBlit.java \ sun/java2d/loops/FillPath.java \
sun/java2d/loops/MaskFill.java \ sun/java2d/loops/MaskBlit.java \
sun/java2d/loops/TransformHelper.java \ sun/java2d/loops/MaskFill.java \
sun/java2d/loops/GraphicsPrimitiveMgr.java \ sun/java2d/loops/TransformHelper.java \
sun/java2d/loops/GraphicsPrimitive.java \ sun/java2d/loops/GraphicsPrimitiveMgr.java \
sun/java2d/cmm/CMSManager.java \ sun/java2d/loops/GraphicsPrimitive.java \
sun/java2d/cmm/PCMM.java \ sun/java2d/cmm/CMSManager.java \
sun/java2d/cmm/ColorTransform.java \ sun/java2d/cmm/PCMM.java \
sun/awt/ScrollPaneWheelScroller.java \ sun/java2d/cmm/ColorTransform.java \
sun/awt/datatransfer/DataTransferer.java \ sun/awt/ScrollPaneWheelScroller.java \
sun/awt/datatransfer/SunClipboard.java \ sun/awt/datatransfer/DataTransferer.java \
sun/awt/dnd/SunDragSourceContextPeer.java \ sun/awt/datatransfer/SunClipboard.java \
sun/awt/windows/WToolkitThreadBlockedHandler.java sun/awt/dnd/SunDragSourceContextPeer.java \
sun/awt/windows/WToolkitThreadBlockedHandler.java
FILES_export3 = \
java/awt/CheckboxMenuItem.java \ FILES_export3 = \
java/awt/Menu.java \ java/awt/CheckboxMenuItem.java \
java/awt/MenuBar.java \ java/awt/Menu.java \
java/awt/MenuComponent.java \ java/awt/MenuBar.java \
java/awt/MenuItem.java \ java/awt/MenuComponent.java \
sun/awt/PlatformFont.java \ java/awt/MenuItem.java \
sun/awt/FontDescriptor.java \ sun/awt/PlatformFont.java \
sun/awt/CharsetString.java \ sun/awt/FontDescriptor.java \
java/awt/image/DataBuffer.java \ sun/awt/CharsetString.java \
sun/awt/image/GifImageDecoder.java \ java/awt/image/DataBuffer.java \
sun/awt/image/ImageRepresentation.java \ sun/awt/image/GifImageDecoder.java \
sun/awt/windows/WCustomCursor.java \ sun/awt/image/ImageRepresentation.java \
sun/awt/windows/WDefaultFontCharset.java \ sun/awt/windows/WCustomCursor.java \
sun/awt/windows/WButtonPeer.java \ sun/awt/windows/WDefaultFontCharset.java \
sun/awt/windows/WCanvasPeer.java \ sun/awt/windows/WButtonPeer.java \
sun/awt/windows/WCheckboxPeer.java \ sun/awt/windows/WCanvasPeer.java \
sun/awt/windows/WCheckboxMenuItemPeer.java \ sun/awt/windows/WCheckboxPeer.java \
sun/awt/windows/WChoicePeer.java \ sun/awt/windows/WCheckboxMenuItemPeer.java \
sun/awt/windows/WClipboard.java \ sun/awt/windows/WChoicePeer.java \
sun/awt/windows/WColor.java \ sun/awt/windows/WClipboard.java \
sun/awt/windows/WDataTransferer.java \ sun/awt/windows/WColor.java \
sun/awt/windows/WDesktopPeer.java \ sun/awt/windows/WDataTransferer.java \
sun/awt/windows/WDesktopProperties.java \ sun/awt/windows/WDesktopPeer.java \
sun/awt/windows/WDialogPeer.java \ sun/awt/windows/WDesktopProperties.java \
sun/awt/windows/WDragSourceContextPeer.java \ sun/awt/windows/WDialogPeer.java \
sun/awt/windows/WDropTargetContextPeer.java \ sun/awt/windows/WDragSourceContextPeer.java \
sun/awt/windows/WFileDialogPeer.java \ sun/awt/windows/WDropTargetContextPeer.java \
sun/awt/windows/WFontPeer.java \ sun/awt/windows/WFileDialogPeer.java \
sun/awt/windows/WFontMetrics.java \ sun/awt/windows/WFontPeer.java \
sun/awt/windows/WFramePeer.java \ sun/awt/windows/WFontMetrics.java \
sun/awt/windows/WGlobalCursorManager.java \ sun/awt/windows/WFramePeer.java \
sun/awt/windows/WInputMethod.java \ sun/awt/windows/WGlobalCursorManager.java \
sun/awt/windows/WInputMethodDescriptor.java \ sun/awt/windows/WInputMethod.java \
sun/awt/windows/WComponentPeer.java \ sun/awt/windows/WInputMethodDescriptor.java \
sun/awt/windows/WLabelPeer.java \ sun/awt/windows/WComponentPeer.java \
sun/awt/windows/WListPeer.java \ sun/awt/windows/WLabelPeer.java \
sun/awt/windows/WMenuBarPeer.java \ sun/awt/windows/WListPeer.java \
sun/awt/windows/WMenuItemPeer.java \ sun/awt/windows/WMenuBarPeer.java \
sun/awt/windows/WMenuPeer.java \ sun/awt/windows/WMenuItemPeer.java \
sun/awt/windows/WObjectPeer.java \ sun/awt/windows/WMenuPeer.java \
sun/awt/windows/WPopupMenuPeer.java \ sun/awt/windows/WObjectPeer.java \
sun/awt/windows/WPrintDialog.java \ sun/awt/windows/WPopupMenuPeer.java \
sun/awt/windows/WPrintDialogPeer.java \ sun/awt/windows/WPrintDialog.java \
sun/awt/windows/WPrinterJob.java \ sun/awt/windows/WPrintDialogPeer.java \
sun/awt/windows/WRobotPeer.java \ sun/awt/windows/WPrinterJob.java \
sun/awt/windows/WScrollbarPeer.java \ sun/awt/windows/WRobotPeer.java \
sun/awt/windows/WScrollPanePeer.java \ sun/awt/windows/WScrollbarPeer.java \
sun/awt/windows/WTextAreaPeer.java \ sun/awt/windows/WScrollPanePeer.java \
sun/awt/windows/WTextComponentPeer.java \ sun/awt/windows/WTextAreaPeer.java \
sun/awt/windows/WTextFieldPeer.java \ sun/awt/windows/WTextComponentPeer.java \
sun/awt/windows/WPanelPeer.java \ sun/awt/windows/WTextFieldPeer.java \
sun/awt/windows/WToolkit.java \ sun/awt/windows/WPanelPeer.java \
sun/awt/windows/WWindowPeer.java \ sun/awt/windows/WToolkit.java \
sun/awt/windows/ThemeReader.java \ sun/awt/windows/WWindowPeer.java \
sun/awt/windows/WBufferStrategy.java \ sun/awt/windows/ThemeReader.java \
sun/awt/windows/WTrayIconPeer.java \ sun/awt/windows/WBufferStrategy.java \
sun/awt/image/ImagingLib.java \ sun/awt/windows/WTrayIconPeer.java \
sun/awt/ExtendedKeyCodes.java \ sun/awt/image/ImagingLib.java \
sun/java2d/pipe/hw/AccelSurface.java \ sun/awt/ExtendedKeyCodes.java \
sun/java2d/pipe/hw/AccelDeviceEventNotifier.java \ sun/java2d/pipe/hw/AccelSurface.java \
sun/java2d/pipe/hw/ContextCapabilities.java \ sun/java2d/pipe/hw/AccelDeviceEventNotifier.java \
sun/java2d/pipe/BufferedContext.java \ sun/java2d/pipe/hw/ContextCapabilities.java \
sun/java2d/pipe/BufferedMaskBlit.java \ sun/java2d/pipe/BufferedContext.java \
sun/java2d/pipe/BufferedOpCodes.java \ sun/java2d/pipe/BufferedMaskBlit.java \
sun/java2d/pipe/BufferedPaints.java \ sun/java2d/pipe/BufferedOpCodes.java \
sun/java2d/pipe/BufferedRenderPipe.java \ sun/java2d/pipe/BufferedPaints.java \
sun/java2d/pipe/BufferedTextPipe.java \ sun/java2d/pipe/BufferedRenderPipe.java \
sun/java2d/pipe/RenderBuffer.java \ sun/java2d/pipe/BufferedTextPipe.java \
sun/java2d/pipe/ShapeSpanIterator.java \ sun/java2d/pipe/RenderBuffer.java \
sun/java2d/pipe/SpanClipRenderer.java \ sun/java2d/pipe/ShapeSpanIterator.java \
sun/java2d/pipe/RegionIterator.java \ sun/java2d/pipe/SpanClipRenderer.java \
sun/java2d/opengl/OGLBlitLoops.java \ sun/java2d/pipe/RegionIterator.java \
sun/java2d/opengl/OGLContext.java \ sun/java2d/opengl/OGLBlitLoops.java \
sun/java2d/opengl/OGLMaskFill.java \ sun/java2d/opengl/OGLContext.java \
sun/java2d/opengl/OGLPaints.java \ sun/java2d/opengl/OGLMaskFill.java \
sun/java2d/opengl/OGLRenderQueue.java \ sun/java2d/opengl/OGLPaints.java \
sun/java2d/opengl/OGLRenderer.java \ sun/java2d/opengl/OGLRenderQueue.java \
sun/java2d/opengl/OGLSurfaceData.java \ sun/java2d/opengl/OGLRenderer.java \
sun/java2d/opengl/OGLTextRenderer.java \ sun/java2d/opengl/OGLSurfaceData.java \
sun/java2d/opengl/WGLGraphicsConfig.java \ sun/java2d/opengl/OGLTextRenderer.java \
sun/java2d/opengl/WGLSurfaceData.java \ sun/java2d/opengl/WGLGraphicsConfig.java \
sun/java2d/d3d/D3DBlitLoops.java \ sun/java2d/opengl/WGLSurfaceData.java \
sun/java2d/d3d/D3DGraphicsDevice.java \ sun/java2d/d3d/D3DBlitLoops.java \
sun/java2d/d3d/D3DSurfaceData.java \ sun/java2d/d3d/D3DGraphicsDevice.java \
sun/java2d/d3d/D3DMaskFill.java \ sun/java2d/d3d/D3DSurfaceData.java \
sun/java2d/d3d/D3DPaints.java \ sun/java2d/d3d/D3DMaskFill.java \
sun/java2d/d3d/D3DRenderQueue.java \ sun/java2d/d3d/D3DPaints.java \
sun/java2d/d3d/D3DRenderer.java \ sun/java2d/d3d/D3DRenderQueue.java \
sun/java2d/d3d/D3DTextRenderer.java \ sun/java2d/d3d/D3DRenderer.java \
sun/java2d/d3d/D3DContext.java sun/java2d/d3d/D3DTextRenderer.java \
sun/java2d/d3d/D3DContext.java

File diff suppressed because one or more lines are too long

View File

@ -477,11 +477,11 @@ SUNWprivate_1.1 {
X11SurfaceData_GetOps; X11SurfaceData_GetOps;
getDefaultConfig; getDefaultConfig;
Java_sun_font_FontManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfig;
Java_sun_font_FontManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigAASettings;
Java_sun_font_FontManager_getFontPath; Java_sun_awt_X11FontManager_getFontPath;
Java_sun_font_FontManager_setNativeFontPath; Java_sun_awt_X11FontManager_setNativeFontPath;
Java_sun_font_FontManager_populateFontFileNameMap; Java_sun_font_SunFontManager_populateFontFileNameMap;
# CDE private entry point # CDE private entry point
Java_sun_awt_motif_XsessionWMcommand; Java_sun_awt_motif_XsessionWMcommand;

View File

@ -533,11 +533,11 @@ SUNWprivate_1.1 {
X11SurfaceData_GetOps; X11SurfaceData_GetOps;
getDefaultConfig; getDefaultConfig;
Java_sun_font_FontManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfig;
Java_sun_font_FontManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigAASettings;
Java_sun_font_FontManager_getFontPath; Java_sun_awt_X11FontManager_getFontPath;
Java_sun_font_FontManager_setNativeFontPath; Java_sun_awt_X11FontManager_setNativeFontPath;
Java_sun_font_FontManager_populateFontFileNameMap; Java_sun_font_SunFontManager_populateFontFileNameMap;
# CDE private entry point # CDE private entry point
Java_sun_awt_motif_XsessionWMcommand; Java_sun_awt_motif_XsessionWMcommand;

View File

@ -33,12 +33,7 @@ SUNWprivate_1.1 {
isNullScalerContext; isNullScalerContext;
Java_sun_font_NullFontScaler_getNullScalerContext; Java_sun_font_NullFontScaler_getNullScalerContext;
Java_sun_font_NullFontScaler_getGlyphImage; Java_sun_font_NullFontScaler_getGlyphImage;
Java_sun_font_FontManager_getPlatformFontVar; Java_sun_font_SunFontManager_initIDs;
Java_sun_font_FontManager_initIDs;
Java_sun_font_FontManager_getFont2D;
Java_sun_font_FontManager_setFont2D;
Java_sun_font_FontManager_isCreatedFont;
Java_sun_font_FontManager_setCreatedFont;
Java_sun_font_StrikeCache_getGlyphCacheDescription; Java_sun_font_StrikeCache_getGlyphCacheDescription;
Java_sun_font_StrikeCache_freeIntPointer; Java_sun_font_StrikeCache_freeIntPointer;
Java_sun_font_StrikeCache_freeLongPointer; Java_sun_font_StrikeCache_freeLongPointer;

View File

@ -35,12 +35,7 @@ SUNWprivate_1.1 {
isNullScalerContext; isNullScalerContext;
Java_sun_font_NullFontScaler_getNullScalerContext; Java_sun_font_NullFontScaler_getNullScalerContext;
Java_sun_font_NullFontScaler_getGlyphImage; Java_sun_font_NullFontScaler_getGlyphImage;
Java_sun_font_FontManager_getPlatformFontVar; Java_sun_font_SunFontManager_initIDs;
Java_sun_font_FontManager_initIDs;
Java_sun_font_FontManager_getFont2D;
Java_sun_font_FontManager_setFont2D;
Java_sun_font_FontManager_isCreatedFont;
Java_sun_font_FontManager_setCreatedFont;
Java_sun_font_StrikeCache_getGlyphCacheDescription; Java_sun_font_StrikeCache_getGlyphCacheDescription;
Java_sun_font_StrikeCache_freeIntPointer; Java_sun_font_StrikeCache_freeIntPointer;
Java_sun_font_StrikeCache_freeLongPointer; Java_sun_font_StrikeCache_freeLongPointer;

View File

@ -59,12 +59,10 @@ SUNWprivate_1.1 {
X11SurfaceData_GetOps; X11SurfaceData_GetOps;
Java_java_awt_Font_initIDs; Java_java_awt_Font_initIDs;
Java_sun_font_FontManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfig;
Java_sun_font_FontManager_getFontConfigVersion; Java_sun_font_FontConfigManager_getFontConfigAASettings;
Java_sun_font_FontManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion;
Java_sun_font_FontManager_getFontPath; Java_sun_awt_X11FontManager_getFontPath;
Java_sun_font_FontManager_setNativeFontPath;
Java_sun_font_FontManager_populateFontFileNameMap;
Java_sun_awt_FontDescriptor_initIDs; Java_sun_awt_FontDescriptor_initIDs;
Java_sun_awt_PlatformFont_initIDs; Java_sun_awt_PlatformFont_initIDs;

View File

@ -182,12 +182,11 @@ SUNWprivate_1.1 {
Java_java_awt_ScrollPane_initIDs; Java_java_awt_ScrollPane_initIDs;
Java_java_awt_TextField_initIDs; Java_java_awt_TextField_initIDs;
Java_java_awt_TrayIcon_initIDs; Java_java_awt_TrayIcon_initIDs;
Java_sun_font_FontManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfig;
Java_sun_font_FontManager_getFontConfigVersion; Java_sun_font_FontConfigManager_getFontConfigAASettings;
Java_sun_font_FontManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion;
Java_sun_font_FontManager_getFontPath; Java_sun_awt_X11FontManager_getFontPath;
Java_sun_font_FontManager_setNativeFontPath; Java_sun_font_X11FontManager_setNativeFontPath;
Java_sun_font_FontManager_populateFontFileNameMap;
Java_sun_awt_X11GraphicsEnvironment_initDisplay; Java_sun_awt_X11GraphicsEnvironment_initDisplay;
Java_sun_awt_X11GraphicsEnvironment_initGLX; Java_sun_awt_X11GraphicsEnvironment_initGLX;
Java_sun_awt_X11GraphicsEnvironment_checkShmExt; Java_sun_awt_X11GraphicsEnvironment_checkShmExt;

View File

@ -29,7 +29,9 @@ import java.awt.*;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import javax.swing.plaf.FontUIResource; import javax.swing.plaf.FontUIResource;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import sun.font.FontManager;
import sun.font.FontConfigManager;
import sun.font.FontUtilities;
/** /**
* @author Shannon Hickey * @author Shannon Hickey
@ -193,13 +195,13 @@ class PangoFonts {
} }
String fcFamilyLC = family.toLowerCase(); String fcFamilyLC = family.toLowerCase();
if (FontManager.mapFcName(fcFamilyLC) != null) { if (FontUtilities.mapFcName(fcFamilyLC) != null) {
/* family is a Fc/Pango logical font which we need to expand. */ /* family is a Fc/Pango logical font which we need to expand. */
return FontManager.getFontConfigFUIR(fcFamilyLC, style, size); return FontUtilities.getFontConfigFUIR(fcFamilyLC, style, size);
} else { } else {
/* It's a physical font which we will create with a fallback */ /* It's a physical font which we will create with a fallback */
Font font = new FontUIResource(family, style, size); Font font = new FontUIResource(family, style, size);
return FontManager.getCompositeFontUIResource(font); return FontUtilities.getCompositeFontUIResource(font);
} }
} }

View File

@ -63,7 +63,7 @@ import java.security.AccessController;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import sun.awt.OSInfo; import sun.awt.OSInfo;
import sun.awt.shell.ShellFolder; import sun.awt.shell.ShellFolder;
import sun.font.FontManager; import sun.font.FontUtilities;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
import sun.swing.DefaultLayoutStyle; import sun.swing.DefaultLayoutStyle;
@ -2347,13 +2347,14 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
font.getStyle(), size); font.getStyle(), size);
} }
} }
if (FontManager.fontSupportsDefaultEncoding(font)) {
if (FontUtilities.fontSupportsDefaultEncoding(font)) {
if (!(font instanceof UIResource)) { if (!(font instanceof UIResource)) {
font = new FontUIResource(font); font = new FontUIResource(font);
} }
} }
else { else {
font = FontManager.getCompositeFontUIResource(font); font = FontUtilities.getCompositeFontUIResource(font);
} }
return font; return font;

View File

@ -74,6 +74,9 @@ import sun.awt.CausedFocusEvent;
import sun.awt.EmbeddedFrame; import sun.awt.EmbeddedFrame;
import sun.awt.dnd.SunDropTargetEvent; import sun.awt.dnd.SunDropTargetEvent;
import sun.awt.im.CompositionArea; import sun.awt.im.CompositionArea;
import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.font.SunFontManager;
import sun.java2d.SunGraphics2D; import sun.java2d.SunGraphics2D;
import sun.java2d.pipe.Region; import sun.java2d.pipe.Region;
import sun.awt.image.VSyncedBSManager; import sun.awt.image.VSyncedBSManager;
@ -2848,8 +2851,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since JDK1.0 * @since JDK1.0
*/ */
public FontMetrics getFontMetrics(Font font) { public FontMetrics getFontMetrics(Font font) {
// REMIND: PlatformFont flag should be obsolete soon... // This is an unsupported hack, but left in for a customer.
if (sun.font.FontManager.usePlatformFontMetrics()) { // Do not remove.
FontManager fm = FontManagerFactory.getInstance();
if (fm instanceof SunFontManager
&& ((SunFontManager) fm).usePlatformFontMetrics()) {
if (peer != null && if (peer != null &&
!(peer instanceof LightweightPeer)) { !(peer instanceof LightweightPeer)) {
return peer.getFontMetrics(font); return peer.getFontMetrics(font);

View File

@ -30,7 +30,6 @@ import java.awt.font.GlyphVector;
import java.awt.font.LineMetrics; import java.awt.font.LineMetrics;
import java.awt.font.TextAttribute; import java.awt.font.TextAttribute;
import java.awt.font.TextLayout; import java.awt.font.TextLayout;
import java.awt.font.TransformAttribute;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
@ -42,21 +41,21 @@ import java.security.PrivilegedExceptionAction;
import java.text.AttributedCharacterIterator.Attribute; import java.text.AttributedCharacterIterator.Attribute;
import java.text.CharacterIterator; import java.text.CharacterIterator;
import java.text.StringCharacterIterator; import java.text.StringCharacterIterator;
import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import sun.font.StandardGlyphVector; import sun.font.StandardGlyphVector;
import sun.java2d.FontSupport;
import sun.font.AttributeMap; import sun.font.AttributeMap;
import sun.font.AttributeValues; import sun.font.AttributeValues;
import sun.font.EAttribute;
import sun.font.CompositeFont; import sun.font.CompositeFont;
import sun.font.CreatedFontTracker; import sun.font.CreatedFontTracker;
import sun.font.Font2D; import sun.font.Font2D;
import sun.font.Font2DHandle; import sun.font.Font2DHandle;
import sun.font.FontAccess;
import sun.font.FontManager; import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.font.FontUtilities;
import sun.font.GlyphLayout; import sun.font.GlyphLayout;
import sun.font.FontLineMetrics; import sun.font.FontLineMetrics;
import sun.font.CoreMetrics; import sun.font.CoreMetrics;
@ -223,10 +222,29 @@ import static sun.font.EAttribute.*;
*/ */
public class Font implements java.io.Serializable public class Font implements java.io.Serializable
{ {
private static class FontAccessImpl extends FontAccess {
public Font2D getFont2D(Font font) {
return font.getFont2D();
}
public void setFont2D(Font font, Font2DHandle handle) {
font.font2DHandle = handle;
}
public void setCreatedFont(Font font) {
font.createdFont = true;
}
public boolean isCreatedFont(Font font) {
return font.createdFont;
}
}
static { static {
/* ensure that the necessary native libraries are loaded */ /* ensure that the necessary native libraries are loaded */
Toolkit.loadLibraries(); Toolkit.loadLibraries();
initIDs(); initIDs();
FontAccess.setFontAccess(new FontAccessImpl());
} }
/** /**
@ -464,16 +482,17 @@ public class Font implements java.io.Serializable
} }
private Font2D getFont2D() { private Font2D getFont2D() {
if (FontManager.usingPerAppContextComposites && FontManager fm = FontManagerFactory.getInstance();
if (fm.usingPerAppContextComposites() &&
font2DHandle != null && font2DHandle != null &&
font2DHandle.font2D instanceof CompositeFont && font2DHandle.font2D instanceof CompositeFont &&
((CompositeFont)(font2DHandle.font2D)).isStdComposite()) { ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
return FontManager.findFont2D(name, style, return fm.findFont2D(name, style,
FontManager.LOGICAL_FALLBACK); FontManager.LOGICAL_FALLBACK);
} else if (font2DHandle == null) { } else if (font2DHandle == null) {
font2DHandle = font2DHandle =
FontManager.findFont2D(name, style, fm.findFont2D(name, style,
FontManager.LOGICAL_FALLBACK).handle; FontManager.LOGICAL_FALLBACK).handle;
} }
/* Do not cache the de-referenced font2D. It must be explicitly /* Do not cache the de-referenced font2D. It must be explicitly
* de-referenced to pick up a valid font in the event that the * de-referenced to pick up a valid font in the event that the
@ -570,8 +589,8 @@ public class Font implements java.io.Serializable
if (created) { if (created) {
if (handle.font2D instanceof CompositeFont && if (handle.font2D instanceof CompositeFont &&
handle.font2D.getStyle() != style) { handle.font2D.getStyle() != style) {
this.font2DHandle = FontManager fm = FontManagerFactory.getInstance();
FontManager.getNewComposite(null, style, handle); this.font2DHandle = fm.getNewComposite(null, style, handle);
} else { } else {
this.font2DHandle = handle; this.font2DHandle = handle;
} }
@ -586,9 +605,9 @@ public class Font implements java.io.Serializable
/* Font2D instances created by this method track their font file /* Font2D instances created by this method track their font file
* so that when the Font2D is GC'd it can also remove the file. * so that when the Font2D is GC'd it can also remove the file.
*/ */
this.font2DHandle = FontManager fm = FontManagerFactory.getInstance();
FontManager.createFont2D(fontFile, fontFormat, this.font2DHandle = fm.createFont2D(fontFile, fontFormat, isCopy,
isCopy, tracker).handle; tracker).handle;
this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault()); this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
this.style = Font.PLAIN; this.style = Font.PLAIN;
this.size = 1; this.size = 1;
@ -640,8 +659,9 @@ public class Font implements java.io.Serializable
} }
if (handle.font2D instanceof CompositeFont) { if (handle.font2D instanceof CompositeFont) {
if (newStyle != -1 || newName != null) { if (newStyle != -1 || newName != null) {
FontManager fm = FontManagerFactory.getInstance();
this.font2DHandle = this.font2DHandle =
FontManager.getNewComposite(newName, newStyle, handle); fm.getNewComposite(newName, newStyle, handle);
} }
} else if (newName != null) { } else if (newName != null) {
this.createdFont = false; this.createdFont = false;
@ -852,7 +872,6 @@ public class Font implements java.io.Serializable
throw new IllegalArgumentException ("font format not recognized"); throw new IllegalArgumentException ("font format not recognized");
} }
boolean copiedFontData = false; boolean copiedFontData = false;
try { try {
final File tFile = AccessController.doPrivileged( final File tFile = AccessController.doPrivileged(
new PrivilegedExceptionAction<File>() { new PrivilegedExceptionAction<File>() {
@ -2320,7 +2339,7 @@ public class Font implements java.io.Serializable
(values.getKerning() == 0 && values.getLigatures() == 0 && (values.getKerning() == 0 && values.getLigatures() == 0 &&
values.getBaselineTransform() == null); values.getBaselineTransform() == null);
if (simple) { if (simple) {
simple = !FontManager.isComplexText(chars, beginIndex, limit); simple = ! FontUtilities.isComplexText(chars, beginIndex, limit);
} }
if (simple) { if (simple) {

View File

@ -29,6 +29,9 @@ package java.awt;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.security.AccessController; import java.security.AccessController;
import java.util.Locale; import java.util.Locale;
import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.java2d.HeadlessGraphicsEnvironment; import sun.java2d.HeadlessGraphicsEnvironment;
import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SunGraphicsEnvironment;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
@ -353,7 +356,8 @@ public abstract class GraphicsEnvironment {
if (font == null) { if (font == null) {
throw new NullPointerException("font cannot be null."); throw new NullPointerException("font cannot be null.");
} }
return sun.font.FontManager.registerFont(font); FontManager fm = FontManagerFactory.getInstance();
return fm.registerFont(font);
} }
/** /**
@ -377,10 +381,8 @@ public abstract class GraphicsEnvironment {
* @since 1.5 * @since 1.5
*/ */
public void preferLocaleFonts() { public void preferLocaleFonts() {
if (!(this instanceof SunGraphicsEnvironment)) { FontManager fm = FontManagerFactory.getInstance();
return; fm.preferLocaleFonts();
}
sun.font.FontManager.preferLocaleFonts();
} }
/** /**
@ -400,10 +402,8 @@ public abstract class GraphicsEnvironment {
* @since 1.5 * @since 1.5
*/ */
public void preferProportionalFonts() { public void preferProportionalFonts() {
if (!(this instanceof SunGraphicsEnvironment)) { FontManager fm = FontManagerFactory.getInstance();
return; fm.preferProportionalFonts();
}
sun.font.FontManager.preferProportionalFonts();
} }
/** /**

View File

@ -26,7 +26,7 @@ package ${PACKAGE};
import javax.swing.Painter; import javax.swing.Painter;
import java.awt.Graphics; import java.awt.Graphics;
import sun.font.FontManager; import sun.font.FontUtilities;
import sun.swing.plaf.synth.DefaultSynthStyle; import sun.swing.plaf.synth.DefaultSynthStyle;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -138,7 +138,7 @@ final class ${LAF_NAME}Defaults {
//regions and their states that this class will use for later lookup. //regions and their states that this class will use for later lookup.
//Additional regions can be registered later by 3rd party components. //Additional regions can be registered later by 3rd party components.
//These are simply the default registrations. //These are simply the default registrations.
defaultFont = FontManager.getFontConfigFUIR("sans", Font.PLAIN, 12); defaultFont = FontUtilities.getFontConfigFUIR("sans", Font.PLAIN, 12);
defaultStyle = new DefaultSynthStyle(); defaultStyle = new DefaultSynthStyle();
defaultStyle.setFont(defaultFont); defaultStyle.setFont(defaultFont);

View File

@ -35,7 +35,7 @@ import javax.swing.event.ChangeEvent;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import sun.font.FontManager; import sun.font.FontUtilities;
/** /**
* A pool of styles and their associated resources. This class determines * A pool of styles and their associated resources. This class determines
@ -263,8 +263,8 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
if (f == null) { if (f == null) {
f = new Font(family, style, size); f = new Font(family, style, size);
} }
if (! FontManager.fontSupportsDefaultEncoding(f)) { if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
f = FontManager.getCompositeFontUIResource(f); f = FontUtilities.getCompositeFontUIResource(f);
} }
FontKey key = new FontKey(family, style, size); FontKey key = new FontKey(family, style, size);
fontTable.put(key, f); fontTable.put(key, f);

View File

@ -30,7 +30,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -49,7 +48,9 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
import sun.font.CompositeFontDescriptor; import sun.font.CompositeFontDescriptor;
import sun.java2d.SunGraphicsEnvironment; import sun.font.SunFontManager;
import sun.font.FontManagerFactory;
import sun.font.FontUtilities;
/** /**
* Provides the definitions of the five logical fonts: Serif, SansSerif, * Provides the definitions of the five logical fonts: Serif, SansSerif,
@ -68,7 +69,7 @@ public abstract class FontConfiguration {
private static Logger logger; private static Logger logger;
protected static boolean isProperties = true; protected static boolean isProperties = true;
protected SunGraphicsEnvironment environment; protected SunFontManager fontManager;
protected boolean preferLocaleFonts; protected boolean preferLocaleFonts;
protected boolean preferPropFonts; protected boolean preferPropFonts;
@ -80,11 +81,11 @@ public abstract class FontConfiguration {
/* A default FontConfiguration must be created before an alternate /* A default FontConfiguration must be created before an alternate
* one to ensure proper static initialisation takes place. * one to ensure proper static initialisation takes place.
*/ */
public FontConfiguration(SunGraphicsEnvironment environment) { public FontConfiguration(SunFontManager fm) {
if (SunGraphicsEnvironment.debugFonts && logger == null) { if (FontUtilities.debugFonts() && logger == null) {
logger = Logger.getLogger("sun.awt.FontConfiguration"); logger = Logger.getLogger("sun.awt.FontConfiguration");
} }
this.environment = environment; fontManager = fm;
setOsNameAndVersion(); /* static initialization */ setOsNameAndVersion(); /* static initialization */
setEncoding(); /* static initialization */ setEncoding(); /* static initialization */
/* Separating out the file location from the rest of the /* Separating out the file location from the rest of the
@ -106,10 +107,10 @@ public abstract class FontConfiguration {
return true; return true;
} }
public FontConfiguration(SunGraphicsEnvironment environment, public FontConfiguration(SunFontManager fm,
boolean preferLocaleFonts, boolean preferLocaleFonts,
boolean preferPropFonts) { boolean preferPropFonts) {
this.environment = environment; fontManager = fm;
this.preferLocaleFonts = preferLocaleFonts; this.preferLocaleFonts = preferLocaleFonts;
this.preferPropFonts = preferPropFonts; this.preferPropFonts = preferPropFonts;
/* fontConfig should be initialised by default constructor, and /* fontConfig should be initialised by default constructor, and
@ -198,17 +199,17 @@ public abstract class FontConfiguration {
loadBinary(in); loadBinary(in);
} }
in.close(); in.close();
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
logger.config("Read logical font configuration from " + f); logger.config("Read logical font configuration from " + f);
} }
} catch (IOException e) { } catch (IOException e) {
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
logger.config("Failed to read logical font configuration from " + f); logger.config("Failed to read logical font configuration from " + f);
} }
} }
} }
String version = getVersion(); String version = getVersion();
if (!"1".equals(version) && SunGraphicsEnvironment.debugFonts) { if (!"1".equals(version) && FontUtilities.debugFonts()) {
logger.config("Unsupported fontconfig version: " + version); logger.config("Unsupported fontconfig version: " + version);
} }
} }
@ -219,8 +220,8 @@ public abstract class FontConfiguration {
File fallbackDir = new File(fallbackDirName); File fallbackDir = new File(fallbackDirName);
if (fallbackDir.exists() && fallbackDir.isDirectory()) { if (fallbackDir.exists() && fallbackDir.isDirectory()) {
String[] ttfs = fallbackDir.list(SunGraphicsEnvironment.ttFilter); String[] ttfs = fallbackDir.list(fontManager.getTrueTypeFilter());
String[] t1s = fallbackDir.list(SunGraphicsEnvironment.t1Filter); String[] t1s = fallbackDir.list(fontManager.getType1Filter());
int numTTFs = (ttfs == null) ? 0 : ttfs.length; int numTTFs = (ttfs == null) ? 0 : ttfs.length;
int numT1s = (t1s == null) ? 0 : t1s.length; int numT1s = (t1s == null) ? 0 : t1s.length;
int len = numTTFs + numT1s; int len = numTTFs + numT1s;
@ -236,7 +237,7 @@ public abstract class FontConfiguration {
installedFallbackFontFiles[i+numTTFs] = installedFallbackFontFiles[i+numTTFs] =
fallbackDir + File.separator + t1s[i]; fallbackDir + File.separator + t1s[i];
} }
environment.registerFontsInDir(fallbackDirName); fontManager.registerFontsInDir(fallbackDirName);
} }
} }
@ -465,7 +466,7 @@ public abstract class FontConfiguration {
nameIDs[index] = getComponentFontID(coreScripts[index], nameIDs[index] = getComponentFontID(coreScripts[index],
fontIndex, styleIndex); fontIndex, styleIndex);
if (preferLocaleFonts && localeMap != null && if (preferLocaleFonts && localeMap != null &&
sun.font.FontManager.usingAlternateFontforJALocales()) { fontManager.usingAlternateFontforJALocales()) {
nameIDs[index] = remapLocaleMap(fontIndex, styleIndex, nameIDs[index] = remapLocaleMap(fontIndex, styleIndex,
coreScripts[index], nameIDs[index]); coreScripts[index], nameIDs[index]);
} }
@ -480,7 +481,7 @@ public abstract class FontConfiguration {
short id = getComponentFontID(fallbackScripts[i], short id = getComponentFontID(fallbackScripts[i],
fontIndex, styleIndex); fontIndex, styleIndex);
if (preferLocaleFonts && localeMap != null && if (preferLocaleFonts && localeMap != null &&
sun.font.FontManager.usingAlternateFontforJALocales()) { fontManager.usingAlternateFontforJALocales()) {
id = remapLocaleMap(fontIndex, styleIndex, fallbackScripts[i], id); id = remapLocaleMap(fontIndex, styleIndex, fallbackScripts[i], id);
} }
if (preferPropFonts) { if (preferPropFonts) {
@ -973,8 +974,8 @@ public abstract class FontConfiguration {
public CompositeFontDescriptor[] get2DCompositeFontInfo() { public CompositeFontDescriptor[] get2DCompositeFontInfo() {
CompositeFontDescriptor[] result = CompositeFontDescriptor[] result =
new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES]; new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES];
String defaultFontFile = environment.getDefaultFontFile(); String defaultFontFile = fontManager.getDefaultFontFile();
String defaultFontFaceName = environment.getDefaultFontFaceName(); String defaultFontFaceName = fontManager.getDefaultFontFaceName();
for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) { for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) {
String fontName = publicFontNames[fontIndex]; String fontName = publicFontNames[fontIndex];
@ -1121,7 +1122,7 @@ public abstract class FontConfiguration {
*/ */
HashMap<String, Boolean> existsMap; HashMap<String, Boolean> existsMap;
public boolean needToSearchForFile(String fileName) { public boolean needToSearchForFile(String fileName) {
if (!environment.isLinux) { if (!FontUtilities.isLinux) {
return false; return false;
} else if (existsMap == null) { } else if (existsMap == null) {
existsMap = new HashMap<String, Boolean>(); existsMap = new HashMap<String, Boolean>();
@ -1139,7 +1140,7 @@ public abstract class FontConfiguration {
} else { } else {
exists = Boolean.valueOf((new File(fileName)).exists()); exists = Boolean.valueOf((new File(fileName)).exists());
existsMap.put(fileName, exists); existsMap.put(fileName, exists);
if (SunGraphicsEnvironment.debugFonts && if (FontUtilities.debugFonts() &&
exists == Boolean.FALSE) { exists == Boolean.FALSE) {
logger.warning("Couldn't locate font file " + fileName); logger.warning("Couldn't locate font file " + fileName);
} }
@ -2067,7 +2068,8 @@ public abstract class FontConfiguration {
throw new Exception(); throw new Exception();
} }
} catch (Exception e) { } catch (Exception e) {
if (SunGraphicsEnvironment.debugFonts && logger != null) { if (FontUtilities.debugFonts() &&
logger != null) {
logger.config("Failed parsing " + key + logger.config("Failed parsing " + key +
" property of font configuration."); " property of font configuration.");

View File

@ -232,7 +232,7 @@ abstract class CMap {
* fonts are using gb2312 encoding, have to use this * fonts are using gb2312 encoding, have to use this
* workaround to make Solaris zh_CN locale work. -sherman * workaround to make Solaris zh_CN locale work. -sherman
*/ */
if (FontManager.isSolaris && font.platName != null && if (FontUtilities.isSolaris && font.platName != null &&
(font.platName.startsWith( (font.platName.startsWith(
"/usr/openwin/lib/locale/zh_CN.EUC/X11/fonts/TrueType") || "/usr/openwin/lib/locale/zh_CN.EUC/X11/fonts/TrueType") ||
font.platName.startsWith( font.platName.startsWith(
@ -407,8 +407,8 @@ abstract class CMap {
subtableLength = buffer.getInt(offset+4) & INTMASK; subtableLength = buffer.getInt(offset+4) & INTMASK;
} }
if (offset+subtableLength > buffer.capacity()) { if (offset+subtableLength > buffer.capacity()) {
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.warning("Cmap subtable overflows buffer."); FontUtilities.getLogger().warning("Cmap subtable overflows buffer.");
} }
} }
switch (subtableFormat) { switch (subtableFormat) {

View File

@ -60,7 +60,7 @@ public final class CompositeFont extends Font2D {
public CompositeFont(String name, String[] compFileNames, public CompositeFont(String name, String[] compFileNames,
String[] compNames, int metricsSlotCnt, String[] compNames, int metricsSlotCnt,
int[] exclRanges, int[] maxIndexes, int[] exclRanges, int[] maxIndexes,
boolean defer) { boolean defer, SunFontManager fm) {
handle = new Font2DHandle(this); handle = new Font2DHandle(this);
fullName = name; fullName = name;
@ -85,13 +85,13 @@ public final class CompositeFont extends Font2D {
* The caller could be responsible for this, but for now it seems * The caller could be responsible for this, but for now it seems
* better that it is handled internally to the CompositeFont class. * better that it is handled internally to the CompositeFont class.
*/ */
if (FontManager.eudcFont != null) { if (fm.getEUDCFont() != null) {
numSlots++; numSlots++;
if (componentNames != null) { if (componentNames != null) {
componentNames = new String[numSlots]; componentNames = new String[numSlots];
System.arraycopy(compNames, 0, componentNames, 0, numSlots-1); System.arraycopy(compNames, 0, componentNames, 0, numSlots-1);
componentNames[numSlots-1] = componentNames[numSlots-1] =
FontManager.eudcFont.getFontName(null); fm.getEUDCFont().getFontName(null);
} }
if (componentFileNames != null) { if (componentFileNames != null) {
componentFileNames = new String[numSlots]; componentFileNames = new String[numSlots];
@ -99,7 +99,7 @@ public final class CompositeFont extends Font2D {
componentFileNames, 0, numSlots-1); componentFileNames, 0, numSlots-1);
} }
components = new PhysicalFont[numSlots]; components = new PhysicalFont[numSlots];
components[numSlots-1] = FontManager.eudcFont; components[numSlots-1] = fm.getEUDCFont();
deferredInitialisation = new boolean[numSlots]; deferredInitialisation = new boolean[numSlots];
if (defer) { if (defer) {
for (int i=0; i<numSlots-1; i++) { for (int i=0; i<numSlots-1; i++) {
@ -165,7 +165,7 @@ public final class CompositeFont extends Font2D {
* it is harmless that we do not know a slot is already initialised * it is harmless that we do not know a slot is already initialised
* and just need to discover that and mark it so. * and just need to discover that and mark it so.
*/ */
synchronized (FontManager.class) { synchronized (FontManagerFactory.getInstance()) {
components = new PhysicalFont[numSlots]; components = new PhysicalFont[numSlots];
components[0] = physFont; components[0] = physFont;
System.arraycopy(compFont.components, 0, System.arraycopy(compFont.components, 0,
@ -235,7 +235,8 @@ public final class CompositeFont extends Font2D {
* This global lock is rarely likely to be an issue as there * This global lock is rarely likely to be an issue as there
* are only going to be a few calls into this code. * are only going to be a few calls into this code.
*/ */
synchronized (FontManager.class) { SunFontManager fm = SunFontManager.getInstance();
synchronized (fm) {
if (componentNames == null) { if (componentNames == null) {
componentNames = new String[numSlots]; componentNames = new String[numSlots];
} }
@ -251,22 +252,21 @@ public final class CompositeFont extends Font2D {
*/ */
if (componentFileNames != null && if (componentFileNames != null &&
componentFileNames[slot] != null) { componentFileNames[slot] != null) {
components[slot] = FontManager.initialiseDeferredFont components[slot] =
(componentFileNames[slot]); fm.initialiseDeferredFont(componentFileNames[slot]);
} }
if (components[slot] == null) { if (components[slot] == null) {
components[slot] = FontManager.getDefaultPhysicalFont(); components[slot] = fm.getDefaultPhysicalFont();
} }
String name = components[slot].getFontName(null); String name = components[slot].getFontName(null);
if (componentNames[slot] == null) { if (componentNames[slot] == null) {
componentNames[slot] = name; componentNames[slot] = name;
} else if (!componentNames[slot].equalsIgnoreCase(name)) { } else if (!componentNames[slot].equalsIgnoreCase(name)) {
components[slot] = components[slot] =
(PhysicalFont) (PhysicalFont) fm.findFont2D(componentNames[slot],
FontManager.findFont2D(componentNames[slot], style,
style, FontManager.PHYSICAL_FALLBACK);
FontManager.PHYSICAL_FALLBACK);
} }
} }
deferredInitialisation[slot] = false; deferredInitialisation[slot] = false;
@ -333,21 +333,22 @@ public final class CompositeFont extends Font2D {
if (deferredInitialisation[slot]) { if (deferredInitialisation[slot]) {
doDeferredInitialisation(slot); doDeferredInitialisation(slot);
} }
SunFontManager fm = SunFontManager.getInstance();
try { try {
PhysicalFont font = components[slot]; PhysicalFont font = components[slot];
if (font == null) { if (font == null) {
try { try {
font = (PhysicalFont)FontManager. font = (PhysicalFont) fm.
findFont2D(componentNames[slot], style, findFont2D(componentNames[slot], style,
FontManager.PHYSICAL_FALLBACK); FontManager.PHYSICAL_FALLBACK);
components[slot] = font; components[slot] = font;
} catch (ClassCastException cce) { } catch (ClassCastException cce) {
font = FontManager.getDefaultPhysicalFont(); font = fm.getDefaultPhysicalFont();
} }
} }
return font; return font;
} catch (Exception e) { } catch (Exception e) {
return FontManager.getDefaultPhysicalFont(); return fm.getDefaultPhysicalFont();
} }
} }

View File

@ -211,10 +211,10 @@ public final class CompositeGlyphMapper extends CharToGlyphMapper {
glyphs[i] = convertToGlyph(code); glyphs[i] = convertToGlyph(code);
} }
if (code < FontManager.MIN_LAYOUT_CHARCODE) { if (code < FontUtilities.MIN_LAYOUT_CHARCODE) {
continue; continue;
} }
else if (FontManager.isComplexCharCode(code)) { else if (FontUtilities.isComplexCharCode(code)) {
return true; return true;
} }
else if (code >= 0x10000) { else if (code >= 0x10000) {

View File

@ -158,7 +158,8 @@ public abstract class FileFont extends PhysicalFont {
* rare maybe it is not worth doing this last part. * rare maybe it is not worth doing this last part.
*/ */
synchronized void deregisterFontAndClearStrikeCache() { synchronized void deregisterFontAndClearStrikeCache() {
FontManager.deRegisterBadFont(this); SunFontManager fm = SunFontManager.getInstance();
fm.deRegisterBadFont(this);
for (Reference strikeRef : strikeCache.values()) { for (Reference strikeRef : strikeCache.values()) {
if (strikeRef != null) { if (strikeRef != null) {
@ -172,14 +173,14 @@ public abstract class FileFont extends PhysicalFont {
} }
} }
scaler.dispose(); scaler.dispose();
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
} }
StrikeMetrics getFontMetrics(long pScalerContext) { StrikeMetrics getFontMetrics(long pScalerContext) {
try { try {
return getScaler().getFontMetrics(pScalerContext); return getScaler().getFontMetrics(pScalerContext);
} catch (FontScalerException fe) { } catch (FontScalerException fe) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getFontMetrics(pScalerContext); return getFontMetrics(pScalerContext);
} }
} }
@ -188,7 +189,7 @@ public abstract class FileFont extends PhysicalFont {
try { try {
return getScaler().getGlyphAdvance(pScalerContext, glyphCode); return getScaler().getGlyphAdvance(pScalerContext, glyphCode);
} catch (FontScalerException fe) { } catch (FontScalerException fe) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getGlyphAdvance(pScalerContext, glyphCode); return getGlyphAdvance(pScalerContext, glyphCode);
} }
} }
@ -197,7 +198,7 @@ public abstract class FileFont extends PhysicalFont {
try { try {
getScaler().getGlyphMetrics(pScalerContext, glyphCode, metrics); getScaler().getGlyphMetrics(pScalerContext, glyphCode, metrics);
} catch (FontScalerException fe) { } catch (FontScalerException fe) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
getGlyphMetrics(pScalerContext, glyphCode, metrics); getGlyphMetrics(pScalerContext, glyphCode, metrics);
} }
} }
@ -206,7 +207,7 @@ public abstract class FileFont extends PhysicalFont {
try { try {
return getScaler().getGlyphImage(pScalerContext, glyphCode); return getScaler().getGlyphImage(pScalerContext, glyphCode);
} catch (FontScalerException fe) { } catch (FontScalerException fe) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getGlyphImage(pScalerContext, glyphCode); return getGlyphImage(pScalerContext, glyphCode);
} }
} }
@ -215,7 +216,7 @@ public abstract class FileFont extends PhysicalFont {
try { try {
return getScaler().getGlyphOutlineBounds(pScalerContext, glyphCode); return getScaler().getGlyphOutlineBounds(pScalerContext, glyphCode);
} catch (FontScalerException fe) { } catch (FontScalerException fe) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getGlyphOutlineBounds(pScalerContext, glyphCode); return getGlyphOutlineBounds(pScalerContext, glyphCode);
} }
} }
@ -224,7 +225,7 @@ public abstract class FileFont extends PhysicalFont {
try { try {
return getScaler().getGlyphOutline(pScalerContext, glyphCode, x, y); return getScaler().getGlyphOutline(pScalerContext, glyphCode, x, y);
} catch (FontScalerException fe) { } catch (FontScalerException fe) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getGlyphOutline(pScalerContext, glyphCode, x, y); return getGlyphOutline(pScalerContext, glyphCode, x, y);
} }
} }
@ -233,7 +234,7 @@ public abstract class FileFont extends PhysicalFont {
try { try {
return getScaler().getGlyphVectorOutline(pScalerContext, glyphs, numGlyphs, x, y); return getScaler().getGlyphVectorOutline(pScalerContext, glyphs, numGlyphs, x, y);
} catch (FontScalerException fe) { } catch (FontScalerException fe) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getGlyphVectorOutline(pScalerContext, glyphs, numGlyphs, x, y); return getGlyphVectorOutline(pScalerContext, glyphs, numGlyphs, x, y);
} }
} }
@ -275,7 +276,8 @@ public abstract class FileFont extends PhysicalFont {
*/ */
fontFile.delete(); fontFile.delete();
/* remove from delete on exit hook list : */ /* remove from delete on exit hook list : */
FontManager.tmpFontFiles.remove(fontFile); // FIXME: still need to be refactored
SunFontManager.getInstance().tmpFontFiles.remove(fontFile);
} catch (Exception e) { } catch (Exception e) {
} }
} }

View File

@ -114,7 +114,7 @@ public class FileFontStrike extends PhysicalStrike {
private static native boolean initNative(); private static native boolean initNative();
private static boolean isXPorLater = false; private static boolean isXPorLater = false;
static { static {
if (FontManager.isWindows && !FontManager.useT2K && if (FontUtilities.isWindows && !FontUtilities.useT2K &&
!GraphicsEnvironment.isHeadless()) { !GraphicsEnvironment.isHeadless()) {
isXPorLater = initNative(); isXPorLater = initNative();
} }
@ -201,7 +201,7 @@ public class FileFontStrike extends PhysicalStrike {
this.disposer = new FontStrikeDisposer(fileFont, desc); this.disposer = new FontStrikeDisposer(fileFont, desc);
initGlyphCache(); initGlyphCache();
pScalerContext = NullFontScaler.getNullScalerContext(); pScalerContext = NullFontScaler.getNullScalerContext();
FontManager.deRegisterBadFont(fileFont); SunFontManager.getInstance().deRegisterBadFont(fileFont);
return; return;
} }
/* First, see if native code should be used to create the glyph. /* First, see if native code should be used to create the glyph.
@ -211,8 +211,8 @@ public class FileFontStrike extends PhysicalStrike {
* except that the advance returned by GDI is always overwritten by * except that the advance returned by GDI is always overwritten by
* the JDK rasteriser supplied one (see getGlyphImageFromWindows()). * the JDK rasteriser supplied one (see getGlyphImageFromWindows()).
*/ */
if (FontManager.isWindows && isXPorLater && if (FontUtilities.isWindows && isXPorLater &&
!FontManager.useT2K && !FontUtilities.useT2K &&
!GraphicsEnvironment.isHeadless() && !GraphicsEnvironment.isHeadless() &&
!fileFont.useJavaRasterizer && !fileFont.useJavaRasterizer &&
(desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HRGB || (desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HRGB ||
@ -241,8 +241,8 @@ public class FileFontStrike extends PhysicalStrike {
} }
} }
} }
if (FontManager.logging && FontManager.isWindows) { if (FontUtilities.isLogging() && FontUtilities.isWindows) {
FontManager.logger.info FontUtilities.getLogger().info
("Strike for " + fileFont + " at size = " + intPtSize + ("Strike for " + fileFont + " at size = " + intPtSize +
" use natives = " + useNatives + " use natives = " + useNatives +
" useJavaRasteriser = " + fileFont.useJavaRasterizer + " useJavaRasteriser = " + fileFont.useJavaRasterizer +
@ -298,7 +298,7 @@ public class FileFontStrike extends PhysicalStrike {
} }
long getGlyphImageFromNative(int glyphCode) { long getGlyphImageFromNative(int glyphCode) {
if (FontManager.isWindows) { if (FontUtilities.isWindows) {
return getGlyphImageFromWindows(glyphCode); return getGlyphImageFromWindows(glyphCode);
} else { } else {
return getGlyphImageFromX11(glyphCode); return getGlyphImageFromX11(glyphCode);
@ -366,8 +366,8 @@ public class FileFontStrike extends PhysicalStrike {
} else { } else {
if (useNatives) { if (useNatives) {
glyphPtr = getGlyphImageFromNative(glyphCode); glyphPtr = getGlyphImageFromNative(glyphCode);
if (glyphPtr == 0L && FontManager.logging) { if (glyphPtr == 0L && FontUtilities.isLogging()) {
FontManager.logger.info FontUtilities.getLogger().info
("Strike for " + fileFont + ("Strike for " + fileFont +
" at size = " + intPtSize + " at size = " + intPtSize +
" couldn't get native glyph for code = " + glyphCode); " couldn't get native glyph for code = " + glyphCode);
@ -528,7 +528,7 @@ public class FileFontStrike extends PhysicalStrike {
if (segmentedCache) { if (segmentedCache) {
int numSegments = (numGlyphs + SEGSIZE-1)/SEGSIZE; int numSegments = (numGlyphs + SEGSIZE-1)/SEGSIZE;
if (FontManager.longAddresses) { if (longAddresses) {
glyphCacheFormat = SEGLONGARRAY; glyphCacheFormat = SEGLONGARRAY;
segLongGlyphImages = new long[numSegments][]; segLongGlyphImages = new long[numSegments][];
this.disposer.segLongGlyphImages = segLongGlyphImages; this.disposer.segLongGlyphImages = segLongGlyphImages;
@ -538,7 +538,7 @@ public class FileFontStrike extends PhysicalStrike {
this.disposer.segIntGlyphImages = segIntGlyphImages; this.disposer.segIntGlyphImages = segIntGlyphImages;
} }
} else { } else {
if (FontManager.longAddresses) { if (longAddresses) {
glyphCacheFormat = LONGARRAY; glyphCacheFormat = LONGARRAY;
longGlyphImages = new long[numGlyphs]; longGlyphImages = new long[numGlyphs];
this.disposer.longGlyphImages = longGlyphImages; this.disposer.longGlyphImages = longGlyphImages;

View File

@ -261,8 +261,9 @@ public final class FontDesignMetrics extends FontMetrics {
* Note that currently Swing native L&F composites are not handled * Note that currently Swing native L&F composites are not handled
* by this code as they use the metrics of the physical anyway. * by this code as they use the metrics of the physical anyway.
*/ */
if (FontManager.maybeUsingAlternateCompositeFonts() && SunFontManager fm = SunFontManager.getInstance();
FontManager.getFont2D(font) instanceof CompositeFont) { if (fm.maybeUsingAlternateCompositeFonts() &&
FontUtilities.getFont2D(font) instanceof CompositeFont) {
return new FontDesignMetrics(font, frc); return new FontDesignMetrics(font, frc);
} }
@ -353,7 +354,7 @@ public final class FontDesignMetrics extends FontMetrics {
private void initMatrixAndMetrics() { private void initMatrixAndMetrics() {
Font2D font2D = FontManager.getFont2D(font); Font2D font2D = FontUtilities.getFont2D(font);
fontStrike = font2D.getStrike(font, frc); fontStrike = font2D.getStrike(font, frc);
StrikeMetrics metrics = fontStrike.getFontMetrics(); StrikeMetrics metrics = fontStrike.getFontMetrics();
this.ascent = metrics.getAscent(); this.ascent = metrics.getAscent();
@ -473,7 +474,7 @@ public final class FontDesignMetrics extends FontMetrics {
char ch = str.charAt(i); char ch = str.charAt(i);
if (ch < 0x100) { if (ch < 0x100) {
width += getLatinCharWidth(ch); width += getLatinCharWidth(ch);
} else if (FontManager.isNonSimpleChar(ch)) { } else if (FontUtilities.isNonSimpleChar(ch)) {
width = new TextLayout(str, font, frc).getAdvance(); width = new TextLayout(str, font, frc).getAdvance();
break; break;
} else { } else {
@ -504,7 +505,7 @@ public final class FontDesignMetrics extends FontMetrics {
char ch = data[i]; char ch = data[i];
if (ch < 0x100) { if (ch < 0x100) {
width += getLatinCharWidth(ch); width += getLatinCharWidth(ch);
} else if (FontManager.isNonSimpleChar(ch)) { } else if (FontUtilities.isNonSimpleChar(ch)) {
String str = new String(data, off, len); String str = new String(data, off, len);
width = new TextLayout(str, font, frc).getAdvance(); width = new TextLayout(str, font, frc).getAdvance();
break; break;

View File

@ -107,8 +107,9 @@ public class FontFamily {
public void setFont(Font2D font, int style) { public void setFont(Font2D font, int style) {
if (font.getRank() > familyRank) { if (font.getRank() > familyRank) {
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.warning("Rejecting adding " + font + FontUtilities.getLogger()
.warning("Rejecting adding " + font +
" of lower rank " + font.getRank() + " of lower rank " + font.getRank() +
" to family " + this + " to family " + this +
" of rank " + familyRank); " of rank " + familyRank);

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@ public class FontManagerNativeLibrary {
public Object run() { public Object run() {
/* REMIND do we really have to load awt here? */ /* REMIND do we really have to load awt here? */
System.loadLibrary("awt"); System.loadLibrary("awt");
if (SunGraphicsEnvironment.isOpenJDK() && if (FontUtilities.isOpenJDK &&
System.getProperty("os.name").startsWith("Windows")) { System.getProperty("os.name").startsWith("Windows")) {
/* Ideally fontmanager library should not depend on /* Ideally fontmanager library should not depend on
particular implementation of the font scaler. particular implementation of the font scaler.

View File

@ -114,7 +114,7 @@ public final class FontResolver {
for (int i=0; i<getAllFonts().length; i++) { for (int i=0; i<getAllFonts().length; i++) {
Font font = allFonts[i]; Font font = allFonts[i];
Font2D font2D = FontManager.getFont2D(font); Font2D font2D = FontUtilities.getFont2D(font);
if (font2D.hasSupplementaryChars()) { if (font2D.hasSupplementaryChars()) {
fonts.add(font); fonts.add(font);
indices.add(Integer.valueOf(i)); indices.add(Integer.valueOf(i));

View File

@ -29,6 +29,9 @@ import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord; import sun.java2d.DisposerRecord;
/* FontScaler is "internal interface" to font rasterizer library. /* FontScaler is "internal interface" to font rasterizer library.
@ -77,6 +80,79 @@ import sun.java2d.DisposerRecord;
* this (and this is probably more important for Type1 fonts). * this (and this is probably more important for Type1 fonts).
*/ */
public abstract class FontScaler implements DisposerRecord { public abstract class FontScaler implements DisposerRecord {
private static FontScaler nullScaler = null;
private static Constructor<FontScaler> scalerConstructor = null;
//Find preferred font scaler
//
//NB: we can allow property based preferences
// (theoretically logic can be font type specific)
static {
Class scalerClass = null;
Class arglst[] = new Class[] {Font2D.class, int.class,
boolean.class, int.class};
try {
if (FontUtilities.isOpenJDK) {
scalerClass = Class.forName("sun.font.FreetypeFontScaler");
} else {
scalerClass = Class.forName("sun.font.T2KFontScaler");
}
} catch (ClassNotFoundException e) {
scalerClass = NullFontScaler.class;
}
//NB: rewrite using factory? constructor is ugly way
try {
scalerConstructor = scalerClass.getConstructor(arglst);
} catch (NoSuchMethodException e) {
//should not happen
}
}
/* This is the only place to instantiate new FontScaler.
* Therefore this is very convinient place to register
* scaler with Disposer as well as trigger deregistring bad font
* in case when scaler reports this.
*/
public static FontScaler getScaler(Font2D font,
int indexInCollection,
boolean supportsCJK,
int filesize) {
FontScaler scaler = null;
try {
Object args[] = new Object[] {font, indexInCollection,
supportsCJK, filesize};
scaler = scalerConstructor.newInstance(args);
Disposer.addObjectRecord(font, scaler);
} catch (Throwable e) {
scaler = nullScaler;
//if we can not instantiate scaler assume bad font
//NB: technically it could be also because of internal scaler
// error but here we are assuming scaler is ok.
FontManager fm = FontManagerFactory.getInstance();
fm.deRegisterBadFont(font);
}
return scaler;
}
/*
* At the moment it is harmless to create 2 null scalers so, technically,
* syncronized keyword is not needed.
*
* But it is safer to keep it to avoid subtle problems if we will be adding
* checks like whether scaler is null scaler.
*/
public static synchronized FontScaler getNullScaler() {
if (nullScaler == null) {
nullScaler = new NullFontScaler();
}
return nullScaler;
}
protected WeakReference<Font2D> font = null; protected WeakReference<Font2D> font = null;
protected long nativeScaler = 0; //used by decendants protected long nativeScaler = 0; //used by decendants
//that have native state //that have native state

View File

@ -79,7 +79,7 @@ class FreetypeFontScaler extends FontScaler {
pScalerContext, pScalerContext,
nativeScaler); nativeScaler);
} }
return FontManager.getNullScaler().getFontMetrics(0L); return FontScaler.getNullScaler().getFontMetrics(0L);
} }
synchronized float getGlyphAdvance(long pScalerContext, int glyphCode) synchronized float getGlyphAdvance(long pScalerContext, int glyphCode)
@ -90,7 +90,8 @@ class FreetypeFontScaler extends FontScaler {
nativeScaler, nativeScaler,
glyphCode); glyphCode);
} }
return FontManager.getNullScaler().getGlyphAdvance(0L, glyphCode); return FontScaler.getNullScaler().
getGlyphAdvance(0L, glyphCode);
} }
synchronized void getGlyphMetrics(long pScalerContext, synchronized void getGlyphMetrics(long pScalerContext,
@ -104,7 +105,8 @@ class FreetypeFontScaler extends FontScaler {
metrics); metrics);
return; return;
} }
FontManager.getNullScaler().getGlyphMetrics(0L, glyphCode, metrics); FontScaler.getNullScaler().
getGlyphMetrics(0L, glyphCode, metrics);
} }
synchronized long getGlyphImage(long pScalerContext, int glyphCode) synchronized long getGlyphImage(long pScalerContext, int glyphCode)
@ -115,7 +117,8 @@ class FreetypeFontScaler extends FontScaler {
nativeScaler, nativeScaler,
glyphCode); glyphCode);
} }
return FontManager.getNullScaler().getGlyphImage(0L, glyphCode); return FontScaler.getNullScaler().
getGlyphImage(0L, glyphCode);
} }
synchronized Rectangle2D.Float getGlyphOutlineBounds( synchronized Rectangle2D.Float getGlyphOutlineBounds(
@ -127,7 +130,8 @@ class FreetypeFontScaler extends FontScaler {
nativeScaler, nativeScaler,
glyphCode); glyphCode);
} }
return FontManager.getNullScaler().getGlyphOutlineBounds(0L,glyphCode); return FontScaler.getNullScaler().
getGlyphOutlineBounds(0L,glyphCode);
} }
synchronized GeneralPath getGlyphOutline( synchronized GeneralPath getGlyphOutline(
@ -140,7 +144,8 @@ class FreetypeFontScaler extends FontScaler {
glyphCode, glyphCode,
x, y); x, y);
} }
return FontManager.getNullScaler().getGlyphOutline(0L, glyphCode, x,y); return FontScaler.getNullScaler().
getGlyphOutline(0L, glyphCode, x,y);
} }
synchronized GeneralPath getGlyphVectorOutline( synchronized GeneralPath getGlyphVectorOutline(
@ -154,8 +159,8 @@ class FreetypeFontScaler extends FontScaler {
numGlyphs, numGlyphs,
x, y); x, y);
} }
return FontManager.getNullScaler().getGlyphVectorOutline( return FontScaler
0L, glyphs, numGlyphs, x, y); .getNullScaler().getGlyphVectorOutline(0L, glyphs, numGlyphs, x, y);
} }
synchronized long getLayoutTableCache() throws FontScalerException { synchronized long getLayoutTableCache() throws FontScalerException {
@ -173,21 +178,21 @@ class FreetypeFontScaler extends FontScaler {
if (nativeScaler != 0L) { if (nativeScaler != 0L) {
return getNumGlyphsNative(nativeScaler); return getNumGlyphsNative(nativeScaler);
} }
return FontManager.getNullScaler().getNumGlyphs(); return FontScaler.getNullScaler().getNumGlyphs();
} }
synchronized int getMissingGlyphCode() throws FontScalerException { synchronized int getMissingGlyphCode() throws FontScalerException {
if (nativeScaler != 0L) { if (nativeScaler != 0L) {
return getMissingGlyphCodeNative(nativeScaler); return getMissingGlyphCodeNative(nativeScaler);
} }
return FontManager.getNullScaler().getMissingGlyphCode(); return FontScaler.getNullScaler().getMissingGlyphCode();
} }
synchronized int getGlyphCode(char charCode) throws FontScalerException { synchronized int getGlyphCode(char charCode) throws FontScalerException {
if (nativeScaler != 0L) { if (nativeScaler != 0L) {
return getGlyphCodeNative(nativeScaler, charCode); return getGlyphCodeNative(nativeScaler, charCode);
} }
return FontManager.getNullScaler().getGlyphCode(charCode); return FontScaler.getNullScaler().getGlyphCode(charCode);
} }
synchronized Point2D.Float getGlyphPoint(long pScalerContext, synchronized Point2D.Float getGlyphPoint(long pScalerContext,
@ -197,7 +202,7 @@ class FreetypeFontScaler extends FontScaler {
return getGlyphPointNative(font.get(), pScalerContext, return getGlyphPointNative(font.get(), pScalerContext,
nativeScaler, glyphCode, ptNumber); nativeScaler, glyphCode, ptNumber);
} }
return FontManager.getNullScaler().getGlyphPoint( return FontScaler.getNullScaler().getGlyphPoint(
pScalerContext, glyphCode, ptNumber); pScalerContext, glyphCode, ptNumber);
} }

View File

@ -259,7 +259,7 @@ public final class GlyphLayout {
*/ */
int aa = int aa =
FontStrikeDesc.getAAHintIntVal(frc.getAntiAliasingHint(), FontStrikeDesc.getAAHintIntVal(frc.getAntiAliasingHint(),
FontManager.getFont2D(font), FontUtilities.getFont2D(font),
(int)Math.abs(ptSize)); (int)Math.abs(ptSize));
int fm = FontStrikeDesc.getFMHintIntVal int fm = FontStrikeDesc.getFMHintIntVal
(frc.getFractionalMetricsHint()); (frc.getFractionalMetricsHint());
@ -407,7 +407,7 @@ public final class GlyphLayout {
int lang = -1; // default for now int lang = -1; // default for now
Font2D font2D = FontManager.getFont2D(font); Font2D font2D = FontUtilities.getFont2D(font);
_textRecord.init(text, offset, lim, min, max); _textRecord.init(text, offset, lim, min, max);
int start = offset; int start = offset;

View File

@ -36,6 +36,14 @@ import java.util.concurrent.ConcurrentHashMap;
public abstract class PhysicalStrike extends FontStrike { public abstract class PhysicalStrike extends FontStrike {
static final long INTMASK = 0xffffffffL; static final long INTMASK = 0xffffffffL;
static boolean longAddresses;
static {
switch (StrikeCache.nativeAddressSize) {
case 8: longAddresses = true; break;
case 4: longAddresses = false; break;
default: throw new RuntimeException("Unexpected address size");
}
}
private PhysicalFont physicalFont; private PhysicalFont physicalFont;
protected CharToGlyphMapper mapper; protected CharToGlyphMapper mapper;

View File

@ -197,7 +197,7 @@ public class StandardGlyphVector extends GlyphVector {
// how do we know its a base glyph // how do we know its a base glyph
// for now, it is if the natural advance of the glyph is non-zero // for now, it is if the natural advance of the glyph is non-zero
Font2D f2d = FontManager.getFont2D(font); Font2D f2d = FontUtilities.getFont2D(font);
FontStrike strike = f2d.getStrike(font, frc); FontStrike strike = f2d.getStrike(font, frc);
float[] deltas = { trackPt.x, trackPt.y }; float[] deltas = { trackPt.x, trackPt.y };
@ -1116,7 +1116,7 @@ public class StandardGlyphVector extends GlyphVector {
} }
private void initFontData() { private void initFontData() {
font2D = FontManager.getFont2D(font); font2D = FontUtilities.getFont2D(font);
float s = font.getSize2D(); float s = font.getSize2D();
if (font.isTransformed()) { if (font.isTransformed()) {
ftx = font.getTransform(); ftx = font.getTransform();

View File

@ -237,7 +237,7 @@ public final class StrikeCache {
* any glyphs. In this case we still want to free the scaler * any glyphs. In this case we still want to free the scaler
* context. * context.
*/ */
if (FontManager.longAddresses) { if (longAddresses()) {
freeLongMemory(new long[0], disposer.pScalerContext); freeLongMemory(new long[0], disposer.pScalerContext);
} else { } else {
freeIntMemory(new int[0], disposer.pScalerContext); freeIntMemory(new int[0], disposer.pScalerContext);
@ -245,6 +245,10 @@ public final class StrikeCache {
} }
} }
private static boolean longAddresses() {
return nativeAddressSize == 8;
}
static void disposeStrike(final FontStrikeDisposer disposer) { static void disposeStrike(final FontStrikeDisposer disposer) {
// we need to execute the strike disposal on the rendering thread // we need to execute the strike disposal on the rendering thread
// because they may be accessed on that thread at the time of the // because they may be accessed on that thread at the time of the

View File

@ -39,7 +39,9 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer; import java.nio.ShortBuffer;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import sun.java2d.Disposer; import sun.java2d.Disposer;
@ -101,6 +103,9 @@ public class TrueTypeFont extends FileFont {
public static final int FULL_NAME_ID = 4; public static final int FULL_NAME_ID = 4;
public static final int POSTSCRIPT_NAME_ID = 6; public static final int POSTSCRIPT_NAME_ID = 6;
private static final short US_LCID = 0x0409; // US English - default
private static Map<String, Short> lcidMap;
class DirectoryEntry { class DirectoryEntry {
int tag; int tag;
@ -176,7 +181,7 @@ public class TrueTypeFont extends FileFont {
* @throws FontFormatException - if the font can't be opened * @throws FontFormatException - if the font can't be opened
* or fails verification, or there's no usable cmap * or fails verification, or there's no usable cmap
*/ */
TrueTypeFont(String platname, Object nativeNames, int fIndex, public TrueTypeFont(String platname, Object nativeNames, int fIndex,
boolean javaRasterizer) boolean javaRasterizer)
throws FontFormatException { throws FontFormatException {
super(platname, nativeNames); super(platname, nativeNames);
@ -207,12 +212,13 @@ public class TrueTypeFont extends FileFont {
* as PCF bitmap fonts on the X11 font path). * as PCF bitmap fonts on the X11 font path).
* This method is called when creating the first strike for this font. * This method is called when creating the first strike for this font.
*/ */
@Override
protected boolean checkUseNatives() { protected boolean checkUseNatives() {
if (checkedNatives) { if (checkedNatives) {
return useNatives; return useNatives;
} }
if (!FontManager.isSolaris || useJavaRasterizer || if (!FontUtilities.isSolaris || useJavaRasterizer ||
FontManager.useT2K || nativeNames == null || FontUtilities.useT2K || nativeNames == null ||
getDirectoryEntry(EBLCTag) != null || getDirectoryEntry(EBLCTag) != null ||
GraphicsEnvironment.isHeadless()) { GraphicsEnvironment.isHeadless()) {
checkedNatives = true; checkedNatives = true;
@ -279,8 +285,8 @@ public class TrueTypeFont extends FileFont {
*/ */
private synchronized FileChannel open() throws FontFormatException { private synchronized FileChannel open() throws FontFormatException {
if (disposerRecord.channel == null) { if (disposerRecord.channel == null) {
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.info("open TTF: " + platName); FontUtilities.getLogger().info("open TTF: " + platName);
} }
try { try {
RandomAccessFile raf = (RandomAccessFile) RandomAccessFile raf = (RandomAccessFile)
@ -296,7 +302,10 @@ public class TrueTypeFont extends FileFont {
}); });
disposerRecord.channel = raf.getChannel(); disposerRecord.channel = raf.getChannel();
fileSize = (int)disposerRecord.channel.size(); fileSize = (int)disposerRecord.channel.size();
FontManager.addToPool(this); FontManager fm = FontManagerFactory.getInstance();
if (fm instanceof SunFontManager) {
((SunFontManager) fm).addToPool(this);
}
} catch (NullPointerException e) { } catch (NullPointerException e) {
close(); close();
throw new FontFormatException(e.toString()); throw new FontFormatException(e.toString());
@ -340,11 +349,11 @@ public class TrueTypeFont extends FileFont {
* isn't updated. If the file has changed whilst we * isn't updated. If the file has changed whilst we
* are executing we want to bail, not spin. * are executing we want to bail, not spin.
*/ */
if (FontManager.logging) { if (FontUtilities.isLogging()) {
String msg = "Read offset is " + offset + String msg = "Read offset is " + offset +
" file size is " + fileSize+ " file size is " + fileSize+
" file is " + platName; " file is " + platName;
FontManager.logger.severe(msg); FontUtilities.getLogger().severe(msg);
} }
return -1; return -1;
} else { } else {
@ -362,8 +371,8 @@ public class TrueTypeFont extends FileFont {
msg += " File size was " + fileSize + msg += " File size was " + fileSize +
" and now is " + currSize; " and now is " + currSize;
} }
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.severe(msg); FontUtilities.getLogger().severe(msg);
} }
// We could still flip() the buffer here because // We could still flip() the buffer here because
// it's possible that we did read some data in // it's possible that we did read some data in
@ -377,10 +386,10 @@ public class TrueTypeFont extends FileFont {
// data was read to probably continue. // data was read to probably continue.
if (bread > length/2 || bread > 16384) { if (bread > length/2 || bread > 16384) {
buffer.flip(); buffer.flip();
if (FontManager.logging) { if (FontUtilities.isLogging()) {
msg = "Returning " + bread + msg = "Returning " + bread +
" bytes instead of " + length; " bytes instead of " + length;
FontManager.logger.severe(msg); FontUtilities.getLogger().severe(msg);
} }
} else { } else {
bread = -1; bread = -1;
@ -395,8 +404,8 @@ public class TrueTypeFont extends FileFont {
} }
} }
} catch (FontFormatException e) { } catch (FontFormatException e) {
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.log(Level.SEVERE, FontUtilities.getLogger().log(Level.SEVERE,
"While reading " + platName, e); "While reading " + platName, e);
} }
bread = -1; // signal EOF bread = -1; // signal EOF
@ -416,8 +425,8 @@ public class TrueTypeFont extends FileFont {
* seems unlikely this would occur as problems opening the * seems unlikely this would occur as problems opening the
* file are handled as a FontFormatException. * file are handled as a FontFormatException.
*/ */
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.log(Level.SEVERE, FontUtilities.getLogger().log(Level.SEVERE,
"While reading " + platName, e); "While reading " + platName, e);
} }
if (bread == 0) { if (bread == 0) {
@ -540,8 +549,8 @@ public class TrueTypeFont extends FileFont {
} }
initNames(); initNames();
} catch (Exception e) { } catch (Exception e) {
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.severe(e.toString()); FontUtilities.getLogger().severe(e.toString());
} }
if (e instanceof FontFormatException) { if (e instanceof FontFormatException) {
throw (FontFormatException)e; throw (FontFormatException)e;
@ -687,7 +696,7 @@ public class TrueTypeFont extends FileFont {
return defaultCodePage; return defaultCodePage;
} }
if (FontManager.isWindows) { if (FontUtilities.isWindows) {
defaultCodePage = defaultCodePage =
(String)java.security.AccessController.doPrivileged( (String)java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("file.encoding")); new sun.security.action.GetPropertyAction("file.encoding"));
@ -724,6 +733,7 @@ public class TrueTypeFont extends FileFont {
/* Theoretically, reserved bits must not be set, include symbol bits */ /* Theoretically, reserved bits must not be set, include symbol bits */
public static final int reserved_bits1 = 0x80000000; public static final int reserved_bits1 = 0x80000000;
public static final int reserved_bits2 = 0x0000ffff; public static final int reserved_bits2 = 0x0000ffff;
@Override
boolean supportsEncoding(String encoding) { boolean supportsEncoding(String encoding) {
if (encoding == null) { if (encoding == null) {
encoding = getCodePage(); encoding = getCodePage();
@ -858,6 +868,7 @@ public class TrueTypeFont extends FileFont {
} }
} }
@Override
byte[] getTableBytes(int tag) { byte[] getTableBytes(int tag) {
ByteBuffer buffer = getTableBuffer(tag); ByteBuffer buffer = getTableBuffer(tag);
if (buffer == null) { if (buffer == null) {
@ -932,6 +943,7 @@ public class TrueTypeFont extends FileFont {
/* This probably won't get called but is there to support the /* This probably won't get called but is there to support the
* contract() of setStyle() defined in the superclass. * contract() of setStyle() defined in the superclass.
*/ */
@Override
protected void setStyle() { protected void setStyle() {
setStyle(getTableBuffer(os_2Tag)); setStyle(getTableBuffer(os_2Tag));
} }
@ -977,7 +989,7 @@ public class TrueTypeFont extends FileFont {
style = Font.ITALIC; style = Font.ITALIC;
break; break;
case fsSelectionBoldBit: case fsSelectionBoldBit:
if (FontManager.isSolaris && platName.endsWith("HG-GothicB.ttf")) { if (FontUtilities.isSolaris && platName.endsWith("HG-GothicB.ttf")) {
/* Workaround for Solaris's use of a JA font that's marked as /* Workaround for Solaris's use of a JA font that's marked as
* being designed bold, but is used as a PLAIN font. * being designed bold, but is used as a PLAIN font.
*/ */
@ -1015,6 +1027,7 @@ public class TrueTypeFont extends FileFont {
ulPos = -sb.get(4) / (float)upem; ulPos = -sb.get(4) / (float)upem;
} }
@Override
public void getStyleMetrics(float pointSize, float[] metrics, int offset) { public void getStyleMetrics(float pointSize, float[] metrics, int offset) {
if (ulSize == 0f && ulPos == 0f) { if (ulSize == 0f && ulPos == 0f) {
@ -1075,8 +1088,8 @@ public class TrueTypeFont extends FileFont {
try { try {
return new String(bytes, 0, len, charset); return new String(bytes, 0, len, charset);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.warning(e + " EncodingID=" + encoding); FontUtilities.getLogger().warning(e + " EncodingID=" + encoding);
} }
return new String(bytes, 0, len); return new String(bytes, 0, len);
} catch (Throwable t) { } catch (Throwable t) {
@ -1101,7 +1114,7 @@ public class TrueTypeFont extends FileFont {
int stringPtr = sbuffer.get() & 0xffff; int stringPtr = sbuffer.get() & 0xffff;
nameLocale = sun.awt.SunToolkit.getStartupLocale(); nameLocale = sun.awt.SunToolkit.getStartupLocale();
short nameLocaleID = FontManager.getLCIDFromLocale(nameLocale); short nameLocaleID = getLCIDFromLocale(nameLocale);
for (int i=0; i<numRecords; i++) { for (int i=0; i<numRecords; i++) {
short platformID = sbuffer.get(); short platformID = sbuffer.get();
@ -1232,7 +1245,7 @@ public class TrueTypeFont extends FileFont {
protected synchronized FontScaler getScaler() { protected synchronized FontScaler getScaler() {
if (scaler == null) { if (scaler == null) {
scaler = FontManager.getScaler(this, fontIndex, scaler = FontScaler.getScaler(this, fontIndex,
supportsCJK, fileSize); supportsCJK, fileSize);
} }
return scaler; return scaler;
@ -1242,6 +1255,7 @@ public class TrueTypeFont extends FileFont {
/* Postscript name is rarely requested. Don't waste cycles locating it /* Postscript name is rarely requested. Don't waste cycles locating it
* as part of font creation, nor storage to hold it. Get it only on demand. * as part of font creation, nor storage to hold it. Get it only on demand.
*/ */
@Override
public String getPostscriptName() { public String getPostscriptName() {
String name = lookupName(ENGLISH_LOCALE_ID, POSTSCRIPT_NAME_ID); String name = lookupName(ENGLISH_LOCALE_ID, POSTSCRIPT_NAME_ID);
if (name == null) { if (name == null) {
@ -1251,13 +1265,14 @@ public class TrueTypeFont extends FileFont {
} }
} }
@Override
public String getFontName(Locale locale) { public String getFontName(Locale locale) {
if (locale == null) { if (locale == null) {
return fullName; return fullName;
} else if (locale.equals(nameLocale) && localeFullName != null) { } else if (locale.equals(nameLocale) && localeFullName != null) {
return localeFullName; return localeFullName;
} else { } else {
short localeID = FontManager.getLCIDFromLocale(locale); short localeID = getLCIDFromLocale(locale);
String name = lookupName(localeID, FULL_NAME_ID); String name = lookupName(localeID, FULL_NAME_ID);
if (name == null) { if (name == null) {
return fullName; return fullName;
@ -1267,16 +1282,239 @@ public class TrueTypeFont extends FileFont {
} }
} }
// Return a Microsoft LCID from the given Locale.
// Used when getting localized font data.
private static void addLCIDMapEntry(Map<String, Short> map,
String key, short value) {
map.put(key, Short.valueOf(value));
}
private static synchronized void createLCIDMap() {
if (lcidMap != null) {
return;
}
Map<String, Short> map = new HashMap<String, Short>(200);
// the following statements are derived from the langIDMap
// in src/windows/native/java/lang/java_props_md.c using the following
// awk script:
// $1~/\/\*/ { next}
// $3~/\?\?/ { next }
// $3!~/_/ { next }
// $1~/0x0409/ { next }
// $1~/0x0c0a/ { next }
// $1~/0x042c/ { next }
// $1~/0x0443/ { next }
// $1~/0x0812/ { next }
// $1~/0x04/ { print " addLCIDMapEntry(map, " substr($3, 0, 3) "\", (short) " substr($1, 0, 6) ");" ; next }
// $3~/,/ { print " addLCIDMapEntry(map, " $3 " (short) " substr($1, 0, 6) ");" ; next }
// { print " addLCIDMapEntry(map, " $3 ", (short) " substr($1, 0, 6) ");" ; next }
// The lines of this script:
// - eliminate comments
// - eliminate questionable locales
// - eliminate language-only locales
// - eliminate the default LCID value
// - eliminate a few other unneeded LCID values
// - print language-only locale entries for x04* LCID values
// (apparently Microsoft doesn't use language-only LCID values -
// see http://www.microsoft.com/OpenType/otspec/name.htm
// - print complete entries for all other LCID values
// Run
// awk -f awk-script langIDMap > statements
addLCIDMapEntry(map, "ar", (short) 0x0401);
addLCIDMapEntry(map, "bg", (short) 0x0402);
addLCIDMapEntry(map, "ca", (short) 0x0403);
addLCIDMapEntry(map, "zh", (short) 0x0404);
addLCIDMapEntry(map, "cs", (short) 0x0405);
addLCIDMapEntry(map, "da", (short) 0x0406);
addLCIDMapEntry(map, "de", (short) 0x0407);
addLCIDMapEntry(map, "el", (short) 0x0408);
addLCIDMapEntry(map, "es", (short) 0x040a);
addLCIDMapEntry(map, "fi", (short) 0x040b);
addLCIDMapEntry(map, "fr", (short) 0x040c);
addLCIDMapEntry(map, "iw", (short) 0x040d);
addLCIDMapEntry(map, "hu", (short) 0x040e);
addLCIDMapEntry(map, "is", (short) 0x040f);
addLCIDMapEntry(map, "it", (short) 0x0410);
addLCIDMapEntry(map, "ja", (short) 0x0411);
addLCIDMapEntry(map, "ko", (short) 0x0412);
addLCIDMapEntry(map, "nl", (short) 0x0413);
addLCIDMapEntry(map, "no", (short) 0x0414);
addLCIDMapEntry(map, "pl", (short) 0x0415);
addLCIDMapEntry(map, "pt", (short) 0x0416);
addLCIDMapEntry(map, "rm", (short) 0x0417);
addLCIDMapEntry(map, "ro", (short) 0x0418);
addLCIDMapEntry(map, "ru", (short) 0x0419);
addLCIDMapEntry(map, "hr", (short) 0x041a);
addLCIDMapEntry(map, "sk", (short) 0x041b);
addLCIDMapEntry(map, "sq", (short) 0x041c);
addLCIDMapEntry(map, "sv", (short) 0x041d);
addLCIDMapEntry(map, "th", (short) 0x041e);
addLCIDMapEntry(map, "tr", (short) 0x041f);
addLCIDMapEntry(map, "ur", (short) 0x0420);
addLCIDMapEntry(map, "in", (short) 0x0421);
addLCIDMapEntry(map, "uk", (short) 0x0422);
addLCIDMapEntry(map, "be", (short) 0x0423);
addLCIDMapEntry(map, "sl", (short) 0x0424);
addLCIDMapEntry(map, "et", (short) 0x0425);
addLCIDMapEntry(map, "lv", (short) 0x0426);
addLCIDMapEntry(map, "lt", (short) 0x0427);
addLCIDMapEntry(map, "fa", (short) 0x0429);
addLCIDMapEntry(map, "vi", (short) 0x042a);
addLCIDMapEntry(map, "hy", (short) 0x042b);
addLCIDMapEntry(map, "eu", (short) 0x042d);
addLCIDMapEntry(map, "mk", (short) 0x042f);
addLCIDMapEntry(map, "tn", (short) 0x0432);
addLCIDMapEntry(map, "xh", (short) 0x0434);
addLCIDMapEntry(map, "zu", (short) 0x0435);
addLCIDMapEntry(map, "af", (short) 0x0436);
addLCIDMapEntry(map, "ka", (short) 0x0437);
addLCIDMapEntry(map, "fo", (short) 0x0438);
addLCIDMapEntry(map, "hi", (short) 0x0439);
addLCIDMapEntry(map, "mt", (short) 0x043a);
addLCIDMapEntry(map, "se", (short) 0x043b);
addLCIDMapEntry(map, "gd", (short) 0x043c);
addLCIDMapEntry(map, "ms", (short) 0x043e);
addLCIDMapEntry(map, "kk", (short) 0x043f);
addLCIDMapEntry(map, "ky", (short) 0x0440);
addLCIDMapEntry(map, "sw", (short) 0x0441);
addLCIDMapEntry(map, "tt", (short) 0x0444);
addLCIDMapEntry(map, "bn", (short) 0x0445);
addLCIDMapEntry(map, "pa", (short) 0x0446);
addLCIDMapEntry(map, "gu", (short) 0x0447);
addLCIDMapEntry(map, "ta", (short) 0x0449);
addLCIDMapEntry(map, "te", (short) 0x044a);
addLCIDMapEntry(map, "kn", (short) 0x044b);
addLCIDMapEntry(map, "ml", (short) 0x044c);
addLCIDMapEntry(map, "mr", (short) 0x044e);
addLCIDMapEntry(map, "sa", (short) 0x044f);
addLCIDMapEntry(map, "mn", (short) 0x0450);
addLCIDMapEntry(map, "cy", (short) 0x0452);
addLCIDMapEntry(map, "gl", (short) 0x0456);
addLCIDMapEntry(map, "dv", (short) 0x0465);
addLCIDMapEntry(map, "qu", (short) 0x046b);
addLCIDMapEntry(map, "mi", (short) 0x0481);
addLCIDMapEntry(map, "ar_IQ", (short) 0x0801);
addLCIDMapEntry(map, "zh_CN", (short) 0x0804);
addLCIDMapEntry(map, "de_CH", (short) 0x0807);
addLCIDMapEntry(map, "en_GB", (short) 0x0809);
addLCIDMapEntry(map, "es_MX", (short) 0x080a);
addLCIDMapEntry(map, "fr_BE", (short) 0x080c);
addLCIDMapEntry(map, "it_CH", (short) 0x0810);
addLCIDMapEntry(map, "nl_BE", (short) 0x0813);
addLCIDMapEntry(map, "no_NO_NY", (short) 0x0814);
addLCIDMapEntry(map, "pt_PT", (short) 0x0816);
addLCIDMapEntry(map, "ro_MD", (short) 0x0818);
addLCIDMapEntry(map, "ru_MD", (short) 0x0819);
addLCIDMapEntry(map, "sr_CS", (short) 0x081a);
addLCIDMapEntry(map, "sv_FI", (short) 0x081d);
addLCIDMapEntry(map, "az_AZ", (short) 0x082c);
addLCIDMapEntry(map, "se_SE", (short) 0x083b);
addLCIDMapEntry(map, "ga_IE", (short) 0x083c);
addLCIDMapEntry(map, "ms_BN", (short) 0x083e);
addLCIDMapEntry(map, "uz_UZ", (short) 0x0843);
addLCIDMapEntry(map, "qu_EC", (short) 0x086b);
addLCIDMapEntry(map, "ar_EG", (short) 0x0c01);
addLCIDMapEntry(map, "zh_HK", (short) 0x0c04);
addLCIDMapEntry(map, "de_AT", (short) 0x0c07);
addLCIDMapEntry(map, "en_AU", (short) 0x0c09);
addLCIDMapEntry(map, "fr_CA", (short) 0x0c0c);
addLCIDMapEntry(map, "sr_CS", (short) 0x0c1a);
addLCIDMapEntry(map, "se_FI", (short) 0x0c3b);
addLCIDMapEntry(map, "qu_PE", (short) 0x0c6b);
addLCIDMapEntry(map, "ar_LY", (short) 0x1001);
addLCIDMapEntry(map, "zh_SG", (short) 0x1004);
addLCIDMapEntry(map, "de_LU", (short) 0x1007);
addLCIDMapEntry(map, "en_CA", (short) 0x1009);
addLCIDMapEntry(map, "es_GT", (short) 0x100a);
addLCIDMapEntry(map, "fr_CH", (short) 0x100c);
addLCIDMapEntry(map, "hr_BA", (short) 0x101a);
addLCIDMapEntry(map, "ar_DZ", (short) 0x1401);
addLCIDMapEntry(map, "zh_MO", (short) 0x1404);
addLCIDMapEntry(map, "de_LI", (short) 0x1407);
addLCIDMapEntry(map, "en_NZ", (short) 0x1409);
addLCIDMapEntry(map, "es_CR", (short) 0x140a);
addLCIDMapEntry(map, "fr_LU", (short) 0x140c);
addLCIDMapEntry(map, "bs_BA", (short) 0x141a);
addLCIDMapEntry(map, "ar_MA", (short) 0x1801);
addLCIDMapEntry(map, "en_IE", (short) 0x1809);
addLCIDMapEntry(map, "es_PA", (short) 0x180a);
addLCIDMapEntry(map, "fr_MC", (short) 0x180c);
addLCIDMapEntry(map, "sr_BA", (short) 0x181a);
addLCIDMapEntry(map, "ar_TN", (short) 0x1c01);
addLCIDMapEntry(map, "en_ZA", (short) 0x1c09);
addLCIDMapEntry(map, "es_DO", (short) 0x1c0a);
addLCIDMapEntry(map, "sr_BA", (short) 0x1c1a);
addLCIDMapEntry(map, "ar_OM", (short) 0x2001);
addLCIDMapEntry(map, "en_JM", (short) 0x2009);
addLCIDMapEntry(map, "es_VE", (short) 0x200a);
addLCIDMapEntry(map, "ar_YE", (short) 0x2401);
addLCIDMapEntry(map, "es_CO", (short) 0x240a);
addLCIDMapEntry(map, "ar_SY", (short) 0x2801);
addLCIDMapEntry(map, "en_BZ", (short) 0x2809);
addLCIDMapEntry(map, "es_PE", (short) 0x280a);
addLCIDMapEntry(map, "ar_JO", (short) 0x2c01);
addLCIDMapEntry(map, "en_TT", (short) 0x2c09);
addLCIDMapEntry(map, "es_AR", (short) 0x2c0a);
addLCIDMapEntry(map, "ar_LB", (short) 0x3001);
addLCIDMapEntry(map, "en_ZW", (short) 0x3009);
addLCIDMapEntry(map, "es_EC", (short) 0x300a);
addLCIDMapEntry(map, "ar_KW", (short) 0x3401);
addLCIDMapEntry(map, "en_PH", (short) 0x3409);
addLCIDMapEntry(map, "es_CL", (short) 0x340a);
addLCIDMapEntry(map, "ar_AE", (short) 0x3801);
addLCIDMapEntry(map, "es_UY", (short) 0x380a);
addLCIDMapEntry(map, "ar_BH", (short) 0x3c01);
addLCIDMapEntry(map, "es_PY", (short) 0x3c0a);
addLCIDMapEntry(map, "ar_QA", (short) 0x4001);
addLCIDMapEntry(map, "es_BO", (short) 0x400a);
addLCIDMapEntry(map, "es_SV", (short) 0x440a);
addLCIDMapEntry(map, "es_HN", (short) 0x480a);
addLCIDMapEntry(map, "es_NI", (short) 0x4c0a);
addLCIDMapEntry(map, "es_PR", (short) 0x500a);
lcidMap = map;
}
private static short getLCIDFromLocale(Locale locale) {
// optimize for common case
if (locale.equals(Locale.US)) {
return US_LCID;
}
if (lcidMap == null) {
createLCIDMap();
}
String key = locale.toString();
while (!"".equals(key)) {
Short lcidObject = (Short) lcidMap.get(key);
if (lcidObject != null) {
return lcidObject.shortValue();
}
int pos = key.lastIndexOf('_');
if (pos < 1) {
return US_LCID;
}
key = key.substring(0, pos);
}
return US_LCID;
}
@Override
public String getFamilyName(Locale locale) { public String getFamilyName(Locale locale) {
if (locale == null) { if (locale == null) {
return familyName; return familyName;
} else if (locale.equals(nameLocale) && localeFamilyName != null) { } else if (locale.equals(nameLocale) && localeFamilyName != null) {
return localeFamilyName; return localeFamilyName;
} else { } else {
short localeID = FontManager.getLCIDFromLocale(locale); short localeID = getLCIDFromLocale(locale);
String name = lookupName(localeID, FAMILY_NAME_ID); String name = lookupName(localeID, FAMILY_NAME_ID);
if (name == null) { if (name == null) {
return familyName; return familyName;
} else { } else {
return name; return name;
} }
@ -1353,6 +1591,7 @@ public class TrueTypeFont extends FileFont {
/* Used by the OpenType engine for mark positioning. /* Used by the OpenType engine for mark positioning.
*/ */
@Override
Point2D.Float getGlyphPoint(long pScalerContext, Point2D.Float getGlyphPoint(long pScalerContext,
int glyphCode, int ptNumber) { int glyphCode, int ptNumber) {
try { try {
@ -1414,6 +1653,7 @@ public class TrueTypeFont extends FileFont {
* REMIND: consider unpacking the table into an array of booleans * REMIND: consider unpacking the table into an array of booleans
* for faster use. * for faster use.
*/ */
@Override
public boolean useAAForPtSize(int ptsize) { public boolean useAAForPtSize(int ptsize) {
char[] gasp = getGaspTable(); char[] gasp = getGaspTable();
@ -1433,12 +1673,15 @@ public class TrueTypeFont extends FileFont {
} }
} }
@Override
public boolean hasSupplementaryChars() { public boolean hasSupplementaryChars() {
return ((TrueTypeGlyphMapper)getMapper()).hasSupplementaryChars(); return ((TrueTypeGlyphMapper)getMapper()).hasSupplementaryChars();
} }
@Override
public String toString() { public String toString() {
return "** TrueType Font: Family="+familyName+ " Name="+fullName+ return "** TrueType Font: Family="+familyName+ " Name="+fullName+
" style="+style+" fileName="+platName; " style="+style+" fileName="+platName;
} }
} }

View File

@ -60,9 +60,9 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
missingGlyph = 0; /* standard for TrueType fonts */ missingGlyph = 0; /* standard for TrueType fonts */
ByteBuffer buffer = font.getTableBuffer(TrueTypeFont.maxpTag); ByteBuffer buffer = font.getTableBuffer(TrueTypeFont.maxpTag);
numGlyphs = buffer.getChar(4); // offset 4 bytes in MAXP table. numGlyphs = buffer.getChar(4); // offset 4 bytes in MAXP table.
if (FontManager.isSolaris && isJAlocale && font.supportsJA()) { if (FontUtilities.isSolaris && isJAlocale && font.supportsJA()) {
needsJAremapping = true; needsJAremapping = true;
if (FontManager.isSolaris8 && if (FontUtilities.isSolaris8 &&
getGlyphFromCMAP(JA_WAVE_DASH_CHAR) == missingGlyph) { getGlyphFromCMAP(JA_WAVE_DASH_CHAR) == missingGlyph) {
remapJAWaveDash = true; remapJAWaveDash = true;
} }
@ -82,8 +82,8 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
glyphCode >= FileFontStrike.INVISIBLE_GLYPHS) { glyphCode >= FileFontStrike.INVISIBLE_GLYPHS) {
return glyphCode; return glyphCode;
} else { } else {
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.warning FontUtilities.getLogger().warning
(font + " out of range glyph id=" + (font + " out of range glyph id=" +
Integer.toHexString((int)glyphCode) + Integer.toHexString((int)glyphCode) +
" for char " + Integer.toHexString(charCode)); " for char " + Integer.toHexString(charCode));
@ -97,11 +97,11 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
} }
private void handleBadCMAP() { private void handleBadCMAP() {
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.severe("Null Cmap for " + font + FontUtilities.getLogger().severe("Null Cmap for " + font +
"substituting for this font"); "substituting for this font");
} }
FontManager.deRegisterBadFont(font); SunFontManager.getInstance().deRegisterBadFont(font);
/* The next line is not really a solution, but might /* The next line is not really a solution, but might
* reduce the exceptions until references to this font2D * reduce the exceptions until references to this font2D
* are gone. * are gone.
@ -242,10 +242,10 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
font.glyphToCharMap[glyphs[i]] = (char)code; font.glyphToCharMap[glyphs[i]] = (char)code;
} }
if (code < FontManager.MIN_LAYOUT_CHARCODE) { if (code < FontUtilities.MIN_LAYOUT_CHARCODE) {
continue; continue;
} }
else if (FontManager.isComplexCharCode(code)) { else if (FontUtilities.isComplexCharCode(code)) {
return true; return true;
} }
else if (code >= 0x10000) { else if (code >= 0x10000) {

View File

@ -635,7 +635,7 @@ public class Type1Font extends FileFont {
protected synchronized FontScaler getScaler() { protected synchronized FontScaler getScaler() {
if (scaler == null) { if (scaler == null) {
scaler = FontManager.getScaler(this, 0, false, fileSize); scaler = FontScaler.getScaler(this, 0, false, fileSize);
} }
return scaler; return scaler;
@ -652,7 +652,7 @@ public class Type1Font extends FileFont {
try { try {
return getScaler().getNumGlyphs(); return getScaler().getNumGlyphs();
} catch (FontScalerException e) { } catch (FontScalerException e) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getNumGlyphs(); return getNumGlyphs();
} }
} }
@ -661,7 +661,7 @@ public class Type1Font extends FileFont {
try { try {
return getScaler().getMissingGlyphCode(); return getScaler().getMissingGlyphCode();
} catch (FontScalerException e) { } catch (FontScalerException e) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getMissingGlyphCode(); return getMissingGlyphCode();
} }
} }
@ -670,7 +670,7 @@ public class Type1Font extends FileFont {
try { try {
return getScaler().getGlyphCode(charCode); return getScaler().getGlyphCode(charCode);
} catch (FontScalerException e) { } catch (FontScalerException e) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getGlyphCode(charCode); return getGlyphCode(charCode);
} }
} }
@ -679,5 +679,4 @@ public class Type1Font extends FileFont {
return "** Type1 Font: Family="+familyName+ " Name="+fullName+ return "** Type1 Font: Family="+familyName+ " Name="+fullName+
" style="+style+" fileName="+platName; " style="+style+" fileName="+platName;
} }
} }

View File

@ -46,7 +46,7 @@ public final class Type1GlyphMapper extends CharToGlyphMapper {
try { try {
missingGlyph = scaler.getMissingGlyphCode(); missingGlyph = scaler.getMissingGlyphCode();
} catch (FontScalerException fe) { } catch (FontScalerException fe) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
try { try {
missingGlyph = scaler.getMissingGlyphCode(); missingGlyph = scaler.getMissingGlyphCode();
} catch (FontScalerException e) { //should not happen } catch (FontScalerException e) { //should not happen
@ -59,7 +59,7 @@ public final class Type1GlyphMapper extends CharToGlyphMapper {
try { try {
return scaler.getNumGlyphs(); return scaler.getNumGlyphs();
} catch (FontScalerException e) { } catch (FontScalerException e) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return getNumGlyphs(); return getNumGlyphs();
} }
} }
@ -72,7 +72,7 @@ public final class Type1GlyphMapper extends CharToGlyphMapper {
try { try {
return scaler.getGlyphCode(ch) != missingGlyph; return scaler.getGlyphCode(ch) != missingGlyph;
} catch(FontScalerException e) { } catch(FontScalerException e) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return canDisplay(ch); return canDisplay(ch);
} }
} }
@ -81,7 +81,7 @@ public final class Type1GlyphMapper extends CharToGlyphMapper {
try { try {
return scaler.getGlyphCode(ch); return scaler.getGlyphCode(ch);
} catch (FontScalerException e) { } catch (FontScalerException e) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return charToGlyph(ch); return charToGlyph(ch);
} }
} }
@ -93,7 +93,7 @@ public final class Type1GlyphMapper extends CharToGlyphMapper {
try { try {
return scaler.getGlyphCode((char)ch); return scaler.getGlyphCode((char)ch);
} catch (FontScalerException e) { } catch (FontScalerException e) {
scaler = FontManager.getNullScaler(); scaler = FontScaler.getNullScaler();
return charToGlyph(ch); return charToGlyph(ch);
} }
} }
@ -160,10 +160,10 @@ public final class Type1GlyphMapper extends CharToGlyphMapper {
glyphs[i] = charToGlyph(code); glyphs[i] = charToGlyph(code);
if (code < FontManager.MIN_LAYOUT_CHARCODE) { if (code < FontUtilities.MIN_LAYOUT_CHARCODE) {
continue; continue;
} }
else if (FontManager.isComplexCharCode(code)) { else if (FontUtilities.isComplexCharCode(code)) {
return true; return true;
} }
else if (code >= 0x10000) { else if (code >= 0x10000) {

View File

@ -66,6 +66,7 @@ import java.awt.Transparency;
import java.awt.font.GlyphVector; import java.awt.font.GlyphVector;
import java.awt.font.TextLayout; import java.awt.font.TextLayout;
import sun.font.FontDesignMetrics; import sun.font.FontDesignMetrics;
import sun.font.FontUtilities;
import sun.java2d.pipe.PixelDrawPipe; import sun.java2d.pipe.PixelDrawPipe;
import sun.java2d.pipe.PixelFillPipe; import sun.java2d.pipe.PixelFillPipe;
import sun.java2d.pipe.ShapeDrawPipe; import sun.java2d.pipe.ShapeDrawPipe;
@ -592,7 +593,7 @@ public final class SunGraphics2D
} }
} }
info.font2D = FontManager.getFont2D(font); info.font2D = FontUtilities.getFont2D(font);
int fmhint = fractionalMetricsHint; int fmhint = fractionalMetricsHint;
if (fmhint == SunHints.INTVAL_FRACTIONALMETRICS_DEFAULT) { if (fmhint == SunHints.INTVAL_FRACTIONALMETRICS_DEFAULT) {
@ -741,7 +742,8 @@ public final class SunGraphics2D
font.isTransformed() || font.isTransformed() ||
fontInfo == null || // Precaution, if true shouldn't get here fontInfo == null || // Precaution, if true shouldn't get here
(fontInfo.aaHint == SunHints.INTVAL_TEXT_ANTIALIAS_ON) != (fontInfo.aaHint == SunHints.INTVAL_TEXT_ANTIALIAS_ON) !=
FontManager.getFont2D(font).useAAForPtSize(font.getSize()))) { FontUtilities.getFont2D(font).
useAAForPtSize(font.getSize()))) {
textpipe = invalidpipe; textpipe = invalidpipe;
} }
this.font = font; this.font = font;

File diff suppressed because it is too large Load Diff

View File

@ -87,6 +87,8 @@ import sun.awt.FontConfiguration;
import sun.awt.FontDescriptor; import sun.awt.FontDescriptor;
import sun.awt.PlatformFont; import sun.awt.PlatformFont;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import sun.font.FontManagerFactory;
import sun.font.FontUtilities;
import java.nio.charset.*; import java.nio.charset.*;
import java.nio.CharBuffer; import java.nio.CharBuffer;
@ -1077,7 +1079,7 @@ public class PSPrinterJob extends RasterPrinterJob {
} }
int styleMask = font.getStyle() | int styleMask = font.getStyle() |
sun.font.FontManager.getFont2D(font).getStyle(); FontUtilities.getFont2D(font).getStyle();
String style = FontConfiguration.getStyleString(styleMask); String style = FontConfiguration.getStyleString(styleMask);

View File

@ -32,6 +32,8 @@ import sun.font.CompositeFont;
import sun.font.Font2D; import sun.font.Font2D;
import sun.font.Font2DHandle; import sun.font.Font2DHandle;
import sun.font.FontManager; import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.font.FontUtilities;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
@ -698,7 +700,7 @@ public abstract class PathGraphics extends ProxyGraphics2D {
} }
Font font = g.getFont(); Font font = g.getFont();
Font2D font2D = FontManager.getFont2D(font); Font2D font2D = FontUtilities.getFont2D(font);
if (font2D.handle.font2D != font2D) { if (font2D.handle.font2D != font2D) {
/* suspicious, may be a bad font. lets bail */ /* suspicious, may be a bad font. lets bail */
return false; return false;
@ -933,7 +935,7 @@ public abstract class PathGraphics extends ProxyGraphics2D {
* The logic here is erring on the side of caution, in particular * The logic here is erring on the side of caution, in particular
* in including supplementary characters. * in including supplementary characters.
*/ */
if (FontManager.isComplexText(chars, 0, chars.length)) { if (FontUtilities.isComplexText(chars, 0, chars.length)) {
return printGlyphVector(g, x, y); return printGlyphVector(g, x, y);
} }

View File

@ -54,7 +54,7 @@ import sun.security.util.SecurityConstants;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import sun.font.FontDesignMetrics; import sun.font.FontDesignMetrics;
import sun.font.FontManager; import sun.font.FontUtilities;
import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SunGraphicsEnvironment;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -193,7 +193,7 @@ public class SwingUtilities2 {
* <tt>false</tt> if TextLayout is not required * <tt>false</tt> if TextLayout is not required
*/ */
public static final boolean isComplexLayout(char[] text, int start, int limit) { public static final boolean isComplexLayout(char[] text, int start, int limit) {
return FontManager.isComplexText(text, start, limit); return FontUtilities.isComplexText(text, start, limit);
} }
// //

View File

@ -71,41 +71,14 @@ JNIEXPORT jlong JNICALL Java_sun_font_NullFontScaler_getGlyphImage
void initLCDGammaTables(); void initLCDGammaTables();
/*
* Class: sun_font_FontManager
* Method: getPlatformFontVar
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL
Java_sun_font_FontManager_getPlatformFontVar(JNIEnv *env, jclass cl) {
char *c = getenv("JAVA2D_USEPLATFORMFONT");
if (c) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}
/* placeholder for extern variable */ /* placeholder for extern variable */
FontManagerNativeIDs sunFontIDs; FontManagerNativeIDs sunFontIDs;
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_font_FontManager_initIDs Java_sun_font_SunFontManager_initIDs
(JNIEnv *env, jclass cls) { (JNIEnv *env, jclass cls) {
jclass tmpClass = (*env)->FindClass(env, "java/awt/Font"); jclass tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont");
sunFontIDs.getFont2DMID =
(*env)->GetMethodID(env, tmpClass, "getFont2D",
"()Lsun/font/Font2D;");
sunFontIDs.font2DHandle =
(*env)->GetFieldID(env, tmpClass,
"font2DHandle", "Lsun/font/Font2DHandle;");
sunFontIDs.createdFont =
(*env)->GetFieldID(env, tmpClass, "createdFont", "Z");
tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont");
sunFontIDs.ttReadBlockMID = sunFontIDs.ttReadBlockMID =
(*env)->GetMethodID(env, tmpClass, "readBlock", (*env)->GetMethodID(env, tmpClass, "readBlock",
"(Ljava/nio/ByteBuffer;II)I"); "(Ljava/nio/ByteBuffer;II)I");
@ -207,40 +180,6 @@ JNIEXPORT FontManagerNativeIDs getSunFontIDs() {
return sunFontIDs; return sunFontIDs;
} }
JNIEXPORT jobject JNICALL
Java_sun_font_FontManager_getFont2D(
JNIEnv *env,
jclass clsFM,
jobject javaFont) {
return (*env)->CallObjectMethod(env, javaFont, sunFontIDs.getFont2DMID);
}
JNIEXPORT void JNICALL
Java_sun_font_FontManager_setFont2D(
JNIEnv *env,
jclass clsFM,
jobject javaFont,
jobject fontHandle) {
(*env)->SetObjectField(env, javaFont, sunFontIDs.font2DHandle, fontHandle);
}
JNIEXPORT void JNICALL
Java_sun_font_FontManager_setCreatedFont(
JNIEnv *env,
jclass clsFM,
jobject javaFont) {
(*env)->SetBooleanField(env, javaFont, sunFontIDs.createdFont, JNI_TRUE);
}
JNIEXPORT jboolean JNICALL
Java_sun_font_FontManager_isCreatedFont(
JNIEnv *env,
jclass clsFM,
jobject javaFont) {
return (*env)->GetBooleanField(env, javaFont, sunFontIDs.createdFont);
}
/* /*
* Class: sun_font_StrikeCache * Class: sun_font_StrikeCache
* Method: freeIntPointer * Method: freeIntPointer

View File

@ -34,11 +34,6 @@ extern "C" {
typedef struct FontManagerNativeIDs { typedef struct FontManagerNativeIDs {
/* java/awt/Font methods & fields */
jmethodID getFont2DMID;
jfieldID font2DHandle;
jfieldID createdFont;
/* sun/font/Font2D methods */ /* sun/font/Font2D methods */
jmethodID getMapperMID; jmethodID getMapperMID;
jmethodID getTableBytesMID; jmethodID getTableBytesMID;

View File

@ -51,6 +51,7 @@ import java.util.logging.Logger;
import javax.swing.LookAndFeel; import javax.swing.LookAndFeel;
import javax.swing.UIDefaults; import javax.swing.UIDefaults;
import sun.awt.*; import sun.awt.*;
import sun.font.FontConfigManager;
import sun.font.FontManager; import sun.font.FontManager;
import sun.misc.PerformanceLogger; import sun.misc.PerformanceLogger;
import sun.print.PrintJob2D; import sun.print.PrintJob2D;
@ -95,6 +96,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
*/ */
private XSettings xs; private XSettings xs;
private FontConfigManager fcManager = new FontConfigManager();
static int arrowCursor; static int arrowCursor;
static TreeMap winMap = new TreeMap(); static TreeMap winMap = new TreeMap();
static HashMap specialPeerMap = new HashMap(); static HashMap specialPeerMap = new HashMap();
@ -1527,7 +1530,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
*/ */
if (desktopProperties.get(SunToolkit.DESKTOPFONTHINTS) == null) { if (desktopProperties.get(SunToolkit.DESKTOPFONTHINTS) == null) {
if (XWM.isKDE2()) { if (XWM.isKDE2()) {
Object hint = FontManager.getFontConfigAAHint(); Object hint = fcManager.getFontConfigAAHint();
if (hint != null) { if (hint != null) {
/* set the fontconfig/KDE property so that /* set the fontconfig/KDE property so that
* getDesktopHints() below will see it * getDesktopHints() below will see it

View File

@ -68,77 +68,6 @@ public class X11GraphicsEnvironment
private static Boolean xinerState; private static Boolean xinerState;
/*
* This is the set of font directories needed to be on the X font path
* to enable AWT heavyweights to find all of the font configuration fonts.
* It is populated by :
* - awtfontpath entries in the fontconfig.properties
* - parent directories of "core" fonts used in the fontconfig.properties
* - looking up font dirs in the xFontDirsMap where the key is a fontID
* (cut down version of the XLFD read from the font configuration file).
* This set is nulled out after use to free heap space.
*/
private static HashSet<String> fontConfigDirs = null;
/*
* fontNameMap is a map from a fontID (which is a substring of an XLFD like
* "-monotype-arial-bold-r-normal-iso8859-7")
* to font file path like
* /usr/openwin/lib/locale/iso_8859_7/X11/fonts/TrueType/ArialBoldItalic.ttf
* It's used in a couple of methods like
* getFileNameFomPlatformName(..) to help locate the font file.
* We use this substring of a full XLFD because the font configuration files
* define the XLFDs in a way that's easier to make into a request.
* E.g., the -0-0-0-0-p-0- reported by X is -*-%d-*-*-p-*- in the font
* configuration files. We need to remove that part for comparisons.
*/
private static Map fontNameMap = new HashMap();
/* xFontDirsMap is also a map from a font ID to a font filepath.
* The difference from fontNameMap is just that it does not have
* resolved symbolic links. Normally this is not interesting except
* that we need to know the directory in which a font was found to
* add it to the X font server path, since although the files may
* be linked, the fonts.dir is different and specific to the encoding
* handled by that directory. This map is nulled out after use to free
* heap space. If the optimal path is taken, such that all fonts in
* font configuration files are referenced by filename, then the font
* dir can be directly derived as its parent directory.
* If a font is used by two XLFDs, each corresponding to a different
* X11 font directory, then precautions must be taken to include both
* directories.
*/
private static Map xFontDirsMap;
/*
* xlfdMap is a map from a platform path like
* /usr/openwin/lib/locale/ja/X11/fonts/TT/HG-GothicB.ttf to an XLFD like
* "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
* Because there may be multiple native names, because the font is used
* to support multiple X encodings for example, the value of an entry in
* this map is always a vector where we store all the native names.
* For fonts which we don't understand the key isn't a pathname, its
* the full XLFD string like :-
* "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
*/
private static Map xlfdMap = new HashMap();
/*
* Used to eliminate redundant work. When a font directory is
* registered it added to this list. Subsequent registrations for the
* same directory can then be skipped by checking this Map.
* Access to this map is not synchronised here since creation
* of the singleton GE instance is already synchronised and that is
* the only code path that accesses this map.
*/
private static HashMap registeredDirs = new HashMap();
/* Array of directories to be added to the X11 font path.
* Used by static method called from Toolkits which use X11 fonts.
* Specifically this means MToolkit
*/
private static String[] fontdirs = null;
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction() {
@ -234,7 +163,6 @@ public class X11GraphicsEnvironment
return getScreenDevices()[getDefaultScreenNum()]; return getScreenDevices()[getDefaultScreenNum()];
} }
@Override
public boolean isDisplayLocal() { public boolean isDisplayLocal() {
if (isDisplayLocal == null) { if (isDisplayLocal == null) {
SunToolkit.awtLock(); SunToolkit.awtLock();
@ -311,657 +239,7 @@ public class X11GraphicsEnvironment
return result.booleanValue(); return result.booleanValue();
} }
/* These maps are used on Linux where we reference the Lucida oblique
* fonts in fontconfig files even though they aren't in the standard
* font directory. This explicitly remaps the XLFDs for these to the
* correct base font. This is needed to prevent composite fonts from
* defaulting to the Lucida Sans which is a bad substitute for the
* monospaced Lucida Sans Typewriter. Also these maps prevent the
* JRE from doing wasted work at start up.
*/
HashMap<String, String> oblmap = null;
private String getObliqueLucidaFontID(String fontID) {
if (fontID.startsWith("-lucidasans-medium-i-normal") ||
fontID.startsWith("-lucidasans-bold-i-normal") ||
fontID.startsWith("-lucidatypewriter-medium-i-normal") ||
fontID.startsWith("-lucidatypewriter-bold-i-normal")) {
return fontID.substring(0, fontID.indexOf("-i-"));
} else {
return null;
}
}
private void initObliqueLucidaFontMap() {
oblmap = new HashMap<String, String>();
oblmap.put("-lucidasans-medium",
jreLibDirName+"/fonts/LucidaSansRegular.ttf");
oblmap.put("-lucidasans-bold",
jreLibDirName+"/fonts/LucidaSansDemiBold.ttf");
oblmap.put("-lucidatypewriter-medium",
jreLibDirName+"/fonts/LucidaTypewriterRegular.ttf");
oblmap.put("-lucidatypewriter-bold",
jreLibDirName+"/fonts/LucidaTypewriterBold.ttf");
}
/**
* Takes family name property in the following format:
* "-linotype-helvetica-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1"
* and returns the name of the corresponding physical font.
* This code is used to resolve font configuration fonts, and expects
* only to get called for these fonts.
*/
public String getFileNameFromPlatformName(String platName) {
/* If the FontConfig file doesn't use xlfds, or its
* FcFontConfiguration, this may be already a file name.
*/
if (platName.startsWith("/")) {
return platName;
}
String fileName = null;
String fontID = specificFontIDForName(platName);
/* If the font filename has been explicitly assigned in the
* font configuration file, use it. This avoids accessing
* the wrong fonts on Linux, where different fonts (some
* of which may not be usable by 2D) may share the same
* specific font ID. It may also speed up the lookup.
*/
fileName = super.getFileNameFromPlatformName(platName);
if (fileName != null) {
if (isHeadless() && fileName.startsWith("-")) {
/* if it's headless, no xlfd should be used */
return null;
}
if (fileName.startsWith("/")) {
/* If a path is assigned in the font configuration file,
* it is required that the config file also specify using the
* new awtfontpath key the X11 font directories
* which must be added to the X11 font path to support
* AWT access to that font. For that reason we no longer
* have code here to add the parent directory to the list
* of font config dirs, since the parent directory may not
* be sufficient if fonts are symbolically linked to a
* different directory.
*
* Add this XLFD (platform name) to the list of known
* ones for this file.
*/
Vector xVal = (Vector) xlfdMap.get(fileName);
if (xVal == null) {
/* Try to be robust on Linux distros which move fonts
* around by verifying that the fileName represents a
* file that exists. If it doesn't, set it to null
* to trigger a search.
*/
if (getFontConfiguration().needToSearchForFile(fileName)) {
fileName = null;
}
if (fileName != null) {
xVal = new Vector();
xVal.add(platName);
xlfdMap.put(fileName, xVal);
}
} else {
if (!xVal.contains(platName)) {
xVal.add(platName);
}
}
}
if (fileName != null) {
fontNameMap.put(fontID, fileName);
return fileName;
}
}
if (fontID != null) {
fileName = (String)fontNameMap.get(fontID);
/* On Linux check for the Lucida Oblique fonts */
if (fileName == null && isLinux && !isOpenJDK()) {
if (oblmap == null) {
initObliqueLucidaFontMap();
}
String oblkey = getObliqueLucidaFontID(fontID);
if (oblkey != null) {
fileName = oblmap.get(oblkey);
}
}
if (fontPath == null &&
(fileName == null || !fileName.startsWith("/"))) {
if (debugFonts) {
logger.warning("** Registering all font paths because " +
"can't find file for " + platName);
}
fontPath = getPlatformFontPath(noType1Font);
registerFontDirs(fontPath);
if (debugFonts) {
logger.warning("** Finished registering all font paths");
}
fileName = (String)fontNameMap.get(fontID);
}
if (fileName == null && !isHeadless()) {
/* Query X11 directly to see if this font is available
* as a native font.
*/
fileName = getX11FontName(platName);
}
if (fileName == null) {
fontID = switchFontIDForName(platName);
fileName = (String)fontNameMap.get(fontID);
}
if (fileName != null) {
fontNameMap.put(fontID, fileName);
}
}
return fileName;
}
private static String getX11FontName(String platName) {
String xlfd = platName.replaceAll("%d", "*");
if (NativeFont.fontExists(xlfd)) {
return xlfd;
} else {
return null;
}
}
/**
* Returns the face name for the given XLFD.
*/
public String getFileNameFromXLFD(String name) {
String fileName = null;
String fontID = specificFontIDForName(name);
if (fontID != null) {
fileName = (String)fontNameMap.get(fontID);
if (fileName == null) {
fontID = switchFontIDForName(name);
fileName = (String)fontNameMap.get(fontID);
}
if (fileName == null) {
fileName = getDefaultFontFile();
}
}
return fileName;
}
// constants identifying XLFD and font ID fields
private static final int FOUNDRY_FIELD = 1;
private static final int FAMILY_NAME_FIELD = 2;
private static final int WEIGHT_NAME_FIELD = 3;
private static final int SLANT_FIELD = 4;
private static final int SETWIDTH_NAME_FIELD = 5;
private static final int ADD_STYLE_NAME_FIELD = 6;
private static final int PIXEL_SIZE_FIELD = 7;
private static final int POINT_SIZE_FIELD = 8;
private static final int RESOLUTION_X_FIELD = 9;
private static final int RESOLUTION_Y_FIELD = 10;
private static final int SPACING_FIELD = 11;
private static final int AVERAGE_WIDTH_FIELD = 12;
private static final int CHARSET_REGISTRY_FIELD = 13;
private static final int CHARSET_ENCODING_FIELD = 14;
private String switchFontIDForName(String name) {
int[] hPos = new int[14];
int hyphenCnt = 1;
int pos = 1;
while (pos != -1 && hyphenCnt < 14) {
pos = name.indexOf('-', pos);
if (pos != -1) {
hPos[hyphenCnt++] = pos;
pos++;
}
}
if (hyphenCnt != 14) {
if (debugFonts) {
logger.severe("Font Configuration Font ID is malformed:" + name);
}
return name; // what else can we do?
}
String slant = name.substring(hPos[SLANT_FIELD-1]+1,
hPos[SLANT_FIELD]);
String family = name.substring(hPos[FAMILY_NAME_FIELD-1]+1,
hPos[FAMILY_NAME_FIELD]);
String registry = name.substring(hPos[CHARSET_REGISTRY_FIELD-1]+1,
hPos[CHARSET_REGISTRY_FIELD]);
String encoding = name.substring(hPos[CHARSET_ENCODING_FIELD-1]+1);
if (slant.equals("i")) {
slant = "o";
} else if (slant.equals("o")) {
slant = "i";
}
// workaround for #4471000
if (family.equals("itc zapfdingbats")
&& registry.equals("sun")
&& encoding.equals("fontspecific")){
registry = "adobe";
}
StringBuffer sb =
new StringBuffer(name.substring(hPos[FAMILY_NAME_FIELD-1],
hPos[SLANT_FIELD-1]+1));
sb.append(slant);
sb.append(name.substring(hPos[SLANT_FIELD],
hPos[SETWIDTH_NAME_FIELD]+1));
sb.append(registry);
sb.append(name.substring(hPos[CHARSET_ENCODING_FIELD-1]));
String retval = sb.toString().toLowerCase (Locale.ENGLISH);
return retval;
}
private String specificFontIDForName(String name) {
int[] hPos = new int[14];
int hyphenCnt = 1;
int pos = 1;
while (pos != -1 && hyphenCnt < 14) {
pos = name.indexOf('-', pos);
if (pos != -1) {
hPos[hyphenCnt++] = pos;
pos++;
}
}
if (hyphenCnt != 14) {
if (debugFonts) {
logger.severe("Font Configuration Font ID is malformed:" + name);
}
return name; // what else can we do?
}
StringBuffer sb =
new StringBuffer(name.substring(hPos[FAMILY_NAME_FIELD-1],
hPos[SETWIDTH_NAME_FIELD]));
sb.append(name.substring(hPos[CHARSET_REGISTRY_FIELD-1]));
String retval = sb.toString().toLowerCase (Locale.ENGLISH);
return retval;
}
protected String[] getNativeNames(String fontFileName,
String platformName) {
Vector nativeNames;
if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) {
if (platformName == null) {
return null;
} else {
/* back-stop so that at least the name used in the
* font configuration file is known as a native name
*/
String []natNames = new String[1];
natNames[0] = platformName;
return natNames;
}
} else {
int len = nativeNames.size();
return (String[])nativeNames.toArray(new String[len]);
}
}
// An X font spec (xlfd) includes an encoding. The same TrueType font file
// may be referenced from different X font directories in font.dir files
// to support use in multiple encodings by X apps.
// So for the purposes of font configuration logical fonts where AWT
// heavyweights need to access the font via X APIs we need to ensure that
// the directory for precisely the encodings needed by this are added to
// the x font path. This requires that we note the platform names
// specified in font configuration files and use that to identify the
// X font directory that contains a font.dir file for that platform name
// and add it to the X font path (if display is local)
// Here we make use of an already built map of xlfds to font locations
// to add the font location to the set of those required to build the
// x font path needed by AWT.
// These are added to the x font path later.
// All this is necessary because on Solaris the font.dir directories
// may contain not real font files, but symbolic links to the actual
// location but that location is not suitable for the x font path, since
// it probably doesn't have a font.dir at all and certainly not one
// with the required encodings
// If the fontconfiguration file is properly set up so that all fonts
// are mapped to files then we will never trigger initialising
// xFontDirsMap (it will be null). In this case the awtfontpath entries
// must specify all the X11 directories needed by AWT.
protected void addFontToPlatformFontPath(String platformName) {
if (xFontDirsMap != null) {
String fontID = specificFontIDForName(platformName);
String dirName = (String)xFontDirsMap.get(fontID);
if (dirName != null) {
fontConfigDirs.add(dirName);
}
}
return;
}
protected void getPlatformFontPathFromFontConfig() {
if (fontConfigDirs == null) {
fontConfigDirs = getFontConfiguration().getAWTFontPathSet();
if (debugFonts && fontConfigDirs != null) {
String[] names = fontConfigDirs.toArray(new String[0]);
for (int i=0;i<names.length;i++) {
logger.info("awtfontpath : " + names[i]);
}
}
}
}
protected void registerPlatformFontsUsedByFontConfiguration() {
if (fontConfigDirs == null) {
return;
}
if (isLinux) {
fontConfigDirs.add(jreLibDirName+File.separator+"oblique-fonts");
}
fontdirs = (String[])fontConfigDirs.toArray(new String[0]);
}
/* Called by MToolkit to set the X11 font path */
public static void setNativeFontPath() {
if (fontdirs == null) {
return;
}
// need to register these individually rather than by one call
// to ensure that one bad directory doesn't cause all to be rejected
for (int i=0; i<fontdirs.length; i++) {
if (debugFonts) {
logger.info("Add " + fontdirs[i] + " to X11 fontpath");
}
FontManager.setNativeFontPath(fontdirs[i]);
}
}
/* Register just the paths, (it doesn't register the fonts).
* If a font configuration file has specified a baseFontPath
* fontPath is just those directories, unless on usage we
* find it doesn't contain what we need for the logical fonts.
* Otherwise, we register all the paths on Solaris, because
* the fontPath we have here is the complete one from
* parsing /var/sadm/install/contents, not just
* what's on the X font path (may be this should be
* changed).
* But for now what it means is that if we didn't do
* this then if the font weren't listed anywhere on the
* less complete font path we'd trigger loadFonts which
* actually registers the fonts. This may actually be
* the right thing tho' since that would also set up
* the X font path without which we wouldn't be able to
* display some "native" fonts.
* So something to revisit is that probably fontPath
* here ought to be only the X font path + jre font dir.
* loadFonts should have a separate native call to
* get the rest of the platform font path.
*
* Registering the directories can now be avoided in the
* font configuration initialisation when filename entries
* exist in the font configuration file for all fonts.
* (Perhaps a little confusingly a filename entry is
* actually keyed using the XLFD used in the font entries,
* and it maps *to* a real filename).
* In the event any are missing, registration of all
* directories will be invoked to find the real files.
*
* But registering the directory performed other
* functions such as filling in the map of all native names
* for the font. So when this method isn't invoked, they still
* must be found. This is mitigated by getNativeNames now
* being able to return at least the platform name, but mostly
* by ensuring that when a filename key is found, that
* xlfd key is stored as one of the set of platform names
* for the font. Its a set because typical font configuration
* files reference the same CJK font files using multiple
* X11 encodings. For the code that adds this to the map
* see X11GE.getFileNameFromPlatformName(..)
* If you don't get all of these then some code points may
* not use the Xserver, and will not get the PCF bitmaps
* that are available for some point sizes.
* So, in the event that there is such a problem,
* unconditionally making this call may be necessary, at
* some cost to JRE start-up
*/
protected void registerFontDirs(String pathName) {
StringTokenizer parser = new StringTokenizer(pathName,
File.pathSeparator);
try {
while (parser.hasMoreTokens()) {
String dirPath = parser.nextToken();
if (dirPath != null && !registeredDirs.containsKey(dirPath)) {
registeredDirs.put(dirPath, null);
registerFontDir(dirPath);
}
}
} catch (NoSuchElementException e) {
}
}
/* NOTE: this method needs to be executed in a privileged context.
* The superclass constructor which is the primary caller of
* this method executes entirely in such a context. Additionally
* the loadFonts() method does too. So all should be well.
*/
protected void registerFontDir(String path) {
/* fonts.dir file format looks like :-
* 47
* Arial.ttf -monotype-arial-regular-r-normal--0-0-0-0-p-0-iso8859-1
* Arial-Bold.ttf -monotype-arial-bold-r-normal--0-0-0-0-p-0-iso8859-1
* ...
*/
if (debugFonts) {
logger.info("ParseFontDir " + path);
}
File fontsDotDir = new File(path + File.separator + "fonts.dir");
FileReader fr = null;
try {
if (fontsDotDir.canRead()) {
fr = new FileReader(fontsDotDir);
BufferedReader br = new BufferedReader(fr, 8192);
StreamTokenizer st = new StreamTokenizer(br);
st.eolIsSignificant(true);
int ttype = st.nextToken();
if (ttype == StreamTokenizer.TT_NUMBER) {
int numEntries = (int)st.nval;
ttype = st.nextToken();
if (ttype == StreamTokenizer.TT_EOL) {
st.resetSyntax();
st.wordChars(32, 127);
st.wordChars(128 + 32, 255);
st.whitespaceChars(0, 31);
for (int i=0; i < numEntries; i++) {
ttype = st.nextToken();
if (ttype == StreamTokenizer.TT_EOF) {
break;
}
if (ttype != StreamTokenizer.TT_WORD) {
break;
}
int breakPos = st.sval.indexOf(' ');
if (breakPos <= 0) {
/* On TurboLinux 8.0 a fonts.dir file had
* a line with integer value "24" which
* appeared to be the number of remaining
* entries in the file. This didn't add to
* the value on the first line of the file.
* Seemed like XFree86 didn't like this line
* much either. It failed to parse the file.
* Ignore lines like this completely, and
* don't let them count as an entry.
*/
numEntries++;
ttype = st.nextToken();
if (ttype != StreamTokenizer.TT_EOL) {
break;
}
continue;
}
if (st.sval.charAt(0) == '!') {
/* TurboLinux 8.0 comment line: ignore.
* can't use st.commentChar('!') to just
* skip because this line mustn't count
* against numEntries.
*/
numEntries++;
ttype = st.nextToken();
if (ttype != StreamTokenizer.TT_EOL) {
break;
}
continue;
}
String fileName = st.sval.substring(0, breakPos);
/* TurboLinux 8.0 uses some additional syntax to
* indicate algorithmic styling values.
* Ignore ':' separated files at the beginning
* of the fileName
*/
int lastColon = fileName.lastIndexOf(':');
if (lastColon > 0) {
if (lastColon+1 >= fileName.length()) {
continue;
}
fileName = fileName.substring(lastColon+1);
}
String fontPart = st.sval.substring(breakPos+1);
String fontID = specificFontIDForName(fontPart);
String sVal = (String) fontNameMap.get(fontID);
if (debugFonts) {
logger.info("file=" + fileName +
" xlfd=" + fontPart);
logger.info("fontID=" + fontID +
" sVal=" + sVal);
}
String fullPath = null;
try {
File file = new File(path,fileName);
/* we may have a resolved symbolic link
* this becomes important for an xlfd we
* still need to know the location it was
* found to update the X server font path
* for use by AWT heavyweights - and when 2D
* wants to use the native rasteriser.
*/
if (xFontDirsMap == null) {
xFontDirsMap = new HashMap();
}
xFontDirsMap.put(fontID, path);
fullPath = file.getCanonicalPath();
} catch (IOException e) {
fullPath = path + File.separator + fileName;
}
Vector xVal = (Vector) xlfdMap.get(fullPath);
if (debugFonts) {
logger.info("fullPath=" + fullPath +
" xVal=" + xVal);
}
if ((xVal == null || !xVal.contains(fontPart)) &&
(sVal == null) || !sVal.startsWith("/")) {
if (debugFonts) {
logger.info("Map fontID:"+fontID +
"to file:" + fullPath);
}
fontNameMap.put(fontID, fullPath);
if (xVal == null) {
xVal = new Vector();
xlfdMap.put (fullPath, xVal);
}
xVal.add(fontPart);
}
ttype = st.nextToken();
if (ttype != StreamTokenizer.TT_EOL) {
break;
}
}
}
}
fr.close();
}
} catch (IOException ioe1) {
} finally {
if (fr != null) {
try {
fr.close();
} catch (IOException ioe2) {
}
}
}
}
@Override
public void loadFonts() {
super.loadFonts();
/* These maps are greatly expanded during a loadFonts but
* can be reset to their initial state afterwards.
* Since preferLocaleFonts() and preferProportionalFonts() will
* trigger a partial repopulating from the FontConfiguration
* it has to be the inital (empty) state for the latter two, not
* simply nulling out.
* xFontDirsMap is a special case in that the implementation
* will typically not ever need to initialise it so it can be null.
*/
xFontDirsMap = null;
xlfdMap = new HashMap(1);
fontNameMap = new HashMap(1);
}
// Implements SunGraphicsEnvironment.createFontConfiguration.
protected FontConfiguration createFontConfiguration() {
/* The logic here decides whether to use a preconfigured
* fontconfig.properties file, or synthesise one using platform APIs.
* On Solaris (as opposed to OpenSolaris) we try to use the
* pre-configured ones, but if the files it specifies are missing
* we fail-safe to synthesising one. This might happen if Solaris
* changes its fonts.
* For OpenSolaris I don't expect us to ever create fontconfig files,
* so it will always synthesise. Note that if we misidentify
* OpenSolaris as Solaris, then the test for the presence of
* Solaris-only font files will correct this.
* For Linux we require an exact match of distro and version to
* use the preconfigured file, and also that it points to
* existent fonts.
* If synthesising fails, we fall back to any preconfigured file
* and do the best we can. For the commercial JDK this will be
* fine as it includes the Lucida fonts. OpenJDK should not hit
* this as the synthesis should always work on its platforms.
*/
FontConfiguration mFontConfig = new MFontConfiguration(this);
if (isOpenSolaris ||
(isLinux &&
(!mFontConfig.foundOsSpecificFile() ||
!mFontConfig.fontFilesArePresent()) ||
(isSolaris && !mFontConfig.fontFilesArePresent()))) {
FcFontConfiguration fcFontConfig =
new FcFontConfiguration(this);
if (fcFontConfig.init()) {
return fcFontConfig;
}
}
mFontConfig.init();
return mFontConfig;
}
public FontConfiguration
createFontConfiguration(boolean preferLocaleFonts,
boolean preferPropFonts) {
FontConfiguration config = getFontConfiguration();
if (config instanceof FcFontConfiguration) {
// Doesn't need to implement the alternate support.
return config;
}
return new MFontConfiguration(this,
preferLocaleFonts, preferPropFonts);
}
/** /**
* Returns face name for default font, or null if * Returns face name for default font, or null if

View File

@ -37,7 +37,12 @@ import java.util.logging.Logger;
import java.util.Properties; import java.util.Properties;
import java.util.Scanner; import java.util.Scanner;
import sun.awt.FontConfiguration; import sun.awt.FontConfiguration;
import sun.awt.X11FontManager;
import sun.awt.X11GraphicsEnvironment; import sun.awt.X11GraphicsEnvironment;
import sun.font.FontManager;
import sun.font.SunFontManager;
import sun.font.FontManagerFactory;
import sun.font.FontUtilities;
import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SunGraphicsEnvironment;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -46,20 +51,20 @@ public class MFontConfiguration extends FontConfiguration {
private static FontConfiguration fontConfig = null; private static FontConfiguration fontConfig = null;
private static Logger logger; private static Logger logger;
public MFontConfiguration(SunGraphicsEnvironment environment) { public MFontConfiguration(SunFontManager fm) {
super(environment); super(fm);
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
logger = Logger.getLogger("sun.awt.FontConfiguration"); logger = Logger.getLogger("sun.awt.FontConfiguration");
} }
initTables(); initTables();
} }
public MFontConfiguration(SunGraphicsEnvironment environment, public MFontConfiguration(SunFontManager fm,
boolean preferLocaleFonts, boolean preferLocaleFonts,
boolean preferPropFonts) { boolean preferPropFonts) {
super(environment, preferLocaleFonts, preferPropFonts); super(fm, preferLocaleFonts, preferPropFonts);
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
logger = Logger.getLogger("sun.awt.FontConfiguration"); logger = Logger.getLogger("sun.awt.FontConfiguration");
} }
initTables(); initTables();
@ -90,7 +95,7 @@ public class MFontConfiguration extends FontConfiguration {
reorderMap.put("UTF-8.th", "thai"); reorderMap.put("UTF-8.th", "thai");
reorderMap.put("UTF-8.zh.TW", "chinese-big5"); reorderMap.put("UTF-8.zh.TW", "chinese-big5");
reorderMap.put("UTF-8.zh.HK", split("chinese-big5,chinese-hkscs")); reorderMap.put("UTF-8.zh.HK", split("chinese-big5,chinese-hkscs"));
if (sun.font.FontManager.isSolaris8) { if (FontUtilities.isSolaris8) {
reorderMap.put("UTF-8.zh.CN", split("chinese-gb2312,chinese-big5")); reorderMap.put("UTF-8.zh.CN", split("chinese-gb2312,chinese-big5"));
} else { } else {
reorderMap.put("UTF-8.zh.CN", reorderMap.put("UTF-8.zh.CN",
@ -100,7 +105,7 @@ public class MFontConfiguration extends FontConfiguration {
split("chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1")); split("chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1"));
reorderMap.put("Big5", "chinese-big5"); reorderMap.put("Big5", "chinese-big5");
reorderMap.put("Big5-HKSCS", split("chinese-big5,chinese-hkscs")); reorderMap.put("Big5-HKSCS", split("chinese-big5,chinese-hkscs"));
if (! sun.font.FontManager.isSolaris8 && ! sun.font.FontManager.isSolaris9) { if (! FontUtilities.isSolaris8 && ! FontUtilities.isSolaris9) {
reorderMap.put("GB2312", split("chinese-gbk,chinese-gb2312")); reorderMap.put("GB2312", split("chinese-gbk,chinese-gb2312"));
} else { } else {
reorderMap.put("GB2312","chinese-gb2312"); reorderMap.put("GB2312","chinese-gb2312");
@ -209,7 +214,7 @@ public class MFontConfiguration extends FontConfiguration {
protected String mapFileName(String fileName) { protected String mapFileName(String fileName) {
if (fileName != null && fileName.startsWith(fontsDirPrefix)) { if (fileName != null && fileName.startsWith(fontsDirPrefix)) {
return SunGraphicsEnvironment.jreFontDirName return SunFontManager.jreFontDirName
+ fileName.substring(fontsDirPrefix.length()); + fileName.substring(fontsDirPrefix.length());
} }
return fileName; return fileName;
@ -310,7 +315,7 @@ public class MFontConfiguration extends FontConfiguration {
!needToSearchForFile(fileName)) { !needToSearchForFile(fileName)) {
return fileName; return fileName;
} }
return ((X11GraphicsEnvironment) environment).getFileNameFromXLFD(componentFontName); return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
} }
/** /**

View File

@ -61,6 +61,7 @@ import java.awt.dnd.InvalidDnDOperationException;
import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.dnd.peer.DragSourceContextPeer;
//import sun.awt.motif.MInputMethod; //import sun.awt.motif.MInputMethod;
import sun.awt.X11FontManager;
import sun.awt.X11GraphicsConfig; import sun.awt.X11GraphicsConfig;
import sun.awt.X11GraphicsEnvironment; import sun.awt.X11GraphicsEnvironment;
import sun.awt.XSettings; import sun.awt.XSettings;
@ -124,7 +125,7 @@ public class MToolkit extends UNIXToolkit implements Runnable {
* and when we know that MToolkit is the one that will be used, * and when we know that MToolkit is the one that will be used,
* since XToolkit doesn't need the X11 font path set * since XToolkit doesn't need the X11 font path set
*/ */
X11GraphicsEnvironment.setNativeFontPath(); X11FontManager.getInstance().setNativeFontPath();
motifdnd = ((Boolean)java.security.AccessController.doPrivileged( motifdnd = ((Boolean)java.security.AccessController.doPrivileged(
new GetBooleanAction("awt.dnd.motifdnd"))).booleanValue(); new GetBooleanAction("awt.dnd.motifdnd"))).booleanValue();

View File

@ -41,11 +41,12 @@ import java.util.Scanner;
import sun.awt.FontConfiguration; import sun.awt.FontConfiguration;
import sun.awt.FontDescriptor; import sun.awt.FontDescriptor;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import sun.awt.X11FontManager;
import sun.font.CompositeFontDescriptor; import sun.font.CompositeFontDescriptor;
import sun.font.FontManager; import sun.font.FontManager;
import sun.font.FontManager.FontConfigInfo; import sun.font.FontConfigManager.FontConfigInfo;
import sun.font.FontManager.FcCompFont; import sun.font.FontConfigManager.FcCompFont;
import sun.font.FontManager.FontConfigFont; import sun.font.FontConfigManager.FontConfigFont;
import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SunGraphicsEnvironment;
public class FcFontConfiguration extends FontConfiguration { public class FcFontConfiguration extends FontConfiguration {
@ -68,16 +69,16 @@ public class FcFontConfiguration extends FontConfiguration {
private FcCompFont[] fcCompFonts = null; private FcCompFont[] fcCompFonts = null;
public FcFontConfiguration(SunGraphicsEnvironment environment) { public FcFontConfiguration(SunFontManager fm) {
super(environment); super(fm);
init(); init();
} }
/* This isn't called but is needed to satisfy super-class contract. */ /* This isn't called but is needed to satisfy super-class contract. */
public FcFontConfiguration(SunGraphicsEnvironment environment, public FcFontConfiguration(SunFontManager fm,
boolean preferLocaleFonts, boolean preferLocaleFonts,
boolean preferPropFonts) { boolean preferPropFonts) {
super(environment, preferLocaleFonts, preferPropFonts); super(fm, preferLocaleFonts, preferPropFonts);
init(); init();
} }
@ -89,24 +90,26 @@ public class FcFontConfiguration extends FontConfiguration {
setFontConfiguration(); setFontConfiguration();
readFcInfo(); readFcInfo();
X11FontManager fm = X11FontManager.getInstance();
FontConfigManager fcm = fm.getFontConfigManager();
if (fcCompFonts == null) { if (fcCompFonts == null) {
fcCompFonts = FontManager.loadFontConfig(); fcCompFonts = fcm.loadFontConfig();
if (fcCompFonts != null) { if (fcCompFonts != null) {
try { try {
writeFcInfo(); writeFcInfo();
} catch (Exception e) { } catch (Exception e) {
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
Logger logger = Logger logger =
Logger.getLogger("sun.awt.FontConfiguration"); Logger.getLogger("sun.awt.FontConfiguration");
logger.warning("Exception writing fcInfo " + e); logger.warning("Exception writing fcInfo " + e);
} }
} }
} else if (SunGraphicsEnvironment.debugFonts) { } else if (FontUtilities.debugFonts()) {
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
logger.warning("Failed to get info from libfontconfig"); logger.warning("Failed to get info from libfontconfig");
} }
} else { } else {
FontManager.populateFontConfig(fcCompFonts); fcm.populateFontConfig(fcCompFonts);
} }
if (fcCompFonts == null) { if (fcCompFonts == null) {
@ -184,7 +187,9 @@ public class FcFontConfiguration extends FontConfiguration {
@Override @Override
public String[] getPlatformFontNames() { public String[] getPlatformFontNames() {
HashSet<String> nameSet = new HashSet<String>(); HashSet<String> nameSet = new HashSet<String>();
FcCompFont[] fcCompFonts = FontManager.loadFontConfig(); X11FontManager fm = X11FontManager.getInstance();
FontConfigManager fcm = fm.getFontConfigManager();
FcCompFont[] fcCompFonts = fcm.loadFontConfig();
for (int i=0; i<fcCompFonts.length; i++) { for (int i=0; i<fcCompFonts.length; i++) {
for (int j=0; j<fcCompFonts[i].allFonts.length; j++) { for (int j=0; j<fcCompFonts[i].allFonts.length; j++) {
nameSet.add(fcCompFonts[i].allFonts[j].fontFile); nameSet.add(fcCompFonts[i].allFonts[j].fontFile);
@ -223,7 +228,9 @@ public class FcFontConfiguration extends FontConfiguration {
@Override @Override
public CompositeFontDescriptor[] get2DCompositeFontInfo() { public CompositeFontDescriptor[] get2DCompositeFontInfo() {
FcCompFont[] fcCompFonts = FontManager.loadFontConfig(); X11FontManager fm = X11FontManager.getInstance();
FontConfigManager fcm = fm.getFontConfigManager();
FcCompFont[] fcCompFonts = fcm.loadFontConfig();
CompositeFontDescriptor[] result = CompositeFontDescriptor[] result =
new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES]; new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES];
@ -321,7 +328,7 @@ public class FcFontConfiguration extends FontConfiguration {
osVersion = getVersionString(f); osVersion = getVersionString(f);
} }
} catch (Exception e) { } catch (Exception e) {
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
logger.warning("Exception identifying Linux distro."); logger.warning("Exception identifying Linux distro.");
} }
@ -356,7 +363,9 @@ public class FcFontConfiguration extends FontConfiguration {
private void writeFcInfo() { private void writeFcInfo() {
Properties props = new Properties(); Properties props = new Properties();
props.setProperty("version", fileVersion); props.setProperty("version", fileVersion);
FontConfigInfo fcInfo = FontManager.getFontConfigInfo(); X11FontManager fm = X11FontManager.getInstance();
FontConfigManager fcm = fm.getFontConfigManager();
FontConfigInfo fcInfo = fcm.getFontConfigInfo();
props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion)); props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion));
if (fcInfo.cacheDirs != null) { if (fcInfo.cacheDirs != null) {
for (int i=0;i<fcInfo.cacheDirs.length;i++) { for (int i=0;i<fcInfo.cacheDirs.length;i++) {
@ -391,13 +400,13 @@ public class FcFontConfiguration extends FontConfiguration {
"JDK Font Configuration Generated File: *Do Not Edit*"); "JDK Font Configuration Generated File: *Do Not Edit*");
fos.close(); fos.close();
boolean renamed = tempFile.renameTo(fcInfoFile); boolean renamed = tempFile.renameTo(fcInfoFile);
if (!renamed && SunGraphicsEnvironment.debugFonts) { if (!renamed && FontUtilities.debugFonts()) {
System.out.println("rename failed"); System.out.println("rename failed");
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
logger.warning("Failed renaming file to "+ getFcInfoFile()); logger.warning("Failed renaming file to "+ getFcInfoFile());
} }
} catch (Exception e) { } catch (Exception e) {
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
logger.warning("IOException writing to "+ getFcInfoFile()); logger.warning("IOException writing to "+ getFcInfoFile());
} }
@ -415,12 +424,14 @@ public class FcFontConfiguration extends FontConfiguration {
return; return;
} }
Properties props = new Properties(); Properties props = new Properties();
X11FontManager fm = X11FontManager.getInstance();
FontConfigManager fcm = fm.getFontConfigManager();
try { try {
FileInputStream fis = new FileInputStream(fcFile); FileInputStream fis = new FileInputStream(fcFile);
props.load(fis); props.load(fis);
fis.close(); fis.close();
} catch (IOException e) { } catch (IOException e) {
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
logger.warning("IOException reading from "+fcFile.toString()); logger.warning("IOException reading from "+fcFile.toString());
} }
@ -439,11 +450,11 @@ public class FcFontConfiguration extends FontConfiguration {
try { try {
fcVersion = Integer.parseInt(fcVersionStr); fcVersion = Integer.parseInt(fcVersionStr);
if (fcVersion != 0 && if (fcVersion != 0 &&
fcVersion != FontManager.getFontConfigVersion()) { fcVersion != fcm.getFontConfigVersion()) {
return; return;
} }
} catch (Exception e) { } catch (Exception e) {
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
Logger logger = Logger logger =
Logger.getLogger("sun.awt.FontConfiguration"); Logger.getLogger("sun.awt.FontConfiguration");
logger.warning("Exception parsing version " + logger.warning("Exception parsing version " +
@ -509,7 +520,7 @@ public class FcFontConfiguration extends FontConfiguration {
} }
fcCompFonts = fci; fcCompFonts = fci;
} catch (Throwable t) { } catch (Throwable t) {
if (SunGraphicsEnvironment.debugFonts) { if (FontUtilities.debugFonts()) {
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); Logger logger = Logger.getLogger("sun.awt.FontConfiguration");
logger.warning(t.toString()); logger.warning(t.toString());
} }

View File

@ -242,7 +242,8 @@ public class NativeFont extends PhysicalFont {
mapper = new NativeGlyphMapper(this); mapper = new NativeGlyphMapper(this);
} else { } else {
/* we need to delegate */ /* we need to delegate */
delegateFont = FontManager.getDefaultPhysicalFont(); SunFontManager fm = SunFontManager.getInstance();
delegateFont = fm.getDefaultPhysicalFont();
mapper = delegateFont.getMapper(); mapper = delegateFont.getMapper();
} }
} }
@ -254,7 +255,8 @@ public class NativeFont extends PhysicalFont {
return new NativeStrike(this, desc); return new NativeStrike(this, desc);
} else { } else {
if (delegateFont == null) { if (delegateFont == null) {
delegateFont = FontManager.getDefaultPhysicalFont(); SunFontManager fm = SunFontManager.getInstance();
delegateFont = fm.getDefaultPhysicalFont();
} }
/* If no FileFont's are found, delegate font may be /* If no FileFont's are found, delegate font may be
* a NativeFont, so we need to avoid recursing here. * a NativeFont, so we need to avoid recursing here.
@ -314,7 +316,8 @@ public class NativeFont extends PhysicalFont {
PhysicalFont getDelegateFont() { PhysicalFont getDelegateFont() {
if (delegateFont == null) { if (delegateFont == null) {
delegateFont = FontManager.getDefaultPhysicalFont(); SunFontManager fm = SunFontManager.getInstance();
delegateFont = fm.getDefaultPhysicalFont();
} }
return delegateFont; return delegateFont;
} }

View File

@ -112,11 +112,12 @@ import java.awt.geom.NoninvertibleTransformException;
double scale = Math.abs(desc.devTx.getScaleX()); double scale = Math.abs(desc.devTx.getScaleX());
pScalerContext = createScalerContext(nameBytes, ptSize, scale); pScalerContext = createScalerContext(nameBytes, ptSize, scale);
if (pScalerContext == 0L) { if (pScalerContext == 0L) {
FontManager.deRegisterBadFont(nativeFont); SunFontManager.getInstance().deRegisterBadFont(nativeFont);
pScalerContext = createNullScalerContext(); pScalerContext = createNullScalerContext();
numGlyphs = 0; numGlyphs = 0;
if (FontManager.logging) { if (FontUtilities.isLogging()) {
FontManager.logger.severe("Could not create native strike " + FontUtilities.getLogger()
.severe("Could not create native strike " +
new String(nameBytes)); new String(nameBytes));
} }
return; return;
@ -134,7 +135,7 @@ import java.awt.geom.NoninvertibleTransformException;
private boolean usingIntGlyphImages() { private boolean usingIntGlyphImages() {
if (intGlyphImages != null) { if (intGlyphImages != null) {
return true; return true;
} else if (FontManager.longAddresses) { } else if (longAddresses) {
return false; return false;
} else { } else {
/* We could obtain minGlyphIndex and index relative to that /* We could obtain minGlyphIndex and index relative to that
@ -153,7 +154,7 @@ import java.awt.geom.NoninvertibleTransformException;
} }
private long[] getLongGlyphImages() { private long[] getLongGlyphImages() {
if (longGlyphImages == null && FontManager.longAddresses) { if (longGlyphImages == null && longAddresses) {
/* We could obtain minGlyphIndex and index relative to that /* We could obtain minGlyphIndex and index relative to that
* if we need to save space. * if we need to save space.

View File

@ -150,15 +150,26 @@ jboolean isDisplayLocal(JNIEnv *env) {
static jboolean isLocalSet = False; static jboolean isLocalSet = False;
jboolean ret; jboolean ret;
if (isLocalSet) { if (! isLocalSet) {
return isLocal; jclass geCls = (*env)->FindClass(env, "java/awt/GraphicsEnvironment");
jmethodID getLocalGE = (*env)->GetStaticMethodID(env, geCls,
"getLocalGraphicsEnvironment",
"()Ljava/awt/GraphicsEnvironment;");
jobject ge = (*env)->CallStaticObjectMethod(env, geCls, getLocalGE);
jclass sgeCls = (*env)->FindClass(env,
"sun/java2d/SunGraphicsEnvironment");
if ((*env)->IsInstanceOf(env, ge, sgeCls)) {
jmethodID isDisplayLocal = (*env)->GetMethodID(env, sgeCls,
"isDisplayLocal",
"()Z");
isLocal = (*env)->CallBooleanMethod(env, ge, isDisplayLocal);
} else {
isLocal = True;
}
isLocalSet = True;
} }
isLocal = JNU_CallStaticMethodByName(env, NULL,
"sun/awt/X11GraphicsEnvironment",
"_isDisplayLocal",
"()Z").z;
isLocalSet = True;
return isLocal; return isLocal;
} }
@ -516,8 +527,8 @@ static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) {
return path; return path;
} }
JNIEXPORT jstring JNICALL Java_sun_font_FontManager_getFontPath JNIEXPORT jstring JNICALL Java_sun_awt_X11FontManager_getFontPath
(JNIEnv *env, jclass obj, jboolean noType1) { (JNIEnv *env, jobject thiz, jboolean noType1) {
jstring ret; jstring ret;
static char *ptr = NULL; /* retain result across calls */ static char *ptr = NULL; /* retain result across calls */
@ -564,7 +575,7 @@ static int shouldSetXFontPath(JNIEnv *env) {
} }
#endif /* !HEADLESS */ #endif /* !HEADLESS */
JNIEXPORT void JNICALL Java_sun_font_FontManager_setNativeFontPath JNIEXPORT void JNICALL Java_sun_font_X11FontManager_setNativeFontPath
(JNIEnv *env, jclass obj, jstring theString) { (JNIEnv *env, jclass obj, jstring theString) {
#ifdef HEADLESS #ifdef HEADLESS
return; return;
@ -592,21 +603,6 @@ JNIEXPORT void JNICALL Java_sun_font_FontManager_setNativeFontPath
#endif #endif
} }
/* This isn't yet used on unix, the implementation is added since shared
* code calls this method in preparation for future use.
*/
/* Obtain all the fontname -> filename mappings.
* This is called once and the results returned to Java code which can
* use it for lookups to reduce or avoid the need to search font files.
*/
JNIEXPORT void JNICALL
Java_sun_font_FontManager_populateFontFileNameMap
(JNIEnv *env, jclass obj, jobject fontToFileMap,
jobject fontToFamilyMap, jobject familyToFontListMap, jobject locale)
{
return;
}
#include <dlfcn.h> #include <dlfcn.h>
#ifndef __linux__ /* i.e. is solaris */ #ifndef __linux__ /* i.e. is solaris */
#include <link.h> #include <link.h>
@ -865,7 +861,7 @@ static char **getFontConfigLocations() {
#define TEXT_AA_LCD_VBGR 7 #define TEXT_AA_LCD_VBGR 7
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_sun_font_FontManager_getFontConfigAASettings Java_sun_font_FontConfigManager_getFontConfigAASettings
(JNIEnv *env, jclass obj, jstring localeStr, jstring fcNameStr) { (JNIEnv *env, jclass obj, jstring localeStr, jstring fcNameStr) {
FcNameParseFuncType FcNameParse; FcNameParseFuncType FcNameParse;
@ -975,7 +971,7 @@ Java_sun_font_FontManager_getFontConfigAASettings
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_sun_font_FontManager_getFontConfigVersion Java_sun_font_FontConfigManager_getFontConfigVersion
(JNIEnv *env, jclass obj) { (JNIEnv *env, jclass obj) {
void* libfontconfig; void* libfontconfig;
@ -1000,7 +996,7 @@ Java_sun_font_FontManager_getFontConfigVersion
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_font_FontManager_getFontConfig Java_sun_font_FontConfigManager_getFontConfig
(JNIEnv *env, jclass obj, jstring localeStr, jobject fcInfoObj, (JNIEnv *env, jclass obj, jstring localeStr, jobject fcInfoObj,
jobjectArray fcCompFontArray, jboolean includeFallbacks) { jobjectArray fcCompFontArray, jboolean includeFallbacks) {
@ -1034,11 +1030,11 @@ Java_sun_font_FontManager_getFontConfig
char* debugMinGlyphsStr = getenv("J2D_DEBUG_MIN_GLYPHS"); char* debugMinGlyphsStr = getenv("J2D_DEBUG_MIN_GLYPHS");
jclass fcInfoClass = jclass fcInfoClass =
(*env)->FindClass(env, "sun/font/FontManager$FontConfigInfo"); (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigInfo");
jclass fcCompFontClass = jclass fcCompFontClass =
(*env)->FindClass(env, "sun/font/FontManager$FcCompFont"); (*env)->FindClass(env, "sun/font/FontConfigManager$FcCompFont");
jclass fcFontClass = jclass fcFontClass =
(*env)->FindClass(env, "sun/font/FontManager$FontConfigFont"); (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigFont");
if (fcInfoObj == NULL || fcCompFontArray == NULL || fcInfoClass == NULL || if (fcInfoObj == NULL || fcCompFontArray == NULL || fcInfoClass == NULL ||
fcCompFontClass == NULL || fcFontClass == NULL) { fcCompFontClass == NULL || fcFontClass == NULL) {
@ -1054,11 +1050,11 @@ Java_sun_font_FontManager_getFontConfig
"fcName", "Ljava/lang/String;"); "fcName", "Ljava/lang/String;");
fcFirstFontID = fcFirstFontID =
(*env)->GetFieldID(env, fcCompFontClass, "firstFont", (*env)->GetFieldID(env, fcCompFontClass, "firstFont",
"Lsun/font/FontManager$FontConfigFont;"); "Lsun/font/FontConfigManager$FontConfigFont;");
fcAllFontsID = fcAllFontsID =
(*env)->GetFieldID(env, fcCompFontClass, "allFonts", (*env)->GetFieldID(env, fcCompFontClass, "allFonts",
"[Lsun/font/FontManager$FontConfigFont;"); "[Lsun/font/FontConfigManager$FontConfigFont;");
fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V"); fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V");

View File

@ -43,6 +43,8 @@ import sun.awt.windows.WFontConfiguration;
import sun.awt.windows.WPrinterJob; import sun.awt.windows.WPrinterJob;
import sun.awt.windows.WToolkit; import sun.awt.windows.WToolkit;
import sun.font.FontManager; import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.font.SunFontManager;
import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.SurfaceManagerFactory; import sun.java2d.SurfaceManagerFactory;
import sun.java2d.WindowsSurfaceManagerFactory; import sun.java2d.WindowsSurfaceManagerFactory;
@ -68,7 +70,6 @@ public class Win32GraphicsEnvironment
// setup flags before initializing native layer // setup flags before initializing native layer
WindowsFlags.initFlags(); WindowsFlags.initFlags();
initDisplayWrapper(); initDisplayWrapper();
eudcFontFileName = getEUDCFontFile();
// Install correct surface manager factory. // Install correct surface manager factory.
SurfaceManagerFactory.setInstance(new WindowsSurfaceManagerFactory()); SurfaceManagerFactory.setInstance(new WindowsSurfaceManagerFactory());
@ -211,14 +212,6 @@ public class Win32GraphicsEnvironment
* ----END DISPLAY CHANGE SUPPORT---- * ----END DISPLAY CHANGE SUPPORT----
*/ */
/* Used on Windows to obtain from the windows registry the name
* of a file containing the system EUFC font. If running in one of
* the locales for which this applies, and one is defined, the font
* defined by this file is appended to all composite fonts as a
* fallback component.
*/
private static native String getEUDCFontFile();
/** /**
* Whether registerFontFile expects absolute or relative * Whether registerFontFile expects absolute or relative
* font file names. * font file names.
@ -227,114 +220,6 @@ public class Win32GraphicsEnvironment
return false; return false;
} }
/* Unlike the shared code version, this expects a base file name -
* not a full path name.
* The font configuration file has base file names and the FontConfiguration
* class reports these back to the GraphicsEnvironment, so these
* are the componentFileNames of CompositeFonts.
*/
protected void registerFontFile(String fontFileName, String[] nativeNames,
int fontRank, boolean defer) {
// REMIND: case compare depends on platform
if (registeredFontFiles.contains(fontFileName)) {
return;
}
registeredFontFiles.add(fontFileName);
int fontFormat;
if (ttFilter.accept(null, fontFileName)) {
fontFormat = FontManager.FONTFORMAT_TRUETYPE;
} else if (t1Filter.accept(null, fontFileName)) {
fontFormat = FontManager.FONTFORMAT_TYPE1;
} else {
/* on windows we don't use/register native fonts */
return;
}
if (fontPath == null) {
fontPath = getPlatformFontPath(noType1Font);
}
/* Look in the JRE font directory first.
* This is playing it safe as we would want to find fonts in the
* JRE font directory ahead of those in the system directory
*/
String tmpFontPath = jreFontDirName+File.pathSeparator+fontPath;
StringTokenizer parser = new StringTokenizer(tmpFontPath,
File.pathSeparator);
boolean found = false;
try {
while (!found && parser.hasMoreTokens()) {
String newPath = parser.nextToken();
boolean ujr = newPath.equals(jreFontDirName);
File theFile = new File(newPath, fontFileName);
if (theFile.canRead()) {
found = true;
String path = theFile.getAbsolutePath();
if (defer) {
FontManager.registerDeferredFont(fontFileName, path,
nativeNames,
fontFormat, ujr,
fontRank);
} else {
FontManager.registerFontFile(path, nativeNames,
fontFormat, ujr,
fontRank);
}
break;
}
}
} catch (NoSuchElementException e) {
System.err.println(e);
}
if (!found) {
addToMissingFontFileList(fontFileName);
}
}
/* register only TrueType/OpenType fonts
* Because these need to be registed just for use when printing,
* we defer the actual registration and the static initialiser
* for the printing class makes the call to registerJREFontsForPrinting()
*/
static String fontsForPrinting = null;
protected void registerJREFontsWithPlatform(String pathName) {
fontsForPrinting = pathName;
}
public static void registerJREFontsForPrinting() {
final String pathName;
synchronized (Win32GraphicsEnvironment.class) {
GraphicsEnvironment.getLocalGraphicsEnvironment();
if (fontsForPrinting == null) {
return;
}
pathName = fontsForPrinting;
fontsForPrinting = null;
}
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
File f1 = new File(pathName);
String[] ls = f1.list(new TTFilter());
if (ls == null) {
return null;
}
for (int i=0; i <ls.length; i++ ) {
File fontFile = new File(f1, ls[i]);
registerFontWithPlatform(fontFile.getAbsolutePath());
}
return null;
}
});
}
protected static native void registerFontWithPlatform(String fontName);
protected static native void deRegisterFontWithPlatform(String fontName);
protected GraphicsDevice makeScreenDevice(int screennum) { protected GraphicsDevice makeScreenDevice(int screennum) {
GraphicsDevice device = null; GraphicsDevice device = null;
if (WindowsFlags.isD3DEnabled()) { if (WindowsFlags.isD3DEnabled()) {
@ -348,7 +233,7 @@ public class Win32GraphicsEnvironment
// Implements SunGraphicsEnvironment.createFontConfiguration. // Implements SunGraphicsEnvironment.createFontConfiguration.
protected FontConfiguration createFontConfiguration() { protected FontConfiguration createFontConfiguration() {
FontConfiguration fc = new WFontConfiguration(this); FontConfiguration fc = new WFontConfiguration(SunFontManager.getInstance());
fc.init(); fc.init();
return fc; return fc;
} }
@ -356,7 +241,12 @@ public class Win32GraphicsEnvironment
public FontConfiguration createFontConfiguration(boolean preferLocaleFonts, public FontConfiguration createFontConfiguration(boolean preferLocaleFonts,
boolean preferPropFonts) { boolean preferPropFonts) {
return new WFontConfiguration(this, preferLocaleFonts,preferPropFonts); return new WFontConfiguration(SunFontManager.getInstance(),
preferLocaleFonts,preferPropFonts);
}
public boolean isDisplayLocal() {
return true;
} }
@Override @Override
@ -394,11 +284,6 @@ public class Win32GraphicsEnvironment
isDWMCompositionEnabled = enabled; isDWMCompositionEnabled = enabled;
} }
@Override
public boolean isDisplayLocal() {
return true;
}
/** /**
* Used to find out if the OS is Windows Vista or later. * Used to find out if the OS is Windows Vista or later.
* *

View File

@ -29,6 +29,8 @@ import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import sun.awt.FontDescriptor; import sun.awt.FontDescriptor;
import sun.awt.FontConfiguration; import sun.awt.FontConfiguration;
import sun.font.FontManager;
import sun.font.SunFontManager;
import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SunGraphicsEnvironment;
import java.nio.charset.*; import java.nio.charset.*;
@ -37,16 +39,16 @@ public class WFontConfiguration extends FontConfiguration {
// whether compatibility fallbacks for TimesRoman and Co. are used // whether compatibility fallbacks for TimesRoman and Co. are used
private boolean useCompatibilityFallbacks; private boolean useCompatibilityFallbacks;
public WFontConfiguration(SunGraphicsEnvironment environment) { public WFontConfiguration(SunFontManager fm) {
super(environment); super(fm);
useCompatibilityFallbacks = "windows-1252".equals(encoding); useCompatibilityFallbacks = "windows-1252".equals(encoding);
initTables(encoding); initTables(encoding);
} }
public WFontConfiguration(SunGraphicsEnvironment environment, public WFontConfiguration(SunFontManager fm,
boolean preferLocaleFonts, boolean preferLocaleFonts,
boolean preferPropFonts) { boolean preferPropFonts) {
super(environment, preferLocaleFonts, preferPropFonts); super(fm, preferLocaleFonts, preferPropFonts);
useCompatibilityFallbacks = "windows-1252".equals(encoding); useCompatibilityFallbacks = "windows-1252".equals(encoding);
} }

View File

@ -64,7 +64,7 @@ import java.util.Arrays;
import sun.font.CharToGlyphMapper; import sun.font.CharToGlyphMapper;
import sun.font.CompositeFont; import sun.font.CompositeFont;
import sun.font.Font2D; import sun.font.Font2D;
import sun.font.FontManager; import sun.font.FontUtilities;
import sun.font.PhysicalFont; import sun.font.PhysicalFont;
import sun.font.TrueTypeFont; import sun.font.TrueTypeFont;
@ -119,6 +119,7 @@ class WPathGraphics extends PathGraphics {
* this graphics context. * this graphics context.
* @since JDK1.0 * @since JDK1.0
*/ */
@Override
public Graphics create() { public Graphics create() {
return new WPathGraphics((Graphics2D) getDelegate().create(), return new WPathGraphics((Graphics2D) getDelegate().create(),
@ -143,6 +144,7 @@ class WPathGraphics extends PathGraphics {
* @see #setClip * @see #setClip
* @see #setComposite * @see #setComposite
*/ */
@Override
public void draw(Shape s) { public void draw(Shape s) {
Stroke stroke = getStroke(); Stroke stroke = getStroke();
@ -250,10 +252,12 @@ class WPathGraphics extends PathGraphics {
* @see java.awt.Graphics#drawChars * @see java.awt.Graphics#drawChars
* @since JDK1.0 * @since JDK1.0
*/ */
@Override
public void drawString(String str, int x, int y) { public void drawString(String str, int x, int y) {
drawString(str, (float) x, (float) y); drawString(str, (float) x, (float) y);
} }
@Override
public void drawString(String str, float x, float y) { public void drawString(String str, float x, float y) {
drawString(str, x, y, getFont(), getFontRenderContext(), 0f); drawString(str, x, y, getFont(), getFontRenderContext(), 0f);
} }
@ -270,6 +274,7 @@ class WPathGraphics extends PathGraphics {
* the default render context (as canDrawStringToWidth() will return * the default render context (as canDrawStringToWidth() will return
* false. That is why it ignores the frc and width arguments. * false. That is why it ignores the frc and width arguments.
*/ */
@Override
protected int platformFontCount(Font font, String str) { protected int platformFontCount(Font font, String str) {
AffineTransform deviceTransform = getTransform(); AffineTransform deviceTransform = getTransform();
@ -294,7 +299,7 @@ class WPathGraphics extends PathGraphics {
* fail that case. Just do a quick check whether its a TrueTypeFont * fail that case. Just do a quick check whether its a TrueTypeFont
* - ie not a Type1 font etc, and let drawString() resolve the rest. * - ie not a Type1 font etc, and let drawString() resolve the rest.
*/ */
Font2D font2D = FontManager.getFont2D(font); Font2D font2D = FontUtilities.getFont2D(font);
if (font2D instanceof CompositeFont || if (font2D instanceof CompositeFont ||
font2D instanceof TrueTypeFont) { font2D instanceof TrueTypeFont) {
return 1; return 1;
@ -320,14 +325,14 @@ class WPathGraphics extends PathGraphics {
*/ */
private boolean strNeedsTextLayout(String str, Font font) { private boolean strNeedsTextLayout(String str, Font font) {
char[] chars = str.toCharArray(); char[] chars = str.toCharArray();
boolean isComplex = FontManager.isComplexText(chars, 0, chars.length); boolean isComplex = FontUtilities.isComplexText(chars, 0, chars.length);
if (!isComplex) { if (!isComplex) {
return false; return false;
} else if (!useGDITextLayout) { } else if (!useGDITextLayout) {
return true; return true;
} else { } else {
if (preferGDITextLayout || if (preferGDITextLayout ||
(isXP() && FontManager.textLayoutIsCompatible(font))) { (isXP() && FontUtilities.textLayoutIsCompatible(font))) {
return false; return false;
} else { } else {
return true; return true;
@ -388,6 +393,7 @@ class WPathGraphics extends PathGraphics {
* @see #setComposite * @see #setComposite
* @see #setClip * @see #setClip
*/ */
@Override
public void drawString(String str, float x, float y, public void drawString(String str, float x, float y,
Font font, FontRenderContext frc, float targetW) { Font font, FontRenderContext frc, float targetW) {
if (str.length() == 0) { if (str.length() == 0) {
@ -498,7 +504,7 @@ class WPathGraphics extends PathGraphics {
float awScale = getAwScale(scaleFactorX, scaleFactorY); float awScale = getAwScale(scaleFactorX, scaleFactorY);
int iangle = getAngle(ptx); int iangle = getAngle(ptx);
Font2D font2D = FontManager.getFont2D(font); Font2D font2D = FontUtilities.getFont2D(font);
if (font2D instanceof TrueTypeFont) { if (font2D instanceof TrueTypeFont) {
textOut(str, font, (TrueTypeFont)font2D, frc, textOut(str, font, (TrueTypeFont)font2D, frc,
scaledFontSizeY, iangle, awScale, scaledFontSizeY, iangle, awScale,
@ -549,6 +555,7 @@ class WPathGraphics extends PathGraphics {
/** return true if the Graphics instance can directly print /** return true if the Graphics instance can directly print
* this glyphvector * this glyphvector
*/ */
@Override
protected boolean printGlyphVector(GlyphVector gv, float x, float y) { protected boolean printGlyphVector(GlyphVector gv, float x, float y) {
/* We don't want to try to handle per-glyph transforms. GDI can't /* We don't want to try to handle per-glyph transforms. GDI can't
* handle per-glyph rotations, etc. There's no way to express it * handle per-glyph rotations, etc. There's no way to express it
@ -693,7 +700,7 @@ class WPathGraphics extends PathGraphics {
glyphAdvPos, 0, //destination glyphAdvPos, 0, //destination
glyphPos.length/2); //num points glyphPos.length/2); //num points
Font2D font2D = FontManager.getFont2D(font); Font2D font2D = FontUtilities.getFont2D(font);
if (font2D instanceof TrueTypeFont) { if (font2D instanceof TrueTypeFont) {
String family = font2D.getFamilyName(null); String family = font2D.getFamilyName(null);
int style = font.getStyle() | font2D.getStyle(); int style = font.getStyle() | font2D.getStyle();
@ -792,7 +799,7 @@ class WPathGraphics extends PathGraphics {
char[] chars = str.toCharArray(); char[] chars = str.toCharArray();
int len = chars.length; int len = chars.length;
GlyphVector gv = null; GlyphVector gv = null;
if (!FontManager.isComplexText(chars, 0, len)) { if (!FontUtilities.isComplexText(chars, 0, len)) {
gv = font.createGlyphVector(frc, str); gv = font.createGlyphVector(frc, str);
} }
if (gv == null) { if (gv == null) {

View File

@ -98,6 +98,8 @@ import javax.print.attribute.standard.PageRanges;
import javax.print.attribute.Size2DSyntax; import javax.print.attribute.Size2DSyntax;
import javax.print.StreamPrintService; import javax.print.StreamPrintService;
import sun.awt.Win32FontManager;
import sun.print.RasterPrinterJob; import sun.print.RasterPrinterJob;
import sun.print.SunAlternateMedia; import sun.print.SunAlternateMedia;
import sun.print.SunPageSelection; import sun.print.SunPageSelection;
@ -359,7 +361,7 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget {
initIDs(); initIDs();
Win32GraphicsEnvironment.registerJREFontsForPrinting(); Win32FontManager.registerJREFontsForPrinting();
} }
/* Constructors */ /* Constructors */

View File

@ -60,6 +60,9 @@ import java.util.Properties;
import java.util.logging.*; import java.util.logging.*;
import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.font.SunFontManager;
import sun.misc.PerformanceLogger; import sun.misc.PerformanceLogger;
public class WToolkit extends SunToolkit implements Runnable { public class WToolkit extends SunToolkit implements Runnable {
@ -572,8 +575,11 @@ public class WToolkit extends SunToolkit implements Runnable {
public FontMetrics getFontMetrics(Font font) { public FontMetrics getFontMetrics(Font font) {
// REMIND: platform font flag should be removed post-merlin. // This is an unsupported hack, but left in for a customer.
if (sun.font.FontManager.usePlatformFontMetrics()) { // Do not remove.
FontManager fm = FontManagerFactory.getInstance();
if (fm instanceof SunFontManager
&& ((SunFontManager) fm).usePlatformFontMetrics()) {
return WFontMetrics.getFontMetrics(font); return WFontMetrics.getFontMetrics(font);
} }
return super.getFontMetrics(font); return super.getFontMetrics(font);

View File

@ -28,12 +28,12 @@
#include <jni.h> #include <jni.h>
#include <jni_util.h> #include <jni_util.h>
#include <sun_font_FontManager.h> #include <sun_awt_Win32FontManager.h>
#define BSIZE (max(512, MAX_PATH+1)) #define BSIZE (max(512, MAX_PATH+1))
JNIEXPORT jstring JNICALL Java_sun_font_FontManager_getFontPath(JNIEnv *env, jclass obj, jboolean noType1) JNIEXPORT jstring JNICALL Java_sun_awt_Win32FontManager_getFontPath(JNIEnv *env, jobject thiz, jboolean noType1)
{ {
char windir[BSIZE]; char windir[BSIZE];
char sysdir[BSIZE]; char sysdir[BSIZE];
@ -68,15 +68,6 @@ JNIEXPORT jstring JNICALL Java_sun_font_FontManager_getFontPath(JNIEnv *env, jcl
return JNU_NewStringPlatform(env, fontpath); return JNU_NewStringPlatform(env, fontpath);
} }
/* This isn't used on windows, the implementation is added in case shared
* code accidentally calls this method to prevent an UnsatisfiedLinkError
*/
JNIEXPORT void JNICALL Java_sun_font_FontManager_setNativeFontPath
(JNIEnv *env, jclass obj, jstring theString)
{
return;
}
/* The code below is used to obtain information from the windows font APIS /* The code below is used to obtain information from the windows font APIS
* and registry on which fonts are available and what font files hold those * and registry on which fonts are available and what font files hold those
* fonts. The results are used to speed font lookup. * fonts. The results are used to speed font lookup.
@ -546,7 +537,7 @@ static void registerFontW(GdiFontMapInfo *fmi, jobject fontToFileMap,
* use it for lookups to reduce or avoid the need to search font files. * use it for lookups to reduce or avoid the need to search font files.
*/ */
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_font_FontManager_populateFontFileNameMap Java_sun_awt_Win32FontManager_populateFontFileNameMap0
(JNIEnv *env, jclass obj, jobject fontToFileMap, (JNIEnv *env, jclass obj, jobject fontToFileMap,
jobject fontToFamilyMap, jobject familyToFontListMap, jobject locale) jobject fontToFamilyMap, jobject familyToFontListMap, jobject locale)
{ {

View File

@ -25,6 +25,7 @@
#include <awt.h> #include <awt.h>
#include <sun_awt_Win32GraphicsEnvironment.h> #include <sun_awt_Win32GraphicsEnvironment.h>
#include <sun_awt_Win32FontManager.h>
#include "awt_Canvas.h" #include "awt_Canvas.h"
#include "awt_Win32GraphicsDevice.h" #include "awt_Win32GraphicsDevice.h"
#include "Devices.h" #include "Devices.h"
@ -173,14 +174,14 @@ Java_sun_awt_Win32GraphicsEnvironment_getDefaultScreen(JNIEnv *env,
} }
/* /*
* Class: sun_awt_Win32GraphicsEnvironment * Class: sun_awt_Win32FontManager
* Method: registerFontWithPlatform * Method: registerFontWithPlatform
* Signature: (Ljava/lang/String;)V * Signature: (Ljava/lang/String;)V
*/ */
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_awt_Win32GraphicsEnvironment_registerFontWithPlatform(JNIEnv *env, Java_sun_awt_Win32FontManager_registerFontWithPlatform(JNIEnv *env,
jclass cl, jclass cl,
jstring fontName) jstring fontName)
{ {
LPTSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, JNI_FALSE); LPTSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, JNI_FALSE);
if (file) { if (file) {
@ -191,16 +192,16 @@ Java_sun_awt_Win32GraphicsEnvironment_registerFontWithPlatform(JNIEnv *env,
/* /*
* Class: sun_awt_Win32GraphicsEnvironment * Class: sun_awt_Win32FontManagerEnvironment
* Method: deRegisterFontWithPlatform * Method: deRegisterFontWithPlatform
* Signature: (Ljava/lang/String;)V * Signature: (Ljava/lang/String;)V
* *
* This method intended for future use. * This method intended for future use.
*/ */
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_awt_Win32GraphicsEnvironment_deRegisterFontWithPlatform(JNIEnv *env, Java_sun_awt_Win32FontManager_deRegisterFontWithPlatform(JNIEnv *env,
jclass cl, jclass cl,
jstring fontName) jstring fontName)
{ {
LPTSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, JNI_FALSE); LPTSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, JNI_FALSE);
if (file) { if (file) {
@ -223,7 +224,7 @@ Java_sun_awt_Win32GraphicsEnvironment_deRegisterFontWithPlatform(JNIEnv *env,
JNIEXPORT jstring JNICALL JNIEXPORT jstring JNICALL
Java_sun_awt_Win32GraphicsEnvironment_getEUDCFontFile(JNIEnv *env, jclass cl) { Java_sun_awt_Win32FontManager_getEUDCFontFile(JNIEnv *env, jclass cl) {
int rc; int rc;
HKEY key; HKEY key;
DWORD type; DWORD type;