Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong text encoding in cf-browser #47

Closed
TarekkMA opened this issue Aug 24, 2020 · 12 comments · Fixed by #48
Closed

Wrong text encoding in cf-browser #47

TarekkMA opened this issue Aug 24, 2020 · 12 comments · Fixed by #48

Comments

@TarekkMA
Copy link
Contributor

When I run mvn javafx:run on a macos I get the cf-browser window but with wrong character encoding.

Screen Shot 2020-08-24 at 10 12 16 PM

@boaks
Copy link
Contributor

boaks commented Aug 26, 2020

I'm not too common to javafx, so I'm not sure, if I'm able to fix that at all ;-(.

Which java version do you use? java 8? java 11?
Which californium.tools version do you use 2.3.0?

@TarekkMA
Copy link
Contributor Author

Thanks a lot for your comment and your effort in this library.
I have used the master branch and this is the result of java --version

java 14.0.2 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

@boaks
Copy link
Contributor

boaks commented Sep 2, 2020

I tried to find some hints about that effect, but they are rare :-).
One issue may be, that the "gui.fxml" is read in a different encoding.
In my opinion that should be not the case, because the xml itself contains the right encoding tag for UTF-8.
Anyway, I added the charset explicit to the FXMLLoader.
The changes are on master, please pull and build it locally.

@boaks
Copy link
Contributor

boaks commented Sep 2, 2020

javafx-actual-default-font

Reading articles like that makes me feel, that it may be also related to your OS.
So, do other applications show latin/ASCII characters?

@TarekkMA
Copy link
Contributor Author

TarekkMA commented Sep 2, 2020

The same issue is happening. And this is the first time I come across this issue on macOS, but I noticed something when running mvn javafx:run, this line indicates that this is an issue with the font API or something

2020-09-02 11:40:56.442 java[9359:120193] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].

This is also the full output of mvn javafx:run in case it helps

~/Developer/Projects/californium.tools/cf-browser · (master)
⟩ mvn javafx:run
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO]
[INFO] -----------------< org.eclipse.californium:cf-browser >-----------------
[INFO] Building Cf-GUIClient 2.5.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- javafx-maven-plugin:0.0.3:run (default-cli) @ cf-browser ---
11:40:55.730 INFO [NetworkConfig]: loading properties from file /Users/tarekkma/Developer/Projects/californium.tools/cf-browser/Californium.properties
11:40:55.735 INFO [RandomTokenGenerator]: using tokens of 8 bytes in length
11:40:55.739 DEBUG [InMemoryMessageExchangeStore]: coap using TokenProvider org.eclipse.californium.core.network.RandomTokenGenerator
11:40:55.745 INFO [CoapEndpoint]: coap CoapEndpoint uses udp plain
11:40:55.752 INFO [BlockwiseLayer]: BlockwiseLayer uses MAX_MESSAGE_SIZE=1024, PREFERRED_BLOCK_SIZE=1024, BLOCKWISE_STATUS_LIFETIME=300000, MAX_RESOURCE_BODY_SIZE=8192, BLOCKWISE_STRICT_BLOCK2_OPTION=false
11:40:55.753 INFO [ReliabilityLayer]: ReliabilityLayer uses ACK_TIMEOUT=2000, ACK_RANDOM_FACTOR=1.5, and ACK_TIMEOUT_SCALE=2.0 as default
11:40:55.756 INFO [CoapEndpoint]: coap Endpoint [coap://0.0.0.0:0] requires an executor to start, using default single-threaded daemon executor
11:40:55.759 DEBUG [CoapEndpoint]: coap Starting endpoint at coap://0.0.0.0:0
11:40:55.760 DEBUG [InMemoryMessageExchangeStore]: coap no MessageIdProvider set, using default org.eclipse.californium.core.network.InMemoryMessageIdProvider
11:40:55.768 INFO [UDPConnector]: UDPConnector starts up 1 sender threads and 1 receiver threads
11:40:55.771 INFO [UDPConnector]: UDPConnector listening on 0.0.0.0/0.0.0.0:49674, recv buf = 65507, send buf = 65507, recv packet size = 2048
11:40:55.771 DEBUG [UDPConnector]: Starting network stage thread [UDP-Sender-0.0.0.0/0.0.0.0:0[0]]
11:40:55.771 DEBUG [UDPConnector]: Starting network stage thread [UDP-Receiver-0.0.0.0/0.0.0.0:0[0]]
11:40:55.772 INFO [CoapEndpoint]: coap Started endpoint at coap://0.0.0.0:49674
11:40:55.772 INFO [ClientInitializer]: endpoint started at 0.0.0.0/0.0.0.0:49674
2020-09-02 11:40:56.442 java[9359:120193] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-09-02 11:40:56.442 java[9359:120193] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.
2020-09-02 11:40:56.523 java[9359:120193] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-09-02 11:40:56.736 java[9359:120227] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-09-02 11:40:56.823 java[9359:120227] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].

