File: ml_font.h

package info (click to toggle)
mlterm 2.4.0.cvs20020414-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 14,416 kB
  • ctags: 3,528
  • sloc: ansic: 48,035; sh: 6,413; perl: 1,701; makefile: 443
file content (133 lines) | stat: -rw-r--r-- 2,730 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 *	$Id: ml_font.h,v 1.12 2002/02/10 09:41:21 arakiken Exp $
 */

/*
 * ANTI_ALIAS macro should be concerned.
 */

#ifndef  __ML_FONT_H__
#define  __ML_FONT_H__


#include  <X11/Xlib.h>
#include  <kiklib/kik_types.h>	/* u_int */
#include  <mkf/mkf_charset.h>	/* mkf_charset_t */

#ifdef  ANTI_ALIAS
#include  <X11/Xft/Xft.h>
#endif

#include  "ml_decsp_font.h"


#define  RESET_FONT_THICKNESS(cs)  ((cs) &= ~(FONT_MEDIUM | FONT_BOLD))
#define  RESET_FONT_SLANT(cs)      ((cs) &= ~(FONT_ROMAN | FONT_ITALIC))
#define  RESET_FONT_WIDTH(cs)      ((cs) &= ~(FONT_NORMAL))

#define  DEFAULT_FONT_ATTR(cs)  ((cs) | FONT_MEDIUM | FONT_ROMAN | FONT_NORMAL)


typedef enum ml_font_present
{
	FONT_VAR_WIDTH = 0x01 ,
	FONT_AA = 0x02 ,
	FONT_VERTICAL = 0x04 ,

} ml_font_present_t ;

typedef enum ml_font_attr
{
	/* 0x00 - MAX_CHARSET(0x7ff) is reserved for mkf_charset_t */

	/* 0x1000 - 0x2000 is reserved for font thickness */
	FONT_MEDIUM = 0x1000u ,
	FONT_BOLD   = 0x2000u ,

	/* 0x4000 - 0x8000 is reserved for font slant */
	FONT_ROMAN  = 0x4000u ,
	FONT_ITALIC = 0x8000u ,
	
	/* 0x10000 - 0x10000 is reserved for font width */
	FONT_NORMAL = 0x10000u ,

	/* 0x20000 - 0x20000 is reserved for font */
	FONT_BIWIDTH = 0x20000u ,

} ml_font_attr_t ;

typedef struct  ml_font
{
	/*
	 * private
	 */
	Display *  display ;

	/*
	 * public(readonly)
	 */
	ml_font_attr_t  attr ;

	int8_t  is_var_col_width ;
	
	/*
	 * private
	 */
	int8_t  is_vertical ;


	/*
	 * public(readonly)
	 */
#ifdef  ANTI_ALIAS
	XftFont *  xft_font ;
#endif
	XFontStruct *  xfont ;
	ml_decsp_font_t *  decsp_font ;

	/*
	 * these members are never zero.
	 */
	u_int  cols ;
	u_int  width ;
	u_int  height ;
	u_int  height_to_baseline ;

	/* this is not zero only when is_proportional is true and xfont is set. */
	int  x_off ;

	int8_t  is_double_drawing ;
	int8_t  is_proportional ;
	
} ml_font_t ;


int  ml_compose_dec_special_font(void) ;


ml_font_t *  ml_font_new( Display *  display , ml_font_attr_t  attr) ;

int  ml_font_delete( ml_font_t *  font) ;

int  ml_font_set_font_present( ml_font_t *  font , ml_font_present_t  font_present) ;

int  ml_font_set_xft_font( ml_font_t *  font , char *  fontname , u_int  fontsize ,
	u_int  col_width , int  use_medium_for_bold) ;
	
int  ml_font_set_xfont( ml_font_t *  font , char *  fontname , u_int  fontsize ,
	u_int  col_width , int  use_medium_for_bold) ;

mkf_charset_t  ml_font_cs( ml_font_t *  font) ;

int  ml_change_font_cs( ml_font_t *  font , mkf_charset_t  cs) ;

int  ml_change_font_cols( ml_font_t *  font , u_int  cols) ;

u_int  ml_calculate_char_width( ml_font_t *  font , u_char *  ch , size_t  len , mkf_charset_t  cs) ;

#ifdef  DEBUG
int  ml_font_dump( ml_font_t *  font) ;
#endif


#endif