2010年11月18日星期四

Linux下的中文字体安装和使用 - 技术文档 - 新手入门 Linux时代 - 开源、自由、共享 - 中国最大的Linux技术社区

Linux下的中文字体安装和使用 - 技术文档 - 新手入门 Linux时代 - 开源、自由、共享 - 中国最大的Linux技术社区


Linux下的中文字体安装和使用
来源: Linux论坛  日期: 2008.03.17 14:55 (共有0条评论) 我要评论

fedora对中文的支持很好,默认情况下安装了两种中文字体,但是系统自带字体的字库很小,对于一些不常用的字无法显示。还有就是部分用户会跨平台办公,也就为了兼容windows 环境,必须要用到windows 的字体,如宋体、仿宋、楷体、黑体等,再有就是为了美化linux 桌面环境安装美化字体。

  1 安装中文字体

  安装字体非常简单,只要把中文字体复制到字体目录就可以了,绝对路径如下,注意大小写:/usr/share/fonts/chinese/TrueType/

  如果大家安装的是双系统,也可以不用把windows下的字体原文件复制到linux 中文字体目录,可以建立每个字体文件的链接(如何用鼠标拖动创建文件链接前面介绍了,比较简单)就可以,如图1 所示,图标右边带一个弯曲箭头符号的就是一个链接文件,大家可能看到的图标也许和我不同,因为我使用了fedora 自带的“薄雾”主题而不是默认的主题,为了节省系统资源加快运行速度。

  xp 下主要字体为:宋体simsun.ttc、黑体simhei.ttc、仿宋simfang.ttf、楷体simkai.ttf、隶书simli.ttf、幼圆simyou.ttf,另外推荐大家安装微软雅黑字体,以便用来美化fedora 的显示,图1 就是使用雅黑字体的效果,挺养眼的。

2010年11月2日星期二

最便捷的方法禁止Windows自动更新后的重启提示 | 技客乐趣

最便捷的方法禁止Windows自动更新后的重启提示 | 技客乐趣

Windows安装更新后会不断的提示你赶紧重启,这个提示真是很烦人。而更令人郁闷的是竟然没有直接的办法来关掉这个提示对话框。

乐子王以前介绍过如何禁止Windows Update安装更新后自动重启的方法,但这里面介绍的两种方法是完全把重启提示给禁用了,有没有临时的、更便捷的方法立刻关闭该提示呢?

其实很简单,只需运行一个命令:

点击“开始”->“运行”;
运行“net stop wuauserv”即可。
该命令是直接停止Windows自动更新服务。该服务停止以后,烦人的重启提示马上就会消失。

同理,你也可以通过“控制面板”->“管理工具”->“服务”来停止自动更新(Automatic Updates)服务:

2010年10月28日星期四

Table of keyboard shortcuts - Wikipedia, the free encyclopedia

Table of keyboard shortcuts - Wikipedia, the free encyclopedia

在LINUX上安装Office 2003

由于OFFICE在Linux上无法正常输入小写和中文,今天重新安装OFFICE中文版本,不成功,采取措施
1)Yum卸载wine(似乎没有作用),重新安装
2)su as root,
3)用Xterm, 写入wine SETUP.EXE
不知道哪种的作用,安装正常结束

再来,删除.wine 重新安装,用菜单里Wine Installer 再安装,就可也运行了,
但似乎不稳定,随时crash。

2010年10月27日星期三

scanf - C Reference

scanf - C Reference
int  scanf ( const char * format, ... );

Read formatted data from stdin

Reads data from stdin and stores them according to the parameter format into the locations pointed by the additional arguments. The additional arguments should point to already allocated objects of the type specified by their corresponding format tag within the format string.

Parameters