@boaks
Copy link
Contributor

boaks commented Sep 2, 2020

Font error on MACOS

Maybe you can check the example in that issue?

@boaks boaks closed this as completed in #48 Sep 2, 2020
@boaks
Copy link
Contributor

boaks commented Oct 23, 2020

Just, if you're interested:

I spent some time into improve the cf-browser. It supports now also observe/notify, a menu, to select some CoAP message details, and a view with connection details.
Feedback will be welcome.

Bildschirmfoto von 2020-10-23 16-36-37

@TarekkMA
Copy link
Contributor Author

TarekkMA commented Oct 23, 2020

Wow, you are awesome. I was planning to add that myself but in my project we decided to leave CoAP for now.

Thank you a lot for this grate addition. CoAP don't have that much GUI tools that do work.

@jcdw99
Copy link

jcdw99 commented Dec 8, 2020

Font error on MACOS

Maybe you can check the example in that issue?

I know its been quite a while, I'm a student and not very experienced with javaFX and maven, but I have exactly the same issue Tarekk describes above. Same style characters appearing when trying to run through the terminal. If I run through my IDE IntelliJ, it runs with the correct encoding.

Was this a relatively simple fix? I have no idea whats wrong, but I get exactly the same error message mentioned in the "Font error on MACOS" article linked above.

I can confirm, this issue is not specific to only this application that I'm currently working on. If I try and run another application coded by someone else using maven, I get a similar incorrect encoding.

@boaks
Copy link
Contributor

boaks commented Dec 8, 2020

I'm also not too common with javaFX.

The issue here was caused using java 11 and the openJFX version. Updating the used version to 14 or newer helped. That is configured in pom.xml in the dependency of "org.openjfx:javafx-fxml"

<dependency>
	<groupId>org.openjfx</groupId>
	<artifactId>javafx-fxml</artifactId>
	<version>14</version>
</dependency>

With that, ensure you also use the "right java fx version" when run from the terminal

According the README, it's started with

java --module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.fxml -jar cf-browser-2.5.0.jar 

I'm not sure, how you start it, but I would recommend to check the "--module-path".

Hope that helps.

@jcdw99
Copy link

jcdw99 commented Dec 9, 2020

As you know I had the same issue. After changing my dependencies related to javafx-graphics to 15 it solved the issue.

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>11</version>
    </dependency>
    
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-media</artifactId>
        <version>11</version>
    </dependency>
    
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>15</version>
    </dependency>

    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>11</version>
    </dependency>

@boaks boaks reopened this Dec 9, 2020
@boaks
Copy link
Contributor

boaks commented Dec 9, 2020

Thanks for reporting that. Did you also check with 14? Or did you just use the "newest / 15"?

Uups, I saw it's javafx-graphics, not javafx-fxml

@boaks boaks closed this as completed Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants