Blame src/font.h

Packit Service a721b1
/* font.h -- header file for the font module.
Packit Service a721b1
   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Packit Service a721b1
     National Institute of Advanced Industrial Science and Technology (AIST)
Packit Service a721b1
     Registration Number H15PRO112
Packit Service a721b1
Packit Service a721b1
   This file is part of the m17n library.
Packit Service a721b1
Packit Service a721b1
   The m17n library is free software; you can redistribute it and/or
Packit Service a721b1
   modify it under the terms of the GNU Lesser General Public License
Packit Service a721b1
   as published by the Free Software Foundation; either version 2.1 of
Packit Service a721b1
   the License, or (at your option) any later version.
Packit Service a721b1
Packit Service a721b1
   The m17n library is distributed in the hope that it will be useful,
Packit Service a721b1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a721b1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service a721b1
   Lesser General Public License for more details.
Packit Service a721b1
Packit Service a721b1
   You should have received a copy of the GNU Lesser General Public
Packit Service a721b1
   License along with the m17n library; if not, write to the Free
Packit Service a721b1
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Packit Service a721b1
   Boston, MA 02110-1301 USA.  */
Packit Service a721b1
Packit Service a721b1
#ifndef _M17N_FONT_H_
Packit Service a721b1
#define _M17N_FONT_H_
Packit Service a721b1
Packit Service a721b1
enum MFontProperty
Packit Service a721b1
  {
Packit Service a721b1
    /* The order of MFONT_FOUNDRY to MFONT_ADSTYLE must be the same as
Packit Service a721b1
       enum MFaceProperty.  */
Packit Service a721b1
    MFONT_FOUNDRY,
Packit Service a721b1
    MFONT_FAMILY,
Packit Service a721b1
    MFONT_WEIGHT,
Packit Service a721b1
    MFONT_STYLE,
Packit Service a721b1
    MFONT_STRETCH,
Packit Service a721b1
    MFONT_ADSTYLE,
Packit Service a721b1
    MFONT_REGISTRY,
Packit Service a721b1
    MFONT_RESY,
Packit Service a721b1
    /* The follwoings should not be used as an index to
Packit Service a721b1
       MFont->propperty.  */
Packit Service a721b1
    MFONT_SIZE,
Packit Service a721b1
    MFONT_SPACING,
Packit Service a721b1
    /* anchor */
Packit Service a721b1
    MFONT_PROPERTY_MAX = MFONT_SIZE
Packit Service a721b1
  };
Packit Service a721b1
Packit Service a721b1
enum MFontType
Packit Service a721b1
  {
Packit Service a721b1
    MFONT_TYPE_SPEC,
Packit Service a721b1
    MFONT_TYPE_OBJECT,
Packit Service a721b1
    MFONT_TYPE_REALIZED,
Packit Service a721b1
    MFONT_TYPE_FAILURE
Packit Service a721b1
  };
Packit Service a721b1
Packit Service a721b1
enum MFontSource
Packit Service a721b1
  {
Packit Service a721b1
    MFONT_SOURCE_UNDECIDED = 0,
Packit Service a721b1
    MFONT_SOURCE_X = 1,
Packit Service a721b1
    MFONT_SOURCE_FT = 2
Packit Service a721b1
  };
Packit Service a721b1
Packit Service a721b1
enum MFontSpacing
Packit Service a721b1
  {
Packit Service a721b1
    MFONT_SPACING_UNDECIDED,
Packit Service a721b1
    MFONT_SPACING_PROPORTIONAL,
Packit Service a721b1
    MFONT_SPACING_MONO,
Packit Service a721b1
    MFONT_SPACING_CHARCELL
Packit Service a721b1
  };
Packit Service a721b1
Packit Service a721b1
typedef struct MFontEncoding MFontEncoding;
Packit Service a721b1
typedef struct MFontDriver MFontDriver;
Packit Service a721b1
Packit Service a721b1
/** Information about a font.  This structure is used in three ways:
Packit Service a721b1
    FONT-OBJ, FONT-OPENED, and FONT-SPEC.  
Packit Service a721b1
Packit Service a721b1
    FONT-OBJ: To store information of an existing font.  Instances
Packit Service a721b1
    appear only in <font_list> of MDisplay.
Packit Service a721b1
Packit Service a721b1
    FONT-OPENED: To store information of an opened font.  Instances
Packit Service a721b1
    appear only in <opend_list> of MDisplay.
Packit Service a721b1
Packit Service a721b1
    FONT-SPEC: To store specifications of a font.  Instances appear
Packit Service a721b1
    only in <spec_list> of MFontset.  */
