Back to index

texmacs  1.0.7.15
font.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : font.hpp
00004 * DESCRIPTION: fonts
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef FONT_H
00013 #define FONT_H
00014 #include "space.hpp"
00015 #include "renderer.hpp"
00016 
00017 RESOURCE(font);
00018 
00019 struct glyph;
00020 
00021 #define FONT_TYPE_TEX      0
00022 #define FONT_TYPE_UNICODE  1
00023 #define FONT_TYPE_OTHER    2
00024 
00025 /******************************************************************************
00026 * The font structure
00027 ******************************************************************************/
00028 
00029 struct font_rep: rep<font> {
00030   int      type;             // font type
00031   SI       size;             // requested size
00032   SI       design_size;      // design size in points/256
00033   SI       display_size;     // display size in points/PIXEL
00034   double   slope;            // italic slope
00035   space    spc;              // usual space between words
00036   space    extra;            // extra space at end of words
00037   SI       sep;              // separation space between close components
00038 
00039   SI       y1;               // bottom y position
00040   SI       y2;               // top y position
00041   SI       yx;               // height of the x character
00042   SI       yfrac;            // vertical position fraction bar
00043   SI       ysub_lo_base;     // base line for subscripts
00044   SI       ysub_hi_lim;      // upper limit for subscripts
00045   SI       ysup_lo_lim;      // lower limit for supscripts
00046   SI       ysup_lo_base;     // base line for supscripts
00047   SI       ysup_hi_lim;      // upper limit for supscripts
00048   SI       yshift;           // vertical script shift inside fractions
00049 
00050   SI       wpt;              // width of one point in font
00051   SI       wfn;              // wpt * design size in points
00052   SI       wline;            // width of fraction bars and so
00053   SI       wquad;            // quad space (often width of widest character M)
00054 
00055   font_rep (string name);
00056   font_rep (string name, font fn);
00057   void copy_math_pars (font fn);
00058 
00059   virtual void   get_extents (string s, metric& ex) = 0;
00060   virtual void   get_xpositions (string s, SI* xpos);
00061   virtual void   draw (renderer ren, string s, SI x, SI y) = 0;
00062 
00063   virtual double get_left_slope  (string s);
00064   virtual double get_right_slope (string s);
00065   virtual SI     get_left_correction  (string s);
00066   virtual SI     get_right_correction (string s);
00067 
00068   void var_get_extents (string s, metric& ex);
00069   void var_get_xpositions (string s, SI* xpos);
00070   void var_draw (renderer ren, string s, SI x, SI y);
00071   virtual glyph get_glyph (string s);
00072 };
00073 
00074 string default_chinese_font_name ();
00075 string default_japanese_font_name ();
00076 string default_korean_font_name ();
00077 
00078 font error_font (font fn);
00079 font virtual_font (font base, string family, int size, int dpi);
00080 font tt_font (string family, int size, int dpi);
00081 font unicode_font (string family, int size, int dpi);
00082 font unicode_math_font (font up, font it, font bup, font bit, font fb);
00083 font x_font (string family, int size, int dpi);
00084 font tex_font (string fam, int size, int dpi, int dsize=10);
00085 font tex_cm_font (string fam, int size, int dpi, int dsize=10);
00086 font tex_ec_font (string fam, int size, int dpi, int dsize=10);
00087 font tex_la_font (string fam, int size, int dpi, int dsize=10);
00088 font tex_adobe_font (string fam, int size, int dpi, int dsize=10);
00089 font tex_rubber_font (string trl_name,
00090                     string fam, int size, int dpi, int dsize=10);
00091 font tex_dummy_rubber_font (font base_fn);
00092 
00093 void font_rule (tree which, tree by);
00094 font find_font (scheme_tree t);
00095 font find_font (string family, string fn_class,
00096               string series, string shape, int sz, int dpi);
00097 
00098 font math_font (scheme_tree t, font base_fn, font error_fn);
00099 font compound_font (scheme_tree def);
00100 
00101 int  script (int sz, int level);
00102 
00103 #endif // defined FONT_H