Mercurial > repos > tabletprog
annotate modules/freetype.tp @ 373:a694ffa8d461
Filter out compiled programs from the samples and modules directories
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 12 Aug 2015 19:16:59 -0700 |
parents | c1fad3d93861 |
children |
rev | line source |
---|---|
321
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 _helper <- #{ |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 includeSystemHeader: "ft2build.h" |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 includeSystemHeader: FT_FREETYPE_H |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 llMessage: newFace withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 libOpaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 opath <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 oindex <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 path <- string ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 index <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 faceOpaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 rescode <- int32_t |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 } andCode: :libOpaque opath oindex { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 path <- (mcall: string 1 opath) castTo: (string ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 index <- (mcall: int32 1 oindex) castTo: (obj_int32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 faceOpaque <- make_object: (addr_of: cpointer_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 rescode <- FT_New_Face: (libOpaque val) (path data) (index num) ((addr_of: (faceOpaque val)) castTo: (FT_Face ptr)) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 if: rescode = 0 { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 mcall: value 2 option faceOpaque |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 } else: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 mcall: none 1 option |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 llMessage: getFirstChar withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 opaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 glyphIndex <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 charCode <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 makeChar <- lambda ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 } andCode: :opaque makeChar { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 glyphIndex <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 charCode <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 charCode num!: (FT_Get_First_Char: (opaque val) (addr_of: (glyphIndex num))) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 ccall: makeChar 2 charCode glyphIndex |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 llMessage: getNextChar withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 opaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 ocurChar <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 curChar <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 glyphIndex <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 charCode <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 makeChar <- lambda ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 } andCode: :opaque ocurChar makeChar { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 curChar <- (mcall: uint32 1 ocurChar) castTo: (obj_uint32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 glyphIndex <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 charCode <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 charCode num!: (FT_Get_Next_Char: (opaque val) (curChar num) (addr_of: (glyphIndex num))) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 ccall: makeChar 2 charCode glyphIndex |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 _makeSlot <- :opaque { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 #{ |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 llProperty: slot withType: FT_GlyphSlot |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 llMessage: _ptr_init withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 opaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 } andCode: :opaque { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 slot <- opaque val |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 self |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 llMessage: linearHoriAdvance withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 intret <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 intret num!: (slot linearHoriAdvance) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 intret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 llMessage: linearVertAdvance withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 intret <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 intret num!: (slot linearVertAdvance) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 intret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 llMessage: bitmapTop withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 intret <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 intret num!: (slot bitmap_top) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 intret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 llMessage: bitmapLeft withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 intret <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 intret num!: (slot bitmap_left) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 intret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 llMessage: bitmapRows withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 uintret <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 uintret <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 uintret num!: ((addr_of: (slot bitmap)) rows) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 uintret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 llMessage: bitmapWidth withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 uintret <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 uintret <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 uintret num!: ((addr_of: (slot bitmap)) width) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 uintret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 llMessage: bitmapPitch withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 intret <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 intret <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 intret num!: ((addr_of: (slot bitmap)) pitch) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 intret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 llMessage: bitmapData withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 opaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 size <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 opaque <- make_object: (addr_of: cpointer_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 opaque val!: ((addr_of: (slot bitmap)) buffer) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 size <- make_object: (addr_of: obj_int32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 size num!: ((addr_of: (slot bitmap)) rows) * ((addr_of: (slot bitmap)) pitch) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 mcall: fromOpaque:withSize 3 bytearray opaque size |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 llMessage: renderGlyph withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 omode <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 mode <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 intret <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 } andCode: :omode { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 mode <- (mcall: uint32 1 omode) castTo: (obj_uint32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 intret num!: (FT_Render_Glyph: slot (mode num)) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 intret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 } _ptr_init: opaque |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 _makeChar <- :_charcode _glyph { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 #{ |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 charcode <- _charcode |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 glyph <- _glyph |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 _makeFace <- :opaque { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 #{ |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 llProperty: face withType: FT_Face |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 llProperty: makeSlot withType: (lambda ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 llMessage: _ptr_init withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 opaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 makeSlotLambda <- lambda ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 } andCode: :opaque makeSlotLambda { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 face <- opaque val |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 makeSlot <- makeSlotLambda |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 self |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 llMessage: faceOpaque withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 opaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 opaque <- make_object: (addr_of: cpointer_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 opaque val!: face |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 opaque |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 llMessage: setCharWidth:height:hRes:vRes withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 ohsize <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 hsize <- obj_float32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 ovsize <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 vsize <- obj_float32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 ohres <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 hres <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 ovres <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 vres <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 intret <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 } andCode: :ohsize ovsize :ohres :ovres { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 hsize <- (mcall: f32 1 ohsize) castTo: (obj_float32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 vsize <- (mcall: f32 1 ovsize) castTo: (obj_float32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 hres <- (mcall: int32 1 ohres) castTo: (obj_int32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 vres <- (mcall: int32 1 ovres) castTo: (obj_int32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 intret num!: (FT_Set_Char_Size: face (hsize num) * 64 (vsize num) * 64 (hres num) (vres num)) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 intret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 setCharSize:res <- :size :res { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 setCharWidth: size height: size hRes: res vRes: res |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 llMessage: getCharIndex withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 ocharcode <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 charcode <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 uintret <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 } andCode: :ocharcode { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 charcode <- (mcall: uint32 1 ocharcode) castTo: (obj_uint32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 uintret <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 uintret num!: (FT_Get_Char_Index: face (charcode num)) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 uintret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 llMessage: loadGlyph:flags withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 oindex <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 index <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 oflags <- object ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 flags <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 intret <- obj_int32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 } andCode: :oindex :oflags { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 index <- (mcall: uint32 1 oindex) castTo: (obj_uint32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 flags <- (mcall: uint32 1 oflags) castTo: (obj_uint32 ptr) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 intret num!: (FT_Load_Glyph: face (index num) (flags num)) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 intret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 llMessage: glyphSlot withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 opaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 opaque <- make_object: (addr_of: cpointer_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 opaque val!: (face glyph) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 ccall: makeSlot 1 opaque |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 |
326
50760ba52b11
Added basic rendering of strings to freetype demo
Michael Pavone <pavone@retrodev.com>
parents:
321
diff
changeset
|
227 llMessage: unitsPerEm withVars: { |
50760ba52b11
Added basic rendering of strings to freetype demo
Michael Pavone <pavone@retrodev.com>
parents:
321
diff
changeset
|
228 u16ret <- obj_uint16 ptr |
50760ba52b11
Added basic rendering of strings to freetype demo
Michael Pavone <pavone@retrodev.com>
parents:
321
diff
changeset
|
229 } andCode: { |
50760ba52b11
Added basic rendering of strings to freetype demo
Michael Pavone <pavone@retrodev.com>
parents:
321
diff
changeset
|
230 u16ret <- make_object: (addr_of: obj_uint16_meta) NULL 0 |
50760ba52b11
Added basic rendering of strings to freetype demo
Michael Pavone <pavone@retrodev.com>
parents:
321
diff
changeset
|
231 u16ret num!: (face units_per_EM) |
50760ba52b11
Added basic rendering of strings to freetype demo
Michael Pavone <pavone@retrodev.com>
parents:
321
diff
changeset
|
232 u16ret |
50760ba52b11
Added basic rendering of strings to freetype demo
Michael Pavone <pavone@retrodev.com>
parents:
321
diff
changeset
|
233 } |
50760ba52b11
Added basic rendering of strings to freetype demo
Michael Pavone <pavone@retrodev.com>
parents:
321
diff
changeset
|
234 |
328
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
235 llMessage: hasKerning? withVars: { |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
236 ret <- object ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
237 } andCode: { |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
238 if: (FT_HAS_KERNING: face) { |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
239 true |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
240 } else { |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
241 false |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
242 } |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
243 } |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
244 |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
245 llMessage: getKerning:mode withVars: { |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
246 oleft <- object ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
247 oright <- object ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
248 omode <- object ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
249 left <- obj_uint32 ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
250 right <- obj_uint32 ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
251 mode <- obj_uint32 ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
252 x <- obj_int32 ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
253 y <- obj_int32 ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
254 ret <- object ptr |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
255 kernVec <- FT_Vector |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
256 err <- int |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
257 } andCode: :oleft oright :omode { |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
258 left <- (mcall: uint32 1 oleft) castTo: (obj_uint32 ptr) |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
259 right <- (mcall: uint32 1 oright) castTo: (obj_uint32 ptr) |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
260 mode <- (mcall: uint32 1 omode) castTo: (obj_uint32 ptr) |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
261 err <- FT_Get_Kerning: face (left num) (right num) (mode num) (addr_of: kernVec) |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
262 if: err != 0 { |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
263 mcall: none 1 option |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
264 } else: { |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
265 x <- make_object: (addr_of: obj_int32_meta) NULL 0 |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
266 y <- make_object: (addr_of: obj_int32_meta) NULL 0 |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
267 x num!: ((addr_of: kernVec) x) |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
268 y num!: ((addr_of: kernVec) y) |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
269 ret <- mcall: x:y 3 vec x y |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
270 mcall: value 2 option ret |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
271 } |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
272 } |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
273 |
321
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 firstChar <- { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 _helper getFirstChar: faceOpaque _makeChar |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 nextChar <- :curChar { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 _helper getNextChar: faceOpaque curChar _makeChar |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
281 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 charmap <- { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 d <- dict hash |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 char <- firstChar |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 d set: (char charcode) (char glyph) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 while: { (char glyph) != 0u32 } do: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 char <- nextChar: (char charcode) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 d set: (char charcode) (char glyph) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 d |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 } _ptr_init: opaque _makeSlot |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 _constant <- macro: :name cname { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 quote: (llMessage: name withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 uintret <- obj_uint32 ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 uintret <- make_object: (addr_of: obj_uint32_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 uintret num!: cname |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 uintret |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 }) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 _loadFlags <- #{ |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 _constant: default FT_LOAD_DEFAULT |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 _constant: noScale FT_LOAD_NO_SCALE |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 _constant: noHinting FT_LOAD_NO_HINTING |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 _constant: render FT_LOAD_RENDER |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 _constant: noBitmap FT_LOAD_NO_BITMAP |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 _constant: verticalLayout FT_LOAD_VERTICAL_LAYOUT |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 _constant: forceAuthohint FT_LOAD_FORCE_AUTOHINT |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 _constant: pedantic FT_LOAD_PEDANTIC |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 _constant: noRecurse FT_LOAD_NO_RECURSE |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 _constant: ignoreTransform FT_LOAD_IGNORE_TRANSFORM |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 _constant: monochrome FT_LOAD_MONOCHROME |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 _constant: linearDesign FT_LOAD_LINEAR_DESIGN |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 _constant: noAutohint FT_LOAD_NO_AUTOHINT |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 _constant: color FT_LOAD_COLOR |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 |
328
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
322 _kerning <- #{ |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
323 _constant: default FT_KERNING_DEFAULT |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
324 _constant: unfitted FT_KERNING_UNFITTED |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
325 _constant: unscaled FT_KERNING_UNSCALED |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
326 } |
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
327 |
321
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
328 #{ |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
329 init <- { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
330 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 #{ |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
332 includeSystemHeader: "ft2build.h" |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 includeSystemHeader: FT_FREETYPE_H |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 llProperty: library withType: FT_Library |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
336 llMessage: _init withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 FT_Init_FreeType: (addr_of: library) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
339 self |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 llMessage: libraryOpaque withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 libOpaque <- cpointer ptr |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
344 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 libOpaque <- make_object: (addr_of: cpointer_meta) NULL 0 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
346 libOpaque val!: library |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
347 libOpaque |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
350 faceFromPath:index <- :path :index { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
351 (_helper newFace: libraryOpaque path index) value: :opaque { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 option value: (_makeFace: opaque) |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
353 } none: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
354 option none |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
355 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
356 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
357 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
358 llMessage: destroy withVars: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
359 } andCode: { |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
360 FT_Done_FreeType: library |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
361 self |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
362 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
363 } _init |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
364 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
365 |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
366 loadFlags <- { _loadFlags } |
328
c1fad3d93861
Add getKerning to freetype module and use it in sample
Michael Pavone <pavone@retrodev.com>
parents:
326
diff
changeset
|
367 kerning <- { _kerning } |
321
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
368 } |
3edd0169311a
Add basic binding to Freetype2
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
369 } |