Packit Service a721b1
Packit Service a721b1
struct MFont
Packit Service a721b1
{
Packit Service a721b1
  /** Numeric value of each font property.  Also used as an index to
Packit Service a721b1
      the table @c mfont__property_table to get the actual name of the
Packit Service a721b1
      property.
Packit Service a721b1
Packit Service a721b1
      For FONT-OBJ, FONT-OPENED: The value is greater than zero.
Packit Service a721b1
Packit Service a721b1
      For FONT-SPEC: The value is equal to or greater than zero.  Zero
Packit Service a721b1
      means that the correponding property is not specified (i.e. wild
Packit Service a721b1
      card).
Packit Service a721b1
Packit Service a721b1
      For FONT-OBJ: If the value is 0, the font is scalable or
Packit Service a721b1
      auto-scaled.
Packit Service a721b1
Packit Service a721b1
      For FONT-OPENED: The actual size of opened font.
Packit Service a721b1
Packit Service a721b1
      <property>[MFONT_RESY] is the designed resolution of the font in
Packit Service a721b1
      DPI, or zero.  Zero means that the font is scalable.
Packit Service a721b1
Packit Service a721b1
      For the time being, we mention only Y-resolution (resy) and
Packit Service a721b1
      assume that resx is always equal to resy.  */
Packit Service a721b1
  unsigned short property[MFONT_PROPERTY_MAX];
Packit Service a721b1
  unsigned type : 2;
Packit Service a721b1
  unsigned source : 2;
Packit Service a721b1
  unsigned spacing : 2;
Packit Service a721b1
  unsigned for_full_width : 1;
Packit Service a721b1
  /* For FONT-OBJ, 1 means `size' is a logical or of bit masks for
Packit Service a721b1
     available pixel sizes (Nth bit corresponds to (6 + N) pixels), 0
Packit Service a721b1
     means `size' is an actual pixel size * 10.  For FONT-SPEC and
Packit Service a721b1
     FONT-OPENED, this is always 0, and `size' is an actual pixel
Packit Service a721b1
     size * 10.  */
Packit Service a721b1
  unsigned multiple_sizes : 1;
Packit Service a721b1
  unsigned size : 24;
Packit Service a721b1
  MSymbol file;
Packit Service a721b1
  MSymbol capability;
Packit Service a721b1
  MFontEncoding *encoding;
Packit Service a721b1
};
Packit Service a721b1
Packit Service a721b1
typedef struct
Packit Service a721b1
{
Packit Service a721b1
  int size, inc, used;
Packit Service a721b1
  MSymbol property;
Packit Service a721b1
  MSymbol *names;
Packit Service a721b1
} MFontPropertyTable;
Packit Service a721b1
Packit Service a721b1
extern MFontPropertyTable mfont__property_table[MFONT_REGISTRY + 1];
Packit Service a721b1
Packit Service a721b1
/** Return the symbol of the Nth font property of FONT.  */
Packit Service a721b1
#define FONT_PROPERTY(font, n)	\
Packit Service a721b1
  (mfont__property_table[(n)].names[(font)->property[(n)]])
