diff --git a/jdk/make/common/Defs-windows.gmk b/jdk/make/common/Defs-windows.gmk index 19a7f6a6f75..63f19d3e794 100644 --- a/jdk/make/common/Defs-windows.gmk +++ b/jdk/make/common/Defs-windows.gmk @@ -365,10 +365,6 @@ ifeq ($(CC_VERSION),msvc) # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file BASELFLAGS = -nologo /opt:REF /incremental:no -ifdef MT - # VS2005, VS2008, and beyond: ask LINK to generate manifests for .dll & .exe - BASELFLAGS += /manifest -endif LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION)) LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION)) diff --git a/jdk/make/common/Library.gmk b/jdk/make/common/Library.gmk index 71758275689..c70d0c4daf7 100644 --- a/jdk/make/common/Library.gmk +++ b/jdk/make/common/Library.gmk @@ -159,9 +159,6 @@ else # LIBRARY # build it into $(OBJDIR) so that the other generated files get put # there, then copy just the DLL (and MAP file) to the requested directory. # -# In VS2005 or VS2008 the link command creates a .manifest file that we want -# to insert into the linked artifact so we do not need to track it separately. -# Use ";#2" for .dll and ";#1" for .exe in the MT command below: $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf @$(prep-target) @$(MKDIR) -p $(OBJDIR) @@ -169,9 +166,6 @@ $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf -map:$(OBJDIR)/$(LIBRARY).map \ $(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \ $(OTHER_LCF) $(JAVALIB) $(LDLIBS) -ifdef MT - $(MT) /manifest $(OBJDIR)/$(@F).manifest /outputresource:$(OBJDIR)/$(@F);#2 -endif $(CP) $(OBJDIR)/$(@F) $@ $(install-module-file) $(CP) $(OBJDIR)/$(LIBRARY).map $(@D) diff --git a/jdk/make/common/Program.gmk b/jdk/make/common/Program.gmk index 005236149d6..751f0fe6898 100644 --- a/jdk/make/common/Program.gmk +++ b/jdk/make/common/Program.gmk @@ -142,10 +142,15 @@ else STACK_SIZE=1048576 endif -# In VS2005 or VS2008 the link command creates a .manifest file that we want -# to insert into the linked artifact so we do not need to track it separately. +IMVERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER) +$(OBJDIR)/$(PROGRAM).exe.manifest: $(JDK_TOPDIR)/src/windows/resource/java.manifest + @$(prep-target) + $(SED) 's%IMVERSION%$(IMVERSION)%g;s%PROGRAM%$(PROGRAM)%g' $< > $@ + +# We used a hand-crafted manifest file for all executables. +# It is tweaked to embed the build number and executable name. # Use ";#2" for .dll and ";#1" for .exe in the MT command below: -$(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LCF) +$(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LCF) $(OBJDIR)/$(PROGRAM).exe.manifest @$(prep-target) @set -- $?; \ $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...}; diff --git a/jdk/make/sun/awt/Makefile b/jdk/make/sun/awt/Makefile index 87fd56b6dad..7d8b4b6a6f1 100644 --- a/jdk/make/sun/awt/Makefile +++ b/jdk/make/sun/awt/Makefile @@ -369,10 +369,6 @@ FONTCONFIGS_SRC = $(CLOSED_SRC)/solaris/classes/sun/awt/fontconfigs _FONTCONFIGS = \ fontconfig.properties \ fontconfig.RedHat.properties \ - fontconfig.RedHat.2.1.properties \ - fontconfig.RedHat.3.properties \ - fontconfig.RedHat.4.properties \ - fontconfig.Sun.properties \ fontconfig.Turbo.properties \ fontconfig.SuSE.10.properties \ fontconfig.SuSE.11.properties @@ -388,9 +384,7 @@ ifeq ($(PLATFORM), solaris) FONTCONFIGS_SRC = $(PLATFORM_SRC)/classes/sun/awt/fontconfigs _FONTCONFIGS = \ - fontconfig.properties \ - fontconfig.5.9.properties \ - fontconfig.5.8.properties + fontconfig.properties FONTCONFIGS_SRC_PREFIX = $(PLATFORM). diff --git a/jdk/make/sun/awt/mapfile-mawt-vers b/jdk/make/sun/awt/mapfile-mawt-vers index b80f30fed50..f1b7143e948 100644 --- a/jdk/make/sun/awt/mapfile-mawt-vers +++ b/jdk/make/sun/awt/mapfile-mawt-vers @@ -515,8 +515,7 @@ SUNWprivate_1.1 { getDefaultConfig; Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_X11FontManager_getFontPath; - Java_sun_awt_X11FontManager_setNativeFontPath; + Java_sun_awt_X11FontManager_getFontPathNative; Java_sun_font_SunFontManager_populateFontFileNameMap; # CDE private entry point diff --git a/jdk/make/sun/awt/mapfile-vers-linux b/jdk/make/sun/awt/mapfile-vers-linux index 60fa9ccef69..d2fbf560c9b 100644 --- a/jdk/make/sun/awt/mapfile-vers-linux +++ b/jdk/make/sun/awt/mapfile-vers-linux @@ -537,8 +537,7 @@ SUNWprivate_1.1 { getDefaultConfig; Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_X11FontManager_getFontPath; - Java_sun_awt_X11FontManager_setNativeFontPath; + Java_sun_awt_X11FontManager_getFontPathNative; Java_sun_font_SunFontManager_populateFontFileNameMap; # CDE private entry point diff --git a/jdk/make/sun/headless/mapfile-vers b/jdk/make/sun/headless/mapfile-vers index c82b6116fcc..dfb6aa361ae 100644 --- a/jdk/make/sun/headless/mapfile-vers +++ b/jdk/make/sun/headless/mapfile-vers @@ -65,7 +65,7 @@ SUNWprivate_1.1 { Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_X11FontManager_getFontPath; + Java_sun_awt_X11FontManager_getFontPathNative; Java_sun_awt_FontDescriptor_initIDs; Java_sun_awt_PlatformFont_initIDs; diff --git a/jdk/make/sun/xawt/Makefile b/jdk/make/sun/xawt/Makefile index ffbe2b97112..f1297ef192f 100644 --- a/jdk/make/sun/xawt/Makefile +++ b/jdk/make/sun/xawt/Makefile @@ -136,8 +136,25 @@ ifeq ($(PLATFORM), linux) -I$(OPENWIN_HOME)/include endif +# We have some odd logic here because some Solaris 10 updates +# have a render.h file that suggests gradients are supported, but +# the Xrender.h doesn't have the corresponding type definitions. +# Earlier updates have neither. We'd like to know if there's a mismatch. +# Whilst in the C preprocessor we can tell if the render.h define's are set +# we can't tell anything about C declarations. +# A grep of Xrender.h is the only way to know this. If they are absent +# we will set a flag indicating this mismatch and the JDK source file +# will interpret it to resolve the problem. ifeq ($(PLATFORM), solaris) CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions + OS_VERSION := $(shell uname -r) + XRENDER_H := $(OPENWIN_HOME)/share/include/X11/extensions/Xrender.h + ifeq ($(OS_VERSION),5.10) + LINEARGRADIENT_CNT := $(shell $(EGREP) -c XLinearGradient $(XRENDER_H)) + ifeq ($(LINEARGRADIENT_CNT),0) + CFLAGS+= -DSOLARIS10_NO_XRENDER_STRUCTS + endif + endif endif ifeq ($(MILESTONE), internal) diff --git a/jdk/make/sun/xawt/mapfile-vers b/jdk/make/sun/xawt/mapfile-vers index 7eac730927d..479a55a800d 100644 --- a/jdk/make/sun/xawt/mapfile-vers +++ b/jdk/make/sun/xawt/mapfile-vers @@ -188,8 +188,7 @@ SUNWprivate_1.1 { Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_X11FontManager_getFontPath; - Java_sun_font_X11FontManager_setNativeFontPath; + Java_sun_awt_X11FontManager_getFontPathNative; Java_sun_awt_X11GraphicsEnvironment_initDisplay; Java_sun_awt_X11GraphicsEnvironment_initGLX; Java_sun_awt_X11GraphicsEnvironment_initXRender; diff --git a/jdk/src/share/classes/java/awt/geom/CubicCurve2D.java b/jdk/src/share/classes/java/awt/geom/CubicCurve2D.java index 766e383ffb0..9f8042229d2 100644 --- a/jdk/src/share/classes/java/awt/geom/CubicCurve2D.java +++ b/jdk/src/share/classes/java/awt/geom/CubicCurve2D.java @@ -1387,203 +1387,13 @@ public abstract class CubicCurve2D implements Shape, Cloneable { return false; } - // Trivially accept if either endpoint is inside the rectangle - // (not on its border since it may end there and not go inside) - // Record where they lie with respect to the rectangle. - // -1 => left, 0 => inside, 1 => right - double x1 = getX1(); - double y1 = getY1(); - int x1tag = getTag(x1, x, x+w); - int y1tag = getTag(y1, y, y+h); - if (x1tag == INSIDE && y1tag == INSIDE) { - return true; - } - double x2 = getX2(); - double y2 = getY2(); - int x2tag = getTag(x2, x, x+w); - int y2tag = getTag(y2, y, y+h); - if (x2tag == INSIDE && y2tag == INSIDE) { - return true; - } - - double ctrlx1 = getCtrlX1(); - double ctrly1 = getCtrlY1(); - double ctrlx2 = getCtrlX2(); - double ctrly2 = getCtrlY2(); - int ctrlx1tag = getTag(ctrlx1, x, x+w); - int ctrly1tag = getTag(ctrly1, y, y+h); - int ctrlx2tag = getTag(ctrlx2, x, x+w); - int ctrly2tag = getTag(ctrly2, y, y+h); - - // Trivially reject if all points are entirely to one side of - // the rectangle. - if (x1tag < INSIDE && x2tag < INSIDE && - ctrlx1tag < INSIDE && ctrlx2tag < INSIDE) - { - return false; // All points left - } - if (y1tag < INSIDE && y2tag < INSIDE && - ctrly1tag < INSIDE && ctrly2tag < INSIDE) - { - return false; // All points above - } - if (x1tag > INSIDE && x2tag > INSIDE && - ctrlx1tag > INSIDE && ctrlx2tag > INSIDE) - { - return false; // All points right - } - if (y1tag > INSIDE && y2tag > INSIDE && - ctrly1tag > INSIDE && ctrly2tag > INSIDE) - { - return false; // All points below - } - - // Test for endpoints on the edge where either the segment - // or the curve is headed "inwards" from them - // Note: These tests are a superset of the fast endpoint tests - // above and thus repeat those tests, but take more time - // and cover more cases - if (inwards(x1tag, x2tag, ctrlx1tag) && - inwards(y1tag, y2tag, ctrly1tag)) - { - // First endpoint on border with either edge moving inside - return true; - } - if (inwards(x2tag, x1tag, ctrlx2tag) && - inwards(y2tag, y1tag, ctrly2tag)) - { - // Second endpoint on border with either edge moving inside - return true; - } - - // Trivially accept if endpoints span directly across the rectangle - boolean xoverlap = (x1tag * x2tag <= 0); - boolean yoverlap = (y1tag * y2tag <= 0); - if (x1tag == INSIDE && x2tag == INSIDE && yoverlap) { - return true; - } - if (y1tag == INSIDE && y2tag == INSIDE && xoverlap) { - return true; - } - - // We now know that both endpoints are outside the rectangle - // but the 4 points are not all on one side of the rectangle. - // Therefore the curve cannot be contained inside the rectangle, - // but the rectangle might be contained inside the curve, or - // the curve might intersect the boundary of the rectangle. - - double[] eqn = new double[4]; - double[] res = new double[4]; - if (!yoverlap) { - // Both y coordinates for the closing segment are above or - // below the rectangle which means that we can only intersect - // if the curve crosses the top (or bottom) of the rectangle - // in more than one place and if those crossing locations - // span the horizontal range of the rectangle. - fillEqn(eqn, (y1tag < INSIDE ? y : y+h), y1, ctrly1, ctrly2, y2); - int num = solveCubic(eqn, res); - num = evalCubic(res, num, true, true, null, - x1, ctrlx1, ctrlx2, x2); - // odd counts imply the crossing was out of [0,1] bounds - // otherwise there is no way for that part of the curve to - // "return" to meet its endpoint - return (num == 2 && - getTag(res[0], x, x+w) * getTag(res[1], x, x+w) <= 0); - } - - // Y ranges overlap. Now we examine the X ranges - if (!xoverlap) { - // Both x coordinates for the closing segment are left of - // or right of the rectangle which means that we can only - // intersect if the curve crosses the left (or right) edge - // of the rectangle in more than one place and if those - // crossing locations span the vertical range of the rectangle. - fillEqn(eqn, (x1tag < INSIDE ? x : x+w), x1, ctrlx1, ctrlx2, x2); - int num = solveCubic(eqn, res); - num = evalCubic(res, num, true, true, null, - y1, ctrly1, ctrly2, y2); - // odd counts imply the crossing was out of [0,1] bounds - // otherwise there is no way for that part of the curve to - // "return" to meet its endpoint - return (num == 2 && - getTag(res[0], y, y+h) * getTag(res[1], y, y+h) <= 0); - } - - // The X and Y ranges of the endpoints overlap the X and Y - // ranges of the rectangle, now find out how the endpoint - // line segment intersects the Y range of the rectangle - double dx = x2 - x1; - double dy = y2 - y1; - double k = y2 * x1 - x2 * y1; - int c1tag, c2tag; - if (y1tag == INSIDE) { - c1tag = x1tag; - } else { - c1tag = getTag((k + dx * (y1tag < INSIDE ? y : y+h)) / dy, x, x+w); - } - if (y2tag == INSIDE) { - c2tag = x2tag; - } else { - c2tag = getTag((k + dx * (y2tag < INSIDE ? y : y+h)) / dy, x, x+w); - } - // If the part of the line segment that intersects the Y range - // of the rectangle crosses it horizontally - trivially accept - if (c1tag * c2tag <= 0) { - return true; - } - - // Now we know that both the X and Y ranges intersect and that - // the endpoint line segment does not directly cross the rectangle. - // - // We can almost treat this case like one of the cases above - // where both endpoints are to one side, except that we may - // get one or three intersections of the curve with the vertical - // side of the rectangle. This is because the endpoint segment - // accounts for the other intersection in an even pairing. Thus, - // with the endpoint crossing we end up with 2 or 4 total crossings. - // - // (Remember there is overlap in both the X and Y ranges which - // means that the segment itself must cross at least one vertical - // edge of the rectangle - in particular, the "near vertical side" - // - leaving an odd number of intersections for the curve.) - // - // Now we calculate the y tags of all the intersections on the - // "near vertical side" of the rectangle. We will have one with - // the endpoint segment, and one or three with the curve. If - // any pair of those vertical intersections overlap the Y range - // of the rectangle, we have an intersection. Otherwise, we don't. - - // c1tag = vertical intersection class of the endpoint segment - // - // Choose the y tag of the endpoint that was not on the same - // side of the rectangle as the subsegment calculated above. - // Note that we can "steal" the existing Y tag of that endpoint - // since it will be provably the same as the vertical intersection. - c1tag = ((c1tag * x1tag <= 0) ? y1tag : y2tag); - - // Now we have to calculate an array of solutions of the curve - // with the "near vertical side" of the rectangle. Then we - // need to sort the tags and do a pairwise range test to see - // if either of the pairs of crossings spans the Y range of - // the rectangle. - // - // Note that the c2tag can still tell us which vertical edge - // to test against. - fillEqn(eqn, (c2tag < INSIDE ? x : x+w), x1, ctrlx1, ctrlx2, x2); - int num = solveCubic(eqn, res); - num = evalCubic(res, num, true, true, null, y1, ctrly1, ctrly2, y2); - - // Now put all of the tags into a bucket and sort them. There - // is an intersection iff one of the pairs of tags "spans" the - // Y range of the rectangle. - int tags[] = new int[num+1]; - for (int i = 0; i < num; i++) { - tags[i] = getTag(res[i], y, y+h); - } - tags[num] = c1tag; - Arrays.sort(tags); - return ((num >= 1 && tags[0] * tags[1] <= 0) || - (num >= 3 && tags[2] * tags[3] <= 0)); + int numCrossings = rectCrossings(x, y, w, h); + // the intended return value is + // numCrossings != 0 || numCrossings == Curve.RECT_INTERSECTS + // but if (numCrossings != 0) numCrossings == INTERSECTS won't matter + // and if !(numCrossings != 0) then numCrossings == 0, so + // numCrossings != RECT_INTERSECT + return numCrossings != 0; } /** @@ -1602,20 +1412,32 @@ public abstract class CubicCurve2D implements Shape, Cloneable { if (w <= 0 || h <= 0) { return false; } - // Assertion: Cubic curves closed by connecting their - // endpoints form either one or two convex halves with - // the closing line segment as an edge of both sides. - if (!(contains(x, y) && - contains(x + w, y) && - contains(x + w, y + h) && - contains(x, y + h))) { - return false; + + int numCrossings = rectCrossings(x, y, w, h); + return !(numCrossings == 0 || numCrossings == Curve.RECT_INTERSECTS); + } + + private int rectCrossings(double x, double y, double w, double h) { + int crossings = 0; + if (!(getX1() == getX2() && getY1() == getY2())) { + crossings = Curve.rectCrossingsForLine(crossings, + x, y, + x+w, y+h, + getX1(), getY1(), + getX2(), getY2()); + if (crossings == Curve.RECT_INTERSECTS) { + return crossings; + } } - // Either the rectangle is entirely inside one of the convex - // halves or it crosses from one to the other, in which case - // it must intersect the closing line segment. - Rectangle2D rect = new Rectangle2D.Double(x, y, w, h); - return !rect.intersectsLine(getX1(), getY1(), getX2(), getY2()); + // we call this with the curve's direction reversed, because we wanted + // to call rectCrossingsForLine first, because it's cheaper. + return Curve.rectCrossingsForCubic(crossings, + x, y, + x+w, y+h, + getX2(), getY2(), + getCtrlX2(), getCtrlY2(), + getCtrlX1(), getCtrlY1(), + getX1(), getY1(), 0); } /** diff --git a/jdk/src/share/classes/sun/font/FileFontStrike.java b/jdk/src/share/classes/sun/font/FileFontStrike.java index ae6045f696c..3782c9ed3ba 100644 --- a/jdk/src/share/classes/sun/font/FileFontStrike.java +++ b/jdk/src/share/classes/sun/font/FileFontStrike.java @@ -151,6 +151,23 @@ public class FileFontStrike extends PhysicalStrike { } } + /* Amble fonts are better rendered unhinted although there's the + * inevitable fuzziness that accompanies this due to no longer + * snapping stems to the pixel grid. The exception is that in B&W + * mode they are worse without hinting. The down side to that is that + * B&W metrics will differ which normally isn't the case, although + * since AA mode is part of the measuring context that should be OK. + * We don't expect Amble to be installed in the Windows fonts folder. + * If we were to, then we'd also might want to disable using the + * native rasteriser path which is used for LCD mode for platform + * fonts. since we have no way to disable hinting by GDI. + * In the case of Amble, since its 'gasp' table says to disable + * hinting, I'd expect GDI to follow that, so likely it should + * all be consistent even if GDI used. + */ + boolean disableHinting = desc.aaHint != INTVAL_TEXT_ANTIALIAS_OFF && + fileFont.familyName.startsWith("Amble"); + /* If any of the values is NaN then substitute the null scaler context. * This will return null images, zero advance, and empty outlines * as no rendering need take place in this case. @@ -165,7 +182,7 @@ public class FileFontStrike extends PhysicalStrike { pScalerContext = fileFont.getScaler().createScalerContext(matrix, fileFont instanceof TrueTypeFont, desc.aaHint, desc.fmHint, - boldness, italic); + boldness, italic, disableHinting); } mapper = fileFont.getMapper(); @@ -566,10 +583,44 @@ public class FileFontStrike extends PhysicalStrike { if (glyphCode >= INVISIBLE_GLYPHS) { return 0f; } + + /* Notes on the (getUserAdv == false) case. + * + * Setting getUserAdv == false is internal to this class. + * If there's no graphics transform we can let + * getGlyphAdvance take its course, and potentially caching in + * advances arrays, except for signalling that + * getUserAdv == false means there is no need to create an image. + * It is possible that code already calculated the user advance, + * and it is desirable to take advantage of that work. + * But, if there's a transform and we want device advance, we + * can't use any values cached in the advances arrays - unless + * first re-transform them into device space using 'desc.devTx'. + * invertDevTx is null if the graphics transform is identity, + * a translate, or non-invertible. The latter case should + * not ever occur in the getUserAdv == false path. + * In other words its either null, or the inversion of a + * simple uniform scale. If its null, we can populate and + * use the advance caches as normal. + * + * If we don't find a cached value, obtain the device advance and + * return it. This will get stashed on the image by the caller and any + * subsequent metrics calls will be able to use it as is the case + * whenever an image is what is initially requested. + * + * Don't query if there's a value cached on the image, since this + * getUserAdv==false code path is entered solely when none exists. + */ if (horizontalAdvances != null) { advance = horizontalAdvances[glyphCode]; if (advance != Float.MAX_VALUE) { - return advance; + if (!getUserAdv && invertDevTx != null) { + Point2D.Float metrics = new Point2D.Float(advance, 0f); + desc.devTx.deltaTransform(metrics, metrics); + return metrics.x; + } else { + return advance; + } } } else if (segmentedCache && segHorizontalAdvances != null) { int segIndex = glyphCode >> SEGSHIFT; @@ -577,11 +628,23 @@ public class FileFontStrike extends PhysicalStrike { if (subArray != null) { advance = subArray[glyphCode % SEGSIZE]; if (advance != Float.MAX_VALUE) { - return advance; + if (!getUserAdv && invertDevTx != null) { + Point2D.Float metrics = new Point2D.Float(advance, 0f); + desc.devTx.deltaTransform(metrics, metrics); + return metrics.x; + } else { + return advance; + } } } } + if (!getUserAdv && invertDevTx != null) { + Point2D.Float metrics = new Point2D.Float(); + fileFont.getGlyphMetrics(pScalerContext, glyphCode, metrics); + return metrics.x; + } + if (invertDevTx != null || !getUserAdv) { /* If there is a device transform need x & y advance to * transform back into user space. @@ -725,7 +788,7 @@ public class FileFontStrike extends PhysicalStrike { return getGlyphMetrics(glyphCode, true); } - private Point2D.Float getGlyphMetrics(int glyphCode, boolean getUserAdv) { + private Point2D.Float getGlyphMetrics(int glyphCode, boolean getImage) { Point2D.Float metrics = new Point2D.Float(); // !!! or do we force sgv user glyphs? @@ -733,7 +796,7 @@ public class FileFontStrike extends PhysicalStrike { return metrics; } long glyphPtr; - if (getImageWithAdvance && getUserAdv) { + if (getImageWithAdvance && getImage) { /* A heuristic optimisation says that for most cases its * worthwhile retrieving the image at the same time as the * metrics. So here we get the image data even if its not @@ -750,9 +813,9 @@ public class FileFontStrike extends PhysicalStrike { metrics.y = StrikeCache.unsafe.getFloat (glyphPtr + StrikeCache.yAdvanceOffset); /* advance is currently in device space, need to convert back - * into user space, unless getUserAdv == false. + * into user space. * This must not include the translation component. */ - if (invertDevTx != null && getUserAdv) { + if (invertDevTx != null) { invertDevTx.deltaTransform(metrics, metrics); } } else { @@ -781,9 +844,9 @@ public class FileFontStrike extends PhysicalStrike { if (value == null) { fileFont.getGlyphMetrics(pScalerContext, glyphCode, metrics); /* advance is currently in device space, need to convert back - * into user space, unless getUserAdv == false. + * into user space. */ - if (invertDevTx != null && getUserAdv) { + if (invertDevTx != null) { invertDevTx.deltaTransform(metrics, metrics); } value = new Point2D.Float(metrics.x, metrics.y); diff --git a/jdk/src/share/classes/sun/font/FontScaler.java b/jdk/src/share/classes/sun/font/FontScaler.java index eae9fb22ab5..a2c1c09ef7f 100644 --- a/jdk/src/share/classes/sun/font/FontScaler.java +++ b/jdk/src/share/classes/sun/font/FontScaler.java @@ -242,9 +242,10 @@ public abstract class FontScaler implements DisposerRecord { freed when corresponding strike is being released. */ abstract long createScalerContext(double[] matrix, - boolean fontType, - int aa, int fm, - float boldness, float italic); + boolean fontType, + int aa, int fm, + float boldness, float italic, + boolean disableHinting); /* Marks context as invalid because native scaler is invalid. Notes: diff --git a/jdk/src/share/classes/sun/font/FreetypeFontScaler.java b/jdk/src/share/classes/sun/font/FreetypeFontScaler.java index bb4143c048d..69d0c53965e 100644 --- a/jdk/src/share/classes/sun/font/FreetypeFontScaler.java +++ b/jdk/src/share/classes/sun/font/FreetypeFontScaler.java @@ -211,7 +211,8 @@ class FreetypeFontScaler extends FontScaler { } long createScalerContext(double[] matrix, boolean fontType, - int aa, int fm, float boldness, float italic) { + int aa, int fm, float boldness, float italic, + boolean disableHinting) { if (nativeScaler != 0L) { return createScalerContextNative(nativeScaler, matrix, fontType, aa, fm, boldness, italic); diff --git a/jdk/src/share/classes/sun/font/NullFontScaler.java b/jdk/src/share/classes/sun/font/NullFontScaler.java index 1258243550b..857ec5a88c8 100644 --- a/jdk/src/share/classes/sun/font/NullFontScaler.java +++ b/jdk/src/share/classes/sun/font/NullFontScaler.java @@ -67,7 +67,7 @@ class NullFontScaler extends FontScaler { long getLayoutTableCache() {return 0L;} long createScalerContext(double[] matrix, boolean fontType, int aa, - int fm, float boldness, float italic) { + int fm, float boldness, float italic, boolean disableHinting) { return getNullScalerContext(); } diff --git a/jdk/src/share/classes/sun/font/SunFontManager.java b/jdk/src/share/classes/sun/font/SunFontManager.java index 991064e38ae..e9b3bf171d0 100644 --- a/jdk/src/share/classes/sun/font/SunFontManager.java +++ b/jdk/src/share/classes/sun/font/SunFontManager.java @@ -1576,7 +1576,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { .info("Trying to resolve file " + fullPath); } do { - ttf = new TrueTypeFont(fullPath, null, fn++, true); + ttf = new TrueTypeFont(fullPath, null, fn++, false); // prefer the font's locale name. String fontName = ttf.getFontName(l).toLowerCase(); if (unmappedFonts.contains(fontName)) { @@ -1595,6 +1595,207 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { } } + /* Hardwire the English names and expected file names of fonts + * commonly used at start up. Avoiding until later even the small + * cost of calling platform APIs to locate these can help. + * The code that registers these fonts needs to "bail" if any + * of the files do not exist, so it will verify the existence of + * all non-null file names first. + * They are added in to a map with nominally the first + * word in the name of the family as the key. In all the cases + * we are using the the family name is a single word, and as is + * more or less required the family name is the initial sequence + * in a full name. So lookup first finds the matching description, + * then registers the whole family, returning the right font. + */ + public static class FamilyDescription { + public String familyName; + public String plainFullName; + public String boldFullName; + public String italicFullName; + public String boldItalicFullName; + public String plainFileName; + public String boldFileName; + public String italicFileName; + public String boldItalicFileName; + } + + static HashMap platformFontMap; + + /** + * default implementation does nothing. + */ + public HashMap populateHardcodedFileNameMap() { + return new HashMap(0); + } + + Font2D findFontFromPlatformMap(String lcName, int style) { + if (platformFontMap == null) { + platformFontMap = populateHardcodedFileNameMap(); + } + + if (platformFontMap == null || platformFontMap.size() == 0) { + return null; + } + + int spaceIndex = lcName.indexOf(' '); + String firstWord = lcName; + if (spaceIndex > 0) { + firstWord = lcName.substring(0, spaceIndex); + } + + FamilyDescription fd = platformFontMap.get(firstWord); + if (fd == null) { + return null; + } + /* Once we've established that its at least the first word, + * we need to dig deeper to make sure its a match for either + * a full name, or the family name, to make sure its not + * a request for some other font that just happens to start + * with the same first word. + */ + int styleIndex = -1; + if (lcName.equalsIgnoreCase(fd.plainFullName)) { + styleIndex = 0; + } else if (lcName.equalsIgnoreCase(fd.boldFullName)) { + styleIndex = 1; + } else if (lcName.equalsIgnoreCase(fd.italicFullName)) { + styleIndex = 2; + } else if (lcName.equalsIgnoreCase(fd.boldItalicFullName)) { + styleIndex = 3; + } + if (styleIndex == -1 && !lcName.equalsIgnoreCase(fd.familyName)) { + return null; + } + + String plainFile = null, boldFile = null, + italicFile = null, boldItalicFile = null; + + boolean failure = false; + /* In a terminal server config, its possible that getPathName() + * will return null, if the file doesn't exist, hence the null + * checks on return. But in the normal client config we need to + * follow this up with a check to see if all the files really + * exist for the non-null paths. + */ + getPlatformFontDirs(noType1Font); + + if (fd.plainFileName != null) { + plainFile = getPathName(fd.plainFileName); + if (plainFile == null) { + failure = true; + } + } + + if (fd.boldFileName != null) { + boldFile = getPathName(fd.boldFileName); + if (boldFile == null) { + failure = true; + } + } + + if (fd.italicFileName != null) { + italicFile = getPathName(fd.italicFileName); + if (italicFile == null) { + failure = true; + } + } + + if (fd.boldItalicFileName != null) { + boldItalicFile = getPathName(fd.boldItalicFileName); + if (boldItalicFile == null) { + failure = true; + } + } + + if (failure) { + if (FontUtilities.isLogging()) { + FontUtilities.getLogger(). + info("Hardcoded file missing looking for " + lcName); + } + platformFontMap.remove(firstWord); + return null; + } + + /* Some of these may be null,as not all styles have to exist */ + final String[] files = { + plainFile, boldFile, italicFile, boldItalicFile } ; + + failure = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Boolean run() { + for (int i=0; i 0 && style != font.style) { + style |= font.style; + font = fontFamily.getFont(style); + if (font == null) { + font = fontFamily.getClosestStyle(style); + } + } + } + + return font; + } private synchronized HashMap getFullNameToFileMap() { if (fontToFileMap == null) { @@ -1998,6 +2199,17 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { } if (FontUtilities.isWindows) { + + font = findFontFromPlatformMap(lowerCaseName, style); + if (FontUtilities.isLogging()) { + FontUtilities.getLogger() + .info("findFontFromPlatformMap returned " + font); + } + if (font != null) { + fontNameCache.put(mapName, font); + return font; + } + /* Don't want Windows to return a Lucida Sans font from * C:\Windows\Fonts */ @@ -2221,7 +2433,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { return FontUtilities.getFont2D(font).supportsEncoding(encoding); } - public abstract String getFontPath(boolean noType1Fonts); + protected abstract String getFontPath(boolean noType1Fonts); private Thread fileCloser = null; Vector tmpFontFiles = null; @@ -2934,8 +3146,15 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { } } + protected String[] getPlatformFontDirs(boolean noType1Fonts) { - String path = getFontPath(true); + + /* First check if we already initialised path dirs */ + if (pathDirs != null) { + return pathDirs; + } + + String path = getPlatformFontPath(noType1Fonts); StringTokenizer parser = new StringTokenizer(path, File.pathSeparator); ArrayList pathList = new ArrayList(); @@ -2945,7 +3164,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { } } catch (NoSuchElementException e) { } - return pathList.toArray(new String[0]); + pathDirs = pathList.toArray(new String[0]); + return pathDirs; } /** @@ -3047,7 +3267,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { /* A call to this method should be followed by a call to * registerFontDirs(..) */ - protected String getPlatformFontPath(boolean noType1Font) { + public String getPlatformFontPath(boolean noType1Font) { if (fontPath == null) { fontPath = getFontPath(noType1Font); } diff --git a/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java b/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java index 0fe6ec9bcc0..5316005c5fe 100644 --- a/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java +++ b/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java @@ -165,7 +165,7 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment return new SunGraphics2D(sd, Color.white, Color.black, defaultFont); } - private static FontManagerForSGE getFontManagerForSGE() { + public static FontManagerForSGE getFontManagerForSGE() { FontManager fm = FontManagerFactory.getInstance(); return (FontManagerForSGE) fm; } diff --git a/jdk/src/share/native/sun/awt/image/jpeg/jmorecfg.h b/jdk/src/share/native/sun/awt/image/jpeg/jmorecfg.h index 95e5f33c394..be20d886c00 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/jmorecfg.h +++ b/jdk/src/share/native/sun/awt/image/jpeg/jmorecfg.h @@ -161,11 +161,11 @@ typedef short INT16; /* INT32 must hold at least signed 32-bit values. */ -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -#ifndef _LP64 -typedef long INT32; -#else +#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ +#if defined(_LP64) || defined(_WIN32) /* _WIN32 is on all windows platfroms (x86 and x64) */ typedef int INT32; +#else +typedef long INT32; #endif #endif @@ -221,11 +221,14 @@ typedef unsigned int JDIMENSION; * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. */ + +#ifndef FAR #ifdef NEED_FAR_POINTERS #define FAR far #else #define FAR #endif +#endif /* diff --git a/jdk/src/share/native/sun/font/FontInstanceAdapter.cpp b/jdk/src/share/native/sun/font/FontInstanceAdapter.cpp index 1db169a6dc3..952523105c1 100644 --- a/jdk/src/share/native/sun/font/FontInstanceAdapter.cpp +++ b/jdk/src/share/native/sun/font/FontInstanceAdapter.cpp @@ -224,6 +224,7 @@ void FontInstanceAdapter::getWideGlyphAdvance(le_uint32 glyph, LEPoint &advance) if (pt != NULL) { advance.fX = env->GetFloatField(pt, sunFontIDs.xFID); advance.fY = env->GetFloatField(pt, sunFontIDs.yFID); + env->DeleteLocalRef(pt); } } diff --git a/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c b/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c index 7493c837cb8..bd2c03c1ac6 100644 --- a/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c +++ b/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c @@ -137,7 +137,7 @@ void errorHandler(cmsContext ContextID, cmsUInt32Number errorCode, JNU_ThrowByName(env, "java/awt/color/CMMException", errMsg); } -JNIEXPORT int JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { javaVM = jvm; cmsSetLogErrorHandler(errorHandler); diff --git a/jdk/src/solaris/classes/sun/awt/X11FontManager.java b/jdk/src/solaris/classes/sun/awt/X11FontManager.java index fea46ff56c3..573d250acba 100644 --- a/jdk/src/solaris/classes/sun/awt/X11FontManager.java +++ b/jdk/src/solaris/classes/sun/awt/X11FontManager.java @@ -718,25 +718,6 @@ public class X11FontManager extends SunFontManager { 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; iSolaris the paths needed by the JRE should - * also be available to the server, although we have no way to check this - * for sure. - * So set the font path if we think its safe to do so: - * All Solaris X servers at least back to 2.6 and up to Solaris 10 - * define the exact same vendor string. - * The version number for Solaris 2.6 is 3600, for 2.7 is 3610 and - * for Solaris 8 6410 - * we want to set the font path only for 2.8 and onwards. Earlier releases - * are unlikely to have the right fonts and can't install "all locales" - * as needed to be sure. Also Solaris 8 is the earliest release supported - * by 1.5. - */ -#ifndef HEADLESS -static int isSunXServer() { -#ifdef __solaris__ - return ((strncmp(ServerVendor(awt_display), "Sun Microsystems, Inc.", 22) == 0) || - (strncmp(ServerVendor(awt_display), "Oracle Corporation", 18) == 0) && - VendorRelease(awt_display) >= 6410); -#else - return 0; -#endif /* __solaris__ */ -} - -/* Avoid re-doing work for every call to setNativeFontPath */ -static int doSetFontPath = -1; -static int shouldSetXFontPath(JNIEnv *env) { - if (doSetFontPath == -1) { - doSetFontPath = - awt_display != NULL && (isDisplayLocal(env) || isSunXServer()); - } - return doSetFontPath; -} -#endif /* !HEADLESS */ - -JNIEXPORT void JNICALL Java_sun_font_X11FontManager_setNativeFontPath -(JNIEnv *env, jclass obj, jstring theString) { -#ifdef HEADLESS - return; -#else - fDirRecord fDir; - const char *theChars; - - if (awt_display == NULL) { - return; - } - AWT_LOCK(); - if (shouldSetXFontPath(env)) { - theChars = (*env)->GetStringUTFChars (env, theString, 0); - fDir.num = 1; - fDir.name[0] = theChars; - /* printf ("Registering the font path here %s \n", theChars ); */ - AddFontsToX11FontPath ( &fDir ); - if (theChars) { - (*env)->ReleaseStringUTFChars (env, - theString, (const char*)theChars); - } - } - AWT_UNLOCK(); - -#endif -} - #include #ifndef __linux__ /* i.e. is solaris */ #include @@ -1178,6 +1120,7 @@ Java_sun_font_FontConfigManager_getFontConfig } pattern = (*FcNameParse)((FcChar8 *)fcName); if (pattern == NULL) { + (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); closeFontConfig(libfontconfig, JNI_FALSE); return; } @@ -1194,6 +1137,8 @@ Java_sun_font_FontConfigManager_getFontConfig (*FcDefaultSubstitute)(pattern); fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result); if (fontset == NULL) { + (*FcPatternDestroy)(pattern); + (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); closeFontConfig(libfontconfig, JNI_FALSE); return; } @@ -1211,6 +1156,21 @@ Java_sun_font_FontConfigManager_getFontConfig file = (FcChar8**)calloc(nfonts, sizeof(FcChar8*)); if (family == NULL || styleStr == NULL || fullname == NULL || file == NULL) { + if (family != NULL) { + free(family); + } + if (styleStr != NULL) { + free(styleStr); + } + if (fullname != NULL) { + free(fullname); + } + if (file != NULL) { + free(file); + } + (*FcPatternDestroy)(pattern); + (*FcFontSetDestroy)(fontset); + (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); closeFontConfig(libfontconfig, JNI_FALSE); return; } @@ -1237,6 +1197,14 @@ Java_sun_font_FontConfigManager_getFontConfig result = (*FcPatternGetCharSet)(fontPattern, FC_CHARSET, 0, &charset); if (result != FcResultMatch) { + free(family); + free(family); + free(styleStr); + free(file); + (*FcPatternDestroy)(pattern); + (*FcFontSetDestroy)(fontset); + (*env)->ReleaseStringUTFChars(env, + fcNameStr, (const char*)fcName); closeFontConfig(libfontconfig, JNI_FALSE); return; } diff --git a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c index 58dfb63d0ce..1ce26c60107 100644 --- a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c +++ b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c @@ -31,6 +31,21 @@ #include +/* On Solaris 10 updates 8, 9, the render.h file defines these + * protocol values but does not define the structs in Xrender.h. + * Thus in order to get these always defined on Solaris 10 + * we will undefine the symbols if we have determined via the + * makefiles that Xrender.h is lacking the structs. This will + * trigger providing our own definitions as on earlier updates. + * We could assume that *all* Solaris 10 update versions will lack the updated + * Xrender.h and do this based solely on O/S being any 5.10 version, but this + * could still change and we'd be broken again as we'd be re-defining them. + */ +#ifdef SOLARIS10_NO_XRENDER_STRUCTS +#undef X_RenderCreateLinearGradient +#undef X_RenderCreateRadialGradient +#endif + #ifndef X_RenderCreateLinearGradient typedef struct _XLinearGradient { XPointFixed p1; diff --git a/jdk/src/windows/classes/sun/awt/Win32FontManager.java b/jdk/src/windows/classes/sun/awt/Win32FontManager.java index a6c9e5d8861..b2dd894e490 100644 --- a/jdk/src/windows/classes/sun/awt/Win32FontManager.java +++ b/jdk/src/windows/classes/sun/awt/Win32FontManager.java @@ -63,7 +63,7 @@ public class Win32FontManager extends SunFontManager { if (eudcFile != null) { try { eudcFont = new TrueTypeFont(eudcFile, null, 0, - true); + false); } catch (FontFormatException e) { } } @@ -81,6 +81,10 @@ public class Win32FontManager extends SunFontManager { */ private static native String getEUDCFontFile(); + public TrueTypeFont getEUDCFont() { + return eudcFont; + } + public Win32FontManager() { super(); AccessController.doPrivileged(new PrivilegedAction() { @@ -137,6 +141,7 @@ public class Win32FontManager extends SunFontManager { try { while (!found && parser.hasMoreTokens()) { String newPath = parser.nextToken(); + boolean isJREFont = newPath.equals(jreFontDirName); File theFile = new File(newPath, fontFileName); if (theFile.canRead()) { found = true; @@ -144,11 +149,11 @@ public class Win32FontManager extends SunFontManager { if (defer) { registerDeferredFont(fontFileName, path, nativeNames, - fontFormat, true, + fontFormat, isJREFont, fontRank); } else { registerFontFile(path, nativeNames, - fontFormat, true, + fontFormat, isJREFont, fontRank); } break; @@ -197,7 +202,7 @@ public class Win32FontManager extends SunFontManager { familyToFontListMap, Locale locale); - public synchronized native String getFontPath(boolean noType1Fonts); + protected synchronized native String getFontPath(boolean noType1Fonts); public String[] getDefaultPlatformFont() { @@ -277,4 +282,79 @@ public class Win32FontManager extends SunFontManager { protected static native void deRegisterFontWithPlatform(String fontName); + /** + * populate the map with the most common windows fonts. + */ + @Override + public HashMap populateHardcodedFileNameMap() { + HashMap platformFontMap + = new HashMap(); + FamilyDescription fd; + + /* Segoe UI is the default UI font for Vista and later, and + * is used by the Win L&F which is used by FX too. + * Tahoma is used for the Win L&F on XP. + * Verdana is used in some FX UI controls. + */ + fd = new FamilyDescription(); + fd.familyName = "Segoe UI"; + fd.plainFullName = "Segoe UI"; + fd.plainFileName = "segoeui.ttf"; + fd.boldFullName = "Segoe UI Bold"; + fd.boldFileName = "segoeuib.ttf"; + fd.italicFullName = "Segoe UI Italic"; + fd.italicFileName = "segoeuii.ttf"; + fd.boldItalicFullName = "Segoe UI Bold Italic"; + fd.boldItalicFileName = "segoeuiz.ttf"; + platformFontMap.put("segoe", fd); + + fd = new FamilyDescription(); + fd.familyName = "Tahoma"; + fd.plainFullName = "Tahoma"; + fd.plainFileName = "tahoma.ttf"; + fd.boldFullName = "Tahoma Bold"; + fd.boldFileName = "tahomabd.ttf"; + platformFontMap.put("tahoma", fd); + + fd = new FamilyDescription(); + fd.familyName = "Verdana"; + fd.plainFullName = "Verdana"; + fd.plainFileName = "verdana.TTF"; + fd.boldFullName = "Verdana Bold"; + fd.boldFileName = "verdanab.TTF"; + fd.italicFullName = "Verdana Italic"; + fd.italicFileName = "verdanai.TTF"; + fd.boldItalicFullName = "Verdana Bold Italic"; + fd.boldItalicFileName = "verdanaz.TTF"; + platformFontMap.put("verdana", fd); + + /* The following are important because they are the core + * members of the default "Dialog" font. + */ + fd = new FamilyDescription(); + fd.familyName = "Arial"; + fd.plainFullName = "Arial"; + fd.plainFileName = "ARIAL.TTF"; + fd.boldFullName = "Arial Bold"; + fd.boldFileName = "ARIALBD.TTF"; + fd.italicFullName = "Arial Italic"; + fd.italicFileName = "ARIALI.TTF"; + fd.boldItalicFullName = "Arial Bold Italic"; + fd.boldItalicFileName = "ARIALBI.TTF"; + platformFontMap.put("arial", fd); + + fd = new FamilyDescription(); + fd.familyName = "Symbol"; + fd.plainFullName = "Symbol"; + fd.plainFileName = "Symbol.TTF"; + platformFontMap.put("symbol", fd); + + fd = new FamilyDescription(); + fd.familyName = "WingDings"; + fd.plainFullName = "WingDings"; + fd.plainFileName = "WINGDING.TTF"; + platformFontMap.put("wingdings", fd); + + return platformFontMap; + } } diff --git a/jdk/src/windows/classes/sun/print/Win32PrintService.java b/jdk/src/windows/classes/sun/print/Win32PrintService.java index 88e8daead50..2697032f6e3 100644 --- a/jdk/src/windows/classes/sun/print/Win32PrintService.java +++ b/jdk/src/windows/classes/sun/print/Win32PrintService.java @@ -439,7 +439,14 @@ public class Win32PrintService implements PrintService, AttributeUpdater, MediaTray[] arr = new MediaTray[nTray]; int dmBin; - for (int i = 0, j=0; i < mediaTr.length; i++) { + + /* Some drivers in Win 7 don't have the same length for DC_BINS and + * DC_BINNAMES so there is no guarantee that lengths of mediaTr and + * winMediaTrayNames are equal. To avoid getting ArrayIndexOutOfBounds, + * we need to make sure we get the minimum of the two. + */ + + for (int i = 0, j=0; i < Math.min(mediaTr.length, winMediaTrayNames.length); i++) { dmBin = mediaTr[i]; if (dmBin > 0) { // check for unsupported DMBINs and create new Win32MediaTray diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp b/jdk/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp index c84e7ea4751..efb20c5d3a3 100644 --- a/jdk/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp +++ b/jdk/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp @@ -396,7 +396,7 @@ Java_sun_java2d_d3d_D3DGraphicsDevice_enumDisplayModesNative UINT adapter; // EnumAdapterModes treats 555 and 565 formats as equivalents static D3DFORMAT formats[] = - { D3DFMT_X8R8G8B8, D3DFMT_R5G6B5 }; + { D3DFMT_X8R8G8B8, D3DFMT_R5G6B5 }; J2dTraceLn(J2D_TRACE_INFO, "D3DGD_enumDisplayModesNative"); @@ -404,7 +404,7 @@ Java_sun_java2d_d3d_D3DGraphicsDevice_enumDisplayModesNative RETURN_IF_NULL(pd3d9 = pMgr->GetD3DObject()); adapter = pMgr->GetAdapterOrdinalForScreen(gdiScreen); - for (formatNum = 0; formatNum < 3; formatNum++) { + for (formatNum = 0; formatNum < (sizeof formats)/(sizeof *formats); formatNum++) { modesCount = pd3d9->GetAdapterModeCount(adapter, formats[formatNum]); for (modeNum = 0; modeNum < modesCount; modeNum++) { if (SUCCEEDED(pd3d9->EnumAdapterModes(adapter, formats[formatNum], diff --git a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp index cf1503981a8..cab78049f23 100644 --- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp @@ -2491,7 +2491,7 @@ Java_sun_awt_windows_WToolkit_loadSystemColors(JNIEnv *env, jobject self, jint* colorsPtr = NULL; try { colorsPtr = (jint *)env->GetPrimitiveArrayCritical(colors, 0); - for (int i = 0; i < sizeof indexMap && i < colorLen; i++) { + for (int i = 0; i < (sizeof indexMap)/(sizeof *indexMap) && i < colorLen; i++) { colorsPtr[i] = DesktopColor2RGB(indexMap[i]); } } catch (...) { diff --git a/jdk/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp b/jdk/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp index 03cb4675075..efe485230a7 100644 --- a/jdk/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp @@ -214,6 +214,7 @@ Java_sun_awt_Win32FontManager_deRegisterFontWithPlatform(JNIEnv *env, #define EUDCKEY_ZH_CN L"EUDC\\936" #define EUDCKEY_ZH_TW L"EUDC\\950" #define EUDCKEY_KO_KR L"EUDC\\949" +#define EUDCKEY_EN_US L"EUDC\\1252" #define LANGID_JA_JP 0x411 #define LANGID_ZH_CN 0x0804 #define LANGID_ZH_SG 0x1004 @@ -221,6 +222,7 @@ Java_sun_awt_Win32FontManager_deRegisterFontWithPlatform(JNIEnv *env, #define LANGID_ZH_HK 0x0c04 #define LANGID_ZH_MO 0x1404 #define LANGID_KO_KR 0x0412 +#define LANGID_EN_US 0x0409 JNIEXPORT jstring JNICALL @@ -237,6 +239,9 @@ Java_sun_awt_Win32FontManager_getEUDCFontFile(JNIEnv *env, jclass cl) { LANGID langID = GetSystemDefaultLangID(); //lookup for encoding ID, EUDC only supported in //codepage 932, 936, 949, 950 (and unicode) + // On Windows 7, at least for me, it shows up in Cp1252 if + // I create a custom font. Might as well support that as it makes + // verification easier. if (langID == LANGID_JA_JP) { eudcKey = EUDCKEY_JA_JP; } else if (langID == LANGID_ZH_CN || langID == LANGID_ZH_SG) { @@ -246,6 +251,8 @@ Java_sun_awt_Win32FontManager_getEUDCFontFile(JNIEnv *env, jclass cl) { eudcKey = EUDCKEY_ZH_TW; } else if (langID == LANGID_KO_KR) { eudcKey = EUDCKEY_KO_KR; + } else if (langID == LANGID_EN_US) { + eudcKey = EUDCKEY_EN_US; } else { return NULL; } diff --git a/jdk/src/windows/resource/java.manifest b/jdk/src/windows/resource/java.manifest index 61ec5999e19..e5b44609820 100644 --- a/jdk/src/windows/resource/java.manifest +++ b/jdk/src/windows/resource/java.manifest @@ -1,12 +1,15 @@ - + -AWT +Java(TM) SE PROGRAM process + + + + + + + + + + + + + + true + + + diff --git a/jdk/test/java/awt/FontClass/LCDScale.java b/jdk/test/java/awt/FontClass/LCDScale.java new file mode 100644 index 00000000000..5f8d1f6a16d --- /dev/null +++ b/jdk/test/java/awt/FontClass/LCDScale.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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 + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * 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 + * accompanied this code). + * + * 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, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * + * @bug 6925760 + * @summary Scaled graphics causes overlapped LCD glyphs on Windows + */ + +import java.awt.*; +import java.awt.font.*; +import java.awt.geom.*; + +public class LCDScale extends Component { + + public static void main(String args[]) { + Frame f = new Frame("TL TEST"); + LCDScale td = new LCDScale(); + f.add("Center", td); + f.pack(); f.setVisible(true); + } + + + public LCDScale() { + super(); + } + + public Dimension getPreferredSize() { + return new Dimension(500,500); + } + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D)g; + g2d.setRenderingHint( + RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); + + Font f = new Font("Dialog", Font.PLAIN, 40); + g.setFont(f); + FontRenderContext frc = g2d.getFontRenderContext(); + GlyphVector gv = f.createGlyphVector(frc, "Help"); + g2d.drawGlyphVector(gv, 10f, 50f); + Rectangle2D bds1 = gv.getLogicalBounds(); + + f = new Font("Arial", Font.PLAIN, 25); + g.setFont(f); + double s = 2.0; + AffineTransform tx = AffineTransform.getScaleInstance(s,s); + g2d.transform(tx); + frc = g2d.getFontRenderContext(); + gv = f.createGlyphVector(frc, "Help"); + g2d.drawGlyphVector(gv, 10f, 100f); + Rectangle2D bds2 = gv.getLogicalBounds(); + + System.out.println(bds1); + System.out.println(bds2); + if (bds2.getWidth()*s < bds1.getWidth()) { + throw new RuntimeException("Bounds too small"); + } + } +} + + diff --git a/jdk/test/java/awt/FontClass/X11FontPathCrashTest.java b/jdk/test/java/awt/FontClass/X11FontPathCrashTest.java new file mode 100644 index 00000000000..cbc762a36ed --- /dev/null +++ b/jdk/test/java/awt/FontClass/X11FontPathCrashTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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 + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * 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 + * accompanied this code). + * + * 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, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6958221 + * @summary Test no crashing getting fonts on X11 + * @run main X11FontPathCrashTest + */ + +import java.awt.*; +import java.awt.font.*; +import java.awt.geom.*; + + +public class X11FontPathCrashTest { + public static void main(String[] args) { + new Font("nonexistentfont", Font.PLAIN, 12).getFamily(); + } +} + diff --git a/jdk/test/java/awt/font/FontNames/LocaleFamilyNames.java b/jdk/test/java/awt/font/FontNames/LocaleFamilyNames.java new file mode 100644 index 00000000000..e6d71feb814 --- /dev/null +++ b/jdk/test/java/awt/font/FontNames/LocaleFamilyNames.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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 + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * 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 + * accompanied this code). + * + * 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, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4935798 6521210 6901159 + * @summary Tests that all family names that are reported in all locales + * correspond to some font returned from getAllFonts(). + * @run main LocaleFamilyNames + */ +import java.awt.*; +import java.util.*; + +public class LocaleFamilyNames { + public static void main(String[] args) throws Exception { + + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + + Font[] all_fonts = ge.getAllFonts(); + + Locale[] all_locales = Locale.getAvailableLocales(); + + HashSet all_families = new HashSet(); + for (int i=0; i