a few updates to the OpenType Layout code still far to go, but I'll dedicate most of my time on it next week
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
diff --git a/src/otlayout/oltypes.c b/src/otlayout/oltypes.c
index 19b34a3..619b7a1 100644
--- a/src/otlayout/oltypes.c
+++ b/src/otlayout/oltypes.c
@@ -477,20 +477,138 @@
return result;
}
- /* compute a BaseCoord value */
+ /* extract a BaseCoord value */
LOCAL_FUNC
- TT_Int OTL_Get_Base_Coordinate( TT_Byte* base_coord,
- TT_UShort *format
- TT_UShort *ref_glyph_id,
- TT_Byte* *device )
+ void OTL_Get_Base_Coordinate( TT_Byte* base_coord,
+ OTL_ValueRecord* coord )
{
- TT_Byte* p =base_coord;
+ TT_Byte* p = base_coord;
TT_Int result = 0;
- *format = OTL_UShort(p);
-
- switch (*format)
+ coord->format = OTL_UShort(p);
+ coord->coordinate = OTL_Short(p);
+ coord->device = 0;
+
+ switch (coord->format)
{
- case
+ case 2: /* format 2 */
+ coord->ref_glyph = OTL_UShort(p);
+ coord->ref_point = OTL_UShort(p);
+ break;
+
+ case 3: /* format 3 */
+ coord->device = p - 4 + OTL_UShort(p);
+ break;
+
+ default:
+ ;
}
}
+
+
+ /* compute size of ValueRecord */
+ LOCAL_FUNC
+ TT_Int OTL_ValueRecord_Size( TT_UShort format )
+ {
+ TT_Int count;
+
+ /* each bit in the value format corresponds to a single ushort */
+ /* we thus count the bits, and multiply the result by 2 */
+
+ count = (TT_Int)(format & 0xFF);
+ count = ((count & 0xAA) >> 1) + (count & 0x55);
+ count = ((count & 0xCC) >> 2) + (count & 0x33);
+ count = ((count & 0xF0) >> 4) + (count & 0x0F);
+
+ return count*2;
+ }
+
+
+
+ /* extract ValueRecord */
+ LOCAL_FUNC
+ void OTL_Get_ValueRecord( TT_Byte* value_record,
+ TT_UShort value_format,
+ TT_Byte* pos_table,
+ OTL_ValueRecord* record )
+ {
+ TT_Byte* p = value_record;
+
+ /* clear vectors */
+ record->placement.x = 0;
+ record->placement.y = 0;
+ record->advance.x = 0;
+ record->advance.y = 0;
+
+ record->device_pla_x = 0;
+ record->device_pla_y = 0;
+ record->device_adv_x = 0;
+ record->device_adv_y = 0;
+
+ if (value_format & 1) record->placement.x = NEXT_Short(p);
+ if (value_format & 2) record->placement.y = NEXT_Short(p);
+ if (value_format & 4) record->advance.x = NEXT_Short(p);
+ if (value_format & 8) record->advance.y = NEXT_Short(p);
+
+ if (value_format & 16) record->device_pla_x = pos_table + NEXT_UShort(p);
+ if (value_format & 32) record->device_pla_y = pos_table + NEXT_UShort(p);
+ if (value_format & 64) record->device_adv_x = pos_table + NEXT_UShort(p);
+ if (value_format & 128) record->device_adv_y = pos_table + NEXT_UShort(p);
+ }
+
+
+
+ /* extract Anchor */
+ LOCAL_FUNC
+ void OTL_Get_Anchor( TT_Byte* anchor_table,
+ OTL_Anchor* anchor )
+ {
+ TT_Byte* p = anchor_table;
+
+ anchor->format = NEXT_UShort(p);
+ anchor->coord.x = NEXT_Short(p);
+ anchor->coord.y = NEXT_Short(p);
+ anchor->point = 0;
+ anchor->device_x = 0;
+ anchor->device_y = 0;
+
+ switch (anchor->format)
+ {
+ case 2:
+ anchor->point = NEXT_UShort(p);
+ break;
+
+ case 3:
+ anchor->device_x = anchor_table + NEXT_UShort(p);
+ anchor->device_y = anchor_table + NEXT_UShort(p);
+ break;
+
+ default:
+ ;
+ }
+ }
+
+
+
+ /* extract Mark from MarkArray */
+ LOCAL_FUNC
+ void OTL_Get_Mark( TT_Byte* mark_array,
+ TT_UInt index,
+ TT_UShort* clazz,
+ OTL_Anchor* anchor )
+ {
+ TT_Byte* p = mark_array;
+ TT_UInt count;
+
+ *clazz = 0;
+ MEM_Set( anchor, 0, sizeof(*anchor) );
+
+ count = NEXT_UShort(p);
+ if (index < count)
+ {
+ p += 4*index;
+ *clazz = NEXT_UShort(p);
+ OTL_Get_Anchor( mark_array + NEXT_UShort(p), anchor );
+ }
+ }
+
diff --git a/src/otlayout/oltypes.h b/src/otlayout/oltypes.h
index eb14077..dc92908 100644
--- a/src/otlayout/oltypes.h
+++ b/src/otlayout/oltypes.h
@@ -24,6 +24,7 @@
*
* max_features :: total number of features in table
* feature_tags :: tags of all features for current script/language
+ * features :: selection flags for all features in current script/lang
*
* max_lookups :: total number of lookups in table
* lookups :: selection flags for all lookups for current
@@ -81,6 +82,40 @@
} OTL_Table;
+ typedef struct OTL_BaseCoord_
+ {
+ TT_UShort format;
+ TT_Short coordinate;
+ TT_UShort ref_glyph;
+ TT_UShort ref_point;
+ TT_Byte* device;
+
+ } OTL_BaseCoord;
+
+
+ typedef struct OTL_ValueRecord_
+ {
+ TT_Vector placement;
+ TT_Vector advance;
+
+ TT_Byte* device_pla_x;
+ TT_Byte* device_pla_y;
+ TT_Byte* device_adv_x;
+ TT_Byte* device_adv_y;
+
+ } OTL_ValueRecord;
+
+
+ typedef struct OTL_Anchor_
+ {
+ TT_UInt format;
+ TT_Vector coord;
+ TT_UInt anchor_point;
+ TT_Byte* device_x;
+ TT_Byte* device_y;
+
+ } OTL_Anchor;
+
LOCAL_DEF
TT_Error OTL_Table_Init( OTL_Table* table,
FT_Memory memory );
@@ -222,10 +257,47 @@
+
LOCAL_DEF
TT_Long OTL_Get_Coverage_Index( TT_Byte* coverage,
TT_UInt glyph_id );
+ LOCAL_DEF
+ TT_UInt OTL_Get_Glyph_Class( TT_Byte* class_def,
+ TT_UInt glyph_id );
+
+ LOCAL_DEF
+ TT_Int OTL_Get_Device_Adjustment( TT_Byte* device,
+ TT_UInt size );
+
+ LOCAL_DEF
+ void OTL_Get_Base_Coordinate( TT_Byte* base_coord,
+ OTL_BaseCoord* coord );
+
+
+ LOCAL_DEF
+ TT_Int OTL_ValueRecord_Size( TT_UShort value_format );
+
+
+ LOCAL_DEF
+ void OTL_Get_ValueRecord( TT_Byte* value_record,
+ TT_UShort value_format,
+ TT_Byte* pos_table,
+ OTL_ValueRecord* record );
+
+
+ LOCAL_DEF
+ void OTL_Get_Anchor( TT_Byte* anchor_table,
+ OTL_Anchor* anchor );
+
+
+ LOCAL_DEF
+ void OTL_Get_Mark( TT_Byte* mark_array,
+ TT_UInt index,
+ TT_UShort* clazz,
+ OTL_Anchor* anchor );
+
+
#define OTL_Byte(p) (p++, p[-1])