1 /* 2 Copyright (C) 2017-2021, Dirk Krause 3 SPDX-License-Identifier: BSD-3-Clause 4 */ 5 6 /* 7 WARNING: This file was generated by the dkct program (see 8 http://dktools.sourceforge.net/ for details). 9 Changes you make here will be lost if dkct is run again! 10 You should modify the original source and run dkct on it. 11 Original source: dk4fontc.ctr 12 */ 13 14 #ifndef DK4FONTC_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4FONTC_H_INCLUDED 1 17 18 19 /** @file dk4fontc.h LaTeX font collector. 20 */ 21 22 #ifndef DK4CONF_H_INCLUDED 23 #if DK4_BUILDING_DKTOOLS4 24 #include "dk4conf.h" 25 #else 26 #include <dktools-4/dk4conf.h> 27 #endif 28 #endif 29 30 #ifndef DK4TYPES_H_INCLUDED 31 #if DK4_BUILDING_DKTOOLS4 32 #include <libdk4base/dk4types.h> 33 #else 34 #include <dktools-4/dk4types.h> 35 #endif 36 #endif 37 38 #ifndef DK4ERROR_H_INCLUDED 39 #if DK4_BUILDING_DKTOOLS4 40 #include <libdk4base/dk4error.h> 41 #else 42 #include <dktools-4/dk4error.h> 43 #endif 44 #endif 45 46 #ifndef DK4FONT_H_INCLUDED 47 #if DK4_BUILDING_DKTOOLS4 48 #include <libdk4gra/dk4font.h> 49 #else 50 #include <dktools-4/dk4font.h> 51 #endif 52 #endif 53 54 #ifndef DK4STO_H_INCLUDED 55 #if DK4_BUILDING_DKTOOLS4 56 #include <libdk4c/dk4sto.h> 57 #else 58 #include <dktools-4/dk4sto.h> 59 #endif 60 #endif 61 62 63 64 /** How to use specified font and size. 65 */ 66 enum dk4_gra_tf_t_ { 67 DK4_GRA_TF_NONE_NONE = 0 , /**< No font choosing. */ 68 DK4_GRA_TF_NONE_SIZE = 1 , /**< No font, with size. */ 69 DK4_GRA_TF_SIMILAR_NONE = 2 , /**< Choose similar font, no size. */ 70 DK4_GRA_TF_SIMILAR_SIZE = 3 , /**< Choose similar font, with size. */ 71 DK4_GRA_TF_EXACT_NONE = 4 , /**< Choose exact font but no size. */ 72 DK4_GRA_TF_EXACT_SIZE = 5 , /**< Exact font and size. */ 73 74 /** For normal text use exact font as specified. 75 */ 76 DK4_GRA_TF_NORMAL = DK4_GRA_TF_EXACT_SIZE , 77 78 /** For special text use similar features and size. 79 */ 80 DK4_GRA_TF_SPECIAL = DK4_GRA_TF_SIMILAR_SIZE , 81 }; 82 83 84 85 /** How to use specified font and size. 86 */ 87 typedef enum dk4_gra_tf_t_ dk4_gra_tf_t; 88 89 90 91 /** One font to register. 92 */ 93 typedef struct { 94 double fsz; /**< Font size in pt. */ 95 size_t nf; /**< Number of font in font collection. */ 96 int fno; /**< Font number or feature set. */ 97 int fex; /**< Flag: Use exact font. */ 98 } dk4_font_item_t; 99 100 101 102 /** Font collection. 103 */ 104 typedef struct { 105 dk4_sto_t *s_fo; /**< Fonts by font ID or font features. */ 106 dk4_sto_t *s_fn; /**< Fonts by number. */ 107 dk4_sto_it_t *i_fo; /**< Iterator for fonts by ID or features. */ 108 dk4_sto_it_t *i_fn; /**< Iterator for fonts by number. */ 109 size_t nfonts; /**< Number of fonts stored, next font. */ 110 } dk4_font_collector_t; 111 112 113 #ifdef __cplusplus 114 extern "C" { 115 #endif 116 117 /** Open new font collector, allocate resources. 118 After using a font collector obtained from this function the collector 119 must be closed using the dk4fontc_close() function. 120 @param erp Error report for diagnostics. 121 @return Valid pointer to new font collector on success, NULL on error. 122 123 Error codes: 124 - DK4_E_MEMORY_ALLOCATION_FAILED<br> 125 if there is not enough memory available. 126 */ 127 dk4_font_collector_t * 128 dk4fontc_open( 129 dk4_er_t *erp 130 ); 131 132 /** Close font collector, release resources. 133 @param fc Font collector to close and release. 134 */ 135 void 136 dk4fontc_close( 137 dk4_font_collector_t *fc 138 ); 139 140 /** Check whether a specified font is already in the collector, 141 add if necessary. 142 @param pdst Address of result variable for font number. 143 @param fc Font collector to query. 144 @param fno Font number. 145 @param fsz Font size in pt. 146 @param fex Flag: Use exact font (1) or similar font (0). 147 @param erp Error report. 148 @return 1 on success (font in collector or successfully added), 149 0 on error (failed to add). 150 151 Error codes: 152 - DK4_E_INVALID_ARGUMENTS<br> 153 if any argument is invalid (pdst or fc is NULL, fno is outside 154 the valid range or fsz is negative), 155 - DK4_E_MEMORY_ALLOCATION_FAILED<br> 156 if a memory allocation failed. 157 - DK4_E_MATH_OVERFLOW<br> 158 on numeric overflow in the number of used fonts 159 (too many fonts used). 160 */ 161 int 162 dk4fontc_add_font( 163 size_t *pdst, 164 dk4_font_collector_t *fc, 165 int fno, 166 double fsz, 167 int fex, 168 dk4_er_t *erp 169 ); 170 171 #ifdef __cplusplus 172 } 173 #endif 174 175 176 /* vim: set ai sw=4 ts=4 : */ 177 178 179 #endif 180