File: gfont.h

package info (click to toggle)
gfontview 0.3.2-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 480 kB
  • ctags: 275
  • sloc: cpp: 4,741; sh: 327; makefile: 47
file content (118 lines) | stat: -rw-r--r-- 3,302 bytes parent folder | download
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
71
72
73
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

/* -*- mode:C++ -*- */


#ifndef _GFONT_H
#define _GFONT_H



#include <t1lib.h>
#include <freetype.h>
#include <ftxerr18.h>
#include <ftxkern.h>
#include <ftxpost.h>



typedef void (Callback) (GtkWidget*, gpointer);


enum FontType {T1FONT, TTFONT};

struct T1Data {
  int fontID;
  char **encoding;
};


struct TTData {
  TT_Face face; 
  TT_Face_Properties properties;
  TT_Kerning kerndir;
  guint kernpairs, kerntable;
  bool PSloaded;
};


/* 
   Each row of the font selection list has a FontData structure associated to it
   A window which needs access to the structure after being created 
   (like the fonttables) has to increase the refcount when
   created and decrease it when destroyed. If the FontData is not visible, 
   the structure shall be destroyed when destroying the window (calling destroyfont)
*/
struct FontData {
  FontType fontType;
  union {
    struct T1Data t1data;
    struct TTData ttdata;
  };
  int num_glyphs;
  char *fontName;
  char *fontFile;
  int refcount;    // How oft the font is used by windows that will access it
  bool visible;    // Whether the font is being displayed in the actual font list
};



class InputDialog {
public:
  InputDialog(const char* labeltext, const char* entrytext);
  GtkWidget* getWidget(void) {return hbox;}
  void setText(const char* text) {gtk_entry_set_text(GTK_ENTRY(entry), text);}
  const char *getText(void) {return gtk_entry_get_text(GTK_ENTRY(entry));}
  void setEntryWidth(int width) {gtk_widget_set_usize(entry, width, -1);};
protected:
  GtkWidget *hbox, *label, *entry;
};



// ********************* Prototypes

// T1 functions
const char* GetT1error(int err);
bool is_t1font(gchar *pathname, FontData *fd);
void t1_showchar(FontData* fd, guint character, double size);
void t1_showstring(FontData* fd, const char* string, double size);
void t1_fonttable(FontData* fd, double size);
void t1_drawsample(FontData* fd, const char* msg, double size);
bool t1_downloadfont(FILE* fp, FontData *fd);
void t1_showproperties(FontData *fd, GtkWidget *window);


// TT funtions
void fill_ttfontdata(FontData* fd);
const char* getfontname(FontData* fd, int idx);
bool is_ttfont(gchar *pathname, FontData *fd);
bool is_ttfontcollection(gchar *pathname, FontData *fd);
void tt_showchar(FontData* fd, guint character, double size);
void tt_showstring(FontData* fd, const char* string, double size);
void tt_fonttable(FontData* fd, double size);
void tt_drawsample(FontData* fd, const char* msg, double size);
bool tt_downloadfont(FILE* fp, FontData *fd);
void tt_showproperties(FontData *fd, GtkWidget *window);


// Others
gint expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data);
gint image_clicked(GtkWidget *widget, GdkEventButton *event, gpointer data);

Callback delete_pixmap, delete_image;
Callback show_message_window, makeabout, printfont, 
  show_properties, save_names;

void make_message_window(void);
void add_error(FontData* fd, const char* msg, ...);
void errormsg(const char* msg, ...);
GtkWidget* makeicon(GtkWidget* toplevel, char** pixmap);
void destroyfont(FontData *fd);
bool ask_yes_no(GtkWidget *parent, const char* msg, ...);
void save_asgif(GtkWidget *window);
GtkWidget *make_imagepopupmenu(GtkWidget *window);
void set_window_busy(GtkWidget *window, bool state);


#endif _GFONT_H