-
Bug
-
Resolution: Fixed
-
P3
-
8, 11, 13, 14
-
b07
-
x86_64
-
windows_7
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8320894 | 11.0.22 | Sonia Zaldana Calles | P3 | Resolved | Fixed | b05 |
ADDITIONAL SYSTEM INFORMATION :
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
We are using two versions of the open source DejaVu Sans font (2.34 and 2.35). If we draw text using version 2.34, and then draw text using version 2.35 with ligatures enabled, the ligatures seem to reference the wrong glyphs.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the attached source code. The code expects DejaVu Sans 2.34 and DejaVu Sans 2.35 to be available on the classpath; they can be downloaded here: https://sourceforge.net/projects/dejavu/files/dejavu/
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The output PNG contains three lines of text, with the third line of text using ligatures to join the "ffi":
foo
affinity
affinity
ACTUAL -
In the third line of text, the "ffi" is replaced with Arabic characters (I think).
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.font.TextAttribute;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import javax.imageio.ImageIO;
public class FontTest {
public static void main(String... args) throws Exception {
Font dejaVuSans234 = Font.createFont(Font.TRUETYPE_FONT, FontTest.class.getResourceAsStream("DejaVuSans-2.34.ttf")).deriveFont(160f);
Font dejaVuSans235 = Font.createFont(Font.TRUETYPE_FONT, FontTest.class.getResourceAsStream("DejaVuSans-2.35.ttf")).deriveFont(160f);
Font dejaVuSans235WithLigatures = dejaVuSans235.deriveFont(Map.of(TextAttribute.LIGATURES, TextAttribute.LIGATURES_ON));
BufferedImage img = new BufferedImage(700, 700, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = img.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, img.getWidth(), img.getHeight());
g2d.setColor(Color.BLACK);
g2d.setFont(dejaVuSans234);
g2d.drawString("foo", 30, 200);
g2d.setFont(dejaVuSans235);
g2d.drawString("affinity", 30, 400);
g2d.setFont(dejaVuSans235WithLigatures);
g2d.drawString("affinity", 30, 600);
g2d.dispose();
ImageIO.write(img, "png", new File("fonts.png"));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Be very careful about font conflicts, or do not enable ligatures.
FREQUENCY : always
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
We are using two versions of the open source DejaVu Sans font (2.34 and 2.35). If we draw text using version 2.34, and then draw text using version 2.35 with ligatures enabled, the ligatures seem to reference the wrong glyphs.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the attached source code. The code expects DejaVu Sans 2.34 and DejaVu Sans 2.35 to be available on the classpath; they can be downloaded here: https://sourceforge.net/projects/dejavu/files/dejavu/
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The output PNG contains three lines of text, with the third line of text using ligatures to join the "ffi":
foo
affinity
affinity
ACTUAL -
In the third line of text, the "ffi" is replaced with Arabic characters (I think).
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.font.TextAttribute;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import javax.imageio.ImageIO;
public class FontTest {
public static void main(String... args) throws Exception {
Font dejaVuSans234 = Font.createFont(Font.TRUETYPE_FONT, FontTest.class.getResourceAsStream("DejaVuSans-2.34.ttf")).deriveFont(160f);
Font dejaVuSans235 = Font.createFont(Font.TRUETYPE_FONT, FontTest.class.getResourceAsStream("DejaVuSans-2.35.ttf")).deriveFont(160f);
Font dejaVuSans235WithLigatures = dejaVuSans235.deriveFont(Map.of(TextAttribute.LIGATURES, TextAttribute.LIGATURES_ON));
BufferedImage img = new BufferedImage(700, 700, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = img.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, img.getWidth(), img.getHeight());
g2d.setColor(Color.BLACK);
g2d.setFont(dejaVuSans234);
g2d.drawString("foo", 30, 200);
g2d.setFont(dejaVuSans235);
g2d.drawString("affinity", 30, 400);
g2d.setFont(dejaVuSans235WithLigatures);
g2d.drawString("affinity", 30, 600);
g2d.dispose();
ImageIO.write(img, "png", new File("fonts.png"));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Be very careful about font conflicts, or do not enable ligatures.
FREQUENCY : always
- backported by
-
JDK-8320894 Wrong font ligatures used when 2 versions of same font used
- Resolved