ref: 9cdddf09964fe994938467a19cc8aea34380a0c6
parent: 456d0c2f16cc64ffe24a8074289339a22d33a724
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Jun 20 22:08:13 EDT 2024
FFTM
--- a/otf.c
+++ b/otf.c
@@ -3702,6 +3702,39 @@
}
int
+read_TableFFTM(Otf *o, TableFFTM *v)
+{
+ u8int *b;
+ if((b = otfreadn(o, 4)) == nil)
+ goto err;
+ v->version = b[0]<<24 | b[1]<<16 | b[2]<<8 | b[3];
+ if(v->version == 1){
+ if((b = otfreadn(o, 24)) == nil)
+ goto err;
+ v->fontforge = ((s64int)b[0]<<56 | (s64int)b[1]<<48 | (s64int)b[2]<<40 | (s64int)b[3]<<32 | b[4]<<24 | b[5]<<16 | b[6]<<8 | b[7]) - 2082844800LL;
+ v->created = ((s64int)b[8]<<56 | (s64int)b[9]<<48 | (s64int)b[10]<<40 | (s64int)b[11]<<32 | b[12]<<24 | b[13]<<16 | b[14]<<8 | b[15]) - 2082844800LL;
+ v->modified = ((s64int)b[16]<<56 | (s64int)b[17]<<48 | (s64int)b[18]<<40 | (s64int)b[19]<<32 | b[20]<<24 | b[21]<<16 | b[22]<<8 | b[23]) - 2082844800LL;
+ }
+ return 0;
+err:
+ werrstr("%s: %r", "TableFFTM");
+ return -1;
+}
+
+void
+print_TableFFTM(Biobuf *f, int indent, Otf *o, TableFFTM *v)
+{
+ Bprint(f, "%*s%s: %ud\n", indent, "", "version", v->version);
+ if(v->version == 1)
+ Bprint(f, "%*s%s: %T\n", indent, "", "fontforge", v->fontforge);
+ if(v->version == 1)
+ Bprint(f, "%*s%s: %T\n", indent, "", "created", v->created);
+ if(v->version == 1)
+ Bprint(f, "%*s%s: %T\n", indent, "", "modified", v->modified);
+ USED(o);
+}
+
+int
read_TableOS∕2(Otf *o, TableOS∕2 *v)
{
u8int *b;
@@ -4070,6 +4103,17 @@
}
rec->parsed = v->loca;
rec->print = (void*)print_TableLoca;
+ break;
+ case (u32int)('F'<<24|'F'<<16|'T'<<8|'M'):
+ if(v->fftm != nil)
+ break;
+ v->fftm = calloc(1, sizeof(TableFFTM));
+ if(read_TableFFTM(o, v->fftm) < 0){
+ free(v->fftm);
+ goto err;
+ }
+ rec->parsed = v->fftm;
+ rec->print = (void*)print_TableFFTM;
break;
case (u32int)('O'<<24|'S'<<16|'/'<<8|'2'):
if(v->os∕2 != nil)
--- a/otf.h
+++ b/otf.h
@@ -87,6 +87,7 @@
typedef struct KernSubtable KernSubtable;
typedef struct TableKern TableKern;
typedef struct TableLoca TableLoca;
+typedef struct TableFFTM TableFFTM;
typedef struct TableOS∕2 TableOS∕2;
typedef struct TableRecord TableRecord;
typedef struct TableDirectory TableDirectory;
@@ -1041,6 +1042,16 @@
int read_TableLoca(Otf *o, TableLoca *v);
void print_TableLoca(Biobuf *f, int indent, Otf *o, TableLoca *v);
+struct TableFFTM {
+ u32int version;
+ s64int fontforge;
+ s64int created;
+ s64int modified;
+};
+
+int read_TableFFTM(Otf *o, TableFFTM *v);
+void print_TableFFTM(Biobuf *f, int indent, Otf *o, TableFFTM *v);
+
struct TableOS∕2 {
u16int version;
s16int xAvgCharWidth;
@@ -1120,6 +1131,7 @@
TableMATH *math;
TableKern *kern;
TableLoca *loca;
+ TableFFTM *fftm;
TableOS∕2 *os∕2;
};
--- a/otf.rkt
+++ b/otf.rkt
@@ -604,6 +604,13 @@
#:tag "loca"
#:after (list TableHead))
+(mkcmplx TableFFTM
+ {uint32 version}
+ {LONGDATETIME fontforge (== version 1)}
+ {LONGDATETIME created (== version 1)}
+ {LONGDATETIME modified (== version 1)}
+ #:tag "FFTM")
+
(mkcmplx TableOS∕2
{uint16 version (<= 5)}
{FWORD xAvgCharWidth}
@@ -711,6 +718,9 @@
(~a " goto err;")
(~a " switch(rec->tableTag){")
(indent (indent (map case-statement tagged)))
+ (~a " default:")
+ (~a " fprint(2, \"no parser for \\\"%t\\\"\\n\", rec->tableTag);")
+ (~a " break;")
(~a " }")
(~a " if(otfpoprange(o) < 0)")
(~a " goto err;")