JavaFx font not showing on Windows/OracleJDK - java

I have a JavaFx application that uses Material Icons ttf font for icons. On Windows, with Oracle JDK, the font seems to be loaded correctly, as System.out.println(font); returns:
Font[name=Material Icons, family=Material Icons, style=Regular, size=10.0]
It is in the list of available fonts:
for (String fontFamily : Font.getFamilies()) {
System.out.println(fontFamily);
}
returns:
...
Material Icons
...
However, no matter whether i set the font in the code (e.g. label.setFont(font)), or I specify the family as a css property (e.g. label.setStyle("-fx-font-family: \"Material Icons\";");), the font is not shown correctly in the application.
On the other hand, everything works perfectly on OpenJDK on Arch Linux. If you have any idea on how to solve or further debug the problem, thank you very much!

Related

JavaFX CSS image loading on Linux

I would like to load an image as a background image in a css file included by my fxml file.
I am certain that the CSS is working, because I can change the background color for instance, but when I try :
GridPane{
-fx-background-image: url('wallpaper.jpg');
}
I always end up with this warning :
WARNING: Error loading image: file:/home/user/IdeaProjects/btnv2/ws_client/out/production/ws_client/wallpaper.jpg
Now the weird thing is that the image path displayed by the error is correct, and when my friend pulled the project the image displayed correctly for him with no error.
I am running Arch Linux and he's on MacOs, i figured that might have something to do with it.
This is the production project structure :

Change Project Explorer tree view font size in Eclipse Oxygen

