Recently, I have attempted to create a textbox that uses a custom font. The problem I had with it though, is that it also requires certain enters in several places. At first, I tried using \n or \r\n, but that didn't work. This lead me to using HTML, but this gave me the problem of my font not loading in. I tried to fix this using several methods, including change the style of the HTML body, like this:
<html><body style="font-family: pixelmix">Text</body></html>
The font in question, pixelmix is an imported font, not installed on the PC. It is, however, known to the program and can be used without HTML. I don't know if HTML can work with uninstalled fonts, but if anyone had any idea on how to get enters AND a custom font, please let me know.
Related
I wrote a program, exported it as ".jar" and ran it on a computer other than my developer desktop PC. The problem arose that the entire JFrame on the laptop was smaller and therefore certain texts were replaced with "..." because the component was too small to display it completely. Now the question arises is there the possibility to change my text size dynamically that it is always getting displayed completely?
Edit 1:
My problem is that I first have to get the font size at which my text is replaced by "...".
|that is the code|
|that is how the gui should look (It looks like this on my desktop pc)|
|that is how the gui looks on my laptop|
I have not really a solution to the problem but I know what was the fault. My windows was scaled to 125% so some text dissapeared...
I'm using netbeans and can't get to write SOME UTF-8 symbols in JLabel components, for example ȵ and ʮ. The weird thing is that both are printed in console normally while they are shown as 口 in labels.
I don't think it's a font problem because they can display without any problem in eclipse. Note they are using exactly the same font, Tahoma.
Any idea what the problem might be?
Does anyone know of an existing solution for font glyph fallthrough in Java? For example, our designers have decided that Calibri is the font that mostly fits our needs, but if I specify Calibri, it can naturally not render characters that do not have a matching glyph in that font. In that case, I would need it to fall through to a second specified font, and if all else fails - use one of Java's logical fonts.
Has anyone come up with a solution for this, which can be plugged into existing Swing components without having to write custom Swing components for the entire project?
This is a very old project already, and building custom graphical components is not a feasible solution.
This isn't a code-based solution and probably won't be of much help, since it requires each user to install a file locally, but just in case...
You can add fallback fonts in a special directory within the JRE installation. From the Java documentation:
Users can add a physical font as a fallback font to logical fonts used in Java 2D rendering by installing it in the lib/fonts/fallback directory within the JRE.
I work with Eclipse & Java.
System.getProperty("file.encoding") == "GBK".
All my Swing UI Labels stored in separate properties files(like messages_ru.properties,messages_sc.properties).
I use native2ascii to convert properties files to get the Unicode.
But one strange thing comes, the label show the Russian correctly,but not correct with the Simple Chinese. My OS supports Simple Chinese.
Anyone has the same question or has some suggestions to find the Reason? If you need more information, I can show you.
Hmm... Find the reason,it is cause by the Font, My app is using the Factory Font("Calibri") which is not support for Simple Chinese.
I extend org.eclipse.swt.widgets.Composite and create many widgets on it, (labels, table, text etc). The problem I am facing is that the labels' text is getting truncated on linux while it appears fine on windows. When I change the linux's font to gothic the truncation is little less but still there. Is there way to homogenize the windows and linux display. What could be the best font to use in linux in such a case.
More likely it is related to this eclipse bug which I just lobbied to have re-opened: https://bugs.eclipse.org/bugs/show_bug.cgi?id=151322
It sounds like you are using absolute positioning instead of dynamic layouts. (If this isn't the case, perhaps you could post code demonstrating the problem). Using a dynamic layout should ensure that controls are resized to accommodate their contents. (They're also great if you ever translate a product, because then you don't have to rejig every dialog for every language.)
To complete McDowel's answer, there is also a bug related to the way Linux check for wrapping label:
It is fixed since 3.4M7.
Even though it may not be related to your case, it would be useful to know which version of eclipse you are using and if you can reproduce your bug with the latest ones (like a 3.5M6)