summaryrefslogtreecommitdiff
path: root/support/dktools/dk4fontc.h
blob: d9a736d02e416720ac3fd573d4ba7b7f8c4fb2e7 (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
Copyright (C) 2017-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/

/*
	WARNING: This file was generated by the dkct program (see
	http://dktools.sourceforge.net/ for details).
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: dk4fontc.ctr
*/

#ifndef DK4FONTC_H_INCLUDED
/** Avoid multiple inclusions. */
#define DK4FONTC_H_INCLUDED 1


#line 8 "dk4fontc.ctr"

/**	@file	dk4fontc.h	LaTeX font collector.
*/

#ifndef	DK4CONF_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4conf.h"
#else
#include <dktools-4/dk4conf.h>
#endif
#endif

#ifndef	DK4TYPES_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4types.h"
#else
#include <dktools-4/dk4types.h>
#endif
#endif

#ifndef	DK4ERROR_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4error.h"
#else
#include <dktools-4/dk4error.h>
#endif
#endif

#ifndef	DK4FONT_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4font.h"
#else
#include <dktools-4/dk4font.h>
#endif
#endif

#ifndef	DK4STO_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4sto.h"
#else
#include <dktools-4/dk4sto.h>
#endif
#endif



/**	How to use specified font and size.
*/
enum dk4_gra_tf_t_ {
	DK4_GRA_TF_NONE_NONE	= 0 ,	/**< No font choosing. */
	DK4_GRA_TF_NONE_SIZE	= 1 ,	/**< No font, with size. */
	DK4_GRA_TF_SIMILAR_NONE	= 2 ,	/**< Choose similar font, no size. */
	DK4_GRA_TF_SIMILAR_SIZE	= 3 ,	/**< Choose similar font, with size. */
	DK4_GRA_TF_EXACT_NONE	= 4 ,	/**< Choose exact font but no size. */
	DK4_GRA_TF_EXACT_SIZE	= 5 ,	/**< Exact font and size. */

							/**	For normal text use exact font as specified.
							*/
	DK4_GRA_TF_NORMAL		= DK4_GRA_TF_EXACT_SIZE ,

							/**	For special text use similar features and size.
							*/
	DK4_GRA_TF_SPECIAL		= DK4_GRA_TF_SIMILAR_SIZE ,
};



/**	How to use specified font and size.
*/
typedef enum dk4_gra_tf_t_ dk4_gra_tf_t;



/**	One font to register.
*/
typedef struct {
	double				fsz;	/**< Font size in pt. */
	size_t				nf;		/**< Number of font in font collection. */
	int					fno;	/**< Font number or feature set. */
	int					fex;	/**< Flag: Use exact font. */
} dk4_font_item_t;



/**	Font collection.
*/
typedef struct {
	dk4_sto_t		*s_fo;		/**< Fonts by font ID or font features. */
	dk4_sto_t		*s_fn;		/**< Fonts by number. */
	dk4_sto_it_t	*i_fo;		/**< Iterator for fonts by ID or features. */
	dk4_sto_it_t	*i_fn;		/**< Iterator for fonts by number. */
	size_t			 nfonts;	/**< Number of fonts stored, next font. */
} dk4_font_collector_t;


#ifdef	__cplusplus
extern "C" {
#endif

/**	Open new font collector, allocate resources.
	After using a font collector obtained from this function the collector
	must be closed using the dk4fontc_close() function.
	@param	erp	Error report for diagnostics.
	@return	Valid pointer to new font collector on success, NULL on error.

	Error codes:
	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
	  if there is not enough memory available.
*/
dk4_font_collector_t *
dk4fontc_open(
	dk4_er_t				*erp
);

/**	Close font collector, release resources.
	@param	fc	Font collector to close and release.
*/
void
dk4fontc_close(
	dk4_font_collector_t	*fc
);

/**	Check whether a specified font is already in the collector,
	add if necessary.
	@param	pdst	Address of result variable for font number.
	@param	fc		Font collector to query.
	@param	fno		Font number.
	@param	fsz		Font size in pt.
	@param	fex		Flag: Use exact font (1) or similar font (0).
	@param	erp		Error report.
	@return			1 on success (font in collector or successfully added),
					0 on error (failed to add).

	Error codes:
	- DK4_E_INVALID_ARGUMENTS<br>
	  if any argument is invalid (pdst or fc is NULL, fno is outside
	  the valid range or fsz is negative),
	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
	  if a memory allocation failed.
	- DK4_E_MATH_OVERFLOW<br>
	  on numeric overflow in the number of used fonts
	  (too many fonts used).
*/
int
dk4fontc_add_font(
	size_t					*pdst,
	dk4_font_collector_t	*fc,
	int						 fno,
	double					 fsz,
	int						 fex,
	dk4_er_t				*erp
);

#ifdef	__cplusplus
}
#endif


/* vim: set ai sw=4 ts=4 : */


#endif