format
C string that contains one or more of the following items:
  • Whitespace character: the function will read and ignore any whitespace characters (this includes blank spaces and the newline and tab characters) which are encountered before the next non-whitespace character. This includes any quantity of whitespace characters, or none.
  • Non-whitespace character, except percentage signs (%): Any character that is not either a whitespace character (blank, newline or tab) or part of a format specifier (which begin with a % character) causes the function to read the next character from stdin, compare it to this non-whitespace character and if it matches, it is discarded and the function continues with the next character of format. If the character does not match, the function fails, returning and leaving subsequent characters of stdin unread.
  • Format specifiers: A sequence formed by an initial percentage sign (%) indicates a format specifier, which is used to specify the type and format of the data to be retrieved from stdin and stored in the locations pointed by the additional arguments. A format specifier follows this prototype:

    %[*][width][modifiers]type

    where:

    *An optional starting asterisk indicates that the data is to be retrieved from stdin but ignored, i.e. it is not stored in the corresponding argument.
    widthSpecifies the maximum number of characters to be read in the current reading operation
    modifiersSpecifies a size different from int (in the case of d, i and n), unsigned int (in the case of o, u and x) or float (in the case of e, f and g) for the data pointed by the corresponding additional argument:
    h : short int (for d, i and n), or unsigned short int (for o, u and x)
    l : long int (for d, i and n), or unsigned long int (for o, u and x), or double (for e, f and g)
    L : long double (for e, f and g)
    typeA character specifying the type of data to be read and how it is expected to be read. See next table.


    scanf type specifiers:
    typeQualifying InputType of argument
    cSingle character: Reads the next character. If a width different from 1 is specified, the function reads width characters and stores them in the successive locations of the array passed as argument. No null character is appended at the end.char *
    dDecimal integer: Number optionally preceded with a + or - sign.int *
    e,E,f,g,GFloating point: Decimal number containing a decimal point, optionally preceded by a + or - sign and optionally folowed by the e or E character and a decimal number. Two examples of valid entries are -732.103 and 7.12e4float *
    oOctal integer.int *
    sString of characters. This will read subsequent characters until a whitespace is found (whitespace characters are considered to be blank, newline and tab).char *
    uUnsigned decimal integer.unsigned int *
    x,XHexadecimal integer.int *
additional arguments
The function expects a sequence of references as additional arguments, each one pointing to an object of the type specified by their corresponding %-tag within the format string, in the same order.
For each format specifier in the format string that retrieves data, an additional argument should be specified.
These arguments are expected to be references (pointers): if you want to store the result of a fscanf operation on a regular variable you should precede its identifier with the reference operator, i.e. an ampersand sign (&), like in:

int n;
scanf ("%d",&n);


Return Value

On success, the function returns the number of items succesfully read. This count can match the expected number of readings or fewer, even zero, if a matching failure happens.
In the case of an input failure before any data could be successfully read, EOF is returned.另存为草稿

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* scanf example */ #include   int main () {   char str [80];   int i;    printf ("Enter your family name: ");   scanf ("%s",str);     printf ("Enter your age: ");   scanf ("%d",&i);   printf ("Mr. %s , %d years old.\n",str,i);   printf ("Enter a hexadecimal number: ");   scanf ("%x",&i);   printf ("You have entered %#x (%d).\n",i,i);      return 0; }


This example demonstrates some of the types that can be read with scanf:
Enter your family name: Soulie
Enter your age: 29
Mr. Soulie , 29 years old.
Enter a hexadecimal number: ff
You have entered 0xff (255).


See also

C语言字符串函数大全|c语言,字符串,函数-中国源码网: 开放源代码&&编程

C语言字符串函数大全|c语言,字符串,函数-中国源码网: 开放源代码&&编程



if (ptr == 0)
printf("buffer 2 equals buffer 1\n");

return 0;
}

函数名: strncmp
功 能: 串比较
用 法: int strncmp(char *str1, char *str2, int maxlen);
程序例:

#include
#include

int main(void)

