font.h 20.5 KB
Newer Older
Kenichi Handa's avatar
Kenichi Handa committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
/* font.h -- Interface definition for font handling.
   Copyright (C) 2006 Free Software Foundation, Inc.
   Copyright (C) 2006
     National Institute of Advanced Industrial Science and Technology (AIST)
     Registration Number H13PRO009

This file is part of GNU Emacs.

GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING.  If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.  */

#ifndef EMACS_FONT_H
#define EMACS_FONT_H

#include "ccl.h"

/* We have three types of Lisp objects related to font.

   FONT-SPEC

	Vector (length FONT_SPEC_MAX) of font properties.  Some
	properties can be left unspecified (i.e. nil).  Emacs asks
	font-drivers to find a font by FONT-SPEC.  A fontset entry
	specifies requisite properties whereas a face specifies just
	preferable properties.  This object is fully modifiable by
	Lisp.

   FONT-ENTITY

	Vector (length FONT_ENTITY_MAX) of fully specified font
	properties that a font-driver returns upon a request of
	FONT-SPEC.

	Note: Only the method `list' of a font-driver can create this
	object, and should never be modified by Lisp.  In that sense,
	it may be cleaner to implement it as a Lisp object of a new
	type (e.g. struct Lisp_Font).

   FONT-OBJECT

	Lisp object of type Lisp_Misc_Save_Value encapsulating a
	pointer to "struct font".  This corresponds to an opened font.

	Note: The note for FONT-ENTITY also applies to this.
*/


struct font_driver;
struct font;

/* An enumerator for each font property.  This is used as an index to
   the vector of FONT-SPEC and FONT-ENTITY.

   Note: The order is important and should not be changed.  */

enum font_property_index
  {
    /* FONT-TYPE is a symbol indicating a font backend; currently `x',
71 72 73
       `xft', `ftx', `freetype' are available on X and gdi on Windows.
       For Windows, we `bdf' and `uniscribe' backends are in progress.
       For Mac OS X, we need `atm'.  */
Kenichi Handa's avatar
Kenichi Handa committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
    FONT_TYPE_INDEX,

    /* FONT-FOUNDRY is a foundry name (symbol).  */
    FONT_FOUNDRY_INDEX,

    /* FONT-FAMILY is a family name (symbol).  */
    FONT_FAMILY_INDEX,

    /* FONT-ADSTYLE is an additional style name (symbol).  */
    FONT_ADSTYLE_INDEX,

    /* FONT-REGISTRY is a combination of a charset-registry and
       charset0encoding name (symbol).  */
    FONT_REGISTRY_INDEX,

    /* FONT-WEIGHT is a numeric value of weight (e.g. medium, bold) of
       the font.  The value is what defined by FC_WEIGHT_* in
       fontconfig. */
    FONT_WEIGHT_INDEX,

    /* FONT-SLANT is a numeric value of slant (e.g. r, i, o) of the
       font.  The value is what defined by FC_SLANT_* in
       fontconfig plus 100. */
    FONT_SLANT_INDEX,

    /* FONT-WIDTH is a numeric value of setwidth (e.g. normal,
       condensed) of the font.  The value is what defined by
       FC_WIDTH_* in fontconfig. */
    FONT_WIDTH_INDEX,

    /* FONT-SIZE is a size of the font.  If integer, it is a pixel
       size.  For a font-spec, the value can be float specifying a
       point size.  For a font-entity, the value can be zero meaning
       that the font is scalable.  */
    FONT_SIZE_INDEX,

    /* In a font-spec, the value is an alist of extra information of a
       font such as name, OpenType features, and language coverage.
       In a font-entity, the value is an extra infomation for
       identifying a font (font-driver dependent).  */
    FONT_EXTRA_INDEX,		/* alist		alist */

    /* This value is the length of font-spec vector.  */
    FONT_SPEC_MAX,

    /* The followings are used only for a font-entity.  */

    /* Frame on which the font is found.  The value is nil if the font
       can be opend on any frame.  */
    FONT_FRAME_INDEX = FONT_SPEC_MAX,

Kenichi Handa's avatar
Kenichi Handa committed
125 126
    /* List of font-objects opened from the font-entity.  The value is
       nil if no font can be opened for this font-entity.  */
Kenichi Handa's avatar
Kenichi Handa committed
127 128 129 130 131 132
    FONT_OBJLIST_INDEX,

    /* This value is the length of font-entity vector.  */
    FONT_ENTITY_MAX
  };