I am using Eclipse Version: Oxygen.1a Release (4.7.1a) and I want to enlarge the Project Explorer tree view font size because I have some sight issues and thus I searched many places to enlarge the project tree view font size.
I only founded the font change in project explorer tree view for older eclipse versions releases which are older or equal to eclipse luna version.
for the information I would like to say that this Oxygen version release is latest in Eclipse IDE, please somebody help me.
There is now (Eclipse 4.17, July 2020) an official setting:
The font used for tree and table views can now be customized with a font preference. This preference is called "Tree and Table font for views" and can be found in Window > Preferences > General > Appearance > Colors and Fonts under the "View and Editor Folders" category.
The Project Explorer is an example of a view that gets affected by this font preference.
I assume that it is important for others also, so I am posting this, for below requireds in eclipse ide,
Increase java editor font size
Window Menu -> Preferences -> General > Appearance > Color and Fonts > Java > Java Editor Text Font > Edit & Apply
Increase console output font size
Window Menu -> Preferences -> General > Appearance > Color and Fonts > Debug > Console font > Edit & Apply
Increase xml bean file font size
Window Menu -> Preferences -> General > Appearance > Color and Fonts > Basic > Text Font > Edit & Apply
Increase dialog view font size
Window Menu -> Preferences -> General > Appearance > Color and Fonts > Basic > Dialog Font > Edit & Apply
Increase project explorer tree view font size
If using Windows 7 or higher architecture, then reach to the eclipse home directory,
go inside of eclipse\plugins\org.eclipse.ui.themes_X.X.X.vXXXXXXXX-XXXX\css directory,
find two css files which are "e4_default_gtk.css" and "e4_default_win.css",
open and add below said css script part in tail of above two files, save those and close accordingly,
.MPart Tree {
font-family: Consolas;
font-size: 14;
}
if eclipse is opened, restart, it all worked for me on eclipse oxygen.1a release version,
and hope on other OS type, you have to edit the same e4_default_gtk.css and other e4_default_os-type.css, thanks.
I have been searching this for every version of Eclipse and finally I got something which helped me to increase the font size and font type of of the project explorer.
1.go to below path on your local environment
.p2 -> pool -> plugins -> org.eclipse.ui.themes_(version) -> css -> e4_basestyle
2.paste below lines at the end of the file.
Tree {
font-size: 14px; /* <-- Desired font size */
font: Consolas; /* <-- Font you want to have */
}
Restart the eclipse
You will get the new defined size and font in your project explorer of eclipse.
NOTE : I tried this on latest version of the eclipse on windows 10 and it worked for me. I did not tried on the previous version.
I'm using eclipse-neon on Ubuntu on Windows-10. The graphical interface is not supported by Microsoft at this time, but I have been using Eclipse Neon and it works decently enough. I added the following to the end of one file: eclipse/plugins/org.eclipse.ui.themes_1.1.300.v20161107-1827/css/e4_default_gtk.css:
.MPart Tree {
font-family: Sans Regular;
font-size: 8;
}
My intent was to make the font smaller, and it worked successfully.
Go to Preferences -> (search for) Fonts -> View and Editor Folders -> (select the last option) Tree and Table font for views -> Edit (left hand side) -> and change the font size.
Thanks for the help. In my case, I use the Dark [Mac OS X] theme in Eclipse Photon on Windows 7, so the file I had to alter was e4-dark_mac.css in eclipse\plugins\org.eclipse.ui.themes_X.X.X.vXXXXXXXX-XXXX\css. Also the .MPart Tree was not in the file so I had to add it as opposed to editing it. I added right under another .Mpart entry so my file looked like below.
...
.MpartStack, .Mpart {
font-family: '#org-eclipse-ui-workbench-TAB_TEXT_FONT';
}
.Mpart Tree {
font-size: 12;
}
...
Ankit Fulzele's answer helped me with minor adjustments.
I use Dark Theme on Mac and the following worked for me for Eclipse 2019-06:
Add the following lines to ~/.p2/pool/plugins/org.eclipse.ui.themes_{version}/css/dark/e4-dark_basestyle.css
Tree {
font-family: '#org-eclipse-ui-workbench-TAB_TEXT_FONT';
}
Instead of setting a fixed font, this will pin it to whatever the "Preferences -> General -> Appearance -> Colors and Fonts -> View and Editor Folders -> Part title font" is configured to.
Note: It would make more sense to pin this to another setting, e.g. to "Preferences -> General -> Appearance -> Colors and Fonts -> Basic -> Text Font", but couldn't find the CSS reference for it.
Note: This update will change not only the "Project Explorer" tab, but others as well.
Answer from Al Breight worked perfectly on Oxygen.3a Release (4.7.3a), Ubuntu 18.04. #pkeller comment (Oct 16 at 14:05) confirmed and solved editing 'Git Uncommited Change Font' size option in Window->Preferences->General->Appearance->Colors and Fonts:
In my case using a MacBook 13", I had to edit the following file /Users/myuser/.p2/pool/plugins/org.eclipse.ui.themes_1.2.800.v20191030-0746/css/e4-dark_mac1013.css
Then I searched for this existing item and added the font-size and font-size-adjust. Doing that prevents the tree line to be cropped:
CTabFolder Tree, CTabFolder Canvas {
background-color: #2F2F2F;
color: #CCC;
font-size-adjust: none;
font-size: 14px;
}
Thanks so much! I can finally see the Eclipse Project Explorer clearly!
I was able to change the project explorer tree font size by making the css file addition shown above in Windows 7 with Eclipse 2018-9 (4.9.0).
The specific folder location I found was at:
C:\Users\myUserName\.p2\pool\plugins\org.eclipse.ui.themes_1.2.200.v20180828-1350\css
Apparently, from my investigation of solving this problem the specific folder location varies based on different factors like Eclipse Version and OS.
So I searched on the css file names to find the latest folder.
I had 7 eclipse themes folders on my workstation, I used the most recent one, corresponding to the specific install/update of Eclipse being currently used.
I'm using Eclipse 2018-09 and could't found .css file similar gtk at Eclipe directory.
But I discover custom css menu on Jeeyul's theme(plugin for Eclipse Color UI).
Just typing css style above comments. And apply and close.
In the end, change UI style.
ECLIPSE FONT CHANGE - Change below to 2 css files.
eclipse/plugins/org.eclipse.ui.themes_x.x.x.vxxxxx/css/e4_basesetyle.css
eclipse/plugins/org.eclipse.ui.themes_x.x.x.vxxxxx/css/dark/e4-dark_globalstyle.css
#org-eclipse-jdt-ui-PackageExplorer Tree,
#org-eclipse-ui-navigator-ProjectExplorer Tree {
font-size: 10px; /* <-- Desired font size */
font: Consolas; /* <-- Font you want to have */
}
and change preference -> General > Appearance > Colors and Fonts > Basic > Text Font : Consolas 12px
To increase font size of eclipse project explorer window for eclipse 2020-06.
First check the theme, you are using in the eclipse from preferences.Increase the value of below property for that theme. For example, if you are using light theme.
In file:
/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.ui.themes_1.2.1000.v20200528-1125/css/light/e4-light_partstyle.css,
Add property if missing or if it is already present, just increase value of font size.
.MPart Tree {
font-size: 13;
}
Eclipse Project/Package explorer, Outline window are using OS default font for labels.
For Win 7+ go to Control Panel\Appearance and Personalization\Personalization click 'Window Color' to start 'Window Color and Appearance' dialog.
Increase 'Message Box' font.
As a bonus you'll have other programs pop-ups more user friendly most likely you are using large display if you bother with eclipse project explorer font.
Eclipse restart required
The changes to the ".css" files don't work, if you have disabled "theming", during your efforts to alter the font size ("Settings.General.Appearance.Enalbe theming (requires restart)" (I mean, I found during my efforts :)
To cover all bases and "themes_versions", rather than hit and miss the right css file, change all ".css" files (find eclipse/plugins -name '*.css') and add "* { font-size:7; }" at the end of every file. Specify your size, and font-family as well if you like.
Works on: Version: 2019-09 R (4.13.0) / Build id: 20190917-1200
I'm using eclipse 2019-06 (4.12.0) version and I didn't find this path (eclipse\plugins\org.eclipse.ui.themes_X.X.X.vXXXXXXXX-XXXX\css), instead I went to the path shown in the below pic with selected folders named org.eclipse.ui.themes_1.2.600.v20190513-0458 and org.eclipse.ui.themes_1.2.1400.v20210315-1604
Under themes_1.2.600.v20190513-0458 folder, go into css folder
Now you can change the selected css files selected here in the below pic.
Add the property highlighted in the below pic for both the css files, save the files, restart eclipse and viola we are done with the font change.
Note: You can either change to small font or big font depending on your choice by changing the font size number.
.MPart Tree {
font-size: 14;
}
Before Change:
After Change:

