Subversion Repositories filter_foundry

Rev

Rev 193 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
259 daniel-mar 1
/*
2
 * ATMInterface.c
3
 *
4
 * Version 3.0
5
 *
6
 * Adobe Type Manager is a trademark of Adobe Systems Incorporated.
7
 * Copyright 1983-1991 Adobe Systems Incorporated.
8
 * All Rights Reserved.
9
 */
10
 
11
#if THINK_C >= 5 || applec
12
#include <Types.h>
13
#include <Dialogs.h>
14
#include <Files.h>
15
#include <Devices.h>
16
#ifdef THINK_C
17
#include <pascal.h>
18
#endif
19
#endif
20
 
21
#if THINK_C >= 5 || applec
22
#define CALL_PASCAL             0                               /* can make Pascal calls directly */
23
#else
24
#define CALL_PASCAL             1                               /* needs CallPascal() help */
25
#endif
26
 
27
#include "ATMInterface.h"
28
 
29
#ifndef FALSE
30
#define FALSE 0
31
#endif
32
 
33
short                   ATMOpen = 0;
34
short                   ATMOpenVersion;
35
LATEST_PROCS    ATMProcs;
36
 
37
short initVersionATM(short version)
38
        {
39
        CntrlParam c;
40
        OSErr   err;
41
 
42
        ATMOpen = 0;
43
 
44
        if (OpenDriver((StringPtr) "\p.ATM", &c.ioCRefNum))
45
                return 0;
46
 
47
        /* Use ATMPascalProcsStatusCode for all routines to use all pascal interfaces. */
48
        c.csCode = ATMProcsStatusCode;
49
        ATMProcs.version = version;
50
        *(ATMProcs5 **) c.csParam = &ATMProcs;
51
 
52
        if (err = PBStatus((ParmBlkPtr) &c, 0))
53
                return 0;
54
 
55
        ATMOpenVersion = version;
56
        return ATMOpen = 1;
57
        }
58
 
59
short initPascalVersionATM(short version)
60
        {
61
        CntrlParam c;
62
        OSErr   err;
63
 
64
        ATMOpen = 0;
65
 
66
        if (OpenDriver((StringPtr) "\p.ATM", &c.ioCRefNum))
67
                return 0;
68
 
69
        /* Use ATMPascalProcsStatusCode for all routines to use all pascal interfaces. */
70
        c.csCode = ATMPascalProcsStatusCode;
71
        ATMProcs.version = version;
72
        *(ATMProcs5 **) c.csParam = &ATMProcs;
73
 
74
        if (err = PBStatus((ParmBlkPtr) &c, 0))
75
                return 0;
76
 
77
        ATMOpenVersion = version;
78
        return ATMOpen = 1;
79
        }
80
 
81
short fontAvailableATM(short family, short style)
82
        {
83
        return ATMOpen ? (*ATMProcs.fontAvailable)(family, style) : 0;
84
        }
85
 
86
short showTextATM(Byte *text, short length, ATMFixedMatrix *matrix)
87
        {
88
        /* Note: this really is "showText", version 3 style. */
89
        return (ATMOpen && ATMOpenVersion == ATMProcs3Version) ?
90
                (*(short (*)(StringPtr , short, ATMFixedMatrix *)) ATMProcs.showTextErr)
91
                        (text, length, matrix) : length;
92
        }
93
 
94
short showTextATMErr(Byte *text, short length, ATMFixedMatrix *matrix, short *errorCode)
95
        {
96
        return (ATMOpen && ATMOpenVersion >= ATMProcs4Version) ? (*ATMProcs.showTextErr)
97
                ((void *) text, length, matrix, errorCode) : length;
98
        }
99
 
100
short xyshowTextATM(Byte *text, short length, ATMFixedMatrix *matrix, ATMFixed *displacements)
101
        {
102
        /* Note: this really is "xyshowText", version 3 style. */
103
        return (ATMOpen && ATMOpenVersion == ATMProcs3Version) ?
104
                (*(short (*)(StringPtr , short, ATMFixedMatrix *, ATMFixed *)) ATMProcs.xyshowTextErr)
105
                        (text, length, matrix, displacements) : length;
106
        }