Kenichi Handa's avatar
Kenichi Handa committed
133
extern Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClanguage, QCscript;
Kenichi Handa's avatar
Kenichi Handa committed
134

135
/* Important character set symbols.  */
Kenichi Handa's avatar
Kenichi Handa committed
136
extern Lisp_Object Qiso8859_1, Qiso10646_1, Qunicode_bmp, Qunicode_sip;
137

Kenichi Handa's avatar
Kenichi Handa committed
138 139 140 141
extern Lisp_Object null_string;
extern Lisp_Object null_vector;

/* Structure for an opened font.  We can safely cast this structure to
Jason Rumney's avatar
Jason Rumney committed
142
   "struct font_info".  */
Kenichi Handa's avatar
Kenichi Handa committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156

struct font
{
  struct font_info font;

  /* From which font-entity the font is opened.  */
  Lisp_Object entity;

  /* By which pixel size the font is opened.  */
  int pixel_size;

  /* Font-driver for the font.  */
  struct font_driver *driver;

157 158 159
  /* Symbol of font font; x, ttf, pcf, etc,   */
  Lisp_Object format;

Kenichi Handa's avatar
Kenichi Handa committed
160 161 162 163
  /* File name of the font, or NULL if the font is not associated with
     a file.  */
  char *file_name;

164 165 166
  /* Charset to encode a character code into a glyph code of the font.
     -1 means that the font doesn't require this information to encode
     a character.  */
Kenichi Handa's avatar
Kenichi Handa committed
167 168 169 170
  int encoding_charset;

  /* Charset to check if a character code is supported by the font.
     -1 means that the contents of the font must be looked up to
171
     determine it.  */
172
  int repertory_charset;
Kenichi Handa's avatar
Kenichi Handa committed
173 174 175 176 177 178 179

  /* Minimum glyph width (in pixels).  */
  int min_width;

  /* Ascent and descent of the font (in pixels).  */
  int ascent, descent;

180 181 182
  /* 1 iff the font is scalable.  */
  int scalable;

Kenichi Handa's avatar
Kenichi Handa committed
183 184 185 186
  /* There will be more to this structure, but they are private to a
     font-driver.  */
};

187 188 189 190 191 192 193 194
enum font_spacing
  {
    FONT_SPACING_PROPORTIONAL = 0,
    FONT_SPACING_DUAL = 90,
    FONT_SPACING_MONO = 100,
    FONT_SPACING_CHARCELL = 110
  };

Kenichi Handa's avatar
Kenichi Handa committed
195 196 197 198 199 200 201
struct font_metrics
{
  short lbearing, rbearing, width, ascent, descent;
};

struct font_bitmap
{
202
  int bits_per_pixel;
Kenichi Handa's avatar
Kenichi Handa committed
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
  int rows;
  int width;
  int pitch;
  unsigned char *buffer;
  int left;
  int top;
  int advance;
  void *extra;
};

/* Predicates to check various font-related objects.  */

#define FONT_SPEC_P(x)	\
  (VECTORP (x) && ASIZE (x) == FONT_SPEC_MAX)
#define FONT_ENTITY_P(x)	\
  (VECTORP (x) && ASIZE (x) == FONT_ENTITY_MAX)
#define FONT_OBJECT_P(x)	\
  (XTYPE (x) == Lisp_Misc && XMISCTYPE (x) == Lisp_Misc_Save_Value)
221 222 223 224
#define FONTP(x)					\
  ((VECTORP (x) && (ASIZE (x) == FONT_SPEC_MAX		\
		    || ASIZE (x) == FONT_ENTITY_MAX))	\
   || FONT_OBJECT_P (x))
Kenichi Handa's avatar
Kenichi Handa committed
225

Kenichi Handa's avatar
Kenichi Handa committed
226 227 228 229 230 231
#define FONT_ENTITY_NOT_LOADABLE(entity)	\
  EQ (AREF (entity, FONT_OBJLIST_INDEX), Qt)

#define FONT_ENTITY_SET_NOT_LOADABLE(entity)	\
  ASET (entity, FONT_OBJLIST_INDEX, Qt)

Kenichi Handa's avatar
Kenichi Handa committed
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250

/* Check macros for various font-related objects.  */

#define CHECK_FONT(x)	\
  do { if (! FONTP (x)) x = wrong_type_argument (Qfont, x); } while (0)
