Hmm, the font it is finding (using the algorithm below) is: Arial Unicode MS, 
which is having problems.

Roger Whitcomb | Architect, Engineering | [email protected] | 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:[email protected]] 
Sent: Tuesday, September 21, 2010 7:29 PM
To: [email protected]
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 | [email protected] | 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:[email protected]] 
> Sent: Tuesday, September 21, 2010 5:43 PM
> To: [email protected]
> 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
>> [email protected]
>> 
>> 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.
>> 
> 

Reply via email to