{
char *buf1 = "aaabbb", *buf2 = "bbbccc", *buf3 = "ccc";
int ptr;

ptr = strncmp(buf2,buf1,3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
else
printf("buffer 2 is less than buffer 1\n");

ptr = strncmp(buf2,buf3,3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 3\n");
else
printf("buffer 2 is less than buffer 3\n");

return(0);
}

函数名: strncmpi
功 能: 把串中的一部分与另一串中的一部分比较, 不管大小写
用 法: int strncmpi(char *str1, char *str2);
程序例:

#include
#include

int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;

ptr = strncmpi(buf2,buf1,3);

if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");

if (ptr <>
printf("buffer 2 is less than buffer 1\n");

if (ptr == 0)
printf("buffer 2 equals buffer 1\n");

return 0;
}

函数名: strncpy
功 能: 串拷贝
用 法: char *strncpy(char *destin, char *source, int maxlen);
程序例:

#include
#include

int main(void)
{
char string[10];
char *str1 = "abcdefghi";

strncpy(string, str1, 3);
string[3] = '\0';
printf("%s\n", string);
return 0;
}

函数名: strnicmp
功 能: 不注重大小写地比较两个串
用 法: int strnicmp(char *str1, char *str2, unsigned maxlen);
程序例:

#include
#include

int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;

ptr = strnicmp(buf2, buf1, 3);

if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");

if (ptr <>
printf("buffer 2 is less than buffer 1\n");

if (ptr == 0)
printf("buffer 2 equals buffer 1\n");

return 0;
}

函数名: strnset
功 能: 将一个串中的所有字符都设为指定字符
用 法: char *strnset(char *str, char ch, unsigned n);
程序例:

#include
#include

int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz";
char letter = 'x';

printf("string before strnset: %s\n", string);
strnset(string, letter, 13);
printf("string after strnset: %s\n", string);

return 0;
}

函数名: strpbrk
功 能: 在串中查找给定字符集中的字符
用 法: char *strpbrk(char *str1, char *str2);
程序例:

#include
#include

int main(void)
{
char *string1 = "abcdefghijklmnopqrstuvwxyz";
char *string2 = "onm";
char *ptr;

ptr = strpbrk(string1, string2);

if (ptr)
printf("strpbrk found first character: %c\n", *ptr);
else
printf("strpbrk didn't find character in set\n");

return 0;
}

函数名: strrchr
功 能: 在串中查找指定字符的最后一个出现
用 法: char *strrchr(char *str, char c);
程序例:

#include
#include

int main(void)
{
char string[15];
char *ptr, c = 'r';

strcpy(string, "This is a string");
ptr = strrchr(string, c);
if (ptr)
printf("The character %c is at position: %d\n", c, ptr-string);
else
printf("The character was not found\n");
return 0;
}

函数名: strrev
功 能: 串倒转
用 法: char *strrev(char *str);
程序例:

#include
#include

int main(void)
{
char *forward = "string";

printf("Before strrev(): %s\n", forward);
strrev(forward);
printf("After strrev(): %s\n", forward);
return 0;
}

函数名: strset
功 能: 将一个串中的所有字符都设为指定字符
用 法: char *strset(char *str, char c);
程序例:

#include
#include

int main(void)
{
char string[10] = "123456789";
char symbol = 'c';

printf("Before strset(): %s\n", string);
strset(string, symbol);
printf("After strset(): %s\n", string);
return 0;
}

函数名: strspn
功 能: 在串中查找指定字符集的子集的第一次出现
用 法: int strspn(char *str1, char *str2);
程序例:

#include
#include
#include

int main(void)
{
char *string1 = "1234567890";
char *string2 = "123DC8";
int length;

length = strspn(string1, string2);
printf("Character where strings differ is at position %d\n", length);
return 0;
}

函数名: strstr
功 能: 在串中查找指定字符串的第一次出现
用 法: char *strstr(char *str1, char *str2);
程序例:

#include
#include

int main(void)
{
char *str1 = "Borland International", *str2 = "nation", *ptr;

ptr = strstr(str1, str2);
printf("The substring is: %s\n", ptr);
return 0;
}

函数名: strtod
功 能: 将字符串转换为double型值
用 法: double strtod(char *str, char **endptr);
程序例:

#include
#include

int main(void)
{
char input[80], *endptr;
double value;

printf("Enter a floating point number:");
gets(input);
value = strtod(input, &endptr);
printf("The string is %s the number is %lf\n", input, value);
return 0;
}

函数名: strtok
功 能: 查找由在第二个串中指定的分界符分隔开的单词
用 法: char *strtok(char *str1, char *str2);
程序例:

#include
#include

int main(void)
{
char input[16] = "abc,d";
char *p;

/* strtok places a NULL terminator
in front of the token, if found */
p = strtok(input, ",");
if (p) printf("%s\n", p);

/* A second call to strtok using a NULL
as the first parameter returns a pointer
to the character following the token */
p = strtok(NULL, ",");
if (p) printf("%s\n", p);
return 0;
}

函数名: strtol
功 能: 将串转换为长整数
用 法: long strtol(char *str, char **endptr, int base);
程序例:

#include
#include

int main(void)
{
char *string = "87654321", *endptr;
long lnumber;

/* strtol converts string to long integer */
lnumber = strtol(string, &endptr, 10);
printf("string = %s long = %ld\n", string, lnumber);

return 0;
}

函数名: strupr
功 能: 将串中的小写字母转换为大写字母
用 法: char *strupr(char *str);
程序例:

#include
#include

int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz", *ptr;

/* converts string to upper case characters */
ptr = strupr(string);
printf("%s\n", ptr);
return 0;
}

