comparison src/font.c @ 90490:8ef2cbaf626a

(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field. (font_has_char): Accept font-object too. (font_find_for_lface): Try at first with a size specified in face.
author Kenichi Handa <handa@m17n.org>
date Wed, 21 Jun 2006 01:24:36 +0000
parents 72186e5bf7ed
children 8e3ffc0a529f
comparison
equal deleted inserted replaced
90489:78a820ef12db 90490:8ef2cbaf626a
860 } 860 }
861 else 861 else
862 { 862 {
863 if (! NILP (f[XLFD_ENCODING_INDEX])) 863 if (! NILP (f[XLFD_ENCODING_INDEX]))
864 f[XLFD_REGISTRY_INDEX] 864 f[XLFD_REGISTRY_INDEX]
865 = Fintern (concat2 (SYMBOL_NAME (f[XLFD_REGISTRY_INDEX]), 865 = Fintern (concat3 (SYMBOL_NAME (f[XLFD_REGISTRY_INDEX]),
866 build_string ("-"),
866 SYMBOL_NAME (f[XLFD_ENCODING_INDEX])), Qnil); 867 SYMBOL_NAME (f[XLFD_ENCODING_INDEX])), Qnil);
867 } 868 }
868 } 869 }
869 870
870 if (! merge || NILP (AREF (font, FONT_FOUNDRY_INDEX))) 871 if (! merge || NILP (AREF (font, FONT_FOUNDRY_INDEX)))
2238 break; 2239 break;
2239 } 2240 }
2240 } 2241 }
2241 2242
2242 int 2243 int
2243 font_has_char (f, font_entity, c) 2244 font_has_char (f, font, c)
2244 FRAME_PTR f; 2245 FRAME_PTR f;
2245 Lisp_Object font_entity; 2246 Lisp_Object font;
2246 int c; 2247 int c;
2247 { 2248 {
2248 Lisp_Object type = AREF (font_entity, FONT_TYPE_INDEX); 2249 struct font *fontp;
2249 struct font_driver_list *driver_list; 2250
2250 2251 if (FONT_ENTITY_P (font))
2251 for (driver_list = f->font_driver_list; 2252 {
2252 driver_list && ! EQ (driver_list->driver->type, type); 2253 Lisp_Object type = AREF (font, FONT_TYPE_INDEX);
2253 driver_list = driver_list->next); 2254 struct font_driver_list *driver_list;
2254 if (! driver_list) 2255
2255 return -1; 2256 for (driver_list = f->font_driver_list;
2256 return driver_list->driver->has_char (font_entity, c); 2257 driver_list && ! EQ (driver_list->driver->type, type);
2258 driver_list = driver_list->next);
2259 if (! driver_list)
2260 return 0;
2261 if (! driver_list->driver->has_char)
2262 return -1;
2263 return driver_list->driver->has_char (font, c);
2264 }
2265
2266 xassert (FONT_OBJECT_P (font));
2267 fontp = XSAVE_VALUE (font)->pointer;
2268
2269 if (fontp->driver->has_char)
2270 {
2271 int result = fontp->driver->has_char (fontp->entity, c);
2272
2273 if (result >= 0)
2274 return result;
2275 }
2276 return (fontp->driver->encode_char (fontp, c) != FONT_INVALID_CODE);
2257 } 2277 }
2258 2278
2259 unsigned 2279 unsigned
2260 font_encode_char (font_object, c) 2280 font_encode_char (font_object, c)
2261 Lisp_Object font_object; 2281 Lisp_Object font_object;
2326 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, 2346 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil,
2327 scratch_font_spec); 2347 scratch_font_spec);
2328 if (NILP (AREF (scratch_font_spec, FONT_REGISTRY_INDEX))) 2348 if (NILP (AREF (scratch_font_spec, FONT_REGISTRY_INDEX)))
2329 ASET (scratch_font_spec, FONT_REGISTRY_INDEX, intern ("iso8859-1")); 2349 ASET (scratch_font_spec, FONT_REGISTRY_INDEX, intern ("iso8859-1"));
2330 2350
2351 if (NILP (AREF (scratch_font_spec, FONT_SIZE_INDEX))
2352 && ! NILP (lface[LFACE_HEIGHT_INDEX]))
2353 {
2354 double pt = XINT (lface[LFACE_HEIGHT_INDEX]);
2355 int pixel_size = POINT_TO_PIXEL (pt / 10, f->resy);
2356
2357 ASET (scratch_font_spec, FONT_SIZE_INDEX, make_number (pixel_size));
2358 }
2359
2331 XSETFRAME (frame, f); 2360 XSETFRAME (frame, f);
2332 entities = font_list_entities (frame, scratch_font_spec); 2361 entities = font_list_entities (frame, scratch_font_spec);
2333 while (ASIZE (entities) == 0) 2362 while (ASIZE (entities) == 0)
2334 { 2363 {
2335 if (! NILP (AREF (scratch_font_spec, FONT_FOUNDRY_INDEX)) 2364 if (! NILP (AREF (scratch_font_spec, FONT_SIZE_INDEX))
2365 && (NILP (spec) || NILP (AREF (spec, FONT_SIZE_INDEX))))
2366 {
2367 ASET (scratch_font_spec, FONT_SIZE_INDEX, Qnil);
2368 entities = font_list_entities (frame, scratch_font_spec);
2369 }
2370 else if (! NILP (AREF (scratch_font_spec, FONT_FOUNDRY_INDEX))
2336 && (NILP (spec) || NILP (AREF (spec, FONT_FOUNDRY_INDEX)))) 2371 && (NILP (spec) || NILP (AREF (spec, FONT_FOUNDRY_INDEX))))
2337 { 2372 {
2338 ASET (scratch_font_spec, FONT_FOUNDRY_INDEX, Qnil); 2373 ASET (scratch_font_spec, FONT_FOUNDRY_INDEX, Qnil);
2339 entities = font_list_entities (frame, scratch_font_spec); 2374 entities = font_list_entities (frame, scratch_font_spec);
2340 } 2375 }