by selecting a format as one of the options (”vcd”, “svcd”, “dvd”, “dv”, “pal-vcd”, “ntsc-svcd”), all the format options (bitrate, codecs, buffer sizes) are then set automatically.
You can just type:
$ ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
#same example but use high quality, ntsc vcd format
$ ffmpeg -i myfile.avi -hq -target ntsc-vcd /tmp/vcd.mpg
#same example but dvd quality
$ ffmpeg -i myfile.avi -target ntsc-dvd /tmp/dvd.mpg
#same example use same quality as source
$ ffmpeg -1 myfile.avi -sameq -target vcd /tmp/vcd.mpg
#converting a file for VCD format using a and b frames for MPEG 2
$ ffmpeg -i myfile.avi -target ntsc-vcd -bf 2 /home/user/Video/vcd.mpg
#same conversion, but start at 0 seconds and convert only first 45 minutes
#use -ss for start position and -t for duration
$ ffmpeg -i myfile.avi -target ntsc-vcd -bf 2 -ss 00:00:00 -t 00:45:00 /home/user/Video/vcd.mpg
then you can use K3b to burn it to VCD or DVD.
source: http://www.smorgasbord.net/conve ... fmpeg-and-mencoder/
2008年9月25日 星期四
2008年3月21日 星期五
Get IP address / Netmask / Broadcast C code
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <ifaddrs.h>
#include <string.h>
int printLocalIps()
{
struct ifaddrs *ifa = NULL, *ifp = NULL;
if (getifaddrs (&ifp) < 0)
{
perror ("getifaddrs");
return 1;
}
for (ifa = ifp; ifa; ifa = ifa->ifa_next)
{
char ip[NI_MAXHOST];
socklen_t salen;
if (ifa->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in *sin = (struct sockaddr_in *)(ifa->ifa_addr);
salen = sizeof (struct sockaddr_in);
/*printf("%s : %s\n", ifa->ifa_name, inet_ntoa(sin->sin_addr)); */
} else if (ifa->ifa_addr->sa_family == AF_INET6)
/*salen = sizeof (struct sockaddr_in6);*/
continue;
else
continue;
printf("<---------->\n");
printf("%s :\n", ifa->ifa_name);
if (getnameinfo (ifa->ifa_addr, salen,
ip, sizeof (ip), NULL, 0, NI_NUMERICHOST) < 0)
{
perror ("getnameinfo");
continue;
}
printf ("IP : %s\n", ip);
if (getnameinfo (ifa->ifa_netmask, salen,
ip, sizeof (ip), NULL, 0, NI_NUMERICHOST) < 0)
{
perror ("getnameinfo");
continue;
}
printf ("Netmask : %s\n", ip);
if (getnameinfo (ifa->ifa_broadaddr, salen,
ip, sizeof (ip), NULL, 0, NI_NUMERICHOST) < 0)
{
perror ("getnameinfo");
continue;
}
printf ("Broadcast : %s\n", ip);
}
freeifaddrs (ifp);
return 0;
}
int main(int argc, char **argv)
{
printLocalIps();
}
Result :
<---------->
lo :
IP : 127.0.0.1
Netmask : 255.0.0.0
Broadcast : 127.0.0.1
<---------->
eth0 :
IP : 192.168.168.67
Netmask : 255.255.255.0
Broadcast : 192.168.168.255
2008年3月10日 星期一
PHP + thttpd + MySQL
MySQL 5.0.18
CC=i386-linux-gcc CXX=i386-linux-g++ AR=i386-linux-ar ./configure --host=i386-linux --target=i386-linux --prefix=/opt/mysql-5.0.18 --disable-shared --enable-static --without-debug --enable-assembler --with-pthread --without-docs --without-man --without-bench --without-innodb --program-prefix= --cache-file=/dev/null
Fix clinet/Makefile -->> LDFLAGS = -s -static
make
make install
php-4.3.10
CC=i386-linux-gcc CXX=i386-linux-g++ AR=i386-linux-ar ./configure --enable-static --build=i386-linux --host=i386-linux --with-thttpd=../thttpd-2.21b --with-mysql=/opt/mysql-5.0.18 --with-config-file-path=/opt/thttpd-2.21b/lib --prefix=/opt/php-4.3.10 --enable-memory-limit --disable-debug --without-gd --enable-sysvshm --cache-file=/dev/null
make
make install
cd thttpd-2.21b
CC=i386-linux-gcc CXX=i386-linux-g++ AR=i386-linux-ar ./configure --host=i386-linux --target=i386-linux --prefix=/opt/thttpd-2.21b --cache-file=/dev/null
make
make install
CC=i386-linux-gcc CXX=i386-linux-g++ AR=i386-linux-ar ./configure --host=i386-linux --target=i386-linux --prefix=/opt/mysql-5.0.18 --disable-shared --enable-static --without-debug --enable-assembler --with-pthread --without-docs --without-man --without-bench --without-innodb --program-prefix= --cache-file=/dev/null
Fix clinet/Makefile -->> LDFLAGS = -s -static
make
make install
php-4.3.10
CC=i386-linux-gcc CXX=i386-linux-g++ AR=i386-linux-ar ./configure --enable-static --build=i386-linux --host=i386-linux --with-thttpd=../thttpd-2.21b --with-mysql=/opt/mysql-5.0.18 --with-config-file-path=/opt/thttpd-2.21b/lib --prefix=/opt/php-4.3.10 --enable-memory-limit --disable-debug --without-gd --enable-sysvshm --cache-file=/dev/null
make
make install
cd thttpd-2.21b
CC=i386-linux-gcc CXX=i386-linux-g++ AR=i386-linux-ar ./configure --host=i386-linux --target=i386-linux --prefix=/opt/thttpd-2.21b --cache-file=/dev/null
make
make install
2008年1月28日 星期一
FLTK-utf8 中文顯示 by gziped pcf fonts
1.Requirement
nano-X support GZIP PCF fonts
字型可用firefly
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR11.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR12.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR13.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR14.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR15.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR16.pcf.gz
在PC上產生fonts.dir在加以修改
[gigijoe@localhost fonts]$ ls
fireflyR13.pcf.gz fireflyR16.pcf.gz
[gigijoe@localhost fonts]$ mkfontdir
[gigijoe@localhost fonts]$ cat fonts.dir
2
fireflyR13.pcf.gz -firefly-firefly new sung-medium-r-normal--13-120-75-75-p-129-iso10646-1
fireflyR16.pcf.gz -firefly-firefly new sung-medium-r-normal--16-150-75-75-p-159-iso10646-1
修改成
[gigijoe@localhost fonts]$ cat fonts.dir
2
fireflyR13.pcf.gz -firefly-sung-medium-r-normal--13-120-75-75-p-129-iso10646-1
fireflyR16.pcf.gz -firefly-sung-medium-r-normal--16-150-75-75-p-159-iso10646-1
修改 x11/Font_xlfd.cxx
////////////////////////////////////////////////////////////////
// The predefined fonts that fltk has:
static IFont fonts [] = {
{{"helvetica",0}, "-*-helvetica-medium-r-normal--*", fonts+1, fonts+2},
{{"helvetica",1}, "-*-helvetica-bold-r-normal--*", fonts+1, fonts+3},
{{"helvetica",2}, "-*-helvetica-medium-o-normal--*", fonts+3, fonts+2},
{{"helvetica",3}, "-*-helvetica-bold-o-normal--*", fonts+3, fonts+3},
{{"courier", 0}, "-*-courier-medium-r-normal--*", fonts+5, fonts+6},
{{"courier", 1}, "-*-courier-bold-r-normal--*", fonts+5, fonts+7},
{{"courier", 2}, "-*-courier-medium-o-normal--*", fonts+7, fonts+6},
{{"courier", 3}, "-*-courier-bold-o-normal--*", fonts+7, fonts+7},
{{"times", 0}, "-*-times-medium-r-normal--*", fonts+9, fonts+10},
{{"times", 1}, "-*-times-bold-r-normal--*", fonts+9, fonts+11},
{{"times", 2}, "-*-times-medium-i-normal--*", fonts+11,fonts+10},
{{"times", 3}, "-*-times-bold-i-normal--*", fonts+11,fonts+11},
{{"symbol", 0}, "-*-symbol-*", fonts+12,fonts+12},
{{"lucidatypewriter", 0}, "-*-lucidatypewriter-medium-r-normal-sans-*", fonts+14,fonts+14},
{{"lucidatypewriter", 1}, "-*-lucidatypewriter-bold-r-normal-sans-*", fonts+14,fonts+14},
{{"zapf dingbats", 0}, "-*-*zapf dingbats-*", fonts+15,fonts+15},
{{"sung", 0}, "-*-sung-medium-*-*--*", fonts+16,fonts+16},
};
fltk::Font* const fltk::HELVETICA = &(fonts[0].f);
fltk::Font* const fltk::HELVETICA_BOLD = &(fonts[1].f);
fltk::Font* const fltk::HELVETICA_ITALIC = &(fonts[2].f);
fltk::Font* const fltk::HELVETICA_BOLD_ITALIC = &(fonts[3].f);
fltk::Font* const fltk::COURIER = &(fonts[4].f);
fltk::Font* const fltk::COURIER_BOLD = &(fonts[5].f);
fltk::Font* const fltk::COURIER_ITALIC = &(fonts[6].f);
fltk::Font* const fltk::COURIER_BOLD_ITALIC = &(fonts[7].f);
fltk::Font* const fltk::TIMES = &(fonts[8].f);
fltk::Font* const fltk::TIMES_BOLD = &(fonts[9].f);
fltk::Font* const fltk::TIMES_ITALIC = &(fonts[10].f);
fltk::Font* const fltk::TIMES_BOLD_ITALIC = &(fonts[11].f);
fltk::Font* const fltk::SYMBOL_FONT = &(fonts[12].f);
fltk::Font* const fltk::SCREEN_FONT = &(fonts[13].f);
fltk::Font* const fltk::SCREEN_BOLD_FONT = &(fonts[14].f);
fltk::Font* const fltk::ZAPF_DINGBATS = &(fonts[15].f);
fltk::Font* const fltk::SUNG = &(fonts[16].f);
/*! For back-compatabilty with FLTK1, this turns an integer into one
of the built-in fonts. 0 = HELVETICA. */
fltk::Font* fltk::font(int i) {return &(fonts[i%16].f);}
修改 src/Style.cxx
// Do not change the contents of this ever. The themes depend on getting
// a known state initially. Make sure the documentation below matches the
// default values!
static void revert(Style* s) {
s->parent_ = 0; // this is the topmost style always
s->box_ = DOWN_BOX;
s->buttonbox_ = UP_BOX;
s->glyph_ = Widget::default_glyph;
s->labelfont_ = SUNG;
s->textfont_ = SUNG;
s->labeltype_ = NORMAL_LABEL;
s->color_ = WHITE; // GRAY99?
s->textcolor_ = BLACK;
s->selection_color_ = WINDOWS_BLUE;
s->selection_textcolor_= WHITE;
s->buttoncolor_ = GRAY75;
s->labelcolor_ = BLACK;
s->highlight_color_ = NO_COLOR;
s->highlight_textcolor_= NO_COLOR;
s->labelsize_ = 12;
s->textsize_ = 12;
s->leading_ = 2;
s->scrollbar_width_ = 15;
s->scrollbar_align_ = ALIGN_RIGHT|ALIGN_BOTTOM;
}
修改 fltk/Style.h
struct Font;
extern FL_API Font* const HELVETICA;
extern FL_API Font* const HELVETICA_BOLD;
extern FL_API Font* const HELVETICA_ITALIC;
extern FL_API Font* const HELVETICA_BOLD_ITALIC;
extern FL_API Font* const COURIER;
extern FL_API Font* const COURIER_BOLD;
extern FL_API Font* const COURIER_ITALIC;
extern FL_API Font* const COURIER_BOLD_ITALIC;
extern FL_API Font* const TIMES;
extern FL_API Font* const TIMES_BOLD;
extern FL_API Font* const TIMES_ITALIC;
extern FL_API Font* const TIMES_BOLD_ITALIC;
extern FL_API Font* const SYMBOL_FONT;
extern FL_API Font* const SCREEN_FONT;
extern FL_API Font* const SCREEN_BOLD_FONT;
extern FL_API Font* const ZAPF_DINGBATS;
extern FL_API Font* const SUNG;
patch
轉載
http://tw.myblog.yahoo.com/jw!GdTvlQ.YCR8E9rpahh6eqfZX9g--/article?mid=163&prev=164&next=149&l=f&fid=17
--- microwindows-0.91-old/src/engine/font_pcf.c 2003-06-16 11:20:09.000000000 +0800
+++ microwindows-0.91-new/src/engine/font_pcf.c 2008-01-10 14:28:37.000000000 +0800
@@ -245,6 +245,37 @@
return dwswap(n);
}
+/* read a 16-bit integer MSB16 format*/
+static unsigned short
+readMSB16(FILEP file)
+{
+ unsigned short s;
+
+ FREAD(file, &s, sizeof(s));
+#if !MW_CPU_BIG_ENDIAN
+ return ((((s) << 8) & 0xff00) | (((s) >> 8) & 0x00ff));
+#else
+ return s;
+#endif
+}
+
+/* read a 32-bit integer MSB32 format*/
+static unsigned long
+readMSB32(FILEP file)
+{
+ unsigned long n;
+
+ FREAD(file, &n, sizeof(n));
+#if !MW_CPU_BIG_ENDIAN
+ return ((((n) << 24) & 0xff000000L) | \
+ (((n) << 8) & 0x00ff0000L) | \
+ (((n) >> 8) & 0x0000ff00L) | \
+ (((n) >> 24) & 0x000000ffL) );
+#else
+ return n;
+#endif
+}
+
/* Get the offset of the given field */
static int
pcf_get_offset(int item)
@@ -272,21 +303,26 @@
struct prop_entry *p;
unsigned char *string_buffer, *spos;
+ unsigned long (*read32)(FILEP);
if ((offset = pcf_get_offset(PCF_PROPERTIES)) == -1)
return (-1);
FSEEK(file, offset, SEEK_SET);
format = readLSB32(file);
- num_props = readLSB32(file);
+ if (format & PCF_BIT_MASK)
+ read32 = readMSB32;
+ else
+ read32 = readLSB32;
+ num_props = read32(file);
p = *prop = (struct prop_entry *) malloc(num_props *
sizeof(struct prop_entry));
for (i = 0; i < num_props; i++) {
- p[i].name = readLSB32(file);
+ p[i].name = read32(file);
p[i].is_string = readINT8(file);
- p[i].value = readLSB32(file);
+ p[i].value = read32(file);
}
/* Pad to 32 bit multiples */
@@ -295,7 +331,7 @@
/* Read the entire set of strings into memory */
- ssize = readLSB32(file);
+ ssize = read32(file);
spos = string_buffer = (unsigned char *) ALLOCA(ssize);
FREAD(file, string_buffer, ssize);
@@ -333,6 +369,7 @@
unsigned long *o;
unsigned char *b;
unsigned long bmsize[GLYPHPADOPTIONS];
+ unsigned long (*read32)(FILEP);
if ((offset = pcf_get_offset(PCF_BITMAPS)) == -1)
return -1;
@@ -340,15 +377,18 @@
format = readLSB32(file);
endian = (format & PCF_BIT_MASK)? PCF_LSB_FIRST: PCF_MSB_FIRST;
-
- num_glyphs = readLSB32(file);
+ if (endian == PCF_LSB_FIRST)
+ read32 = readMSB32;
+ else
+ read32 = readLSB32;
+ num_glyphs = read32(file);
o = *offsets = (unsigned long *)malloc(num_glyphs * sizeof(unsigned long));
for (i=0; i < num_glyphs; ++i)
- o[i] = readLSB32(file);
+ o[i] = read32(file);
for (i=0; i < GLYPHPADOPTIONS; ++i)
- bmsize[i] = readLSB32(file);
+ bmsize[i] = read32(file);
pad = format & PCF_GLYPH_PAD_MASK;
*bits_size = bmsize[pad]? bmsize[pad] : 1;
@@ -358,14 +398,9 @@
FREAD(file, b, *bits_size);
/* convert bitmaps*/
- bit_order_invert(b, *bits_size);
-#if MW_CPU_BIG_ENDIAN
- if (endian == PCF_LSB_FIRST)
- two_byte_swap(b, *bits_size);
-#else
if (endian == PCF_MSB_FIRST)
- two_byte_swap(b, *bits_size);
-#endif
+ bit_order_invert(b, *bits_size);
+ two_byte_swap(b, *bits_size);
return num_glyphs;
}
@@ -376,29 +411,39 @@
long i, size, offset;
unsigned long format;
struct metric_entry *m;
+ unsigned long (*read32)(FILEP);
+ unsigned short (*read16)(FILEP);
if ((offset = pcf_get_offset(PCF_METRICS)) == -1)
return -1;
FSEEK(file, offset, SEEK_SET);
format = readLSB32(file);
+ if (format & PCF_BIT_MASK) {
+ read16 = readMSB16;
+ read32 = readMSB32;
+ }
+ else {
+ read16 = readLSB16;
+ read32 = readLSB32;
+ }
if ((format & PCF_FORMAT_MASK) == PCF_DEFAULT_FORMAT) {
- size = readLSB32(file); /* 32 bits - Number of metrics*/
+ size = read32(file); /* 32 bits - Number of metrics*/
m = *metrics = (struct metric_entry *) malloc(size *
sizeof(struct metric_entry));
for (i=0; i < size; i++) {
- m[i].leftBearing = readLSB16(file);
- m[i].rightBearing = readLSB16(file);
- m[i].width = readLSB16(file);
- m[i].ascent = readLSB16(file);
- m[i].descent = readLSB16(file);
- m[i].attributes = readLSB16(file);
+ m[i].leftBearing = read16(file);
+ m[i].rightBearing = read16(file);
+ m[i].width = read16(file);
+ m[i].ascent = read16(file);
+ m[i].descent = read16(file);
+ m[i].attributes = read16(file);
}
} else {
- size = readLSB16(file); /* 16 bits - Number of metrics*/
+ size = read16(file); /* 16 bits - Number of metrics*/
m = *metrics = (struct metric_entry *) malloc(size *
sizeof(struct metric_entry));
@@ -421,30 +466,35 @@
long offset, n;
unsigned long format;
struct encoding_entry *e;
+ unsigned short (*read16)(FILEP);
if ((offset = pcf_get_offset(PCF_BDF_ENCODINGS)) == -1)
return -1;
FSEEK(file, offset, SEEK_SET);
format = readLSB32(file);
+ if (format & PCF_BIT_MASK)
+ read16 = readMSB16;
+ else
+ read16 = readLSB16;
e = *encoding = (struct encoding_entry *)
malloc(sizeof(struct encoding_entry));
- e->min_byte2 = readLSB16(file);
- e->max_byte2 = readLSB16(file);
- e->min_byte1 = readLSB16(file);
- e->max_byte1 = readLSB16(file);
- e->defaultchar = readLSB16(file);
+ e->min_byte2 = read16(file);
+ e->max_byte2 = read16(file);
+ e->min_byte1 = read16(file);
+ e->max_byte1 = read16(file);
+ e->defaultchar = read16(file);
e->count = (e->max_byte2 - e->min_byte2 + 1) *
(e->max_byte1 - e->min_byte1 + 1);
e->map = (unsigned short *) malloc(e->count * sizeof(unsigned short));
DPRINTF("def char %d (%x)\n", e->defaultchar, e->defaultchar);
for (n = 0; n < e->count; ++n) {
- e->map[n] = readLSB16(file);
+ e->map[n] = read16(file);
/*DPRINTF("ncode %x (%c) %x\n", n, n, e->map[n]);*/
}
- DPRINTF("size %d byte1 %d,%d byte2 %d,%d\n", e->count,
+ DPRINTF("size %ld byte1 %d,%d byte2 %d,%d\n", e->count,
e->min_byte1, e->max_byte1, e->min_byte2, e->max_byte2);
return e->count;
}
2.Compile procdure as FLTK
3.修改 test/utf8.cxx
//"-*-fixed-*-*-*--*-*-*-*-*-*-gost19768.74-*,"
"-*-fixed-*-iso10646-1"*/
/*"-*-unifont-*-*-*-*-*-*-*-*-*-*-iso10646-1"*/ <<-- Mark這行
"-*-sung-medium-*-*--*-*-*-*-*-*-iso10646-1" <<-- 加入這行,這樣才會認得firefly字型
#if 0
xchar arabic1[] ={/*8238,*/ 1610, 0x20, 1608, 0x20, 1606, 0x20, 1616, 0x20, 1603, 0x20, 1608, 0x20, 1583, 0};
l = fl_unicode2utf(arabic1, 14, abuf);
abuf[l] = 0;
#endif
strcpy(abuf, "中華電信");
4.run utf8
nano-X support GZIP PCF fonts
字型可用firefly
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR11.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR12.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR13.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR14.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR15.pcf.gz
http://cle.linux.org.tw/fonts/FireFly/bitmaps/pcf/fireflyR16.pcf.gz
在PC上產生fonts.dir在加以修改
[gigijoe@localhost fonts]$ ls
fireflyR13.pcf.gz fireflyR16.pcf.gz
[gigijoe@localhost fonts]$ mkfontdir
[gigijoe@localhost fonts]$ cat fonts.dir
2
fireflyR13.pcf.gz -firefly-firefly new sung-medium-r-normal--13-120-75-75-p-129-iso10646-1
fireflyR16.pcf.gz -firefly-firefly new sung-medium-r-normal--16-150-75-75-p-159-iso10646-1
修改成
[gigijoe@localhost fonts]$ cat fonts.dir
2
fireflyR13.pcf.gz -firefly-sung-medium-r-normal--13-120-75-75-p-129-iso10646-1
fireflyR16.pcf.gz -firefly-sung-medium-r-normal--16-150-75-75-p-159-iso10646-1
修改 x11/Font_xlfd.cxx
////////////////////////////////////////////////////////////////
// The predefined fonts that fltk has:
static IFont fonts [] = {
{{"helvetica",0}, "-*-helvetica-medium-r-normal--*", fonts+1, fonts+2},
{{"helvetica",1}, "-*-helvetica-bold-r-normal--*", fonts+1, fonts+3},
{{"helvetica",2}, "-*-helvetica-medium-o-normal--*", fonts+3, fonts+2},
{{"helvetica",3}, "-*-helvetica-bold-o-normal--*", fonts+3, fonts+3},
{{"courier", 0}, "-*-courier-medium-r-normal--*", fonts+5, fonts+6},
{{"courier", 1}, "-*-courier-bold-r-normal--*", fonts+5, fonts+7},
{{"courier", 2}, "-*-courier-medium-o-normal--*", fonts+7, fonts+6},
{{"courier", 3}, "-*-courier-bold-o-normal--*", fonts+7, fonts+7},
{{"times", 0}, "-*-times-medium-r-normal--*", fonts+9, fonts+10},
{{"times", 1}, "-*-times-bold-r-normal--*", fonts+9, fonts+11},
{{"times", 2}, "-*-times-medium-i-normal--*", fonts+11,fonts+10},
{{"times", 3}, "-*-times-bold-i-normal--*", fonts+11,fonts+11},
{{"symbol", 0}, "-*-symbol-*", fonts+12,fonts+12},
{{"lucidatypewriter", 0}, "-*-lucidatypewriter-medium-r-normal-sans-*", fonts+14,fonts+14},
{{"lucidatypewriter", 1}, "-*-lucidatypewriter-bold-r-normal-sans-*", fonts+14,fonts+14},
{{"zapf dingbats", 0}, "-*-*zapf dingbats-*", fonts+15,fonts+15},
{{"sung", 0}, "-*-sung-medium-*-*--*", fonts+16,fonts+16},
};
fltk::Font* const fltk::HELVETICA = &(fonts[0].f);
fltk::Font* const fltk::HELVETICA_BOLD = &(fonts[1].f);
fltk::Font* const fltk::HELVETICA_ITALIC = &(fonts[2].f);
fltk::Font* const fltk::HELVETICA_BOLD_ITALIC = &(fonts[3].f);
fltk::Font* const fltk::COURIER = &(fonts[4].f);
fltk::Font* const fltk::COURIER_BOLD = &(fonts[5].f);
fltk::Font* const fltk::COURIER_ITALIC = &(fonts[6].f);
fltk::Font* const fltk::COURIER_BOLD_ITALIC = &(fonts[7].f);
fltk::Font* const fltk::TIMES = &(fonts[8].f);
fltk::Font* const fltk::TIMES_BOLD = &(fonts[9].f);
fltk::Font* const fltk::TIMES_ITALIC = &(fonts[10].f);
fltk::Font* const fltk::TIMES_BOLD_ITALIC = &(fonts[11].f);
fltk::Font* const fltk::SYMBOL_FONT = &(fonts[12].f);
fltk::Font* const fltk::SCREEN_FONT = &(fonts[13].f);
fltk::Font* const fltk::SCREEN_BOLD_FONT = &(fonts[14].f);
fltk::Font* const fltk::ZAPF_DINGBATS = &(fonts[15].f);
fltk::Font* const fltk::SUNG = &(fonts[16].f);
/*! For back-compatabilty with FLTK1, this turns an integer into one
of the built-in fonts. 0 = HELVETICA. */
fltk::Font* fltk::font(int i) {return &(fonts[i%16].f);}
修改 src/Style.cxx
// Do not change the contents of this ever. The themes depend on getting
// a known state initially. Make sure the documentation below matches the
// default values!
static void revert(Style* s) {
s->parent_ = 0; // this is the topmost style always
s->box_ = DOWN_BOX;
s->buttonbox_ = UP_BOX;
s->glyph_ = Widget::default_glyph;
s->labelfont_ = SUNG;
s->textfont_ = SUNG;
s->labeltype_ = NORMAL_LABEL;
s->color_ = WHITE; // GRAY99?
s->textcolor_ = BLACK;
s->selection_color_ = WINDOWS_BLUE;
s->selection_textcolor_= WHITE;
s->buttoncolor_ = GRAY75;
s->labelcolor_ = BLACK;
s->highlight_color_ = NO_COLOR;
s->highlight_textcolor_= NO_COLOR;
s->labelsize_ = 12;
s->textsize_ = 12;
s->leading_ = 2;
s->scrollbar_width_ = 15;
s->scrollbar_align_ = ALIGN_RIGHT|ALIGN_BOTTOM;
}
修改 fltk/Style.h
struct Font;
extern FL_API Font* const HELVETICA;
extern FL_API Font* const HELVETICA_BOLD;
extern FL_API Font* const HELVETICA_ITALIC;
extern FL_API Font* const HELVETICA_BOLD_ITALIC;
extern FL_API Font* const COURIER;
extern FL_API Font* const COURIER_BOLD;
extern FL_API Font* const COURIER_ITALIC;
extern FL_API Font* const COURIER_BOLD_ITALIC;
extern FL_API Font* const TIMES;
extern FL_API Font* const TIMES_BOLD;
extern FL_API Font* const TIMES_ITALIC;
extern FL_API Font* const TIMES_BOLD_ITALIC;
extern FL_API Font* const SYMBOL_FONT;
extern FL_API Font* const SCREEN_FONT;
extern FL_API Font* const SCREEN_BOLD_FONT;
extern FL_API Font* const ZAPF_DINGBATS;
extern FL_API Font* const SUNG;
patch
轉載
http://tw.myblog.yahoo.com/jw!GdTvlQ.YCR8E9rpahh6eqfZX9g--/article?mid=163&prev=164&next=149&l=f&fid=17
--- microwindows-0.91-old/src/engine/font_pcf.c 2003-06-16 11:20:09.000000000 +0800
+++ microwindows-0.91-new/src/engine/font_pcf.c 2008-01-10 14:28:37.000000000 +0800
@@ -245,6 +245,37 @@
return dwswap(n);
}
+/* read a 16-bit integer MSB16 format*/
+static unsigned short
+readMSB16(FILEP file)
+{
+ unsigned short s;
+
+ FREAD(file, &s, sizeof(s));
+#if !MW_CPU_BIG_ENDIAN
+ return ((((s) << 8) & 0xff00) | (((s) >> 8) & 0x00ff));
+#else
+ return s;
+#endif
+}
+
+/* read a 32-bit integer MSB32 format*/
+static unsigned long
+readMSB32(FILEP file)
+{
+ unsigned long n;
+
+ FREAD(file, &n, sizeof(n));
+#if !MW_CPU_BIG_ENDIAN
+ return ((((n) << 24) & 0xff000000L) | \
+ (((n) << 8) & 0x00ff0000L) | \
+ (((n) >> 8) & 0x0000ff00L) | \
+ (((n) >> 24) & 0x000000ffL) );
+#else
+ return n;
+#endif
+}
+
/* Get the offset of the given field */
static int
pcf_get_offset(int item)
@@ -272,21 +303,26 @@
struct prop_entry *p;
unsigned char *string_buffer, *spos;
+ unsigned long (*read32)(FILEP);
if ((offset = pcf_get_offset(PCF_PROPERTIES)) == -1)
return (-1);
FSEEK(file, offset, SEEK_SET);
format = readLSB32(file);
- num_props = readLSB32(file);
+ if (format & PCF_BIT_MASK)
+ read32 = readMSB32;
+ else
+ read32 = readLSB32;
+ num_props = read32(file);
p = *prop = (struct prop_entry *) malloc(num_props *
sizeof(struct prop_entry));
for (i = 0; i < num_props; i++) {
- p[i].name = readLSB32(file);
+ p[i].name = read32(file);
p[i].is_string = readINT8(file);
- p[i].value = readLSB32(file);
+ p[i].value = read32(file);
}
/* Pad to 32 bit multiples */
@@ -295,7 +331,7 @@
/* Read the entire set of strings into memory */
- ssize = readLSB32(file);
+ ssize = read32(file);
spos = string_buffer = (unsigned char *) ALLOCA(ssize);
FREAD(file, string_buffer, ssize);
@@ -333,6 +369,7 @@
unsigned long *o;
unsigned char *b;
unsigned long bmsize[GLYPHPADOPTIONS];
+ unsigned long (*read32)(FILEP);
if ((offset = pcf_get_offset(PCF_BITMAPS)) == -1)
return -1;
@@ -340,15 +377,18 @@
format = readLSB32(file);
endian = (format & PCF_BIT_MASK)? PCF_LSB_FIRST: PCF_MSB_FIRST;
-
- num_glyphs = readLSB32(file);
+ if (endian == PCF_LSB_FIRST)
+ read32 = readMSB32;
+ else
+ read32 = readLSB32;
+ num_glyphs = read32(file);
o = *offsets = (unsigned long *)malloc(num_glyphs * sizeof(unsigned long));
for (i=0; i < num_glyphs; ++i)
- o[i] = readLSB32(file);
+ o[i] = read32(file);
for (i=0; i < GLYPHPADOPTIONS; ++i)
- bmsize[i] = readLSB32(file);
+ bmsize[i] = read32(file);
pad = format & PCF_GLYPH_PAD_MASK;
*bits_size = bmsize[pad]? bmsize[pad] : 1;
@@ -358,14 +398,9 @@
FREAD(file, b, *bits_size);
/* convert bitmaps*/
- bit_order_invert(b, *bits_size);
-#if MW_CPU_BIG_ENDIAN
- if (endian == PCF_LSB_FIRST)
- two_byte_swap(b, *bits_size);
-#else
if (endian == PCF_MSB_FIRST)
- two_byte_swap(b, *bits_size);
-#endif
+ bit_order_invert(b, *bits_size);
+ two_byte_swap(b, *bits_size);
return num_glyphs;
}
@@ -376,29 +411,39 @@
long i, size, offset;
unsigned long format;
struct metric_entry *m;
+ unsigned long (*read32)(FILEP);
+ unsigned short (*read16)(FILEP);
if ((offset = pcf_get_offset(PCF_METRICS)) == -1)
return -1;
FSEEK(file, offset, SEEK_SET);
format = readLSB32(file);
+ if (format & PCF_BIT_MASK) {
+ read16 = readMSB16;
+ read32 = readMSB32;
+ }
+ else {
+ read16 = readLSB16;
+ read32 = readLSB32;
+ }
if ((format & PCF_FORMAT_MASK) == PCF_DEFAULT_FORMAT) {
- size = readLSB32(file); /* 32 bits - Number of metrics*/
+ size = read32(file); /* 32 bits - Number of metrics*/
m = *metrics = (struct metric_entry *) malloc(size *
sizeof(struct metric_entry));
for (i=0; i < size; i++) {
- m[i].leftBearing = readLSB16(file);
- m[i].rightBearing = readLSB16(file);
- m[i].width = readLSB16(file);
- m[i].ascent = readLSB16(file);
- m[i].descent = readLSB16(file);
- m[i].attributes = readLSB16(file);
+ m[i].leftBearing = read16(file);
+ m[i].rightBearing = read16(file);
+ m[i].width = read16(file);
+ m[i].ascent = read16(file);
+ m[i].descent = read16(file);
+ m[i].attributes = read16(file);
}
} else {
- size = readLSB16(file); /* 16 bits - Number of metrics*/
+ size = read16(file); /* 16 bits - Number of metrics*/
m = *metrics = (struct metric_entry *) malloc(size *
sizeof(struct metric_entry));
@@ -421,30 +466,35 @@
long offset, n;
unsigned long format;
struct encoding_entry *e;
+ unsigned short (*read16)(FILEP);
if ((offset = pcf_get_offset(PCF_BDF_ENCODINGS)) == -1)
return -1;
FSEEK(file, offset, SEEK_SET);
format = readLSB32(file);
+ if (format & PCF_BIT_MASK)
+ read16 = readMSB16;
+ else
+ read16 = readLSB16;
e = *encoding = (struct encoding_entry *)
malloc(sizeof(struct encoding_entry));
- e->min_byte2 = readLSB16(file);
- e->max_byte2 = readLSB16(file);
- e->min_byte1 = readLSB16(file);
- e->max_byte1 = readLSB16(file);
- e->defaultchar = readLSB16(file);
+ e->min_byte2 = read16(file);
+ e->max_byte2 = read16(file);
+ e->min_byte1 = read16(file);
+ e->max_byte1 = read16(file);
+ e->defaultchar = read16(file);
e->count = (e->max_byte2 - e->min_byte2 + 1) *
(e->max_byte1 - e->min_byte1 + 1);
e->map = (unsigned short *) malloc(e->count * sizeof(unsigned short));
DPRINTF("def char %d (%x)\n", e->defaultchar, e->defaultchar);
for (n = 0; n < e->count; ++n) {
- e->map[n] = readLSB16(file);
+ e->map[n] = read16(file);
/*DPRINTF("ncode %x (%c) %x\n", n, n, e->map[n]);*/
}
- DPRINTF("size %d byte1 %d,%d byte2 %d,%d\n", e->count,
+ DPRINTF("size %ld byte1 %d,%d byte2 %d,%d\n", e->count,
e->min_byte1, e->max_byte1, e->min_byte2, e->max_byte2);
return e->count;
}
2.Compile procdure as FLTK
3.修改 test/utf8.cxx
//"-*-fixed-*-*-*--*-*-*-*-*-*-gost19768.74-*,"
"-*-fixed-*-iso10646-1"*/
/*"-*-unifont-*-*-*-*-*-*-*-*-*-*-iso10646-1"*/ <<-- Mark這行
"-*-sung-medium-*-*--*-*-*-*-*-*-iso10646-1" <<-- 加入這行,這樣才會認得firefly字型
#if 0
xchar arabic1[] ={/*8238,*/ 1610, 0x20, 1608, 0x20, 1606, 0x20, 1616, 0x20, 1603, 0x20, 1608, 0x20, 1583, 0};
l = fl_unicode2utf(arabic1, 14, abuf);
abuf[l] = 0;
#endif
strcpy(abuf, "中華電信");
4.run utf8
2008年1月15日 星期二
Build nxlib-0.45
1.Modify Makefile
MWIN=../microwindows-0.91/src
X11_INCLUDE=$(X11)/include
CC = mipsel-linux-gcc
CFLAGS += -G 0 -Wall $(DEBUG) -I$(MWIN_INCLUDE) -I$(X11_INCLUDE)
xCFLAGS += -G 0 -O2 -fno-strength-reduce
libnx11.a: keysymstr.h $(OBJS)
mipsel-linux-ar r libnx11.a $(OBJS)
Add Selection.o to $OBJS
Modify
# perl ./keymap.pl $(X11_INCLUDE)/X11 > ./keysymstr.h
perl ./keymap.pl . > ./keysymstr.h
2. CFLAGS="-D_XP_PRINT_SERVER_" make
3.http://www.linuxhacker.org/cgi-bin/ezmlm-cgi/5/11115
FLTK with nxlib and nano-X
1.Modify configure.in
# LIBS="$LIBS -lXext -lX11 $X_EXTRA_LIBS"
If static link
LIBS="$LIBS -lnx11 -lnano-X $X_EXTRA_LIBS"
If dynamic link
LIBS="$LIBS -lX11 -lnano-X $X_EXTRA_LIBS"
2.Fix
Compiling Fl_x.cxx...
Fl_x.cxx: In function `int fl_wait(double)':
Fl_x.cxx:238: error: impossible constraint in `asm'
Fl_x.cxx:239: error: impossible constraint in `asm'
Fl_x.cxx:240: error: impossible constraint in `asm'
make[1]: *** [Fl_x.o] Error 1
The problem casue by reference to host header file.
Remove -I/usr/include to solve it.
Because we need X header files
cp -a /usr/include/X11 /usr/local/MIPSEL/mipsel-linux/include/
Add config param --x-include=-Iinclude
3.Configure
CFLAGS="-G 0" CXXFLAGS="-G 0" LDFLAGS="-s -L$PWD/../nxlib-0.45 -L$PWD/../microwindows-0.91/src/lib" ./configure --host=mipsel-linux --target=mipsel-linux --enable-shared --with-x --disable-gl --disable-cygwin --x-includes=include/ --x-libraries=$PWD/../nxlib-0.45 --cache-file=/dev/null
Fix ar in makeinclude
LIBCOMMAND = mipsel-linux-ar cr
Fix strip in makeinclude
STRIP = mipsel-linux-strip
4.make
5.Fix
Linking fluid...
../lib/libfltk.a(Fl_x.o)(.text+0x1420): In function `Fl::paste(Fl_Widget&, int)':
: undefined reference to `XConvertSelection'
../lib/libfltk.a(Fl_x.o)(.text+0x1624): In function `Fl::copy(char const*, int, int)':
: undefined reference to `XSetSelectionOwner'
../lib/libfltk.a(Fl_x.o)(.text+0x22c4): In function `fl_handle(_XEvent const&)':
: undefined reference to `XConvertSelection'
../lib/libfltk.a(fl_dnd.o)(.text+0x29c): In function `Fl::dnd()':
: undefined reference to `XSetSelectionOwner'
collect2: ld returned 1 exit status
Append the following to nxlib-0.45/stub.c
/* required for FLTK 1.1.7*/
int XConvertSelection() { printf("XConvertSelection called\n"); return 0; }
int XSetSelectionOwner() { printf("XSetSelectionOwner called\n"); return 0; }
6.vi test/Makefile
Mark following item
# fast_slow(EXEEXT) \
# keyboard$(EXEEXT) \
# mandelbrot$(EXEEXT) \
# preferences$(EXEEXT) \
# radio$(EXEEXT) \
# resize$(EXEEXT) \
# sudoku$(EXEEXT) \
# tabs$(EXEEXT) \
# valuators$(EXEEXT)
7.Copy shared library to lib/
cp src/*.so.* lib/
8.make again to let demo programs on test/ as dynamic link
9.Library needed
/tmp # /lib/ld-2.2.5.so --list ./utf8
libfltk-utf8.so.1.1 => /phone/lib/libfltk-utf8.so.1.1 (0x2aaa9000)
libm.so.6 => /lib/libm.so.6 (0x2aba3000)
libX11.so.6 => /phone/lib/libX11.so.6 (0x2ac65000)
libnano-X.so => /usr/lib/libnano-X.so (0x2acdf000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x2ad31000)
libc.so.6 => /lib/libc.so.6 (0x2ad82000)
/lib/ld.so.1 => /lib/ld-2.2.5.so (0x55550000)
# LIBS="$LIBS -lXext -lX11 $X_EXTRA_LIBS"
If static link
LIBS="$LIBS -lnx11 -lnano-X $X_EXTRA_LIBS"
If dynamic link
LIBS="$LIBS -lX11 -lnano-X $X_EXTRA_LIBS"
2.Fix
Compiling Fl_x.cxx...
Fl_x.cxx: In function `int fl_wait(double)':
Fl_x.cxx:238: error: impossible constraint in `asm'
Fl_x.cxx:239: error: impossible constraint in `asm'
Fl_x.cxx:240: error: impossible constraint in `asm'
make[1]: *** [Fl_x.o] Error 1
The problem casue by reference to host header file.
Remove -I/usr/include to solve it.
Because we need X header files
cp -a /usr/include/X11 /usr/local/MIPSEL/mipsel-linux/include/
Add config param --x-include=-Iinclude
3.Configure
CFLAGS="-G 0" CXXFLAGS="-G 0" LDFLAGS="-s -L$PWD/../nxlib-0.45 -L$PWD/../microwindows-0.91/src/lib" ./configure --host=mipsel-linux --target=mipsel-linux --enable-shared --with-x --disable-gl --disable-cygwin --x-includes=include/ --x-libraries=$PWD/../nxlib-0.45 --cache-file=/dev/null
Fix ar in makeinclude
LIBCOMMAND = mipsel-linux-ar cr
Fix strip in makeinclude
STRIP = mipsel-linux-strip
4.make
5.Fix
Linking fluid...
../lib/libfltk.a(Fl_x.o)(.text+0x1420): In function `Fl::paste(Fl_Widget&, int)':
: undefined reference to `XConvertSelection'
../lib/libfltk.a(Fl_x.o)(.text+0x1624): In function `Fl::copy(char const*, int, int)':
: undefined reference to `XSetSelectionOwner'
../lib/libfltk.a(Fl_x.o)(.text+0x22c4): In function `fl_handle(_XEvent const&)':
: undefined reference to `XConvertSelection'
../lib/libfltk.a(fl_dnd.o)(.text+0x29c): In function `Fl::dnd()':
: undefined reference to `XSetSelectionOwner'
collect2: ld returned 1 exit status
Append the following to nxlib-0.45/stub.c
/* required for FLTK 1.1.7*/
int XConvertSelection() { printf("XConvertSelection called\n"); return 0; }
int XSetSelectionOwner() { printf("XSetSelectionOwner called\n"); return 0; }
6.vi test/Makefile
Mark following item
# fast_slow(EXEEXT) \
# keyboard$(EXEEXT) \
# mandelbrot$(EXEEXT) \
# preferences$(EXEEXT) \
# radio$(EXEEXT) \
# resize$(EXEEXT) \
# sudoku$(EXEEXT) \
# tabs$(EXEEXT) \
# valuators$(EXEEXT)
7.Copy shared library to lib/
cp src/*.so.* lib/
8.make again to let demo programs on test/ as dynamic link
9.Library needed
/tmp # /lib/ld-2.2.5.so --list ./utf8
libfltk-utf8.so.1.1 => /phone/lib/libfltk-utf8.so.1.1 (0x2aaa9000)
libm.so.6 => /lib/libm.so.6 (0x2aba3000)
libX11.so.6 => /phone/lib/libX11.so.6 (0x2ac65000)
libnano-X.so => /usr/lib/libnano-X.so (0x2acdf000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x2ad31000)
libc.so.6 => /lib/libc.so.6 (0x2ad82000)
/lib/ld.so.1 => /lib/ld-2.2.5.so (0x55550000)
2008年1月6日 星期日
microwindew True Type Fonts support
http://tw.myblog.yahoo.com/jw!GdTvlQ.YCR8E9rpahh6eqfZX9g--/article?mid=128&prev=132&next=126&l=f&fid=17
1.Set ttf font environment, if *.ttf at /tmp
export MWFONTS=/tmp
2.Load ttf font
GR_FONT_ID ttf_font;
ttf_font = GrCreateFont("kaiu", 12, NULL);
GrSetFontAttr(ttf_font, GR_TFANTIALIAS|GR_TFKERNING, 0);
3.Show ttf font
GrSetGCFont(w->gid, ttf_font);
GrText(w->wid, w->gid, 20, 20, "ABCDEFGHIJK", 8, GR_TFASCII | GR_TFTOP);
訂閱:
文章 (Atom)