Tuesday, October 16, 2012

Make XeTeX show quotation marks properly

Because of some annoying CJK font problems, I've switched from traditional LaTeX to Unicode-capable XeTeX.

After several trials, I finally made it worked on my computer and got the result which fitted almost my expectation. I said ``almost'' because there was a little problem of the quotation marks. In stead of showing expected curly marks, XeTeX outputted the marks in original text mode.

The solution I found is to add a bit of setting as follows.
\defaultfontfeatures{Mapping=tex-text}
\setmainfont{YOUR_FONT_NAME}

or simply
\setmainfont[Mapping=tex-text]{YOUR_FONT_NAME}
Actually I have no idea about the difference between the two implements listed above. My own guess is: the first one provides global effect while the second one affects only on the main font?

---
ref:
http://tug.org/pipermail/xetex/2008-October/010929.html

Monday, October 15, 2012

CThruView Transparent Image Viewer -- test in Ubuntu 12.04

In addition to qiv mentioned in the previous post, I found another image viewer which could do some amazing things when viewing transparent images. It is CThruView written in Java.

However, my trial got some problems. The transparent background was replaced by a gray one, and its visibility can only be reduced along with the foreground image by setting the opacity of overall image. The following screenshot shows my test.

At the first trial, I though the fails might be due to the OpenJDK which is the default installation in Ubuntu. So I found the method to install Sun Java 6 but got the same result.

Another failed test was the option ``Click-Thru'' which had no function. Except for these, other options worked properly.

Sunday, October 14, 2012

qiv -- Viewing image with transparent background

In Ubuntu, there is a image viewer named qiv which can show image files with transparent backgrounds.

For installation, just type
$ sudo apt-get install qiv

Invoke qiv in command line, and there are many many options to meet most requirements.

To show the image with its transparent background, the argument -p has to be used:
$ qiv -p IMAGE_FILE.png

Below is a screenshot of my own test. Note that the original image was save as png file with transparent background.

Use qiv to show image with transparent background.

Thursday, October 04, 2012

Visual Studio 2005: the symbol xxx is not defined

I've encountered the problem several times. Every time I have to use Ctrl+F to go through all the source code and it's somewhat annoying.

The only solution I could think of is to delete the *.ncb file or rebuild the project. And it's what I found on internet when I launched the search.

Unfortunately, it didn't work for me.

Fortunately, I finally got a solution which save my live.

Here is the method to solve the ``symbol xxx is not defined'' error:

Edit -> Intellisense -> List Members


XeTeX -- using the system fonts for CJK tex files

After using LaTeX for several years, I found XeTeX might be the best choice for Unicode files and therefore for the production of CJK documents.

When producing the CJK documents, it will be convenient to make the system fonts available for XeTeX. Here is a simple method to make it work.

To install system fonts, put *.ttc or *.ttf  files to the following folder:
/usr/share/fonts/truetype

Then build the font information cache files:
$ sudo fc-cache -f -v 

---
ref:
Mac下的Latex中文解決方案: XeTeX
http://www.hitripod.com/blog/2011/04/xetex-chinese-font-cjk-latex/
http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?post_id=230060#forumpost230060
http://www.tmes.mlc.edu.tw/wiki/index.php/Freefonts
http://www.ptt.cc/bbs/LaTeX/M.1315925855.A.C38.html

Saturday, March 03, 2012

Set Vim in Windows to work with Unicode

My Windows has been installed and set for traditional Chinese environment and occasionally it makes some trouble when I need text files encoded in Unicode instead of Big5.

I've started to write some personal working logs in Markdown syntax with Vim. It's simple and quick. But when I tried to compile the plain text into HTML file, the Chinese characters introduced trouble for the Python implementation of Markdown. The error message was something like:
UnicodeDecodeError: 'utf8' codec can't decode byte
To prevent this kind of error, I thought the best approach was to make Vim work with Unicode in my Windows. The settings were added in C:\Program Files\Vim\_vimrc and they are as follows:

set fileencoding=utf8
set fileencodings=ucs-bom,utf-8,default,latin1

The first line tells Vim to save the text in utf8 and the second line gives Vim to open and convert the files in the given order of encoding.

Sunday, January 08, 2012

Cannot set Chromium as your default browser?

I was using FreeMind to manage information of my work, and there were several links embedded in the mind map. When I was trying to open the links, they were opened in Firefox instead of Chromium that has been my default browser. I tried to set Chromium as the default browser in the Preferences tab but it said ``Chromium cannot determine or set the default browser.''
The solution was found on Ubuntu Forums. In the thread, user cavalier911 provided a method using update-alternatives to set the default browser. The command is as follows.

$ sudo update-alternatives --config x-www-browser

Pretty easy and works like a charm.

Monday, January 02, 2012

Screencast of particular window in Ubuntu using ffmpeg

When you want to record the screen output, there have been some software good to use [1]. However, I found none of them can properly record the zone in which a C++ program produced video stream combining webcam input and OpenGL objects.

After some trials, I found an useful solution [2] and made some modifications. It is a shell script that uses ffmpeg to record the video content of target window.

#!/bin/sh

echo -e "Usage: bash $0 outputfile\nClick on the window to be recorded."

size=$(xwininfo -frame | awk '/geometry/ {print $2}')
offset=$(echo $size | awk -F + '{print $2","$3}')

ffmpeg -f alsa -ac 2 -ab 192k -i pulse -f x11grab -s $size -r 30 -i :0.0+$offset -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 $1
---
[1] Such as recordMyDesktop and xvidcap
[2] Run FFMPEG with x11grab