#define CHECK_FONT_SPEC(x)	\
  do { if (! FONT_SPEC_P (x)) x = wrong_type_argument (Qfont, x); } while (0)
#define CHECK_FONT_ENTITY(x)	\
  do { if (! FONT_ENTITY_P (x)) x = wrong_type_argument (Qfont, x); } while (0)
#define CHECK_FONT_OBJECT(x)	\
  do { if (! FONT_OBJECT_P (x)) x = wrong_type_argument (Qfont, x); } while (0)

#define CHECK_FONT_GET_OBJECT(x, font)					\
  do {									\
    if (! FONT_OBJECT_P (x)) x = wrong_type_argument (Qfont, x);	\
    if (! XSAVE_VALUE (x)->pointer) error ("Font already closed");	\
    font = XSAVE_VALUE (x)->pointer;					\
  } while (0)

251 252 253 254
/* Ignore the difference of font pixel sizes less than or equal to
   this value.  */
#define FONT_PIXEL_SIZE_QUANTUM 1

Kenichi Handa's avatar
Kenichi Handa committed
255 256 257 258 259
struct face;
struct composition;

/* Macros for lispy glyph-string.  */
#define LGSTRING_FONT(lgs) AREF (AREF ((lgs), 0), 0)
Kenichi Handa's avatar
Kenichi Handa committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
#define LGSTRING_WIDTH(lgs) XINT (AREF (AREF ((lgs), 0), 1))
#define LGSTRING_LBEARING(lgs) XINT (AREF (AREF ((lgs), 0), 2))
#define LGSTRING_RBEARING(lgs) XINT (AREF (AREF ((lgs), 0), 3))
#define LGSTRING_ASCENT(lgs) XINT (AREF (AREF ((lgs), 0), 4))
#define LGSTRING_DESCENT(lgs) XINT (AREF (AREF ((lgs), 0), 5))
#define LGSTRING_SET_FONT(lgs, val)	\
  ASET (AREF ((lgs), 0), 0, (val))
#define LGSTRING_SET_WIDTH(lgs, val)	\
  ASET (AREF ((lgs), 0), 1, make_number (val))
#define LGSTRING_SET_LBEARING(lgs, val) \
  ASET (AREF ((lgs), 0), 2, make_number (val))
#define LGSTRING_SET_RBEARING(lgs, val)	\
  ASET (AREF ((lgs), 0), 3, make_number (val))
#define LGSTRING_SET_ASCENT(lgs, val)	\
  ASET (AREF ((lgs), 0), 4, make_number (val))
#define LGSTRING_SET_DESCENT(lgs, val)	\
  ASET (AREF ((lgs), 0), 5, make_number (val))
Kenichi Handa's avatar
Kenichi Handa committed
277 278 279

#define LGSTRING_LENGTH(lgs) (ASIZE ((lgs)) - 1)
#define LGSTRING_GLYPH(lgs, idx) AREF ((lgs), (idx) + 1)
Kenichi Handa's avatar
Kenichi Handa committed
280 281
#define LGSTRING_SET_GLYPH(lgs, idx, val) ASET ((lgs), (idx) + 1, (val))

Kenichi Handa's avatar
Kenichi Handa committed
282 283
/* Vector size of Lispy glyph.  */
#define LGLYPH_SIZE 10
Kenichi Handa's avatar
Kenichi Handa committed
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
#define LGLYPH_FROM(g) XINT (AREF ((g), 0))
#define LGLYPH_TO(g) XINT (AREF ((g), 1))
#define LGLYPH_CHAR(g) XINT (AREF ((g), 2))
#define LGLYPH_CODE(g) XINT (AREF ((g), 3))
#define LGLYPH_WIDTH(g) XINT (AREF ((g), 4))
#define LGLYPH_LBEARING(g) XINT (AREF ((g), 5))
#define LGLYPH_RBEARING(g) XINT (AREF ((g), 6))
#define LGLYPH_ASCENT(g) XINT (AREF ((g), 7))
#define LGLYPH_DESCENT(g) XINT (AREF ((g), 8))
#define LGLYPH_ADJUSTMENT(g) AREF ((g), 9)
#define LGLYPH_SET_FROM(g, val) ASET ((g), 0, make_number (val))
#define LGLYPH_SET_TO(g, val) ASET ((g), 1, make_number (val))
#define LGLYPH_SET_CHAR(g, val) ASET ((g), 2, make_number (val))
#define LGLYPH_SET_CODE(g, val) ASET ((g), 3, make_number (val))
#define LGLYPH_SET_WIDTH(g, val) ASET ((g), 4, make_number (val))
#define LGLYPH_SET_LBEARING(g, val) ASET ((g), 5, make_number (val))
#define LGLYPH_SET_RBEARING(g, val) ASET ((g), 6, make_number (val))
#define LGLYPH_SET_ASCENT(g, val) ASET ((g), 7, make_number (val))
#define LGLYPH_SET_DESCENT(g, val) ASET ((g), 8, make_number (val))
#define LGLYPH_SET_ADJUSTMENT(g, val) ASET ((g), 9, (val))
304

