]> www.fi.muni.cz Git - evince.git/blob - dvi/dvilib/dl-pkfont.hh
New directory with the beginning of a .dvi backend.
[evince.git] / dvi / dvilib / dl-pkfont.hh
1 #ifndef DL_PKFONT_HH__
2 #define DL_PKFONT_HH__
3
4 #include "dl-loader.hh"
5 #include "dl-refcounted.hh"
6 #include "dl-font.hh"
7
8 #include <vector>
9 #include <map>
10
11 namespace DviLib {
12     
13     class RleContext;
14     
15     enum CountType {
16         RUN_COUNT,
17         REPEAT_COUNT
18     };
19     
20     class PkChar : public AbstractCharacter {
21         uint dyn_f;
22         bool first_is_black;    // if first run count is black or white
23         int character_code;
24         int tfm_width;          // in what units? FIXME
25         uint dx;                // escapement - what is this? FIXME
26         uint dy;
27         uint width;             // in pixels
28         uint height;            // in pixels
29         int hoffset;
30         int voffset;
31         
32         bool unpacked;
33         union {
34             unsigned char *bitmap;  // 32 bit/pixel ARGB format
35             unsigned char *packed;
36         } data;
37         
38         CountType get_count (RleContext& nr, uint *count);
39         void unpack_rle (RleContext& nr);
40         void unpack_bitmap (void);
41         void unpack (void);
42     public:
43         PkChar (AbstractLoader &l);
44         virtual void paint (DviRuntime &runtime);
45         const unsigned char *get_bitmap (void) 
46         { 
47             if (!unpacked)
48                 unpack ();
49             return data.bitmap;
50         }
51         uint get_width (void)
52         {
53             return width;
54         }
55         uint get_height (void)
56         {
57             return height;
58         }
59         virtual int get_tfm_width (void)
60         {
61             return tfm_width;
62         }
63         int get_hoffset (void) 
64         {
65             return hoffset;
66         }
67         int get_voffset (void)
68         {
69             return voffset;
70         }
71         int get_character_code (void) { return character_code; }
72     };
73     
74     class PkFont : public AbstractFont {
75         AbstractLoader& loader;
76         uint id;
77         string comment;
78         uint design_size;
79         uint checksum;
80         uint hppp;              /* horizontal pixels per point */
81         uint vppp;              /* vertical  pixels per point */
82         map <uint, PkChar *> chars;
83         int at_size;
84         void load (void);
85     public:
86         PkFont (AbstractLoader& l);
87         PkFont (AbstractLoader& l, int at_size);
88         virtual PkChar *get_char (int ccode)
89         {
90             return chars[ccode]; 
91         }
92         virtual int get_design_size (void)
93         {
94             return design_size; 
95         }
96         virtual int get_at_size (void)
97         {
98             return at_size;
99         }
100         virtual ~PkFont () {}
101     };
102 }
103
104 #endif /* DL_PKFONT_HH__ */