107
 
108
short xyshowTextATMErr(Byte *text, short length, ATMFixedMatrix *matrix,
109
                                        ATMFixed *displacements, short *errorCode)
110
        {
111
        return (ATMOpen && ATMOpenVersion >= ATMProcs4Version) ? (*ATMProcs.xyshowTextErr)
112
                ((void *) text, length, matrix, displacements, errorCode) : length;
113
        }
114
 
115
short getOutlineATM(
116
        short c,
117
        ATMFixedMatrix *matrix,
118
        Ptr clientHook,
119
        short (*MoveTo)(),
120
        short (*LineTo)(),
121
        short (*CurveTo)(),
122
        short (*ClosePath)())
123
        {
124
        if (!ATMOpen)
125
                return ATM_NOT_ON;
126
        return ATMOpenVersion >= ATMProcs4Version ?
127
                (*ATMProcs.getOutline)(c, matrix, clientHook, MoveTo, LineTo, CurveTo, ClosePath) : ATM_WRONG_VERSION;
128
        }                              
129
 
130
short startFillATM(void)
131
        {
132
        if (!ATMOpen)
133
                return ATM_NOT_ON;
134
        return ATMOpenVersion >= ATMProcs4Version ?
135
                (*ATMProcs.startFill)() : ATM_WRONG_VERSION;
136
        }                              
137
 
138
short fillMoveToATM(pc)
139
        ATMPFixedPoint pc;
140
        {
141
        if (!ATMOpen)
142
                return ATM_NOT_ON;
143
        return ATMOpenVersion >= ATMProcs4Version ?
144
                (*ATMProcs.fillMoveTo)(pc) : ATM_WRONG_VERSION;
145
        }                              
146
 
147
short fillLineToATM(pc)
148
        ATMPFixedPoint pc;
149
        {
150
        if (!ATMOpen)
151
                return ATM_NOT_ON;
152
        return ATMOpenVersion >= ATMProcs4Version ?
153
                (*ATMProcs.fillLineTo)(pc) : ATM_WRONG_VERSION;
154
        }                              
155
 
156
short fillCurveToATM(pc1, pc2, pc3)
157
        ATMPFixedPoint pc1, pc2, pc3;
158
        {
159
        if (!ATMOpen)
160
                return ATM_NOT_ON;
161
        return ATMOpenVersion >= ATMProcs4Version ?
162
                (*ATMProcs.fillCurveTo)(pc1, pc2, pc3) : ATM_WRONG_VERSION;
163
        }                              
164
 
165
short fillClosePathATM(void)
166
        {
167
        if (!ATMOpen)
168
                return ATM_NOT_ON;
169
        return ATMOpenVersion >= ATMProcs4Version ?
170
                (*ATMProcs.fillClosePath)() : ATM_WRONG_VERSION;
171
        }                              
172
 
173
short endFillATM(void)
174
        {
175
        if (!ATMOpen)
176
                return ATM_NOT_ON;
177
        return ATMOpenVersion >= ATMProcs4Version ?
178
                (*ATMProcs.endFill)() : ATM_WRONG_VERSION;
179
        }                              
180
 
181
void disableATM(void)
182
        {
183
        if (!ATMOpen)
184
                return;
185
        if (ATMOpenVersion >= ATMProcs5Version)
186
#if CALL_PASCAL
187
                CallPascal(ATMProcs.disable);
188
#else
189
                (*ATMProcs.disable)();
190
#endif
191
        }                              
192
 
193
void reenableATM(void)
194
        {
195
        if (!ATMOpen)
196
                return;
197
        if (ATMOpenVersion >= ATMProcs5Version)
198
#if CALL_PASCAL
199
                CallPascal(ATMProcs.reenable);
200
#else
201
                (*ATMProcs.reenable)();
202
#endif
203
        }                              
204
 
205
short getBlendedFontTypeATM(StringPtr fontName, short fondID)
206
        {
207
        if (!ATMOpen)
208
                return ATMNotBlendFont;
209
        return ATMOpenVersion >= ATMProcs5Version ?
210
#if CALL_PASCAL
211
                CallPascalW(fontName, fondID, ATMProcs.getBlendedFontType)
212
#else
213
                (*ATMProcs.getBlendedFontType)(fontName, fondID)
214
#endif
215
                        : ATMNotBlendFont;
216
        }
