1 /* 2 * Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). 3 * All Rights Reserved. 4 * 5 * This software is licensed as OpenSource, under the Apache License, Version 6 * 2.0. 7 * This license is available at: http://opensource.org/licenses/Apache-2.0. 8 */ 9 10 /* The following ifdef block is the standard way of creating macros which make 11 * exporting from a DLL simpler. All files within this DLL are compiled with 12 * the ACLIB_API symbol defined on the command line. This symbol should not be 13 * defined on any project that uses this DLL. This way any other project whose 14 * source files include this file see ACLIB_API functions as being imported 15 * from a DLL, wheras this DLL sees symbols defined with this macro as being 16 * exported. 17 */ 18 #ifndef PSAUTOHINT_H_ 19 #define PSAUTOHINT_H_ 20 21 #include <stddef.h> 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 #ifdef AC_C_LIB_EXPORTS 28 29 #ifdef _WIN32 30 #define ACLIB_API __declspec(dllexport) 31 #elif __GNUC__ && __MACH__ 32 #define ACLIB_API __attribute__((visibility("default"))) 33 #else 34 #define ACLIB_API 35 #endif 36 37 #else 38 #define ACLIB_API 39 #endif 40 41 enum 42 { 43 AC_Success, 44 AC_FatalError, 45 AC_UnknownError, 46 AC_InvalidParameterError 47 }; 48 49 enum 50 { 51 AC_LogDebug = -1, 52 AC_LogInfo, 53 AC_LogWarning, 54 AC_LogError 55 }; 56 57 58 typedef struct ACBuffer ACBuffer; 59 60 ACLIB_API ACBuffer* ACBufferNew(size_t size); 61 ACLIB_API void ACBufferFree(ACBuffer* buffer); 62 ACLIB_API void ACBufferReset(ACBuffer* buffer); 63 ACLIB_API void ACBufferWrite(ACBuffer* buffer, char* data, size_t length); 64 ACLIB_API void ACBufferWriteF(ACBuffer* buffer, char* format, ...); 65 ACLIB_API void ACBufferRead(ACBuffer* buffer, char** data, size_t* length); 66 67 /* 68 * Function: AC_getVersion 69 * 70 * Returns AC library version. 71 */ 72 ACLIB_API const char* AC_getVersion(void); 73 74 /* 75 * Function: AC_SetMemManager 76 * 77 * If this is supplied, then the AC lib will call this function for all memory 78 * allocations. Otherwise it will use alloc/malloc/free. 79 */ 80 typedef void* (*AC_MEMMANAGEFUNCPTR)(void* ctxptr, void* old, size_t size); 81 82 ACLIB_API void AC_SetMemManager(void* ctxptr, AC_MEMMANAGEFUNCPTR func); 83 84 /* 85 * Function: AC_SetReportCB 86 * 87 * If this is supplied, then the AC lib will use this call back to report 88 * messages. 89 * 90 */ 91 typedef void (*AC_REPORTFUNCPTR)(char* msg, int level); 92 93 ACLIB_API void AC_SetReportCB(AC_REPORTFUNCPTR reportCB); 94 95 /* 96 * Function: AC_SetReportStemsCB 97 * 98 * If this is called, then the AC lib will write all the stem widths it 99 * encounters. 100 * 101 * If allStems is false, then stems defined by curves are excluded from the 102 * reporting. 103 * 104 * userData is a pointer provided by the client, and will be passed to report 105 * callback functions. 106 * 107 * Note that the callbacks should not dispose of the glyphName memory; that 108 * belongs to the AC lib. It should be copied immediately - it may may last 109 * past the return of the callback. 110 */ 111 typedef void (*AC_REPORTSTEMPTR)(float top, float bottom, char* glyphName, 112 void* userData); 113 114 ACLIB_API void AC_SetReportStemsCB(AC_REPORTSTEMPTR hstemCB, 115 AC_REPORTSTEMPTR vstemCB, 116 unsigned int allStems, 117 void* userData); 118 119 /* 120 * Function: AC_SetReportZonesCB 121 * 122 * If this is called , then the AC lib will write all the alignment zones it 123 * encounters. 124 * 125 * userData is a pointer provided by the client, and will be passed to report 126 * callback functions. 127 * 128 * Note that the callbacks should not dispose of the glyphName memory; that 129 * belongs to the AC lib. It should be copied immediately - it may may last 130 * past the return of the callback. 131 */ 132 typedef void (*AC_REPORTZONEPTR)(float top, float bottom, char* glyphName, 133 void* userData); 134 135 ACLIB_API void AC_SetReportZonesCB(AC_REPORTZONEPTR charCB, 136 AC_REPORTZONEPTR stemCB, 137 void* userData); 138 139 /* 140 * Function: AC_SetReportRetryCB 141 * 142 * If this is called, then the AC lib will call this function when it wants to 143 * discard the previous log content and start from scratch. 144 * 145 * This is to be used when AC_SetReportZonesCB or AC_SetReportStemsCB are used. 146 */ 147 typedef void (*AC_RETRYPTR)(void* userData); 148 149 ACLIB_API void AC_SetReportRetryCB(AC_RETRYPTR retryCB, void* userData); 150 151 /* 152 * Function: AutoHintString 153 * 154 * This function takes srcbezdata, a pointer to null terminated C string 155 * containing glyph data in the bez format (see bez spec) and fontinfo, a 156 * pointer to null terminated C string containing fontinfo for the bez glyph. 157 * 158 * Hint information is added to the bez data and returned to the caller through 159 * the buffer dstbezdata. dstbezdata must be allocated before the call and a 160 * pointer to its length passed as *length. If the space allocated is 161 * insufficient for the target bezdata, it will be reallocated as needed. 162 */ 163 ACLIB_API int AutoHintString(const char* srcbezdata, const char* fontinfo, 164 ACBuffer* outbuffer, int allowEdit, 165 int allowHintSub, int roundCoords); 166 167 /* 168 * Function: AutoHintStringMM 169 * 170 */ 171 ACLIB_API int AutoHintStringMM(const char** srcbezdata, int nmasters, 172 const char** masters, ACBuffer** outbuffers); 173 174 /* 175 * Function: AC_initCallGlobals 176 * 177 * This function must be called in the case where the program is switching 178 * between any of the auto-hinting and stem reporting modes while running. 179 */ 180 ACLIB_API void AC_initCallGlobals(void); 181 182 #ifdef __cplusplus 183 } 184 #endif 185 #endif /* PSAUTOHINT_H_ */ 186