PDA

View Full Version : what font the laszlo will use in different case


leon
04-04-2007, 01:33 AM
I have read the developer guide, and search by google. And I also have some question that I can't understand.

In Laszlo developer guide, it says that Laszlo applications use the client font by default, so

1. does it mean the applications can use all the font of the client?
For example, the client is "Windows", can the laszlo applications use all the fonts in the folder "%systemroot%\fonts"?

2. If it can access all the client fonts, how can I use the client fonts? just use the attribute "font=windowsfontname"?

3. In LZX developer guide, it says that all Laszlo applications come bundled with a default font." I think i can get the default font name by typing "canvas.fontname" in the debug window. If the default font is the client font, what's the substitute if the client doesn't have the default font? How can I get the substitute font name?

Thanks.

RoloDMonkey
04-04-2007, 12:03 PM
OpenLaszlo has some of the best documentation I have ever seen for an open source project. Please use it.

http://www.openlaszlo.org/lps/docs/guide/fonts.html

The link above answers all of your questions.

leon
04-04-2007, 05:43 PM
I have read the developer guide for several times. And I can't find the answers in the guide for some reasons. After that, I posted my question here for some answers that I can understand.


Thank you

RoloDMonkey
04-05-2007, 05:52 AM
Okay,

1 & 2. If you wish to use a system font on the client, you can use the human readable name, like this:

<text font="Times New Roman" />

However, this is not guaranteed. For instance, the client might spell the font name slightly differently, or have a variation with a different name. I don't know if you can specify fallbacks like you can in CSS, and I don't know what will happen if the client doesn't have the font. You'll have to experiment.

3. OpenLaszlo comes bundled with a default font. That means that the font will be embeded directly into the SWF. It is not on the client machine.

Lastly, you can embed your own fonts into the SWF. There are two drawbacks to this. One, it can drastically increase the size of your SWF. Two, most fonts aren't optimized to be pixel perfect at certain sizes. Therefore they will not look great at small sizes.

leon
04-05-2007, 11:58 PM
When I define a certain font:

<canvas height="500" width="500" debug="true">
<view font="aaa">
<text text="aaa"/>
</view>
</canvas>


Obviously, the font will be not found by laszlo, so the application use another font to replace. I don't know how to get the replaced font name.

I'm sure it's not the canvas's default font. I can get the canvas's default fontname by typing "canvas.fontname".

RoloDMonkey
04-06-2007, 07:34 AM
From my earlier post:

I don't know if you can specify fallbacks like you can in CSS, and I don't know what will happen if the client doesn't have the font. You'll have to experiment.

Take a look at this:

<canvas>


<simplelayout axis="y" spacing="5" />

<text width="250">This is the default font</text>
<text font="Non Existant Font" width="250">What happens here?</text>

<view font="Comic Sans MS" fontsize="16" width="250" bgcolor="#FFFFCC">
<simplelayout axis="y" spacing="5" />
<text>This should be Comic Sans MS</text>
<text font="Non Existant Font">What happens here?</text>
</view>

</canvas>

On my computer, Windows XP, the text "This is the default font" was rendered in a sans-serif. The two phrases "What happens here." were rendered in a serif font. This happened in both Firefox and IE7.

Exploring further, I deliberately changed my browser defaults to some weird fonts and nothing happened. So, if you specify a font by name, and OpenLaszlo can't find it, it falls back on something else, which is not the OpenLaszlo default. It may be a default built into the Flash player, or into the operating system. I don't know.

Why are you so concerned about it anyway? If you are planning on using system fonts, you should always use a flexible design that can handle when sizes change arbitrarily. If you want something specific, you should embed the font in your application.