217
 
218
ATMErr encodeBlendedFontNameATM(StringPtr familyName, short numAxes,
219
                                Fixed *coords, StringPtr blendName)
220
        {
221
        if (!ATMOpen)
222
                return ATM_NOT_ON;
223
        return ATMOpenVersion >= ATMProcs5Version ?
224
#if CALL_PASCAL
225
                CallPascalW(familyName, numAxes, coords, blendName, ATMProcs.encodeBlendedFontName)
226
#else
227
                (*ATMProcs.encodeBlendedFontName)(familyName, numAxes, coords, blendName)
228
#endif
229
                        : ATM_WRONG_VERSION;
230
        }
231
 
232
ATMErr decodeBlendedFontNameATM(StringPtr blendName, StringPtr familyName,
233
                        short *numAxes, Fixed *coords, StringPtr displayInstanceStr)
234
        {
235
        if (!ATMOpen)
236
                return ATM_NOT_ON;
237
        return ATMOpenVersion >= ATMProcs5Version ?
238
#if CALL_PASCAL
239
                CallPascalW(blendName, familyName, numAxes, coords, displayInstanceStr,
240
                                                ATMProcs.decodeBlendedFontName)
241
#else
242
                (*ATMProcs.decodeBlendedFontName)(blendName, familyName, numAxes, coords, displayInstanceStr)
243
#endif
244
                        : ATM_WRONG_VERSION;
245
        }
246
 
247
ATMErr  addMacStyleToCoordsATM(Fixed *coords, short macStyle, Fixed *newCoords, short *stylesLeft)
248
        {
249
        if (!ATMOpen)
250
                return ATM_NOT_ON;
251
        return ATMOpenVersion >= ATMProcs5Version ?
252
#if CALL_PASCAL
253
                CallPascalW(coords, macStyle, newCoords, stylesLeft,
254
                                                ATMProcs.addMacStyleToCoords)
255
#else
256
                (*ATMProcs.addMacStyleToCoords)(coords, macStyle, newCoords, stylesLeft)
257
#endif
258
                        : ATM_WRONG_VERSION;
259
        }
260
 
261
ATMErr convertCoordsToBlendATM(Fixed *coords, Fixed *weightVector)
262
        {
263
        if (!ATMOpen)
264
                return ATM_NOT_ON;
265
        return ATMOpenVersion >= ATMProcs5Version ?
266
#if CALL_PASCAL
267
                CallPascalW(coords, weightVector, ATMProcs.convertCoordsToBlend)
268
#else
269
                (*ATMProcs.convertCoordsToBlend)(coords, weightVector)
270
#endif
271
                        : ATM_WRONG_VERSION;
272
        }
273
 
274
ATMErr normToUserCoordsATM(Fixed *normalCoords, Fixed *coords)
275
        {
276
        if (!ATMOpen)
277
                return ATM_NOT_ON;
278
        return ATMOpenVersion >= ATMProcs5Version ?
279
#if CALL_PASCAL
280
                CallPascalW(normalCoords, coords, ATMProcs.normToUserCoords)
281
#else
282
                (*ATMProcs.normToUserCoords)(normalCoords, coords)
283
#endif
284
                        : ATM_WRONG_VERSION;
285
        }
286
 
287
ATMErr userToNormCoordsATM(Fixed *coords, Fixed *normalCoords)
288
        {
289
        if (!ATMOpen)
290
                return ATM_NOT_ON;
291
        return ATMOpenVersion >= ATMProcs5Version ?
292
#if CALL_PASCAL
293
                CallPascalW(coords, normalCoords, ATMProcs.userToNormCoords)
294
#else
295
                (*ATMProcs.userToNormCoords)(coords, normalCoords)
296
#endif
297
                        : ATM_WRONG_VERSION;
298
        }
299
 