Packit Service a721b1
Packit Service a721b1
struct MRealizedFont
Packit Service a721b1
{
Packit Service a721b1
  /* Font spec used to find the font.
Packit Service a721b1
     MRealizedFont::spec.property[MFONT_TYPE] is MFONT_TYPE_REALIZED
Packit Service a721b1
     so that this object can be distingushed from MFont.  */
Packit Service a721b1
  MFont spec;
Packit Service a721b1
Packit Service a721b1
  /* Font identifier. */
Packit Service a721b1
  MSymbol id;
Packit Service a721b1
Packit Service a721b1
  /* Frame on which the font is realized.  */
Packit Service a721b1
  MFrame *frame;
Packit Service a721b1
Packit Service a721b1
  /* The found font.  */
Packit Service a721b1
  MFont *font;
Packit Service a721b1
Packit Service a721b1
  MFontDriver *driver;
Packit Service a721b1
Packit Service a721b1
  /* Font Layout Table for the font.  This is just a container to
Packit Service a721b1
     carry the infomation.  */
Packit Service a721b1
  MSymbol layouter;
Packit Service a721b1
Packit Service a721b1
  /* 1 iff the font is opend by encapsulating client-side font data.  */
Packit Service a721b1
  int encapsulating;
Packit Service a721b1
Packit Service a721b1
  /* Extra information set by MRealizedFont::driver->open.  If
Packit Service a721b1
     non-NULL, it must be a pointer to a managed object.  */
Packit Service a721b1
  void *info;
Packit Service a721b1
Packit Service a721b1
  int x_ppem, y_ppem;
Packit Service a721b1
Packit Service a721b1
  int ascent, descent, max_advance, average_width, baseline_offset;
Packit Service a721b1
Packit Service a721b1
  /* Pointer to the font structure.  */
Packit Service a721b1
  void *fontp;
Packit Service a721b1
Packit Service a721b1
  MRealizedFont *next;
Packit Service a721b1
};
Packit Service a721b1
Packit Service a721b1
typedef struct MFLTFontForRealized {
Packit Service a721b1
  MFLTFont font;
Packit Service a721b1
  MRealizedFont *rfont;
Packit Service a721b1
} MFLTFontForRealized;
Packit Service a721b1
Packit Service a721b1
typedef struct {
Packit Service a721b1
  MFont *font;
Packit Service a721b1
  int score;
Packit Service a721b1
} MFontScore;
Packit Service a721b1
Packit Service a721b1
/** Structure to hold a list of fonts.  */
Packit Service a721b1
Packit Service a721b1
typedef struct
Packit Service a721b1
{
Packit Service a721b1
  MFont object;
Packit Service a721b1
  MFontScore *fonts;
Packit Service a721b1
  int nfonts;
Packit Service a721b1
} MFontList;
Packit Service a721b1
Packit Service a721b1
struct MFontDriver
Packit Service a721b1
{
Packit Service a721b1
  /** Return a font best matching with FONT.  */
Packit Service a721b1
  MFont *(*select) (MFrame *frame, MFont *font, int limited_size);
Packit Service a721b1
Packit Service a721b1
  /** Open a font specified by RFONT.  */
Packit Service a721b1
  MRealizedFont *(*open) (MFrame *frame, MFont *font, MFont *spec,
Packit Service a721b1
			  MRealizedFont *rfont);
Packit Service a721b1
Packit Service a721b1
  /** Set metrics of glyphs in GSTRING from FROM to TO.  */
Packit Service a721b1
  void (*find_metric) (MRealizedFont *rfont, MGlyphString *gstring,
Packit Service a721b1
		       int from, int to);
Packit Service a721b1
Packit Service a721b1
  /** Check if the font has a glyph for CODE.  CODE is a code point of
Packit Service a721b1
      a character in font->encoder->encoding_charset.  Return nonzero
Packit Service a721b1
      iff the font has the glyph.  */
Packit Service a721b1
  int (*has_char) (MFrame *frame, MFont *font, MFont *spec,
Packit Service a721b1
		   int c, unsigned code);
Packit Service a721b1
Packit Service a721b1
  /** Encode CODE into a glyph code the font.  CODE is a code point of
Packit Service a721b1
      a character in rfont->encoder->encoding_charset.  If the font
Packit Service a721b1
      has no glyph for CODE, return MCHAR_INVALID_CODE.  */
Packit Service a721b1
  unsigned (*encode_char) (MFrame *frame, MFont *font, MFont *spec,
Packit Service a721b1
			   unsigned code);
Packit Service a721b1
Packit Service a721b1
  /** Draw glyphs from FROM to TO (exclusive) on window WIN of FRAME
Packit Service a721b1
      at coordinate (X, Y) relative to WIN.  */
Packit Service a721b1
  void (*render) (MDrawWindow win, int x, int y,
Packit Service a721b1
		  MGlyphString *gstring, MGlyph *from, MGlyph *to,
Packit Service a721b1
		  int reverse, MDrawRegion region);
Packit Service a721b1
Packit Service a721b1
  /** Push to PLIST fonts matching with FONT.  MAXNUM if greater than
Packit Service a721b1
      0 limits the number of listed fonts.  Return the number of fonts
Packit Service a721b1
      listed.  */
Packit Service a721b1
  int (*list) (MFrame *frame, MPlist *plist, MFont *font, int maxnum);
Packit Service a721b1
Packit Service a721b1
  /** Push to PLIST font family names (symbol) available on FRAME.  */
Packit Service a721b1
  void (*list_family_names) (MFrame *frame, MPlist *plist);
Packit Service a721b1
Packit Service a721b1
  /** Check if RFONT support CAPABILITY.  */
Packit Service a721b1
  int (*check_capability) (MRealizedFont *rfont, MSymbol capability);
Packit Service a721b1
Packit Service a721b1
  /** Open a font by encapsulating DATA.  */
Packit Service a721b1
  MRealizedFont *(*encapsulate) (MFrame *frame, MSymbol source, void *data);
Packit Service a721b1
Packit Service a721b1
  void (*close) (MRealizedFont *rfont);
Packit Service a721b1
Packit Service a721b1
  int (*check_otf) (MFLTFont *font, MFLTOtfSpec *spec);
Packit Service a721b1
Packit Service a721b1
  int (*drive_otf) (MFLTFont *font, MFLTOtfSpec *spec,
Packit Service a721b1
		    MFLTGlyphString *in, int from, int to,
Packit Service a721b1
		    MFLTGlyphString *out, MFLTGlyphAdjustment *adjustment);
Packit Service a721b1
Packit Service a721b1
  int (*try_otf) (MFLTFont *font, MFLTOtfSpec *spec,
Packit Service a721b1
		  MFLTGlyphString *in, int from, int to);
Packit Service a721b1
Packit Service a721b1
  int (*iterate_otf_feature) (struct _MFLTFont *font, MFLTOtfSpec *spec,
Packit Service a721b1
			      int from, int to, unsigned char *table);
Packit Service a721b1
};
Packit Service a721b1
Packit Service a721b1
/** Initialize the members of FONT.  */
Packit Service a721b1
Packit Service a721b1
#define MFONT_INIT(font) memset ((font), 0, sizeof (MFont))
Packit Service a721b1
Packit Service a721b1
extern MSymbol Mlayouter;
Packit Service a721b1
extern MSymbol Miso8859_1, Miso10646_1, Municode_bmp, Municode_full;
Packit Service a721b1
extern MSymbol Mapple_roman;
Packit Service a721b1
Packit Service a721b1
extern int mfont__flt_init ();
Packit Service a721b1
Packit Service a721b1
extern void mfont__flt_fini ();
Packit Service a721b1
Packit Service a721b1
#ifdef HAVE_FREETYPE
Packit Service a721b1
#include <ft2build.h>
Packit Service a721b1
#include FT_FREETYPE_H
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
#ifdef HAVE_FONTCONFIG
Packit Service a721b1
#include <fontconfig/fontconfig.h>
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
#ifdef HAVE_OTF
Packit Service a721b1
#include <otf.h>
Packit Service a721b1
#else  /* not HAVE_OTF */
Packit Service a721b1
typedef unsigned OTF_Tag;
Packit Service a721b1
#endif /* not HAVE_OTF */
Packit Service a721b1
Packit Service a721b1
enum MFontOpenTypeTable
Packit Service a721b1
  {
Packit Service a721b1
    MFONT_OTT_GSUB,
Packit Service a721b1
    MFONT_OTT_GPOS,
Packit Service a721b1
    MFONT_OTT_MAX
Packit Service a721b1
  };
