ref: 5bbd5fb88a804ccbf9d642d5f68be4acd74e9eaa
parent: 781e4139f4c6ff4606c131fbc9649108862041b2
author: Ali Gholami Rudi <[email protected]>
date: Tue Aug 5 13:07:45 EDT 2014
font: allocate rule->pats from the heap
--- a/font.c
+++ b/font.c
@@ -47,8 +47,6 @@
int feat_set[NFEATS]; /* feature enabled */
int feat_n;
/* glyph substitution and positioning */
- struct gpat pats[NGPATS]; /* glyph pattern space */
- int pats_pos; /* current position in pats[] */
struct grule gsub[NGRULES]; /* glyph substitution rules */
int gsub_n;
struct grule gpos[NGRULES]; /* glyph positioning rules */
@@ -316,14 +314,9 @@
static struct gpat *font_gpat(struct font *fn, int len)
{
- int pos = fn->pats_pos;
- if (pos < LEN(fn->pats) - 10 && pos + len > LEN(fn->pats) - 10)
- errmsg("neatroff: NGPATS too low\n");
- if (pos + len > LEN(fn->pats))
- return NULL;
- memset(fn->pats + pos, 0, sizeof(fn->pats[0]) * len);
- fn->pats_pos += len;
- return fn->pats + pos;
+ struct gpat *pats = xmalloc(len * sizeof(pats[0]));
+ memset(pats, 0, len * sizeof(pats[0]));
+ return pats;
}
static struct grule *font_gsub(struct font *fn, char *feat, int len)
@@ -529,6 +522,11 @@
void font_close(struct font *fn)
{
+ int i;
+ for (i = 0; i < fn->gsub_n; i++)
+ free(fn->gsub[i].pats);
+ for (i = 0; i < fn->gpos_n; i++)
+ free(fn->gpos[i].pats);
dict_done(&fn->gdict);
dict_done(&fn->cdict);
free(fn);
--- a/roff.h
+++ b/roff.h
@@ -50,8 +50,7 @@
#define NHCODES 512 /* number of .hcode characters */
#define WORDLEN 256 /* word length (for hyph.c) */
#define NFEATS 128 /* number of features per font */
-#define NGRULES 1024 /* number of gsub/gpos rules per font */
-#define NGPATS 4096 /* number of gsub/gpos pattern glyphs */
+#define NGRULES 4096 /* number of gsub/gpos rules per font */
/* converting scales */
#define SC_IN (dev_res) /* inch in units */