300
ATMErr createTempBlendedFontATM(short numAxes, Fixed *coords, short *useFondID)
301
        {
302
        if (!ATMOpen)
303
                return ATM_NOT_ON;
304
        return ATMOpenVersion >= ATMProcs5Version ?
305
#if CALL_PASCAL
306
                CallPascalW(numAxes, coords, useFondID, ATMProcs.createTempBlendedFont)
307
#else
308
                (*ATMProcs.createTempBlendedFont)(numAxes, coords, useFondID)
309
#endif
310
                        : ATM_WRONG_VERSION;
311
        }
312
 
313
ATMErr disposeTempBlendedFontATM(short fondID)
314
        {
315
        if (!ATMOpen)
316
                return ATM_NOT_ON;
317
        return ATMOpenVersion >= ATMProcs5Version ?
318
#if CALL_PASCAL
319
                CallPascalW(fondID, ATMProcs.disposeTempBlendedFont)
320
#else
321
                (*ATMProcs.disposeTempBlendedFont)(fondID)
322
#endif
323
                        : ATM_WRONG_VERSION;
324
        }
325
 
326
ATMErr createPermBlendedFontATM(StringPtr fontName, short fontSize, short fontFileID, short *retFondID)
327
        {
328
        if (!ATMOpen)
329
                return ATM_NOT_ON;
330
        return ATMOpenVersion >= ATMProcs5Version ?
331
#if CALL_PASCAL
332
                CallPascalW(fontName, fontSize, fontFileID, retFondID, ATMProcs.createPermBlendedFont)
333
#else
334
                (*ATMProcs.createPermBlendedFont)(fontName, fontSize, fontFileID, retFondID)
335
#endif
336
                        : ATM_WRONG_VERSION;
337
        }
338
 
339
ATMErr disposePermBlendedFontATM(short fondID)
340
        {
341
        if (!ATMOpen)
342
                return ATM_NOT_ON;
343
        return ATMOpenVersion >= ATMProcs5Version ?
344
#if CALL_PASCAL
345
                CallPascalW(fondID, ATMProcs.disposePermBlendedFont)
346
#else
347
                (*ATMProcs.disposePermBlendedFont)(fondID)
348
#endif
349
                        : ATM_WRONG_VERSION;
350
        }
351
 
352
ATMErr getTempBlendedFontFileIDATM(short *fileID)
353
        {
354
        if (!ATMOpen)
355
                return ATM_NOT_ON;
356
        return ATMOpenVersion >= ATMProcs5Version ?
357
#if CALL_PASCAL
358
                CallPascalW(fileID, ATMProcs.getTempBlendedFontFileID)
359
#else
360
                (*ATMProcs.getTempBlendedFontFileID)(fileID)
361
#endif
362
                        : ATM_WRONG_VERSION;
363
        }
364
 
365
ATMErr getNumAxesATM(short *numAxes)
366
        {
367
        if (!ATMOpen)
368
                return ATM_NOT_ON;
369
        *numAxes = 0;
370
        return ATMOpenVersion >= ATMProcs5Version ?
371
#if CALL_PASCAL
372
                CallPascalW(numAxes, ATMProcs.getNumAxes)
373
#else
374
                (*ATMProcs.getNumAxes)(numAxes)
375
#endif
376
                        : ATM_WRONG_VERSION;
377
        }
378
 
379
ATMErr getNumMastersATM(short *numMasters)
380
        {
381
        if (!ATMOpen)
382
                return ATM_NOT_ON;
383
        *numMasters = 0;
384
        return ATMOpenVersion >= ATMProcs5Version ?
385
#if CALL_PASCAL
386
                CallPascalW(numMasters, ATMProcs.getNumMasters)
387
#else
388
                (*ATMProcs.getNumMasters)(numMasters)
389
#endif
390
                        : ATM_WRONG_VERSION;
391
        }
392
 
393
ATMErr getMasterFONDATM(short i, short *masterFOND)
394
        {
395
        if (!ATMOpen)
396
                return ATM_NOT_ON;
397
        return ATMOpenVersion >= ATMProcs5Version ?
398
#if CALL_PASCAL
399
                CallPascalW(i, masterFOND, ATMProcs.getMasterFOND)
400
#else
401
                (*ATMProcs.getMasterFOND)(i, masterFOND)
402
#endif
403
                        : 0;
404
        }