Change the "about this" window on mac app

On Macs, there's a default menu at the top for basic application handling functions:
I've made an application using Java for my Grade 10 final project, (and I'm quite convinced that it's better than Microsoft Paint) and I decided to package it. Using Eclipse, I exported it as a Mac OS X Application Bundle. However, I want to change the "About Editor" on the default menu. Currently, it shows this:
How can I change the contents of the About Window (My app is definitely not Version 1.0.1)? I'm hoping not to go into Xcode or anything, but is there something that I can change with something like System.setProperty(key, value)?
If your application is an .app bundle then it should have an info.plist. Inside the info.plist will normally contain version information that should display the version number:
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
Typically the version information here is populated in places that call for it (eg. About). To change the name that would display on the menu and within the about dialog box:
<key>CFBundleName</key>
<string>My Application</string>
Copyright Info:
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Your Company</string>
Bundle Icon File:
<key>CFBundleIconFile</key>
<string>icon.icns</string>

Specifying a base or default font with PDFBox

Is there a system property or other parameter that can be passed to PDFBox when attempting to convert from a PDF document into an Image? I am utilizing the provided PDF2Image class like so:
String[] args = new String[]{"-imageType", "jpg", "myfile.pdf"};
org.apache.pdfbox.PDFToImage.main(args);
It works great on Windows and fails with this warning on Ubuntu:
[org.apache.pdfbox.util.PDFStreamEngine] java.lang.NullPointerException java.lang.NullPointerException at org.apache.pdfbox.pdmodel.font.PDType1Font.getawtFont(PDType1Font.java:261)
I assume from my research that this is a problem with a "missing" font, but I've found very little help so far using google and the projects website.
I've tried both versions 1.7.1 and 1.8.2 of PDFBox.
Similar question here: setting ttf for PDF to Image on PDFbox

Use custom fonts when creating pdf using iReport

iReport Version : 3.7.1
I approached this problem in two ways.
My first method
I am creating a pdf page in iReport and I have one of the fields (from database) set to a font Gujarati-Salarl (A font for a regional language of India).
This font is available in the font list of iReport.
When I hit preview I get the desired output , with the field in the required font style.
Everything till here is fine.
But the pdf file generated still contains the same original font in English characters.
The result is same whether i call the report from the application or from a JAVA file.
After a bit of study I found this , a second method
JRProperties.setProperty("net.sf.jasperreports.default.pdf.font.name", "C:\\Gujrati-Saral-1.ttf");
This sets the font of the pdf to the ttf font provided but now the entire pdf comes in the Guarati-saral font which is not what I am looking for..
Is there a way to specifically apply this font only to that one particular field?
or
when going by the second method is there a way to not applying the font Guarati-saral to all other fields except the required one ?
You should use the Font Extensions mechanism.
After creating the font and exporting it as a jar file you should add generated jar file to the application classpath.
a) Creating new font in iReport (via Options -> Fonts -> "Install Font" Button)
b) Exporting the new font (or the existing one) as jar file in iReport (via Options -> Fonts -> "Export as extension" Button)
a) Creating new font in JasperReports Studio (via Window -> Preferences -> JasperStudio -> Fonts -> "Add" Button)
b) Configure your fonts
c) Create JAR with your fonts in it
You can find more information about using Font Extensions here.
if you have problems displaying UTF-8 characters in the pdf,
from version 4.8.0 of the IReport, no need to do nothing!
Just change the font of the cells in the table from sanserif to Dejavu sans.
thats it.
For those, who need Russian language in Jasper Reports (at least in opennms of old versions), following combination does the trick without using the Font Extension:
Font Name: SanSerif
PDF Font: Courier
PDF Encoding: CP1251
PDF Embedded: Yes (not sure, may be it works even without)
Alexey Bakhmutov
Select the field and go to filed properties and change the
select DejaVu Sans as Font Name
select Pdf Encoding to CP1256 (Arabic)
select pdf font name to Courier
with these changes in I got arabic data showing in PDF.

Categories

Resources