函数名: swab
功 能: 交换字节
用 法: void swab (char *from, char *to, int nbytes);
程序例:

#include
#include
#include

char source[15] = "rFna koBlrna d";
char target[15];

int main(void)
{
swab(source, target, strlen(source));
printf("This is target: %s\n", target);
return 0;
}

2010年10月22日星期五

用rpm安装了GSVIEW4.9

用rpm安装了GSVIEW4.9



http://rpm.pbone.net/index.php3/stat/4/idpl/9692782/dir/opensuse/com/gsview-4.9-10.1.i386.rpm.html
下载rpm

需要在/usr/lib 做
ln -s libgs.so.8 libgs.so即可

compile gsiew 和ghostscript9.0是作无用功

在Fedora13上安装NVDIDIA GeForce 驱动程序

1)确认并了解自己显卡的型号。
/sbin/lspci | grep VGA

00:05.0 VGA compatible controller: nVidia Corporation C51 [GeForce 6150 LE] (rev a2)
uname -a
Linux Linux 2.6.34.7-56.fc13.i686 #1 SMP Wed Sep 15 03:33:58 UTC 2010 i686 i686 i386 GNU/Linux

2) 找 NVIDIA网页搜索Driver
http://www.nvidia.com/Download/index.aspx?lang=en-us
GeForce 6150 LE
下载 NVIDIA-Linux-x86-260.19.12.run

3)修改fedora启动程序图,关闭 nouveau
Modify the initramfs:

[mirandam@charon ~]$ su -
Password:
[root@charon ~]# mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
[root@charon ~]# dracut /boot/initramfs-$(uname -r).img $(uname -r)

4)修改 /etc/inittab,把启动水平调到3(没有X11)
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

5)reboot, 然后login to root
sh NVIDIA-Linux-x86-260.19.12.run

完成后 修改 inittab,
id:5:initdefault:

reboot即 成功


2010年10月21日星期四

总是在Linux没有连好无线卡USB时试图寻找网络

找了半天,Fedora 13 里iwconfig已经消失,如果连好USB无线卡,在上方控制半网络自动会显示无限网络选择

StarDict的安装

引用

Linux下中英翻译字典的安装与配置

StarDict的安装- -

说起Linux上的StarDict,可以说是咱们中国人在这个自由软件的国度作出的一大贡献,同时也让国人看到为Linux在中国的发展所应该走的一条光明大道—创作出使Linux更方便于使用于普及的软件,而不是像国内所谓“Linux公司”所走的“只会汉化”、“软件缩水”、“自由软件(包括Linux)的收费”这样一条背离GPL精神的路子。

StarDict是Linux上最强大的词典软件,庞大且可扩展的词汇量(尤其是Oxford)再加上真人发音,一点都不向Windows里的金山词霸示弱,更难能可贵的是这是GPL的,也就是免费的。相信每个像我这样已经跟Microsoft说“No”的朋友都会在自己的Linux里装上这个的吧。

说到安装(不推荐rpm安装),不外乎:
./configure
make
make install
这些当然没什么可说的。不过经常在一些BBS里看到一些朋友会在configure或是make时遇到这样那样的麻烦,所以我就在此处把一些可能遇到的问题整理一下。

1、configure
这一步一般就用如下的命令:./configure –prefix=/opt/stardict (要是你跟我一样不装gnome系统的话,那还请再在后面加上–disable-gnome-support,否则就算是前两步都通过了,在make install时还是会遇到问题,会提示找不到stardict-C.omf.out)
在这一步经常遇到的问题就是gtk找不到、pkg-config找不到、libgnomeui-devel >= 2.2.0不满足等等,找包装上就行,如果是发行版,那就把相关devel也装上。这以后有些发行版还可能遇到的一个问题就是gconftool-2的路徑不对,这时只要对路径赋正确参数指定gconftool-2位置就行,比如“PATH=$PATH:/opt/gnome/bin”,然后就能顺利通过了。