305 306 307 308 309 310
#define LGLYPH_XOFF(g) (VECTORP (LGLYPH_ADJUSTMENT (g)) \
			? XINT (AREF (LGLYPH_ADJUSTMENT (g), 0)) : 0)
#define LGLYPH_YOFF(g) (VECTORP (LGLYPH_ADJUSTMENT (g)) \
			? XINT (AREF (LGLYPH_ADJUSTMENT (g), 1)) : 0)
#define LGLYPH_WADJUST(g) (VECTORP (LGLYPH_ADJUSTMENT (g)) \
			   ? XINT (AREF (LGLYPH_ADJUSTMENT (g), 2)) : 0)
Kenichi Handa's avatar
Kenichi Handa committed
311 312 313

#define FONT_INVALID_CODE 0xFFFFFFFF

314 315
/* Font driver.  Members specified as "optional" can be NULL.  */

Kenichi Handa's avatar
Kenichi Handa committed
316 317 318 319 320
struct font_driver
{
  /* Symbol indicating the type of the font-driver.  */
  Lisp_Object type;

321
  /* Return a cache of font-entities on frame F.  The cache must be a
Kenichi Handa's avatar
Kenichi Handa committed
322
     cons whose cdr part is the actual cache area.  */
323
  Lisp_Object (*get_cache) P_ ((FRAME_PTR F));
Kenichi Handa's avatar
Kenichi Handa committed
324

325 326 327
  /* List fonts exactly matching with FONT_SPEC on FRAME.  The value
     is a vector of font-entities.  This is the sole API that
     allocates font-entities.  */
Kenichi Handa's avatar
Kenichi Handa committed
328 329
  Lisp_Object (*list) P_ ((Lisp_Object frame, Lisp_Object font_spec));

330 331 332 333 334
  /* Return a font entity most closely maching with FONT_SPEC on
     FRAME.  The closeness is detemined by the font backend, thus
     `face-font-selection-order' is ignored here.  */
  Lisp_Object (*match) P_ ((Lisp_Object frame, Lisp_Object font_spec));

335 336 337
  /* Optional.
     List available families.  The value is a list of family names
     (symbols).  */
Kenichi Handa's avatar
Kenichi Handa committed
338 339
  Lisp_Object (*list_family) P_ ((Lisp_Object frame));

340 341
  /* Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value).
     Free FONT_EXTRA_INDEX field of FONT_ENTITY.  */
Kenichi Handa's avatar
Kenichi Handa committed
342 343 344 345 346 347 348 349 350 351
  void (*free_entity) P_ ((Lisp_Object font_entity));

  /* Open a font specified by FONT_ENTITY on frame F.  If the font is
     scalable, open it with PIXEL_SIZE.  */
  struct font *(*open) P_ ((FRAME_PTR f, Lisp_Object font_entity,
			    int pixel_size));

