# Changing font theme - 2 different form factors in one server

ansancle
317 9

I have a problem where I have both Iphones/Itouch devices and desktops connecting to the same application. I can handle changing the stylesheets depending upon which device connects - but have run into a problem with font sizes which I had been setting in zk.xml using the library-property settings :

	<library-property>
<name>org.zkoss.zul.theme.fontSizeM</name>
<value>60px</value>
</library-property>

Using the library-property for setting the font theme doesn't work since both the desktops and hand-helds end up sharing the same value - which means it's either too big for the desktop or too small for the hand-helds. I hate to have to create 2 additional custom stylesheets for just changing all the font sizes, is there another way I can setup the org.zkoss.zul.theme.fontSizeM so each client gets the correct value for the display area?

delete retag edit

## 3 Replies

jumperchen
3909 2 8
http://jumperchen.blogspo...

Hi,

So far ZK don't provide a way to easily check the browser whether it is iphone/itouch or not.
However you can check them as follows.

(( javax.servlet.http.HttpServletRequest)Executions.getCurrent().getNativeRequest()).getHeader("user-agent")

Then,
if (iphone) {
org.zkoss.lang.Library.setProperty("org.zkoss.zul.theme.fontSizeM", "60px")
} else {
....
}


ansancle
317 9

Yeah,
I have been using the following to determine browser type :

<zk>
<zscript>
if (browserType.indexOf("iPhone") != -1)
{
........


And this actually works fine. From here I was able to select and include the correct style sheet for all of my images etc...
The problem I was then having is I had been setting the org.zkoss.zul.theme.fontSizeM etc.. in the zk.xml file. I then tried setting these values at run time but since all the different browsers are sharing the same server - one setting in the Library for fonts was being used by all browsers. I tried to figure out how to use the ThemeProvider so I could override the fonts per client but was unable to get that to work correctly. My provider was called but when I tried to override the norm*.css.dsp files with all of my own versions it just didn't work. I had created new versions called mynorm*.css.dsp for all the norm*.css.dsp files and then gave the correct paths etc.. but the changes did not show up. Any additional sample code on using ThemeProviders and the accompanying css.dsp files would be a great help - I searched the existing documentation/forums/etc.. at length.

Thanks!

jumperchen
3909 2 8
http://jumperchen.blogspo...

Hello,

You can refer to org.zkoss.zkdemo.userguide.FontSizeThemeProvider class, which can be found in zkdemo.war.

[hide preview]