ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Chinese font mingliu.tcc on other place? (ASP)
Posted by Frank on Dec-05-2011 22:30
Dear Peter,

Is it possible to put the chines font [mingliu.tcc] in a different place on our server?

If so, what would the command be in ASP?
[Call c.setDefaultFonts("mingliu.ttc")]

Thank you!

Frank.

  Re: Chinese font mingliu.tcc on other place? (ASP)
Posted by Peter Kwan on Dec-05-2011 23:19
Hi Frank,

Yes. You can put the font in any location that is addressible by your file system. For example:

Call c.setDefaultFonts("c:\\kkk\\ppp\\mingliu.ttc")

or

Call c.setDefaultFonts(Server.MapPath("\\myFonts\\mingliu.ttc")

To do the above, please make sure the server have the security to read the font file in the directory. The server is usually running under a special account that represents the "anonymous user".

Hope this can help.

Regards
Peter Kwan

  Re: Chinese font mingliu.tcc on other place? (ASP)
Posted by Frank on Dec-06-2011 00:43
Hello Peter,

Thanks you for your kind reply. It does not work yet, the rights are okay.

Below a example of a graph that does not work. Do you see anything wrong?

Thank you again for your help,

Frank.


<%
some_text = "再"
new_id = "335"

Set cd = CreateObject("ChartDirector.API")
Set c = cd.PieChart(150, 150)
Call c.setDefaultFonts(Server.MapPath("mingliu.ttc"))

' Add a title to the chart
Call c.addText(10, 20, some_text, "mingliu.ttc")

'output the chart
Call c.makeChart(Server.MapPath(new_id &".jpg"))

' Name graph
name_graph = new_id & ".jpg"
%>

  Re: Chinese font mingliu.tcc on other place? (ASP)
Posted by Peter Kwan on Dec-06-2011 01:03
Hi Frank,

The default "normal" font in your system is set to Server.MapPath("mingliu.ttc"). For BaseChart.addText, the default normal font is used if your code do not specify the font. For example:

Call c.addText(10, 20, some_text)

If your code does specify the font as "mingliu.ttc", then this font will be used, instead of Server.MapPath("mingliu.ttc").

So for your case, you can either left out the font in addText, and let ChartDirector uses the default font, or you can use:

Call c.addText(10, 20, some_text, Server.MapPath("mingliu.ttc"))

If the above code is used, then it is not necessary to use setDefaultFont.

Hope this can help.

Regards
Peter Kwan

  Re: Chinese font mingliu.tcc on other place? (ASP)
Posted by Frank on Dec-06-2011 06:55
Attachments:
Hi Peter,

Thanks again, however it doesn't work completely.

In the attached graph you can see the chinese characters in the browserline which are being send through a request to the page.
These chines characters do not all come out good using mingliu.ttc. I have no clue why, have you?

Thank you,

Frank.
graph1.jpg

  Re: Chinese font mingliu.tcc on other place? (ASP)
Posted by Peter Kwan on Dec-07-2011 02:29
Hi Frank,

The error is not related to the font, but is because your Chinese characters encoding is not recognized by your IIS/ASP. So it became "strange characters" in ASP/VBScript. Then your code pass those strange characters to ChartDirector, so ChartDirector draws the strange characters.

To confirm if your IIS/ASP can understand your Chinese characters, you may try the followings:

'assume the query parameter abc is some chinese characters
x = Request("abc")
Response.Write ("Text Length = " & Len(x) & "<BR>")

You should see the length of your text. If your text contains 3 Chinese characters, but the string length is not 3 according to the server, then the server does not understand your Chinese characters.

Note that even if the server does not understand your Chinese characters, if you ask the server to send the characters back to the browser to display, the browser can still display them proper, because the browser understands the Chinese characters. However, if you want to use the Chinese characters on the server, it will result in "strange characters".

For your case, please try the followings:

(a) Please do not put Chinese characters in the URL. This is invalid according to the URL standard. The URL standard states that the URL can only contain ASCII characters. All other characters must be escaped using URL escape sequence %xx. In ASP, there is a Server.URLEncode function that encodes the URL using %xx for non ASCII characters. Also, if the text is entered by the user in a HTML FORM, the browser should automatically translate the non-ASCII characters to %xx in the URL.

(b) Please tell both the server and the browser which encoding you would like to use, so that they understand each others encoding. For the server, please use <%@ codepage %> to specify the code page. For the browser, please use the <META> tag. For example, the followings use UTF8 encoding on both the server and browser side.

<%@ language="vbscript" codepage="65001" %>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
......

Hope this can help.

Regards
Peter Kwan

  Re: Chinese font mingliu.tcc on other place? (ASP)
Posted by Frank on Dec-07-2011 23:05
Hi Peter,

Thank you for your extensive reply!

We dumped the request and extracted the chinese fonts directly from our utf-8-database with the help and tips you gave..., and quess what: it worked!! Thumbs up!!!

Thank you very much for your super support,

Frank.