  /* Close FONT on frame F.  */
  void (*close) P_ ((FRAME_PTR f, struct font *font));

352 353 354 355
  /* Optional (if FACE->extra is not used).
     Prepare FACE for displaying characters by FONT on frame F by
     storing some data in FACE->extra.  If successful, return 0.
     Otherwise, return -1.  */
Kenichi Handa's avatar
Kenichi Handa committed
356 357
  int (*prepare_face) P_ ((FRAME_PTR f, struct face *face));

358 359
  /* Optional.
     Done FACE for displaying characters by FACE->font on frame F.  */
Kenichi Handa's avatar
Kenichi Handa committed
360 361
  void (*done_face) P_ ((FRAME_PTR f, struct face *face));

362 363 364 365
  /* Optional.
     If FONT_ENTITY has a glyph for character C (Unicode code point),
     return 1.  If not, return 0.  If a font must be opened to check
     it, return -1.  */
Kenichi Handa's avatar
Kenichi Handa committed
366 367
  int (*has_char) P_ ((Lisp_Object entity, int c));

368 369
  /* Return a glyph code of FONT for characer C (Unicode code point).
     If FONT doesn't have such a glyph, return FONT_INVALID_CODE.  */
Kenichi Handa's avatar
Kenichi Handa committed
370 371
  unsigned (*encode_char) P_ ((struct font *font, int c));

372 373 374
  /* Computate the total metrics of the NGLYPHS glyphs specified by
     the font FONT and the sequence of glyph codes CODE, and store the
     result in METRICS.  */
Kenichi Handa's avatar
Kenichi Handa committed
375 376 377 378
  int (*text_extents) P_ ((struct font *font,
			   unsigned *code, int nglyphs,
			   struct font_metrics *metrics));

379 380
  /* Optional.
     Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
Kenichi Handa's avatar
Kenichi Handa committed
381 382 383 384 385 386
     position of frame F with S->FACE and S->GC.  If WITH_BACKGROUND
     is nonzero, fill the background in advance.  It is assured that
     WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars).  */
  int (*draw) P_ ((struct glyph_string *s, int from, int to,
		   int x, int y, int with_background));

387 388 389 390
  /* Optional.
     Store bitmap data for glyph-code CODE of FONT in BITMAP.  It is
     intended that this method is callled from the other font-driver
     for actual drawing.  */
Kenichi Handa's avatar
Kenichi Handa committed
391 392 393 394
  int (*get_bitmap) P_ ((struct font *font, unsigned code,
			 struct font_bitmap *bitmap,
			 int bits_per_pixel));

395 396
  /* Optional.
     Free bitmap data in BITMAP.  */
Kenichi Handa's avatar
Kenichi Handa committed
397 398
  void (*free_bitmap) P_ ((struct font *font, struct font_bitmap *bitmap));

399 400 401
  /* Optional.
     Return an outline data for glyph-code CODE of FONT.  The format
     of the outline data depends on the font-driver.  */
Kenichi Handa's avatar
Kenichi Handa committed
402 403
  void *(*get_outline) P_ ((struct font *font, unsigned code));

404 405
  /* Optional.
     Free OUTLINE (that is obtained by the above method).  */
Kenichi Handa's avatar
Kenichi Handa committed
406 407
  void (*free_outline) P_ ((struct font *font, void *outline));

408 409
  /* Optional.
     Get coordinates of the INDEXth anchor point of the glyph whose
Kenichi Handa's avatar
Kenichi Handa committed
410
     code is CODE.  Store the coordinates in *X and *Y.  Return 0 if
411
     the operations was successfull.  Otherwise return -1.  */
Kenichi Handa's avatar
Kenichi Handa committed
412 413 414
  int (*anchor_point) P_ ((struct font *font, unsigned code, int index,
			   int *x, int *y));

415 416
  /* Optional.
     Return a list describing which scripts/languages FONT
Kenichi Handa's avatar
Kenichi Handa committed
417 418 419
     supports by which GSUB/GPOS features of OpenType tables.  */
  Lisp_Object (*otf_capability) P_ ((struct font *font));

420
  /* Optional.
Kenichi Handa's avatar
Kenichi Handa committed
421 422 423 424 425
     Apply FONT's OTF-FEATURES to the glyph string.

     FEATURES specifies which OTF features to apply in this format:
	(SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE)
     See the documentation of `font-drive-otf' for the detail.
Kenichi Handa's avatar
Kenichi Handa committed
426 427 428 429 430 431 432 433 434

     This method applies the specified features to the codes in the
     elements of GSTRING-IN (between FROMth and TOth).  The output
     codes are stored in GSTRING-OUT at the IDXth element and the
     following elements.

     Return the number of output codes.  If none of the features are
     applicable to the input data, return 0.  If GSTRING-OUT is too
     short, return -1.  */
Kenichi Handa's avatar
Kenichi Handa committed
435
  int (*otf_drive) P_ ((struct font *font, Lisp_Object features,
Kenichi Handa's avatar
Kenichi Handa committed
436
		       Lisp_Object gstring_in, int from, int to,
437
		       Lisp_Object gstring_out, int idx, int alternate_subst));
438 439 440 441 442 443 444 445 446 447 448