Packit Service a721b1
Packit Service a721b1
typedef struct
Packit Service a721b1
{
Packit Service a721b1
  M17NObject control;
Packit Service a721b1
  MSymbol language;
Packit Service a721b1
  MSymbol script;
Packit Service a721b1
  MSymbol otf;
Packit Service a721b1
  OTF_Tag script_tag;
Packit Service a721b1
  OTF_Tag langsys_tag;
Packit Service a721b1
  struct {
Packit Service a721b1
    char *str;
Packit Service a721b1
    int nfeatures;
Packit Service a721b1
    OTF_Tag *tags;
Packit Service a721b1
  } features[MFONT_OTT_MAX];
Packit Service a721b1
} MFontCapability;
Packit Service a721b1
Packit Service a721b1
#ifdef HAVE_FREETYPE
Packit Service a721b1
extern MFontDriver mfont__ft_driver;
Packit Service a721b1
Packit Service a721b1
extern int mfont__ft_init ();
Packit Service a721b1
Packit Service a721b1
extern void mfont__ft_fini ();
Packit Service a721b1
Packit Service a721b1
extern int mfont__ft_parse_name (const char *name, MFont *font);
Packit Service a721b1
Packit Service a721b1
extern char *mfont__ft_unparse_name (MFont *font);
Packit Service a721b1
Packit Service a721b1
#ifdef HAVE_OTF
Packit Service a721b1
Packit Service a721b1
extern int mfont__ft_drive_otf (MGlyphString *gstring, int from, int to,
Packit Service a721b1
				MFontCapability *capability);
