Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions c/rotatefont/source/rotateFont.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef struct
float origMatrix[6]; /* rotation/translation matrix specified by user. */
float curMatrix[6]; /* rotation/translation matrix currently in use. */
abfGlyphCallbacks savedGlyphCB; /* originally chosen writer call-backs */
void (*begfont)(txCtx h, abfTopDict *top); /* override to fix up ufow beg callback */
void (*endfont)(txCtx h); /* override to fix up hint dicts */
char rtFile[FILENAME_MAX]; /* text file containing per-glyph entries */
dnaDCL(RotateGlyphEntry, rotateGlyphEntries);
Expand Down Expand Up @@ -1014,9 +1015,8 @@ static void rotateLoadGlyphList(txCtx h, char *filePath) {
return;
}

static void setupRotationCallbacks(txCtx h) {
static void setupRotationGlyphCallbacks(txCtx h) {
RotateInfo *rotateInfo = (RotateInfo *)h->appSpecificInfo;
rotateInfo->savedGlyphCB = h->cb.glyph;
h->cb.glyph.indirect_ctx = h;
h->cb.glyph.beg = rotate_beg;
h->cb.glyph.width = rotate_width;
Expand All @@ -1025,15 +1025,30 @@ static void setupRotationCallbacks(txCtx h) {
h->cb.glyph.curve = rotate_curve;
if ((rotateInfo->flags & ROTATE_KEEP_HINTS) || (rotateInfo->origMatrix[1] == 0)) /* rotation is some multiple of 90 degrees */
{
h->cb.glyph.stem = rotate_stem;
h->cb.glyph.flex = rotate_flex;
h->cb.glyph.stem = (rotateInfo->savedGlyphCB.stem != NULL) ? rotate_stem : NULL;
h->cb.glyph.flex = (rotateInfo->savedGlyphCB.flex != NULL) ? rotate_flex : NULL;
} else {
h->cb.glyph.stem = NULL;
h->cb.glyph.flex = NULL;
}
h->cb.glyph.genop = rotate_genop;
h->cb.glyph.seac = rotate_seac;
h->cb.glyph.end = rotate_end;
}

static void rotateBegFont(txCtx h, abfTopDict *top) {
/* restore our callback after ufow overwrites it at begfont */
RotateInfo *rotateInfo = (RotateInfo *)h->appSpecificInfo;
rotateInfo->begfont(h, top);
setupRotationGlyphCallbacks(h);
}

static void setupRotationCallbacks(txCtx h) {
RotateInfo *rotateInfo = (RotateInfo *)h->appSpecificInfo;
rotateInfo->savedGlyphCB = h->cb.glyph;
setupRotationGlyphCallbacks(h);
rotateInfo->begfont = h->dst.begfont;
h->dst.begfont = rotateBegFont;
rotateInfo->endfont = h->dst.endfont;
h->dst.endfont = rotateEndFont;
if (rotateInfo->rtFile[0] != 0)
Expand Down