  /* Optional.
     Make the font driver ready for frame F.  Usually this function
     makes some data specific to F and store it in F by calling
     font_put_frame_data ().  */
  int (*start_for_frame) P_ ((FRAME_PTR f));
  
  /* Optional.
     End using the driver for frame F.  Usually this function free
     some data stored for F.  */
  int (*end_for_frame) P_ ((FRAME_PTR f));
Kenichi Handa's avatar
Kenichi Handa committed
449 450

  /* Optional.
451 452 453 454 455 456 457 458 459 460 461 462

     Shape text in LGSTRING.  See the docstring of `font-make-gstring'
     for the format of LGSTRING.  If the (N+1)th element of LGSTRING
     is nil, input of shaping is from the 1st to (N)th elements.  In
     each input glyph, FROM, TO, CHAR, and CODE are already set.

     This function updates all fields of the input glyphs.  If the
     output glyphs (M) are more than the input glyphs (N), (N+1)th
     through (M)th elements of LGSTRING are updated possibly by making
     a new glyph object and storing it in LGSTRING.  If (M) is greater
     than the length of LGSTRING, nil should be return.  In that case,
     this function is called again with the larger LGSTRING.  */
Kenichi Handa's avatar
Kenichi Handa committed
463
  Lisp_Object (*shape) P_ ((Lisp_Object lgstring));
Kenichi Handa's avatar
Kenichi Handa committed
464 465 466
};


467 468 469 470
/* Chain of font drivers.  There's one global font driver list
   (font_driver_list in font.c).  In addition, each frame has it's own
   font driver list at FRAME_PTR->font_driver_list.  */

Kenichi Handa's avatar
Kenichi Handa committed
471 472
struct font_driver_list
{
473 474
  /* 1 iff this driver is currently used.  It is igonred in the global
     font driver list.*/
Kenichi Handa's avatar
Kenichi Handa committed
475
  int on;
476
  /* Pointer to the font driver.  */
Kenichi Handa's avatar
Kenichi Handa committed
477
  struct font_driver *driver;
478
  /* Pointer to the next element of the chain.  */
Kenichi Handa's avatar
Kenichi Handa committed
479 480 481
  struct font_driver_list *next;
};

482 483 484 485 486 487 488 489 490 491 492 493 494 495

/* Chain of arbitrary data specific to each font driver.  Each frame
   has it's own font data list at FRAME_PTR->font_data_list.  */

struct font_data_list
{
  /* Pointer to the font driver.  */
  struct font_driver *driver;
  /* Data specific to the font driver.  */
  void *data;
  /* Pointer to the next element of the chain.  */
  struct font_data_list *next;
};

Kenichi Handa's avatar
Kenichi Handa committed
496 497 498
extern int enable_font_backend;

EXFUN (Ffont_spec, MANY);
Kenichi Handa's avatar
Kenichi Handa committed
499
EXFUN (Ffont_get, 2);
Kenichi Handa's avatar
Kenichi Handa committed
500
EXFUN (Flist_fonts, 4);
Kenichi Handa's avatar
Kenichi Handa committed
501
EXFUN (Fclear_font_cache, 0);
Kenichi Handa's avatar
Kenichi Handa committed
502
EXFUN (Ffont_xlfd_name, 1);
Kenichi Handa's avatar
Kenichi Handa committed
503

Kenichi Handa's avatar
Kenichi Handa committed
504 505
extern int font_registry_charsets P_ ((Lisp_Object, struct charset **,
				       struct charset **));
Kenichi Handa's avatar
Kenichi Handa committed
506 507 508 509
extern Lisp_Object font_symbolic_weight P_ ((Lisp_Object font));
extern Lisp_Object font_symbolic_slant P_ ((Lisp_Object font));
extern Lisp_Object font_symbolic_width P_ ((Lisp_Object font));

510 511
extern int font_match_p P_ ((Lisp_Object spec, Lisp_Object entity));

Kenichi Handa's avatar
Kenichi Handa committed
512
extern Lisp_Object font_find_object P_ ((struct font *font));
513 514 515
extern Lisp_Object font_get_name P_ ((Lisp_Object font_object));
extern Lisp_Object font_get_spec P_ ((Lisp_Object font_object));
extern Lisp_Object font_get_frame P_ ((Lisp_Object font_object));
Kenichi Handa's avatar
Kenichi Handa committed
516 517 518 519 520 521 522 523
extern int font_has_char P_ ((FRAME_PTR, Lisp_Object, int));
extern unsigned font_encode_char P_ ((Lisp_Object, int));

