comparison font/font_peer_x11.cc @ 65:4416cfac86ae

Convert EUC-JP files to UTF8
author Thibaut Girka <thib@sitedethib.com>
date Fri, 26 Nov 2010 10:53:15 +0100
parents 15a18fbe6f21
children
comparison
equal deleted inserted replaced
64:045ca45f9610 65:4416cfac86ae
59 59
60 /*********************************** 60 /***********************************
61 ** 61 **
62 ** Fontinfo / FontSetInfo 62 ** Fontinfo / FontSetInfo
63 ** 63 **
64 ** fontset から特定 pixel size を持つ 64 ** fontset 劫 pixel size
65 ** 別のfontsetを作成するためのクラス 65 ** ャfontset篏
66 */ 66 */
67 struct FontInfo { 67 struct FontInfo {
68 std::map<int, string> fontlist; 68 std::map<int, string> fontlist;
69 FontInfo(Display* display, const char* fontname_orig); 69 FontInfo(Display* display, const char* fontname_orig);
70 string Search(int pixsize); 70 string Search(int pixsize);
81 ** 81 **
82 ** Methods of Fontinfo / FontSetInfo 82 ** Methods of Fontinfo / FontSetInfo
83 ** 83 **
84 */ 84 */
85 FontInfo::FontInfo(Display* display, const char* fontname_orig) { 85 FontInfo::FontInfo(Display* display, const char* fontname_orig) {
86 /* フォントの大きさ関係の情報を消去 */ 86 /* 潟紊с≫宴羔サ */
87 int i; 87 int i;
88 char* fontname = new char[strlen(fontname_orig)+50]; 88 char* fontname = new char[strlen(fontname_orig)+50];
89 int minus_count = 0; 89 int minus_count = 0;
90 bool is_skip = false; 90 bool is_skip = false;
91 int fc = 0; 91 int fc = 0;
100 is_skip = false; 100 is_skip = false;
101 } 101 }
102 } 102 }
103 if (! is_skip) fontname[fc++] = fontname_orig[i]; 103 if (! is_skip) fontname[fc++] = fontname_orig[i];
104 } 104 }
105 /* フォント情報を得る */ 105 /* 潟宴緇 */
106 fontname[fc] = 0; 106 fontname[fc] = 0;
107 int count; 107 int count;
108 char** fontnamelist = XListFonts(display, fontname, 100, &count); 108 char** fontnamelist = XListFonts(display, fontname, 100, &count);
109 for (i=0; i<count; i++) { 109 for (i=0; i<count; i++) {
110 char* curfont = fontnamelist[i]; 110 char* curfont = fontnamelist[i];
111 /* fontname から pixel size 情報を得る */ 111 /* fontname pixel size 宴緇 */
112 int j; 112 int j;
113 int minus_count = 0; 113 int minus_count = 0;
114 for (j=0; curfont[j] != 0; j++) { 114 for (j=0; curfont[j] != 0; j++) {
115 if (curfont[j] == '-') minus_count++; 115 if (curfont[j] == '-') minus_count++;
116 if (minus_count == 7) { 116 if (minus_count == 7) {
120 } 120 }
121 break; 121 break;
122 } 122 }
123 } 123 }
124 } 124 }
125 /* 検索に失敗した場合、とりあえず fontname を入れておく */ 125 /* 罎膣≪紊掩翫 fontname ャ */
126 if (fontlist.find(0) == fontlist.end()) { 126 if (fontlist.find(0) == fontlist.end()) {
127 fontlist[0] = string(fontname); 127 fontlist[0] = string(fontname);
128 } 128 }
129 XFreeFontNames(fontnamelist); 129 XFreeFontNames(fontnamelist);
130 delete[] fontname; 130 delete[] fontname;
131 return; 131 return;
132 } 132 }
133 string FontInfo::Search(int pixsize) { 133 string FontInfo::Search(int pixsize) {
134 int i; 134 int i;
135 /* pixsize に近いフォントが(あれば)帰す */ 135 /* pixsize 菴潟()絽違 */
136 if (fontlist.find(pixsize) != fontlist.end()) return fontlist[pixsize]; 136 if (fontlist.find(pixsize) != fontlist.end()) return fontlist[pixsize];
137 for (i=1; i<4; i++) { 137 for (i=1; i<4; i++) {
138 if (fontlist.find(pixsize-i) != fontlist.end()) return fontlist[pixsize-i]; 138 if (fontlist.find(pixsize-i) != fontlist.end()) return fontlist[pixsize-i];
139 if (fontlist.find(pixsize+i) != fontlist.end()) return fontlist[pixsize+i]; 139 if (fontlist.find(pixsize+i) != fontlist.end()) return fontlist[pixsize+i];
140 } 140 }
141 /* 見つからない:fontlist[0] を加工して帰す */ 141 /* 荀ゃ鐚fontlist[0] 綏ャ絽違 */
142 /* pt/xres/yres などのフィールドに '-0-' というのがあれば '-*-'に変換 142 /* pt/xres/yres c若 '-0-' '-*-'紊
143 ** pixsize は与えられた pixsize にする 143 ** pixsize 筝 pixsize
144 */ 144 */
145 string basefont_s = fontlist[0]; 145 string basefont_s = fontlist[0];
146 const char* basefont = basefont_s.c_str(); 146 const char* basefont = basefont_s.c_str();
147 char* retfont = new char[strlen(basefont)+50]; 147 char* retfont = new char[strlen(basefont)+50];
148 int minus_count = 0; 148 int minus_count = 0;
244 244
245 if (visual->c_class != TrueColor && visual->c_class != DirectColor) { 245 if (visual->c_class != TrueColor && visual->c_class != DirectColor) {
246 string err = "XKFont::PeerX11:PeerX11() : No supported Color mode of X : neither TrueColor nor DirectColor"; 246 string err = "XKFont::PeerX11:PeerX11() : No supported Color mode of X : neither TrueColor nor DirectColor";
247 throw std::runtime_error(err); 247 throw std::runtime_error(err);
248 } 248 }
249 /* 色の初期化 */ 249 /* 蚊 */
250 white = visual->red_mask | visual->green_mask | visual->blue_mask; 250 white = visual->red_mask | visual->green_mask | visual->blue_mask;
251 black = 0; 251 black = 0;
252 if (visual->green_mask == 0) { 252 if (visual->green_mask == 0) {
253 string err = "XKFont::PeerX11:PeerX11() : Invalid Visual on X"; 253 string err = "XKFont::PeerX11:PeerX11() : Invalid Visual on X";
254 throw std::runtime_error(err); 254 throw std::runtime_error(err);
264 colortable[i] = i*255/tablesize; 264 colortable[i] = i*255/tablesize;
265 } 265 }
266 266
267 XSupportsLocale(); //FIXME: er... yes? 267 XSupportsLocale(); //FIXME: er... yes?
268 268
269 /* font 読み込み */ 269 /* font 茯粋昭 */
270 FontSetInfo fsinfo(display,fontname); 270 FontSetInfo fsinfo(display,fontname);
271 string fontset_name = fsinfo.Search(fontsize); 271 string fontset_name = fsinfo.Search(fontsize);
272 char** missing_cl; 272 char** missing_cl;
273 int missing_cc; 273 int missing_cc;
274 char* def_s; 274 char* def_s;
304 ascent = 0; 304 ascent = 0;
305 for (i=0; i<num_fonts; i++) { 305 for (i=0; i<num_fonts; i++) {
306 ascent = MAX(ascent, font_structs[i]->ascent); 306 ascent = MAX(ascent, font_structs[i]->ascent);
307 } 307 }
308 308
309 /* 描画用の pixmap を作成 */ 309 /* 紫 pixmap 篏 */
310 XGCValues gc_values; 310 XGCValues gc_values;
311 unsigned int gc_values_mask; 311 unsigned int gc_values_mask;
312 gc_values.function = GXcopy; 312 gc_values.function = GXcopy;
313 gc_values.fill_style = FillSolid; 313 gc_values.fill_style = FillSolid;
314 gc_values.arc_mode = ArcPieSlice; 314 gc_values.arc_mode = ArcPieSlice;
319 gc_values_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures | GCForeground | GCBackground; 319 gc_values_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures | GCForeground | GCBackground;
320 gc = XCreateGC(display, w, gc_values_mask, &gc_values); 320 gc = XCreateGC(display, w, gc_values_mask, &gc_values);
321 321
322 canvas = XCreatePixmap(display, w, width, height, DefaultDepth(display, scr)); 322 canvas = XCreatePixmap(display, w, width, height, DefaultDepth(display, scr));
323 323
324 /* イメージ転送用の image の作成 */ 324 /* ゃ<若梧拶 image 篏 */
325 int ignore; 325 int ignore;
326 use_shm = false; 326 use_shm = false;
327 if (XShmQueryExtension(display) == True) { 327 if (XShmQueryExtension(display) == True) {
328 x_shm_info.shmid = -1; 328 x_shm_info.shmid = -1;
329 x_shm_info.shmaddr = (char*)-1; 329 x_shm_info.shmaddr = (char*)-1;