aboutsummaryrefslogtreecommitdiffstats
path: root/src/demos/com
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-02-03 01:14:10 +0100
committerSven Göthel <[email protected]>2024-02-03 01:14:10 +0100
commit4ba099b97df41be220c4b2816c728e6b8cc1b037 (patch)
tree7c20f28515ed9d5dba71b0721c24b29c8d3d12eb /src/demos/com
parent7928ed90104f71fb53ae8201b3140b8e347b83ee (diff)
Graph/GraphUI: Move getDefault*() to FontFactory and add {get,set}FallbackFont() + Font.getBestCoverage(..); Use fallback-font in MediaButton in case chosen font doesn't match (foreign languages, e.g. 'zho' Chinese .. )
Diffstat (limited to 'src/demos/com')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java8
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java3
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java16
3 files changed, 18 insertions, 9 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
index 0fef325bd..d8f75610f 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
@@ -112,7 +112,7 @@ public class FontView01 {
public static void main(final String[] args) throws IOException {
float mmPerCell = 8f;
- String fontfilename = null;
+ String fontFilename = null;
int gridColumns = -1;
boolean showUnderline = false;
boolean showLabel = false;
@@ -125,7 +125,7 @@ public class FontView01 {
continue;
} else if(args[idx[0]].equals("-font")) {
idx[0]++;
- fontfilename = args[idx[0]];
+ fontFilename = args[idx[0]];
} else if(args[idx[0]].equals("-mmPerCell")) {
idx[0]++;
mmPerCell = MiscUtils.atof(args[idx[0]], mmPerCell);
@@ -147,11 +147,11 @@ public class FontView01 {
System.err.println(options);
Font font;
- if( null == fontfilename ) {
+ if( null == fontFilename ) {
font = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeSerif.ttf",
FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
} else {
- font = FontFactory.get( new File( fontfilename ) );
+ font = FontFactory.get( new File( fontFilename ) );
}
System.err.println("Font "+font.getFullFamilyName());
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java
index 888a5bd28..c41604af0 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid00.java
@@ -34,6 +34,7 @@ import java.util.List;
import com.jogamp.common.net.Uri;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.font.FontScale;
import com.jogamp.graph.ui.Group;
import com.jogamp.graph.ui.Scene;
@@ -213,7 +214,7 @@ public class UIMediaGrid00 {
final List<Shape> customCtrls = new ArrayList<Shape>();
{
- final Font fontSymbols = Scene.getSymbolsFont();
+ final Font fontSymbols = FontFactory.getSymbolsFont();
if( null == fontSymbols ) {
grid.addShape( new Rectangle(options.renderModes, 16f/9f, 1, 0.10f) );
return;
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java
index ffba565f5..60366ac45 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java
@@ -37,6 +37,7 @@ import java.util.List;
import com.jogamp.common.net.Uri;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.font.FontScale;
import com.jogamp.graph.ui.Group;
import com.jogamp.graph.ui.Scene;
@@ -53,8 +54,8 @@ import com.jogamp.graph.ui.shapes.MediaButton;
import com.jogamp.graph.ui.shapes.Rectangle;
import com.jogamp.graph.ui.widgets.MediaPlayer;
import com.jogamp.graph.ui.widgets.RangeSlider;
-import com.jogamp.graph.ui.widgets.RangedGroup;
import com.jogamp.graph.ui.widgets.RangeSlider.SliderAdapter;
+import com.jogamp.graph.ui.widgets.RangedGroup;
import com.jogamp.graph.ui.widgets.RangedGroup.SliderParam;
import com.jogamp.math.Vec2f;
import com.jogamp.math.Vec2i;
@@ -97,6 +98,7 @@ public class UIMediaGrid01 {
float mmPerCellWidth = 50f;
int maxMediaFiles = 10000; // Integer.MAX_VALUE;
int gridColumns = -1;
+ String subFallbackFontFilename = null;
String mediaDir = null;
if( 0 != args.length ) {
final int[] idx = { 0 };
@@ -129,12 +131,18 @@ public class UIMediaGrid01 {
} else if(args[idx[0]].equals("-col")) {
idx[0]++;
gridColumns = MiscUtils.atoi(args[idx[0]], gridColumns);
+ } else if(args[idx[0]].equals("-fallbackFont")) {
+ idx[0]++;
+ subFallbackFontFilename = args[idx[0]];
} else if(args[idx[0]].equals("-texCount")) {
idx[0]++;
texCount = MiscUtils.atoi(args[idx[0]], texCount);
}
}
}
+ if( null != subFallbackFontFilename ) {
+ FontFactory.setFallbackFont( FontFactory.get( new File( subFallbackFontFilename ) ) );
+ }
System.err.println(options);
System.err.println("mediaDir "+mediaDir);
System.err.println("maxMediaFiles "+maxMediaFiles);
@@ -143,6 +151,7 @@ public class UIMediaGrid01 {
System.err.println("boxRatio "+videoAspectRatio);
System.err.println("letterBox "+letterBox);
System.err.println("columns "+gridColumns);
+ System.err.println("FallbackFont "+FontFactory.getFallbackFont());
final List<Uri> mediaFiles = new ArrayList<Uri>();
if( null != mediaDir && mediaDir.length() > 0 ) {
@@ -284,7 +293,7 @@ public class UIMediaGrid01 {
mainGrid.setName("MainGrid");
mainGrid.addShape(mediaView);
{
- final Font fontInfo = Scene.getDefaultFont();
+ final Font fontInfo = FontFactory.getDefaultFont();
final Label infoLabel = new Label(options.renderModes, fontInfo, "Not yet");
infoLabel.setColor(0.1f, 0.1f, 0.1f, 1f);
final Group labelBox = new Group(new BoxLayout(mediaGridSize.x(), mediaCellHeight / 10, new Alignment(Alignment.Bit.Fill.value | Alignment.Bit.CenterVert.value),
@@ -348,7 +357,7 @@ public class UIMediaGrid01 {
final List<Shape> customCtrls = new ArrayList<Shape>();
if( true ) {
- final Font fontSymbols = Scene.getSymbolsFont();
+ final Font fontSymbols = FontFactory.getSymbolsFont();
if( null == fontSymbols ) {
grid.addShape( new Rectangle(options.renderModes, defRatio, 1, 0.10f) );
return;
@@ -380,7 +389,6 @@ public class UIMediaGrid01 {
customCtrls.add(button);
}
final MediaPlayer graphMPlayer = new MediaPlayer(options.renderModes, scene, glMPlayer, medium, defRatio, letterBox, zoomSize, customCtrls);
- // graphMPlayer.setSubtitleParams(MiscUtils.getSerifFont(), 0.1f);
grid.addShape( graphMPlayer );
glMPlayer.playStream(medium, GLMediaPlayer.STREAM_ID_AUTO, aid, sid, texCount);
if( start_pos > 0 ) {