| 1 |
/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. |
| 2 |
This software is licensed as OpenSource, under the Apache License, Version 2.0. |
| 3 |
This license is available at: http://opensource.org/licenses/Apache-2.0. */ |
| 4 |
/***********************************************************************/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Subroutinization support. |
| 8 |
* |
| 9 |
* xxx get this comment up to date. |
| 10 |
* After initialization each font's charstring data is added with |
| 11 |
* subrFont(). When all charstring data in the font set has been added |
| 12 |
* the fonts are rescanned and overlap conflicts are resolved by a call to |
| 13 |
* subrRescanFont(). Partial subroutine selection is then performed by a call |
| 14 |
* to subrSelect(). Finally, each font is subroutinized by a call to |
| 15 |
* subrAddLocal(). |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef CFFWRITE_SUBR_H |
| 19 |
#define CFFWRITE_SUBR_H |
| 20 |
|
| 21 |
#include "cffwrite.h" |
| 22 |
#include "cffwrite_share.h" |
| 23 |
#include "txops.h" |
| 24 |
|
| 25 |
/* In order to avoid matching repeats across charstring boundaries it is |
| 26 |
necessary to add a unique separator between charstrings. This is achieved by |
| 27 |
inserting the t2_separator operator after each endchar. The 1-byte operator |
| 28 |
value is followed by a 24-bit number that is guaranteed to be different for |
| 29 |
each charstring thereby removing any possibility of a match spanning an |
| 30 |
endchar operator. These operators are inserted by the recode module and |
| 31 |
removed by the subroutinizer */ |
| 32 |
#define t2_separator t2_reserved9 |
| 33 |
|
| 34 |
/* Types */ |
| 35 |
typedef unsigned char subr_FDIndex; /* FDArray index */ |
| 36 |
|
| 37 |
typedef struct { |
| 38 |
unsigned short nStrings; |
| 39 |
Offset *offset; /* Offset (index) array */ |
| 40 |
char *data; /* Charstring data buffer */ |
| 41 |
char *refcopy; /* Copy of "data" pointer for use by subroutinizer */ |
| 42 |
} subr_CSData; |
| 43 |
|
| 44 |
typedef struct /* INDEX table header */ |
| 45 |
{ |
| 46 |
unsigned short count; |
| 47 |
OffSize offSize; |
| 48 |
} INDEXHdr; |
| 49 |
|
| 50 |
/* CID FD info */ |
| 51 |
typedef struct { |
| 52 |
subr_CSData subrs; |
| 53 |
subr_CSData chars; /* Temporary subroutinized charstrings for DICT */ |
| 54 |
unsigned short iChar; /* Index of next char to be copied */ |
| 55 |
} subr_FDInfo; |
| 56 |
|
| 57 |
typedef struct { |
| 58 |
short flags; |
| 59 |
#define SUBR_FONT_CID (1 << 1) /* CID font */ |
| 60 |
subr_FDIndex *fdIndex; /* CID: Map each glyph into fdInfo */ |
| 61 |
short fdCount; /* CID: Number of font & private dicts */ |
| 62 |
subr_FDInfo *fdInfo; /* CID: [fdCount] */ |
| 63 |
subr_CSData subrs; /* Subr data (non-CID) */ |
| 64 |
subr_CSData chars; /* Char data */ |
| 65 |
} subr_Font; |
| 66 |
|
| 67 |
void cfwSubrNew(cfwCtx g); |
| 68 |
void cfwSubrFree(cfwCtx g); |
| 69 |
void cfwSubrReuse(cfwCtx g); |
| 70 |
|
| 71 |
void cfwSubrSubrize(cfwCtx g, int nFonts, subr_Font *fonts); |
| 72 |
|
| 73 |
long cfwSubrSizeLocal(cfwCtx g, subr_CSData *subrs); |
| 74 |
void cfwSubrWriteLocal(cfwCtx g, subr_CSData *subrs); |
| 75 |
|
| 76 |
long cfwSubrSizeGlobal(cfwCtx g); |
| 77 |
void cfwSubrWriteGlobal(cfwCtx g); |
| 78 |
|
| 79 |
#endif /* CFFWRITE_SUBR_H */ |