Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
To make display Variation Selectors on Win and MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
nakajima-akira committed Jul 6, 2018
1 parent 324585f commit cbed71d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class PlatformUtil {
private static final boolean WINDOWS_VISTA_OR_LATER = WINDOWS && versionNumberGreaterThanOrEqualTo(6.0f);
private static final boolean WINDOWS_7_OR_LATER = WINDOWS && versionNumberGreaterThanOrEqualTo(6.1f);
private static final boolean MAC = os.startsWith("Mac");
private static final boolean MAC_10_6_OR_LATER = MAC && versionNumberGreaterThanOrEqualTo(10.6f);
private static final boolean LINUX = os.startsWith("Linux") && !ANDROID;
private static final boolean SOLARIS = os.startsWith("SunOS");
private static final boolean IOS = os.startsWith("iOS");
Expand Down Expand Up @@ -117,6 +118,13 @@ public static boolean isMac(){
return MAC;
}

/**
* Returns true if the operating system is at least Mac OS X 10.6(v10.6).
*/
public static boolean isMac10_6_OrLater(){
return MAC_10_6_OR_LATER;
}

/**
* Returns true if the operating system is a form of Linux.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

package com.sun.javafx.text;
import com.sun.javafx.PlatformUtil;

public class ScriptMapper {

Expand Down Expand Up @@ -80,7 +81,9 @@ public static synchronized int getScript(int codePoint) {
* in the case where the caller interprets 'layout' to mean where
* one 'char' (ie the java type char) does not map to one glyph
*/
private static final int MAX_LAYOUT_CHARCODE = 0x206F;
private static final int MAX_LAYOUT_CHARCODE
= (PlatformUtil.isWinVistaOrLater() || PlatformUtil.isMac10_6_OrLater())
? 0xE01EF : 0x206F;

/* If the character code falls into any of a number of unicode ranges
* where we know that simple left->right layout mapping chars to glyphs
Expand Down Expand Up @@ -166,6 +169,12 @@ else if (code >= 0x202a && code <= 0x202e) { // directional control
else if (code >= 0x206a && code <= 0x206f) { // directional control
return true;
}
else if (code >= 0xfe00 && code <= 0xfe0f) { // SVS
return true;
}
else if (code >= 0xe0100 && code <= 0xe01ef) { // IVS
return true;
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
import com.sun.prism.paint.ImagePattern;
import com.sun.prism.paint.Paint;

import com.sun.javafx.font.CharToGlyphMapper;

final class SWGraphics implements ReadbackGraphics {

private static final BasicStroke DEFAULT_STROKE =
Expand Down Expand Up @@ -627,8 +629,10 @@ public void drawString(GlyphList gl, FontStrike strike, float x, float y,
private void drawGlyph(FontStrike strike, GlyphList gl, int idx, BaseTransform glyphTx,
boolean drawAsMasks, float x, float y)
{

final Glyph g = strike.getGlyph(gl.getGlyphCode(idx));
if (g.getGlyphCode() == CharToGlyphMapper.INVISIBLE_GLYPH_ID) {
return;
}
if (drawAsMasks) {
final Point2D pt = new Point2D((float)(x + tx.getMxt() + gl.getPosX(idx)),
(float)(y + tx.getMyt() + gl.getPosY(idx)));
Expand Down
33 changes: 33 additions & 0 deletions tests/system/src/test/java/test/javafx/scene/text/Test_VS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.control.TextArea;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;

public class Test_VS extends Application {
@Override
public void start(Stage stage) throws Exception {
final String fontName = "ipamjm.ttf";
// download from https://mojikiban.ipa.go.jp/1300.html
// place in $(user.home)/fonts/

Font ourFont = Font.loadFont("file://"+System.getProperty("user.home")+"/fonts/"+fontName.toString(), 48);
TextFlow textFlow = new TextFlow();

final String str = "\u795E+VS1 --> \u795E\uFE00\n" // U+795E,U+FE00 SVS
+ "\u795E+VS20 --> \u795E\uDB40\uDD03\n" // U+795E,U+E0103 IVS
+ "\uD87A\uDF79+VS17 --> \uD87A\uDF79\uDB40\uDD01\n"; // U+2EB79(Surrogate Pair),U+E0101 IVS
TextArea text = new TextArea(str);
text.setFont(ourFont);

Group group = new Group(text);
Scene scene = new Scene(group, 400, 200, Color.WHITE);
stage.setScene(scene);
stage.show();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cbed71d

Please sign in to comment.