ref: 3971a4df802cc5a9ffea410418ac4d94c9da4774
parent: 71d16479bba591f616f91d2b928fec49b72015b0
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Jul 22 22:12:24 EDT 2024
add otfpriv.h to share stuff with rasterizer
--- a/gen.rkt
+++ b/gen.rkt
@@ -604,15 +604,21 @@
(filter-map (λ (f) (and (field-context? f) (indent (gen-h f)))) (cmplx-fields c))
empty))
-(out (at out-dir "otf.c")
+(out (at out-dir "otfpriv.h")
(λ ()
(begin
- (define c-data (port->lines (open-input-file (at in-dir "otf.c.in")) #:close? #t))
+ (define c-data (port->lines (open-input-file (at in-dir "otfpriv.h.in")) #:close? #t))
(define extra-fields-index (index-of c-data "OTF_EXTRA_FIELDS"))
(define extra-fields-data
(string-append (format extra-context-fields #:on-all remove-duplicates)
- (~a "#line " (+ extra-fields-index 2) "\"otf.c.in\"")))
- (printf "#line 1 \"otf.c.in\"\n")
+ (~a "#line " (+ extra-fields-index 2) "\"otfpriv.h.in\"")))
+ (printf "#line 1 \"otfpriv.h.in\"\n")
(for-each (λ (s) (printf "~a\n" s)) (list-set c-data extra-fields-index extra-fields-data))
- (printf "\n")
- (printf "~a" (format (λ (c) (gen-c c #f #f)))))))
+ (printf "\n"))))
+
+(out (at out-dir "otf.c")
+ (λ ()
+ (printf "#line 1 \"otf.c.in\"\n")
+ (printf "~a" (port->string (open-input-file (at in-dir "otf.c.in")) #:close? #t))
+ (printf "\n")
+ (printf "~a" (format (λ (c) (gen-c c #f #f))))))
--- a/meson.build
+++ b/meson.build
@@ -28,10 +28,12 @@
'otf.rkt',
'otf.c.in',
'otf.h.in',
+ 'otfpriv.h.in',
],
output: [
'otf.c',
'otf.h',
+ 'otfpriv.h',
],
command: [
racket, '@SOURCE_ROOT@/gen.rkt',
--- a/mkfile
+++ b/mkfile
@@ -12,6 +12,7 @@
HFILES=\
plan9/otf.h\
+ plan9/otfpriv.h\
plan9/otfsys.h\
default:V: all
@@ -25,7 +26,7 @@
test.$O: plan9/test.c test.h
$CC $CFLAGS plan9/test.c
-plan9/otf.h plan9/otf.c: gen.rkt otf.rkt otf.h.in otf.c.in
+plan9/otf.h plan9/otf.c plan9/otfpriv.h: gen.rkt otf.rkt otf.h.in otfpriv.h.in otf.c.in
test -n $"s76 && ssh $s76 'cd w/_/fnt && ./gen.rkt --out-dir plan9' || echo can''t code-gen
</sys/src/cmd/mkone
--- a/otf.c.in
+++ b/otf.c.in
@@ -1,33 +1,12 @@
/* this file is generated. do not modify. */
#include "otfsys.h"
#include "otf.h"
+#include "otfpriv.h"
#define f2dot14(o) (f = b[2*o]<<8 | b[2*o+1], (f>>14)+(f&((1<<14)-1))/16384.0)
int indentΔ = 2;
-typedef struct Range Range;
-
-struct Otf {
- Otfile *f;
- Range *r;
- u8int *buf;
- int bufsz;
- int off;
-
- /* extra fields to simplify parsing */
- TableDirectory td;
- TableRecord glyf;
-OTF_EXTRA_FIELDS
-};
-
-struct Range {
- int start;
- int len;
- int prevoff;
- Range *par;
-};
-
#define rchr(s) (be ? ((s)[0]<<8 | (s)[1]) : ((s)[1]<<8 | (s)[0]))
static u8int mark[] = {0x00, 0x00, 0xc0, 0xe0, 0xf0};
@@ -607,12 +586,6 @@
otfglyfnum(Otf *o)
{
return o->numGlyphs;
-}
-
-int
-otfupem(Otf *o)
-{
- return o->td.head->unitsPerEm;
}
int
--- /dev/null
+++ b/otfpriv.h.in
@@ -1,0 +1,21 @@
+typedef struct Range Range;
+
+struct Otf {
+ Otfile *f;
+ Range *r;
+ u8int *buf;
+ int bufsz;
+ int off;
+
+ /* extra fields to simplify parsing */
+ TableDirectory td;
+ TableRecord glyf;
+OTF_EXTRA_FIELDS
+};
+
+struct Range {
+ int start;
+ int len;
+ int prevoff;
+ Range *par;
+};
--- a/plan9/otf.c
+++ b/plan9/otf.c
@@ -2,48 +2,12 @@
/* this file is generated. do not modify. */
#include "otfsys.h"
#include "otf.h"
+#include "otfpriv.h"
#define f2dot14(o) (f = b[2*o]<<8 | b[2*o+1], (f>>14)+(f&((1<<14)-1))/16384.0)
int indentΔ = 2;
-typedef struct Range Range;
-
-struct Otf {
- Otfile *f;
- Range *r;
- u8int *buf;
- int bufsz;
- int off;
-
- /* extra fields to simplify parsing */
- TableDirectory td;
- TableRecord glyf;
- s16int indexToLocFormat;
- u16int numberOfHMetrics;
- s16int numberOfContours;
- u16int numGlyphs;
- u16int platformID;
- u16int encodingID;
- u16int storageOffset;
- u16int firstGlyphIndex;
- u16int lastGlyphIndex;
- u16int axisCount;
- u16int instanceCount;
- u16int instanceSize;
- u16int designAxisSize;
- u16int designAxisCount;
- u16int axisValueCount;
-#line 22"otf.c.in"
-};
-
-struct Range {
- int start;
- int len;
- int prevoff;
- Range *par;
-};
-
#define rchr(s) (be ? ((s)[0]<<8 | (s)[1]) : ((s)[1]<<8 | (s)[0]))
static u8int mark[] = {0x00, 0x00, 0xc0, 0xe0, 0xf0};
@@ -623,12 +587,6 @@
otfglyfnum(Otf *o)
{
return o->numGlyphs;
-}
-
-int
-otfupem(Otf *o)
-{
- return o->td.head->unitsPerEm;
}
int
--- /dev/null
+++ b/plan9/otfpriv.h
@@ -1,0 +1,38 @@
+#line 1 "otfpriv.h.in"
+typedef struct Range Range;
+
+struct Otf {
+ Otfile *f;
+ Range *r;
+ u8int *buf;
+ int bufsz;
+ int off;
+
+ /* extra fields to simplify parsing */
+ TableDirectory td;
+ TableRecord glyf;
+ s16int indexToLocFormat;
+ u16int numberOfHMetrics;
+ s16int numberOfContours;
+ u16int numGlyphs;
+ u16int platformID;
+ u16int encodingID;
+ u16int storageOffset;
+ u16int firstGlyphIndex;
+ u16int lastGlyphIndex;
+ u16int axisCount;
+ u16int instanceCount;
+ u16int instanceSize;
+ u16int designAxisSize;
+ u16int designAxisCount;
+ u16int axisValueCount;
+#line 14"otfpriv.h.in"
+};
+
+struct Range {
+ int start;
+ int len;
+ int prevoff;
+ Range *par;
+};
+
--- a/rast.c
+++ b/rast.c
@@ -21,6 +21,7 @@
*/
#include "otfsys.h"
#include "otf.h"
+#include "otfpriv.h"
#pragma clang float_control(precise, on)
@@ -589,7 +590,7 @@
}
*/
- scale = ppem / otfupem(o);
+ scale = ppem / o->td.head->unitsPerEm;
Sval bb[4] = {g->xMin*scale, g->yMin*scale, g->xMax*scale, g->yMax*scale};
pts = calloc(1, maxpts*sizeof(*pts) + maxptstotal/2*sizeof(*s));
s = s₀ = (SegQ*)(pts + maxpts);