405
 
406
ATMErr copyFitATM(short method, Fixed TargetWidth, Fixed *beginCoords,
407
                                        Fixed *baseWidths, Fixed *resultWidth, Fixed *resultCoords)
408
        {
409
        if (!ATMOpen)
410
                return ATM_NOT_ON;
411
        return ATMOpenVersion >= ATMProcs5Version ?
412
#if CALL_PASCAL
413
                CallPascalW(method, TargetWidth, beginCoords, baseWidths, resultWidth, resultCoords,
414
                                                ATMProcs.copyFit)
415
#else
416
                (*ATMProcs.copyFit)(method, TargetWidth, beginCoords, baseWidths, resultWidth, resultCoords)
417
#endif
418
                        : ATM_WRONG_VERSION;
419
        }
420
 
421
ATMErr showTextDesignATM(StringPtr fontFamily, Byte *text, short len, ATMFixedMatrix *matrix,
422
                                Fixed *coords, Fixed *displacements, short *lenDisplayed)
423
        {
424
        if (!ATMOpen)
425
                return ATM_NOT_ON;
426
        return ATMOpenVersion >= ATMProcs5Version ?
427
#if CALL_PASCAL
428
                CallPascalW(fontFamily, text, len, matrix, coords, displacements, lenDisplayed,
429
                                                ATMProcs.showTextDesign)
430
#else
431
                (*ATMProcs.showTextDesign)(fontFamily, text, len, matrix, coords, displacements, lenDisplayed)
432
#endif
433
                        : ATM_WRONG_VERSION;
434
        }
435
 
436
ATMErr getAxisBlendInfoATM(short axis, short *userMin, short *userMax, StringPtr axisType,
437
                                        StringPtr axisLabel, StringPtr axisShortLabel)
438
        {
439
        if (!ATMOpen)
440
                return ATM_NOT_ON;
441
        return ATMOpenVersion >= ATMProcs5Version ?
442
#if CALL_PASCAL
443
                CallPascalW(axis, userMin, userMax, axisType, axisLabel, axisShortLabel,
444
                                                ATMProcs.getAxisBlendInfo)
445
#else
446
                (*ATMProcs.getAxisBlendInfo)(axis, userMin, userMax, axisType, axisLabel, axisShortLabel)
447
#endif
448
                        : ATM_WRONG_VERSION;
449
        }
450
 
451
ATMErr getFontSpecsATM(FontSpecs *specs)
452
        {
453
        if (!ATMOpen)
454
                return ATM_NOT_ON;
455
        return ATMOpenVersion >= ATMProcs5Version ?
456
#if CALL_PASCAL
457
                CallPascalW(specs, ATMProcs.getFontSpecs)
458
#else
459
                (*ATMProcs.getFontSpecs)(specs)
460
#endif
461
                        : ATM_WRONG_VERSION;
462
        }
463
 
464
ATMErr fontFitATM(Fixed *origCoords, short numTargets, short *varyAxes,
465
                                Fixed *targetMetrics, Fixed **masterMetrics,
466
                                Fixed *retCoords, Fixed *retWeightVector)
467
        {
468
        if (!ATMOpen)
469
                return ATM_NOT_ON;
470
        return ATMOpenVersion >= ATMProcs5Version ?
471
#if CALL_PASCAL
472
                CallPascalW(origCoords, numTargets, varyAxes, targetMetrics,
473
                        masterMetrics, retCoords, retWeightVector,
474
                                                ATMProcs.fontFit)
475
#else
476
                (*ATMProcs.fontFit)(origCoords, numTargets, varyAxes, targetMetrics,
477
                        masterMetrics, retCoords, retWeightVector)
478
#endif
479
                        : ATM_WRONG_VERSION;
480
        }
481
 
482
ATMErr          getNumBlessedFontsATM(short *numBlessedFonts)
483
        {
484
        if (!ATMOpen)
485
                return ATM_NOT_ON;
486
        return ATMOpenVersion >= ATMProcs5Version ?
487
#if CALL_PASCAL
488
                CallPascalW(numBlessedFonts, ATMProcs.getNumBlessedFonts)
489
#else
490
                (*ATMProcs.getNumBlessedFonts)(numBlessedFonts)
491
#endif
492
                        : ATM_WRONG_VERSION;
493
        }
