Back to index

texmacs  1.0.7.15
charmap.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : compound_font.cpp
00004 * DESCRIPTION: fonts which are agglomerated from several other fonts.
00005 * COPYRIGHT  : (C) 2005  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 CHARMAP_H
00013 #define CHARMAP_H
00014 #include "resource.hpp"
00015 
00016 RESOURCE(charmap);
00017 
00018 /******************************************************************************
00019 * The charmap structure for finding the physical font
00020 ******************************************************************************/
00021 
00022 struct charmap_rep: rep<charmap> {
00023   int                    fast_map[256];
00024   hashmap<string,int>    slow_map;
00025   hashmap<string,string> slow_subst;
00026 
00027 public:
00028   charmap_rep (string name);
00029 
00030   inline virtual int arity () { return 1; }
00031   inline virtual charmap child (int i) {
00032     ASSERT (i == 0, "bad child");
00033     return this; }
00034   inline virtual void lookup (string s, int& ch, string& r) { ch= 0; r= s; }
00035   inline void cached_lookup (string s, int& ch, string& r) {
00036     if (!slow_map->contains (s)) lookup (s, slow_map (s), slow_subst (s));
00037     ch= slow_map   (s);
00038     r = slow_subst (s);
00039   }
00040 
00041   void advance (string s, int& pos, string& r, int& ch);
00042 };
00043 
00044 charmap load_charmap (tree def);
00045 
00046 #endif // defined CHARMAP_H