2、make
这一步里一般也都是缺包的问题(尤其是自定义选择性安装没有选gnome的)。下面列出一些(左边的是缺的文件,右边是需要安装的包):
libgnome-keyring.la gnome-keyring
libjpeg.la libjpeg-devel
libesd.la esound-devel
装上这些就能顺利make了。

安装完成后,自然要加上词典才能用,下载后的词典只要解压就能用,不过路径一定要正确(如果前面configure时使用的是默认的参数,那么下面的/opt/stardict/share应该都改成/usr/local/share):

Dictionaries(http://stardict.sourceforge.net/Dictionaries.php):
tar -xjvf a.tar.bz2
mv a /opt/stardict/share/stardict/dic

Tree Dictionaries(http://stardict.sourceforge.net/TreeDictionaries.php):
tar -xjvf a.tar.bz2
mv a /opt/stardict/share/stardict/treedict

另外,如果要让StarDict具有朗读功能,那么解压WyabdcRealPeopleTTS到/usr/share/WyabdcRealPeopleTTS,再在主程序的选项里选上“Pronouce the word when pop up”就可以了。

你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=2681960

另外:debian linux下,

rpm文件使用 alien -d xxx.rpm

deb文件使用 dpkg -i xxx.deb

install stardict in fedora 13

The configure file in Fedora 14 can not figure out the glib is glib2.0, I have to manually change Makefile in src/sigc++,
replacing g++ with
g++ `pkg-config --cflags --libs glib-2.0`
(Perhaps in Makefile too,)
The rest is to solve dependence
xml2po is in gnome-doc-utils (yum or GUI rpm)
~
~

config glib 版本

../../config-custom.h:15:18: error: glib.h: No such file or directory


gcc `pkg-config --cflags --libs glib-2.0` file.c -o program


Your need the contents of pkg-config --libs --cflags glib-2.0 in your makefile. So your makefile should have this line in it somewhere:

CFLAGS=`pkg-config --cflags --libs glib-2.0`

I forget how to do this with autoconf. But I can look it up... If you need gtk, do the same thing, replacing glib-2.0 with gtk+-2.0.

2010年10月17日星期日

递归两则 recursion

1)方程系数
1 10 45 120 210 252 210 120 45 10 1
1 9 36 84 126 126 84 36 9 1
1 8 28 56 70 56 28 8 1
1 7 21 35 35 21 7 1
1 6 15 20 15 6 1
1 5 10 10 5 1
1 4 6 4 1
1 3 3 1
1 2 1
1 1
1

2)转移盘子Number of plate 10
==> 10 9 8 7 6 5 4 3 2 1
==>
==>

==> 10 9 8 7 6 5 4 3 2
==>
==> 1

==> 10 9 8 7 6 5 4 3 2
==> 1
==>

==> 10 9 8 7 6 5 4 3
==> 1
==> 2

==> 10 9 8 7 6 5 4 3
==>
==> 2 1

==> 10 9 8 7 6 5 4 3
==> 1
==> 2

==> 10 9 8 7 6 5 4 3 1
==>
==> 2
.....

==>
==>
==> 10 9 8 7 6 5 4 3 2 1


~

2010年10月14日星期四

Return Array from C++

Re: Return Array from C++

Quote originally posted by tlee ...
However, my current knowledge does not allow me to see how the pointer can solve this C++ limitation (return a pointer might be dangerous because it might point to the address of local variable, and this variable will go out of scope. Hence, this pointer will point to invalid value). I appreciate for your information.
Pass a pointer to the start as a parameter to the function, and then return this pointer when you're done.
C++ Syntax (Toggle Plain Text)
  1. #include
  2. int *foo(int *array)
  3. {
  4. int *start = array;
  5. while ( *array )
  6. {
  7. std::cout << *array++ << ' ';
  8. }
  9. std::cout << class="me2">endl;
  10. return start;
  11. }
  12. int *bar(int *array)
  13. {
  14. int *start = array;
  15. while ( *array )
  16. {
  17. *array++ += 1;
  18. }
  19. return start;
  20. }
  21. int main()
  22. {
  23. int myarray[] = {1,2,3,4,5,0};
  24. foo(bar(foo(bar(foo(myarray)))));
  25. return 0;
  26. }
  27. /* my output
  28. 1 2 3 4 5
  29. 2 3 4 5 6
  30. 3 4 5 6 7
  31. */