You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Roger Whitcomb <ro...@gmail.com> on 2010/09/21 21:43:55 UTC
Small drawing problem with Chinese-compatible font
I’m seeing a clipping problem with italic text when using a Chinese-compatible font. This is 1.5.2 (latest as of today) on Windows XP SP3:
In my application, I basically copied the code for font selection from “Localization.java” in the Tutorials section:
Theme theme = Theme.getTheme();
Font font = theme.getFont();
// Search for a font that can support the sample string
String sampleResource = resources.getString("mainAppTitle");
if (font.canDisplayUpTo(sampleResource) != -1) {
Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (int i = 0; i < fonts.length; i++) {
if (fonts[i].canDisplayUpTo(sampleResource) == -1) {
theme.setFont(fonts[i].deriveFont(Font.PLAIN, 12));
break;
}
}
}
So, am I doing something wrong, or is this a bug?? Thanks.
Roger Whitcomb
Architect, Engineering
Ingres Corporation
roger.whitcomb@ingres.com
PHONE +1 650.587.5596
FAX +1 650.587.5550
www.ingres.com
This transmission is confidential and intended solely for the use of the recipient named above. It may contain confidential, proprietary, or legally privileged information. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, disclosure or distribution is strictly prohibited. If you have received this transmission in error, please contact the sender by reply e-mail and delete the original transmission and all copies from your system.
RE: Small drawing problem with Chinese-compatible font
Posted by "Roger L. Whitcomb" <Ro...@ingres.com>.
Yes, adding a space at the end of the string works to prevent the text
being truncated.
Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com |
Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 |
USA +1 650-587-5596 | fax: +1 650-587-5550
-----Original Message-----
From: Sandro Martini [mailto:sandro.martini@gmail.com]
Sent: Thursday, September 23, 2010 2:16 PM
To: dev@pivot.apache.org
Subject: Re: Small drawing problem with Chinese-compatible font
Hi to all,
a quick work-around: adding a space character at the end of the
trimmed string works ?
If this works maybe we could think at an optional property to add a
little more space to labels ... but I agree that this is only a
work-around.
Sandro
Re: Small drawing problem with Chinese-compatible font
Posted by Sandro Martini <sa...@gmail.com>.
Hi to all,
a quick work-around: adding a space character at the end of the
trimmed string works ?
If this works maybe we could think at an optional property to add a
little more space to labels ... but I agree that this is only a
work-around.
Sandro
RE: Small drawing problem with Chinese-compatible font
Posted by "Roger L. Whitcomb" <Ro...@ingres.com>.
Hmm, the font it is finding (using the algorithm below) is: Arial Unicode MS, which is having problems.
Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com | Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 | USA +1 650-587-5596 | fax: +1 650-587-5550
-----Original Message-----
From: Greg Brown [mailto:gkbrown@mac.com]
Sent: Tuesday, September 21, 2010 7:29 PM
To: dev@pivot.apache.org
Subject: Re: Small drawing problem with Chinese-compatible font
It doesn't appear to happen with all fonts. For example, this works:
<?xml version="1.0" encoding="UTF-8"?>
<Window bxml:id="window" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk">
<BoxPane orientation="vertical">
<Label text="版本0.0.2" styles="{font:{name:'MingLiU', italic:true, bold:true, size:11}}"/>
</BoxPane>
</Window>
I have found that Batang, Dotum, and MS Mincho also work. But when the font is SimSun, I get the clipping you notice. So this may actually be a bug with the font itself, or the AWT code that is responsible for rendering it.
Not sure what the best solution would be. We might want to think about adding support to the Terra theme for specific language/font overrides - in other words, use the main language unless the current locale uses a language that is in the override list.
Greg
On Sep 21, 2010, at 8:59 PM, Roger L. Whitcomb wrote:
> The Prompt body looks like this (__DATE__ and __TIME__ and so forth get preprocessed into real values):
> <?xml version="1.0" encoding="UTF-8"?>
> <BoxPane xmlns:wtkx="http://pivot.apache.org/wtkx"
> xmlns="org.apache.pivot.wtk"
> orientation="vertical">
> <Label wtkx:id="aboutVersionLabel" text="%aboutVersionLabel" styles="{font:{italic:true, bold:true, size:11}}"/>
> <Label text="%copyright" styles="{font:{size:11}}"/>
> <Separator/>
> <Label text="Built on $(__DATE__) at $(__TIME__)" styles="{font:{size:9}}"/>
> <Label text="Java version $(__JAVA_VERSION__)" styles="{font:{size:9}}"/>
> </BoxPane>
>
> The resources for this look like:
> "copyright": "版权所有(c) 2010安格尔公司",
> "aboutVersionLabel": "版本%1$s",
>
> And the code to do the formatting and everything looks like this:
> @Override
> public void aboutRequested() {
> BoxPane body = (BoxPane)readObject("about", this);
> aboutVersionLabel.setText(String.format(aboutVersionLabel.getText(), APP_VERSION));
> Prompt.prompt(MessageType.INFO, (String)resources.get("mainAppTitle"), body, mainWindow);
> }
>
> It will take me a little bit to try the "Window (maximized)" test you suggested. I will let you know.
>
> BTW, the same thing happens with Japanese.
>
> I used the same code as in Localization.java because I am also doing the same thing: passing "--language=blah" on the command-line, so I have to dynamically pick a suitable font on the user machine.
>
> Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com | Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 | USA +1 650-587-5596 | fax: +1 650-587-5550
>
> -----Original Message-----
> From: Greg Brown [mailto:gkbrown@mac.com]
> Sent: Tuesday, September 21, 2010 5:43 PM
> To: dev@pivot.apache.org
> Subject: Re: Small drawing problem with Chinese-compatible font
>
> How are you generating that text? It looks like you are using an a Prompt with a custom body. What does the source code for the body look like? What happens if you place this text in the following hierarchy?
>
> Window (maximized)/BoxPane (horizontal)/Label (using Chinese font)
>
> FYI, you don't need to programmatically select a compatible font if you already know of one that will work. In that case, you can just call Theme.setFont() directly.
>
> On Sep 21, 2010, at 3:43 PM, Roger Whitcomb wrote:
>
>> I’m seeing a clipping problem with italic text when using a Chinese-compatible font. This is 1.5.2 (latest as of today) on Windows XP SP3:
>> <image001.png>
>>
>> In my application, I basically copied the code for font selection from “Localization.java” in the Tutorials section:
>> Theme theme = Theme.getTheme();
>> Font font = theme.getFont();
>>
>> // Search for a font that can support the sample string
>> String sampleResource = resources.getString("mainAppTitle");
>> if (font.canDisplayUpTo(sampleResource) != -1) {
>> Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
>>
>> for (int i = 0; i < fonts.length; i++) {
>> if (fonts[i].canDisplayUpTo(sampleResource) == -1) {
>> theme.setFont(fonts[i].deriveFont(Font.PLAIN, 12));
>> break;
>> }
>> }
>> }
>>
>> So, am I doing something wrong, or is this a bug?? Thanks.
>>
>>
>> Roger Whitcomb
>> Architect, Engineering
>> Ingres Corporation
>> roger.whitcomb@ingres.com
>>
>> PHONE +1 650.587.5596
>> FAX +1 650.587.5550
>>
>> www.ingres.com
>>
>> This transmission is confidential and intended solely for the use of the recipient named above. It may contain confidential, proprietary, or legally privileged information. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, disclosure or distribution is strictly prohibited. If you have received this transmission in error, please contact the sender by reply e-mail and delete the original transmission and all copies from your system.
>>
>
Re: Small drawing problem with Chinese-compatible font
Posted by Greg Brown <gk...@mac.com>.
It doesn't appear to happen with all fonts. For example, this works:
<?xml version="1.0" encoding="UTF-8"?>
<Window bxml:id="window" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk">
<BoxPane orientation="vertical">
<Label text="版本0.0.2" styles="{font:{name:'MingLiU', italic:true, bold:true, size:11}}"/>
</BoxPane>
</Window>
I have found that Batang, Dotum, and MS Mincho also work. But when the font is SimSun, I get the clipping you notice. So this may actually be a bug with the font itself, or the AWT code that is responsible for rendering it.
Not sure what the best solution would be. We might want to think about adding support to the Terra theme for specific language/font overrides - in other words, use the main language unless the current locale uses a language that is in the override list.
Greg
On Sep 21, 2010, at 8:59 PM, Roger L. Whitcomb wrote:
> The Prompt body looks like this (__DATE__ and __TIME__ and so forth get preprocessed into real values):
> <?xml version="1.0" encoding="UTF-8"?>
> <BoxPane xmlns:wtkx="http://pivot.apache.org/wtkx"
> xmlns="org.apache.pivot.wtk"
> orientation="vertical">
> <Label wtkx:id="aboutVersionLabel" text="%aboutVersionLabel" styles="{font:{italic:true, bold:true, size:11}}"/>
> <Label text="%copyright" styles="{font:{size:11}}"/>
> <Separator/>
> <Label text="Built on $(__DATE__) at $(__TIME__)" styles="{font:{size:9}}"/>
> <Label text="Java version $(__JAVA_VERSION__)" styles="{font:{size:9}}"/>
> </BoxPane>
>
> The resources for this look like:
> "copyright": "版权所有(c) 2010安格尔公司",
> "aboutVersionLabel": "版本%1$s",
>
> And the code to do the formatting and everything looks like this:
> @Override
> public void aboutRequested() {
> BoxPane body = (BoxPane)readObject("about", this);
> aboutVersionLabel.setText(String.format(aboutVersionLabel.getText(), APP_VERSION));
> Prompt.prompt(MessageType.INFO, (String)resources.get("mainAppTitle"), body, mainWindow);
> }
>
> It will take me a little bit to try the "Window (maximized)" test you suggested. I will let you know.
>
> BTW, the same thing happens with Japanese.
>
> I used the same code as in Localization.java because I am also doing the same thing: passing "--language=blah" on the command-line, so I have to dynamically pick a suitable font on the user machine.
>
> Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com | Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 | USA +1 650-587-5596 | fax: +1 650-587-5550
>
> -----Original Message-----
> From: Greg Brown [mailto:gkbrown@mac.com]
> Sent: Tuesday, September 21, 2010 5:43 PM
> To: dev@pivot.apache.org
> Subject: Re: Small drawing problem with Chinese-compatible font
>
> How are you generating that text? It looks like you are using an a Prompt with a custom body. What does the source code for the body look like? What happens if you place this text in the following hierarchy?
>
> Window (maximized)/BoxPane (horizontal)/Label (using Chinese font)
>
> FYI, you don't need to programmatically select a compatible font if you already know of one that will work. In that case, you can just call Theme.setFont() directly.
>
> On Sep 21, 2010, at 3:43 PM, Roger Whitcomb wrote:
>
>> I’m seeing a clipping problem with italic text when using a Chinese-compatible font. This is 1.5.2 (latest as of today) on Windows XP SP3:
>> <image001.png>
>>
>> In my application, I basically copied the code for font selection from “Localization.java” in the Tutorials section:
>> Theme theme = Theme.getTheme();
>> Font font = theme.getFont();
>>
>> // Search for a font that can support the sample string
>> String sampleResource = resources.getString("mainAppTitle");
>> if (font.canDisplayUpTo(sampleResource) != -1) {
>> Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
>>
>> for (int i = 0; i < fonts.length; i++) {
>> if (fonts[i].canDisplayUpTo(sampleResource) == -1) {
>> theme.setFont(fonts[i].deriveFont(Font.PLAIN, 12));
>> break;
>> }
>> }
>> }
>>
>> So, am I doing something wrong, or is this a bug?? Thanks.
>>
>>
>> Roger Whitcomb
>> Architect, Engineering
>> Ingres Corporation
>> roger.whitcomb@ingres.com
>>
>> PHONE +1 650.587.5596
>> FAX +1 650.587.5550
>>
>> www.ingres.com
>>
>> This transmission is confidential and intended solely for the use of the recipient named above. It may contain confidential, proprietary, or legally privileged information. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, disclosure or distribution is strictly prohibited. If you have received this transmission in error, please contact the sender by reply e-mail and delete the original transmission and all copies from your system.
>>
>
RE: Small drawing problem with Chinese-compatible font
Posted by "Roger L. Whitcomb" <Ro...@ingres.com>.
The Prompt body looks like this (__DATE__ and __TIME__ and so forth get preprocessed into real values):
<?xml version="1.0" encoding="UTF-8"?>
<BoxPane xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk"
orientation="vertical">
<Label wtkx:id="aboutVersionLabel" text="%aboutVersionLabel" styles="{font:{italic:true, bold:true, size:11}}"/>
<Label text="%copyright" styles="{font:{size:11}}"/>
<Separator/>
<Label text="Built on $(__DATE__) at $(__TIME__)" styles="{font:{size:9}}"/>
<Label text="Java version $(__JAVA_VERSION__)" styles="{font:{size:9}}"/>
</BoxPane>
The resources for this look like:
"copyright": "版权所有(c) 2010安格尔公司",
"aboutVersionLabel": "版本%1$s",
And the code to do the formatting and everything looks like this:
@Override
public void aboutRequested() {
BoxPane body = (BoxPane)readObject("about", this);
aboutVersionLabel.setText(String.format(aboutVersionLabel.getText(), APP_VERSION));
Prompt.prompt(MessageType.INFO, (String)resources.get("mainAppTitle"), body, mainWindow);
}
It will take me a little bit to try the "Window (maximized)" test you suggested. I will let you know.
BTW, the same thing happens with Japanese.
I used the same code as in Localization.java because I am also doing the same thing: passing "--language=blah" on the command-line, so I have to dynamically pick a suitable font on the user machine.
Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com | Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 | USA +1 650-587-5596 | fax: +1 650-587-5550
-----Original Message-----
From: Greg Brown [mailto:gkbrown@mac.com]
Sent: Tuesday, September 21, 2010 5:43 PM
To: dev@pivot.apache.org
Subject: Re: Small drawing problem with Chinese-compatible font
How are you generating that text? It looks like you are using an a Prompt with a custom body. What does the source code for the body look like? What happens if you place this text in the following hierarchy?
Window (maximized)/BoxPane (horizontal)/Label (using Chinese font)
FYI, you don't need to programmatically select a compatible font if you already know of one that will work. In that case, you can just call Theme.setFont() directly.
On Sep 21, 2010, at 3:43 PM, Roger Whitcomb wrote:
> I’m seeing a clipping problem with italic text when using a Chinese-compatible font. This is 1.5.2 (latest as of today) on Windows XP SP3:
> <image001.png>
>
> In my application, I basically copied the code for font selection from “Localization.java” in the Tutorials section:
> Theme theme = Theme.getTheme();
> Font font = theme.getFont();
>
> // Search for a font that can support the sample string
> String sampleResource = resources.getString("mainAppTitle");
> if (font.canDisplayUpTo(sampleResource) != -1) {
> Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
>
> for (int i = 0; i < fonts.length; i++) {
> if (fonts[i].canDisplayUpTo(sampleResource) == -1) {
> theme.setFont(fonts[i].deriveFont(Font.PLAIN, 12));
> break;
> }
> }
> }
>
> So, am I doing something wrong, or is this a bug?? Thanks.
>
>
> Roger Whitcomb
> Architect, Engineering
> Ingres Corporation
> roger.whitcomb@ingres.com
>
> PHONE +1 650.587.5596
> FAX +1 650.587.5550
>
> www.ingres.com
>
> This transmission is confidential and intended solely for the use of the recipient named above. It may contain confidential, proprietary, or legally privileged information. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, disclosure or distribution is strictly prohibited. If you have received this transmission in error, please contact the sender by reply e-mail and delete the original transmission and all copies from your system.
>
Re: Small drawing problem with Chinese-compatible font
Posted by Greg Brown <gk...@mac.com>.
How are you generating that text? It looks like you are using an a Prompt with a custom body. What does the source code for the body look like? What happens if you place this text in the following hierarchy?
Window (maximized)/BoxPane (horizontal)/Label (using Chinese font)
FYI, you don't need to programmatically select a compatible font if you already know of one that will work. In that case, you can just call Theme.setFont() directly.
On Sep 21, 2010, at 3:43 PM, Roger Whitcomb wrote:
> I’m seeing a clipping problem with italic text when using a Chinese-compatible font. This is 1.5.2 (latest as of today) on Windows XP SP3:
> <image001.png>
>
> In my application, I basically copied the code for font selection from “Localization.java” in the Tutorials section:
> Theme theme = Theme.getTheme();
> Font font = theme.getFont();
>
> // Search for a font that can support the sample string
> String sampleResource = resources.getString("mainAppTitle");
> if (font.canDisplayUpTo(sampleResource) != -1) {
> Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
>
> for (int i = 0; i < fonts.length; i++) {
> if (fonts[i].canDisplayUpTo(sampleResource) == -1) {
> theme.setFont(fonts[i].deriveFont(Font.PLAIN, 12));
> break;
> }
> }
> }
>
> So, am I doing something wrong, or is this a bug?? Thanks.
>
>
> Roger Whitcomb
> Architect, Engineering
> Ingres Corporation
> roger.whitcomb@ingres.com
>
> PHONE +1 650.587.5596
> FAX +1 650.587.5550
>
> www.ingres.com
>
> This transmission is confidential and intended solely for the use of the recipient named above. It may contain confidential, proprietary, or legally privileged information. If you are not the intended recipient, you are hereby notified that any unauthorized review, use, disclosure or distribution is strictly prohibited. If you have received this transmission in error, please contact the sender by reply e-mail and delete the original transmission and all copies from your system.
>