Wednesday, March 28, 2007

Get fonts right in pdf formated papers

I was struggling with font problem in my paper these days, and finally got done with it. I use winedt/MikTex companions under windows XP since 3-4 years ago. And PowerPoint for the figures, since I can directly print to pdf-printer (feature of acrobat) to get pdf figures nowadays. All these tools works efficiently. However, they didn't comply with ACM's strict requirement of fonts in publications, which restricts to the use of "type 1" and "embedded" fonts ONLY. Now, I have two problems. First one, I always have "truetype" font in my figures, since I don't have any "type 1" font installed on my windows. Second one, there are several "type 1" fonts cannot be embedded, such as "times", "courier" and etc.

================================================================

For the first problem, I need to install and use the "type 1" font corresponding to the "truetype" font I used in PowerPoint, so that the pdf figures generated contain "type 1". The free way of getting "type 1" font is to convert from existing truetype font (under \WINDOWS\Fonts). There are two ways of doing this:

First, use fft2pt1 (truetype to type 1 converter) to convert the truetype font (from a .fft file to a .pfb file and a .afm file), then use afm2pfm to convert the .afm to a .pfm file that windows recognizes, and finally drag the .pfm file to \WINDOWS\Fonts folder to get it installed. Note that if you're NOT using windows XP or 2000, you need to install Adobe Type Manager (ATM) to install the type 1 font. For now, if you're lucky, you can see and use the type 1 font in the PowerPoint font box (I cannot for some reason I don't know).

The second way to do this is to use FontLab (a commercial software) to generate the type 1 font. Just open the .ttf font, go to File->Font Info to give it a different font name (first page), go to File->Generate font, and choose to generate the "type 1 binary file (*.pfb)". Then install the font by dragging the .pfm file to \WINDOWS\Fonts folder. I managed to see the font in PowerPoint using this second method.

In PowerPoint, substitute all the fonts with the type 1 fonts you generated. When printing to the pdf printer, make sure to set the options of pdf printer to embed all the fonts (for my case, under "conversion settings->fonts->embedding" and add all the fonts to the "always embed" list). When the pdf file is produced, open it with acrobat, press CTRL+D to see the fonts. Most likely, you'll have all the fonts embedded.

An exception may occur if you use a non-English version of PowerPoint. For me, Chinese version. The default font is Sim-Sun. Some times, even all the places you can touch is set to non Sim-Sun font, it will still be included in the pdf file. In this case, open a new PowerPoint file, copy and paste you figure part by part to the new file. Produce a pdf file and check the font to see where Sim-Sun is introduced, and then try to modify or remove them. For me, I found starting spaces (by accident) introduces Sim-Sun, so I removed them.

==================================================================

For the second problem, the cannot-be-embedded fonts are from the text compiled with pdflatex, which are assumed (by whom?) to be available on all systems (but not true), and referred as Base14 fonts.

To embed them, the simplest way is to install the latest version of MikTex (2.5) and ensure the pdfeTex version is above 1.20. By default, Base14 fonts are embedded. If you're using Tex system under Linux, similarly you need to ensure the pdfeTex (or pdfTex, or pdflatex) is above version 1.20. And then edit "/web2c/updmap.cfg" to ensure the following options is set to true: pdftexDownloadBase14, dvipdfmDownloadBase14. Finally, run updmap as root to update the configuration.

Another way of doing this is save your pdf document with the not-yet-embedded fonts as a PS file, using "save as..." in acrobat. Then use the command "ps2pdf14 -dPDFSETTINGS=/prepress -dEmbedAllFonts=true mydoc.ps" to generate the pdf file with fonts embedded.

I compared the results of the above two approaches, i.e., the direct pdflatex generating approach and the pdf->ps->pdf approach. It seems to me that the former approach is better in the following aspects. It includes less redundant fonts, so the file size is smaller. The graphs looks more original, and scrolls faster especially when complex patterns are used (pdf->ps->pdf approach converts 2 times, and may introduce some distortions and more fragments to the vector graph, thus show up slowly).

We're done.

Monday, March 19, 2007

Tips

Do not try to compile a large program not compatible with your current version of gcc, instead, compile a version of gcc compatible with the program, and then use the gcc to compile it. (however, newest gcc does not even compile the old versions. In this case, compile a not-that-old version which compiles the old version to compile the old version. What a mess!)

Installing Fedora Core 6 on VMWare 5.5

Since the up-to-date VMWare still doesn't support FC linux officially, you need to pay some effort installing and configuring FC6. I assume the readers have successful installation experience of other linux under VMware before, so only key points related to FC6 installation will be addressed.

1. Create a VM:
Open VM's "New Virtual Machine Wizard", make sure you choose the following options: "Custom" -> New - Workstation 5 -> "Other Linux with 2.6.x kernel" -> ... -> LSI Logic (for SCSI Adaptor) -> ... -> SCSI (recommended).

The above options will make sure FC6 installation wizard find your virtual disk properly.

2. Install VMWare Tools:
Make sure you have kernel-devel corresponding your running kernel installed, which provides the kernel headers needed by VMWare Tools. By default, you need to download and install kernel-devel by yourself. Note that the version of kernel-devel must match your running kernel exactly (for example, "2.6.18-1.2798.fc6xen.i686" does not match with "2.6.18-1.2798.fc6.i686), so if you cannot find a kernel-devel matches the kernel, you need to install a kernel that matches the kernel-devel. I don't recommend using yum to update the kernel and kernel-devel, because they don't always match (and you may not be able to find a co-existing pair). So we go the traditional rpm way.

To check your current running kernel, use "uname -r".

To download kernel-devel, goto "http://fedora.redhat.com/download/mirrors.html", find a mirror site close to your place, and download the rpm package of kernel-devel. For example, I would go to "ftp://ftp.oss.eznetsols.org/linux/fedora/6/i386/os/Fedora/RPMS/" in Singapore, and download "kernel-devel-2.6.18-1.2798.fc6.i686.rpm", and install it by "rpm -ivh kernel-devel-2.6.18-1.2798.fc6.i686.rpm".

You may need to download and install the kernel matches the kernel-devel as well. Similarly, download kernel-2.6.18-1.2798.fc6.i686.rpm and install it. Then reboot your linux. Stroke "enter" at boot up to choose the newly installed kernel. Or you can modify the grub configuration file "/etc/grub.conf", change the "default=" parameter (0 for the first kernel, 1 for the second kernel) for the new kernel.

Now you can locate the kernel headers under, for example, /usr/src/kernels/2.6.18-1.2798.fc6-i686/include.

Then mount your VMWare Tools iso, and run "vmware-install.pl". Key in the above kernel headers when asked. You should be able to install it successfully now.

3. Configure resolution of your X.
Edit "/etc/X11/xorg.conf" with root. Add the following section at the beginning of the file.

Section "Monitor"
Identifier "vmware"
HorizSync 1.0 - 10000.0
VertRefresh 1.0 - 10000.0
EndSection

Add a line "DefaultDepth 24" after "Mornitor "vmware"" line in "Screen" section (assuming you have a OK graphic card). Then change the "Modes" line under Depth 24 to your desired resolution. For example "Modes 1280x800". Then startX.

Reference
http://www.thoughtpolice.co.uk/vmware/howto/fedora-core-6-vmware-tools-install.html
http://www.linuxquestions.org/questions/showthread.php?t=503651
http://www.lowlevel.cz/log/pivot/entry.php?id=80

Saturday, March 17, 2007

My Must-have Firefox Addons

As a IT guy, switching among different OS and migrating from systems to systems (e.g., my desktop and a few of my laptops) is not uncommon. Whenever this happens, the first thing I would make sure is the up-to-date Firefox is installed with the following must-have addons:
  1. Del.icio.us Bookmarks: for online bookmarking service, sharing bookmark links with others or myself (so that i don't need to synchronize the bookmarks from 3, 4 computers I use).
  2. GUtil: grants me instant access to various google services I'm using (i.e., gmail, reader, docs, calendar, blogger, album) with button click.
  3. ScrapBook: great substitution for "save page as..." function, which allows you to capture (and capture certain parts), organize, comment and edit on interesting web pages. The only problem is that it's not an online thing, and you need to export/import among different systems you have.
  4. Google Toolbar for Firefox: this is actually with Firefox package, but I remind you to click on the "G" icon with the downward arrow, you will find it's not only for googling (i.g., I need Webster for English words that doesn't recognize me).
  5. Session Manager: resume the tabs I was reading last time after restarting Firefox.
  6. FireFTP: for lazy guys.

Friday, March 16, 2007

如何在3.10OE-A下使用USB连接电脑玩ISO游戏

信我们每个人都有一个巨大的ISO游戏库,而现在最大的棒子也只有4GB,而且价格不菲。所以有人提出了用USB连接电 脑,直接读取电脑上存放的ISO来游戏的概念。这篇文章就是介绍怎样在3.10OE-A系统下面实现用USB->ISO来玩游戏的。DH可能自带这 样的功能,由于我自己已经不用DH了,还希望达人补全。最后说明一下,使用自治软件,特别是写入固件(第2步)有可能损坏你的PSP系统,想要尝试的人必须有视死如归的精神,坏了我不承担任何责任,这也是自治软件社群的潜规则了。

本文参考了以下网页,特此感谢
http://psp3d.com/member-news/133 ... wares-released.html
http://www.hoodong.com/entrygroupview.do?doc_id=200000813384
http://forums.afterdawn.com/thread_view.cfm/454995

首先准备以下工具:
工具1. [USB Mod v4b For 3.10 OE-A]: 含有PSP端插件的工具包,用来与PC通信,以及切换USB->ISO状态还是普通ISO状态。
工具2. [usbhostfs_PC_Win_1.5]: PC端的USB通信服务器程序。
工具3. [libusb-win32-device-bin-0.1.10.1]: PSP设备驱动信息提取程序。
工具4. 如果是TA-082主板降级的机器,还需要[TA082_USB_Fix]来修复固件里面的错误信息,这样工具3才能提取正确的信息。


下面是具体步骤:
1. 解压工具1,把MS_ROOT/seplugins里usbhostfs.prx,buzzusbvsh.prx和buzzusb.txt复制到"psp 根目录/seplugins"。如果"PSP根目录/seplugins"下没有game.txt和vsh.txt,那这两个文件也复制过来。如果已经存 在,则把工具1中2个txt文件的内容复制追加到已存在的2个txt文件中。
2. 关闭psp,按住R键开机进入恢复模式。在plugin选项中激活(enable)所有与usbhostfs和buzzusbvsh的插件。退出 plugin选项,选择Advanced->toggle USB (flash0),之后把工具1中Flash0/kn/vshctrl.prx和systemctrl.prx复制到PSP的kn目录(先备份),覆盖原 文件。退出 恢复模式。重启以后就能通过长按"口"键切换普通ISO模式(原来的模式)和USB->ISO模式了。不过现在USB->ISO模式里还不会 出现PC端的游戏,所以我们还需要安装PC端的服务器程序。

3. 解压工具2,复制PC上的游戏psp文件到解压后目录的ISO文件夹中(其实只要保证游戏iso文件在usbhostsf.exe程序所在目录的ISO子 文件夹中就可以了)。复制cygusb0.dll和cygwin1.dll至 C:\windows\system32中。这样运行usbhostsf.exe,服务器端就算是设置好了。不过现在PSP的驱动程序还没有安装(不是平 常识别为存储设备的那个驱动),所以还不能连接。
4. 接下来需要用工具3提取并安装PSP驱动程序。先启动PSP,这时windows会跳出检测到新硬件的对话框,暂时不必理会。解压工具3,运行bin\ inf-wizard.exe,选择next,会出现一个已连接USB设备的列表。通过开关psp来确定哪一项是psp对应的设备(需要back再 next来刷新列表),之后选择此设备,next, next,把导出文件以默认文件名"your_file.inf"存至工具2的driver目录中。最后,关闭再打开psp,根据windows新硬件向 导,选择工具2的driver目录来安装刚才导出的psp驱动了。安装完毕后,再接入psp的时候就不会跳出新硬件的对话框了。
5. 所有准备完毕。最后,运行usbhostfs.exe(工具2),出现一个dos窗口。连接并打开psp,长按"口"键切换到USB->ISO模 式,如果dos窗口中显示"connected to device",那么恭喜你,你可以运行在PC上的iso游戏了。

6. 如果你用的是TA-082主 板的psp,psp的驱动信息并不能被正确的提取。这 时需要使用工具4来修复psp的固件,之后再提取驱动信息。解压工具4,把MS_ROOT里面内容复制到psp根目录(确保043.bin在psp根目 录)。在psp里运行UsbHostfs-Fix程序,全部显示successful之后重启psp。之后跳到步骤4制作驱动。后面相同。

=============================================================

问题1:安装工具2之后,我怎么辨别切换到了USB->ISO模式还是普通ISO模式?
回 答: 按住"口"键之后,psp上面读盘的指示灯会闪烁一会儿,这个说明正在切换模式。之后记忆棒中的游戏图标可能并没有刷新,需要进入“游戏存档”,然后退 出,之后就刷新了。如果刷新之后显示的是原来棒子里面的游戏,就是出于普通ISO模式,如果显示了硬盘上面的iso游戏,就是进入了USB-> ISO模式。如果什么游戏都没有显示,那是处于USB->ISO模式,这个时候,如果usbhostsf.exe的dos窗口中显示 "connected to device",那么是因为iso游戏放置的文件夹没有设对;如果dos窗口没有显示,就是psp驱动的问题了。

=============================================================

你可以用google搜索,或者到http://www.cngba.com/thread-16648557-1-1.html下载
以下工具(须注册为cngba会员):
USB_Mod_v4b_For_3.10_OE-A_For_PSP.zip
usbhostfs_PC_Win_1.5.rar
libusb-win32-device-bin-0.1.10.1.rar
TA082_USB_Fix.rar