Packit Service a721b1
Packit Service a721b1
extern int mfont__ft_decode_otf (MGlyph *g);
Packit Service a721b1
Packit Service a721b1
#endif	/* HAVE_OTF */
Packit Service a721b1
Packit Service a721b1
#endif /* HAVE_FREETYPE */
Packit Service a721b1
Packit Service a721b1
extern void mfont__free_realized (MRealizedFont *rfont);
Packit Service a721b1
Packit Service a721b1
extern int mfont__match_p (MFont *font, MFont *spec, int prop);
Packit Service a721b1
Packit Service a721b1
extern int mfont__merge (MFont *dst, MFont *src, int error_on_conflict);
Packit Service a721b1
Packit Service a721b1
extern void mfont__set_spec_from_face (MFont *spec, MFace *face);
Packit Service a721b1
Packit Service a721b1
extern MSymbol mfont__set_spec_from_plist (MFont *spec, MPlist *plist);
Packit Service a721b1
Packit Service a721b1
extern int mfont__has_char (MFrame *frame, MFont *font, MFont *spec, int c);
Packit Service a721b1
Packit Service a721b1
extern unsigned mfont__encode_char (MFrame *frame, MFont *font, MFont *spec,
Packit Service a721b1
				    int c);
Packit Service a721b1
Packit Service a721b1
extern int mfont__get_glyph_id (MFLTFont *font, MFLTGlyphString *gstring,
Packit Service a721b1
				int from, int to);
Packit Service a721b1
Packit Service a721b1
extern MFont *mfont__select (MFrame *frame, MFont *font, int max_size);
Packit Service a721b1
Packit Service a721b1
extern MFontList *mfont__list (MFrame *frame, MFont *spec, MFont *request,
Packit Service a721b1
			       int limited_size);
Packit Service a721b1
Packit Service a721b1
extern MRealizedFont *mfont__open (MFrame *frame, MFont *font, MFont *spec);
Packit Service a721b1
Packit Service a721b1
extern void mfont__get_metric (MGlyphString *gstring, int from, int to);
Packit Service a721b1
Packit Service a721b1
extern int mfont__get_metrics (MFLTFont *font, MFLTGlyphString *gstring,
Packit Service a721b1
			       int from, int to);
Packit Service a721b1
Packit Service a721b1
extern void mfont__set_property (MFont *font, enum MFontProperty key,
Packit Service a721b1
				 MSymbol val);
Packit Service a721b1
Packit Service a721b1
extern int mfont__split_name (char *name, int *property_idx,
Packit Service a721b1
			      unsigned short *point, unsigned short *resy);
Packit Service a721b1
Packit Service a721b1
extern int mfont__parse_name_into_font (const char *name, MSymbol format,
Packit Service a721b1
					MFont *font);
Packit Service a721b1
Packit Service a721b1
extern MPlist *mfont__encoding_list (void);
Packit Service a721b1
Packit Service a721b1
extern MFontCapability *mfont__get_capability (MSymbol sym);
Packit Service a721b1
Packit Service a721b1
extern int mfont__check_capability (MRealizedFont *rfont, MSymbol capability);
Packit Service a721b1
Packit Service a721b1
extern unsigned mfont__flt_encode_char (MSymbol layouter_name, int c);
Packit Service a721b1
Packit Service a721b1
extern int mfont__flt_run (MGlyphString *gstring, int from, int to,
Packit Service a721b1
			   MRealizedFace *rface);
Packit Service a721b1
Packit Service a721b1
#endif /* _M17N_FONT_H_ */