extern int font_set_lface_from_name P_ ((FRAME_PTR f,
					 Lisp_Object lface,
					 Lisp_Object fontname,
					 int force_p, int may_fail_p));
extern Lisp_Object font_find_for_lface P_ ((FRAME_PTR f, Lisp_Object *lface,
Kenichi Handa's avatar
Kenichi Handa committed
524
					    Lisp_Object spec, int c));
Kenichi Handa's avatar
Kenichi Handa committed
525 526 527
extern Lisp_Object font_open_for_lface P_ ((FRAME_PTR f, Lisp_Object entity,
					    Lisp_Object *lface,
					    Lisp_Object spec));
Kenichi Handa's avatar
Kenichi Handa committed
528 529 530
extern void font_load_for_face P_ ((FRAME_PTR f, struct face *face));
extern void font_prepare_for_face P_ ((FRAME_PTR f, struct face *face));
extern Lisp_Object font_open_by_name P_ ((FRAME_PTR f, char *name));
531
extern void font_close_object (FRAME_PTR f, Lisp_Object font_object);
Kenichi Handa's avatar
Kenichi Handa committed
532 533 534 535

extern Lisp_Object intern_downcase P_ ((char *str, int len));
extern void font_update_sort_order P_ ((int *order));

536 537
extern void font_merge_old_spec P_ ((Lisp_Object name, Lisp_Object family,
				     Lisp_Object registry, Lisp_Object spec));
Kenichi Handa's avatar
Kenichi Handa committed
538 539


Kenichi Handa's avatar
Kenichi Handa committed
540
extern int font_parse_xlfd P_ ((char *name, Lisp_Object font));
Kenichi Handa's avatar
Kenichi Handa committed
541 542
extern int font_unparse_xlfd P_ ((Lisp_Object font, int pixel_size,
				  char *name, int bytes));
Kenichi Handa's avatar
Kenichi Handa committed
543
extern int font_parse_fcname P_ ((char *name, Lisp_Object font));
544 545
extern int font_unparse_fcname P_ ((Lisp_Object font, int pixel_size,
				  char *name, int bytes));
Kenichi Handa's avatar
Kenichi Handa committed
546 547
extern void register_font_driver P_ ((struct font_driver *driver, FRAME_PTR f));
extern void free_font_driver_list P_ ((FRAME_PTR f));
548
extern Lisp_Object font_update_drivers P_ ((FRAME_PTR f, Lisp_Object list));
549 550
extern Lisp_Object font_at P_ ((int c, EMACS_INT pos, struct face *face,
				struct window *w, Lisp_Object object));
Kenichi Handa's avatar
Kenichi Handa committed
551

Kenichi Handa's avatar
Kenichi Handa committed
552 553
extern struct font *font_prepare_composition P_ ((struct composition *cmp,
						  FRAME_PTR f));
Kenichi Handa's avatar
Kenichi Handa committed
554

555 556
extern Lisp_Object font_put_extra P_ ((Lisp_Object font, Lisp_Object prop,
                                       Lisp_Object val));
Kenichi Handa's avatar
Kenichi Handa committed
557

558 559 560 561 562 563
extern int font_put_frame_data P_ ((FRAME_PTR f,
				    struct font_driver *driver,
				    void *data));
extern void *font_get_frame_data P_ ((FRAME_PTR f,
				      struct font_driver *driver));

Kenichi Handa's avatar
Kenichi Handa committed
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
#ifdef HAVE_FREETYPE
extern struct font_driver ftfont_driver;
#endif	/* HAVE_FREETYPE */
#ifdef HAVE_X_WINDOWS
extern struct font_driver xfont_driver;
extern struct font_driver ftxfont_driver;
#ifdef HAVE_XFT
extern struct font_driver xftfont_driver;
#endif	/* HAVE_XFT */
#endif	/* HAVE_X_WINDOWS */
#ifdef WINDOWSNT
extern struct font_driver w32font_driver;
#endif	/* WINDOWSNT */
#ifdef MAC_OS
extern struct font_driver atmfont_driver;
#endif	/* MAC_OS */

#endif	/* not EMACS_FONT_H */
Miles Bader's avatar
Miles Bader committed
582 583 584

/* arch-tag: 3b7260c3-5bec-4d6b-a0db-95c1b431b1a2
   (do not change this comment) */