494
 
495
ATMErr          getBlessedFontNameATM(short i, StringPtr blessedFontName, Fixed *coords)
496
        {
497
        if (!ATMOpen)
498
                return ATM_NOT_ON;
499
        return ATMOpenVersion >= ATMProcs5Version ?
500
#if CALL_PASCAL
501
                CallPascalW(i, blessedFontName, coords, ATMProcs.getBlessedFontName)
502
#else
503
                (*ATMProcs.getBlessedFontName)(i, blessedFontName, coords)
504
#endif
505
                        : ATM_WRONG_VERSION;
506
        }
507
 
508
ATMErr          getRegularBlessedFontATM(short *regularID)
509
        {
510
        if (!ATMOpen)
511
                return ATM_NOT_ON;
512
        return ATMOpenVersion >= ATMProcs5Version ?
513
#if CALL_PASCAL
514
                CallPascalW(regularID, ATMProcs.getRegularBlessedFont)
515
#else
516
                (*ATMProcs.getRegularBlessedFont)(regularID)
517
#endif
518
                        : ATM_WRONG_VERSION;
519
        }
520
 
521
ATMErr          flushCacheATM(void)
522
        {
523
        if (!ATMOpen)
524
                return ATM_NOT_ON;
525
        return ATMOpenVersion >= ATMProcs5Version ?
526
#if CALL_PASCAL
527
                CallPascalW(ATMProcs.flushCache)
528
#else
529
                (*ATMProcs.flushCache)()
530
#endif
531
                        : ATM_WRONG_VERSION;
532
        }
533
 
534
ATMErr          getFontFamilyFONDATM(StringPtr familyName, short *retFondID)
535
        {
536
        if (!ATMOpen)
537
                return ATM_NOT_ON;
538
        return ATMOpenVersion >= ATMProcs5Version ?
539
#if CALL_PASCAL
540
                CallPascalW(familyName, retFondID, ATMProcs.getFontFamilyFOND)
541
#else
542
                (*ATMProcs.getFontFamilyFOND)(familyName, retFondID)
543
#endif
544
                        : ATM_WRONG_VERSION;
545
        }
546
 
547
ATMErr          MMFontPickerATM(struct MMFP_Parms *parms, struct MMFP_Reply *reply)
548
        {
549
        if (!ATMOpen)
550
                return ATM_NOT_ON;
551
        return ATMOpenVersion >= ATMProcs5Version ?
552
#if CALL_PASCAL
553
                CallPascalW(parms, reply, ATMProcs.MMFontPicker)
554
#else
555
                (*ATMProcs.MMFontPicker)(parms, reply)
556
#endif
557
                        : ATM_WRONG_VERSION;
558
        }
559
 
560
Boolean isSubstFontATM(StringPtr fontName, short fondID, short style, FontSpecs ***fontSpecs, Handle *chamName)
561
        {
562
        if (!ATMOpen)
563
                return FALSE;
564
        return ATMOpenVersion >= ATMProcs8Version ?
565
#if CALL_PASCAL
566
                CallPascalB(fontName, fondID, style, fontSpecs, chamName, ATMProcs.isSubstFont)
567
#else
568
                (*ATMProcs.isSubstFont)(fontName, fondID, style, fontSpecs, chamName)
569
#endif
570
                 : FALSE;
571
        }
572
 
573
ATMErr getPSNumATM(StringPtr psName, short *retFondID, Boolean doCreate)
574
        {
575
        if (!ATMOpen)
576
                return ATM_NOT_ON;
577
        return ATMOpenVersion >= ATMProcs8Version ?
578
#if CALL_PASCAL
579
                CallPascalW(psName, retFondID, doCreate, ATMProcs.getPSNum)
580
#else
581
                (*ATMProcs.getPSNum)(psName, retFondID, doCreate)
582
#endif
583
                        : ATM_WRONG_VERSION;
584
}