1// Glyph outlines from a `CFF ` or `CFF2` table: Type 2 charstrings with2// their global and local subroutines, run into contours of lines and3// cubic curves; name-keyed fonts with one private dictionary, CID-keyed4// ones (as Noto Sans CJK is) and CFF2 fonts choosing one per glyph5// through FDSelect, and CFF2's `blend` taking the face's position on its6// axes. Hints are read past, `seac` accents and the arithmetic operators7// left out, as they are from modern fonts.89import std::vector;10import std::option;11import std::math;1213import pkg::alloy::text::font::reader;14import pkg::alloy::text::font::face;15import pkg::alloy::text::font::outline;16import variations;1718// An INDEX: `count` items, item k from data + offset k to data + offset19// k + 1 (offsets counting from 1).20pub type Index = struct {21 pub count: u32,22 off_size: u64,23 offsets: u64,24 data: u64,25 pub end: u64, // past its last item26};2728pub fn Index::read(d: &[u8], at: u64, version2: bool) -> Index {29 var count = if (version2) u32_at(&d, at) else u16_at(&d, at);30 const header: u64 = if (version2) 4 else 2;31 const off_size = u8_at(&d, at + header) to u64;32 // an index whose offsets do not fit in the data reads as empty33 if (34 off_size == 035 || off_size > 436 || at + header + 1 + (count to u64 + 1) * off_size > d.length()37 ) {38 count = 0;39 }40 if (count == 0) {41 return Index {42 .count = 0,43 .off_size = 1,44 .offsets = at + header,45 .data = at,46 .end = at + header47 };48 }49 const offsets = at + header + 1;50 var index = Index {51 .count = count,52 .off_size = off_size,53 .offsets = offsets,54 .data = offsets + (count to u64 + 1) * off_size - 1,55 .end = 056 };57 index.end = index.data + index.offset(&d, count to u64);58 return index;59}6061fn offset(self index: &Index, d: &[u8], k: u64) -> u64 {62 const at = index.offsets + k * index.off_size;63 return match (index.off_size) {64 1 u8_at(&d, at) to u64;65 2 u16_at(&d, at) to u64;66 3 (u16_at(&d, at) to u64 << 8) | u8_at(&d, at + 2) to u64;67 else u32_at(&d, at) to u64;68 };69}7071// The bytes of item k, none past the index's or the data's end.72pub fn item(self index: &Index, d: &[u8], k: u64) -> [u64 : 2] {73 if (k >= index.count to u64) {74 return [0, 0];75 }76 const start = index.data + index.offset(&d, k);77 const end = index.data + index.offset(&d, k + 1);78 if (start > end || end > d.length()) {79 return [0, 0];80 }81 return [start, end];82}8384// A subroutine number's bias, by the count of subroutines.85fn bias(self index: &Index) -> i32 {86 if (index.count < 1240) {87 return 107;88 }89 return if (index.count < 33900) 1131 else 32768;90}9192// A font dictionary's private part: its local subroutines and, in CFF2,93// the variation data its blends take by default.94pub type FontDict = struct {95 pub subrs: Index,96 pub vsindex: u32,97};9899// How glyphs pick their font dictionary.100pub type FontSelect = enum {101 Single,102 Bytes: u64, // format 0: one a glyph103 Ranges: u64, // format 3: 16-bit glyphs and 8-bit dictionaries104 LongRanges: u64, // format 4 (CFF2): 32-bit glyphs and 16-bit dictionaries105};106107pub type Cff : Outlines = struct {108 pub version2: bool,109 pub charstrings: Index,110 pub global_subrs: Index,111 pub dicts: Vector<FontDict>,112 pub select: FontSelect,113 pub store: Option<u64>, // CFF2's item variation store114};115116// What the dictionaries read here set; offsets from the table's start.117type Dict = struct {118 charstrings: u64 = 0,119 private_size: u64 = 0,120 private_at: u64 = 0,121 fd_array: u64 = 0,122 fd_select: u64 = 0,123 subrs: u64 = 0, // from the private dictionary's start124 vsindex: u32 = 0,125 store: u64 = 0,126};127128// DICT operators read, escaped ones as 1200 + their second byte129const CHARSTRINGS: u32 = 17;130const PRIVATE: u32 = 18;131const SUBRS: u32 = 19;132const VSINDEX_DICT: u32 = 22;133const BLEND_DICT: u32 = 23;134const VSTORE: u32 = 24;135const FD_ARRAY: u32 = 1236;136const FD_SELECT: u32 = 1237;137138// A dictionary's operators and their operands, the ones read kept.139fn read_dict(d: &[u8], start: u64, end: u64) -> Dict {140 var dict = Dict {};141 var operands: [f64 : 48] = [0.0 : 48];142 var count: u64 = 0;143 var p = start;144 while (p < end && p < d.length()) {145 const b = d[p];146 if (b >= 28 || b == 30) {147 const value = dict_operand(&d, &var p);148 if (count < 48) {149 operands[count] = value;150 count += 1;151 }152 continue;153 }154 var operator = b to u32;155 p += 1;156 if (b == 12) {157 operator = 1200 + u8_at(&d, p);158 p += 1;159 }160 const first = if (count > 0) offset_of(operands[0]) else 0;161 match (operator) {162 CHARSTRINGS {163 dict.charstrings = first;164 }165 PRIVATE {166 if (count >= 2) {167 dict.private_size = first;168 dict.private_at = offset_of(operands[1]);169 }170 }171 SUBRS {172 dict.subrs = first;173 }174 VSINDEX_DICT {175 dict.vsindex = first to u32;176 }177 BLEND_DICT {178 // the defaults stay, for the operator they are given to179 if (count > 0) {180 count = min_count(offset_of(operands[count - 1]), count - 1);181 continue;182 }183 }184 VSTORE {185 dict.store = first;186 }187 FD_ARRAY {188 dict.fd_array = first;189 }190 FD_SELECT {191 dict.fd_select = first;192 }193 }194 count = 0;195 }196 return dict;197}198199fn min_count(a: u64, b: u64) -> u64 => if (a < b) a else b;200201// A DICT operand as a count or offset, 0 when negative or not a number;202// read as f64, which holds every 32-bit operand exactly.203fn offset_of(v: f64) -> u64 => if (v > 0.0 && v < 4294967296.0) v to u64 else 0;204205// A charstring operand as a count or index, 0 when negative or not a206// number.207fn whole(v: f32) -> u64 => if (v > 0.0 && v < 4294967296.0) v to u64 else 0;208209// A DICT operand at p, moving p past it; a real number's value is not210// needed by any operator read, so it reads as 0.211fn dict_operand(d: &[u8], p: &var u64) -> f64 {212 const b0 = d[p] to i32;213 if (b0 == 30) {214 p += 1;215 while (p < d.length()) {216 const b = d[p];217 p += 1;218 if ((b & 0x0F) == 0x0F || (b >> 4) == 0x0F) {219 break;220 }221 }222 return 0.0;223 }224 if (b0 == 28) {225 p += 3;226 return i16_at(&d, p - 2) to f64;227 }228 if (b0 == 29) {229 p += 5;230 return (u32_at(&d, p - 4) as i32) to f64;231 }232 p += 1;233 if (b0 >= 32 && b0 <= 246) {234 return (b0 - 139) to f64;235 }236 const b1 = u8_at(&d, p) to i32;237 p += 1;238 if (b0 >= 247 && b0 <= 250) {239 return ((b0 - 247) * 256 + b1 + 108) to f64;240 }241 if (b0 >= 251 && b0 <= 254) {242 return (-(b0 - 251) * 256 - b1 - 108) to f64;243 }244 return 0.0;245}246247// The table at `at` (CFF2's with `version2`), None when it does not read.248pub fn Cff::read(d: &[u8], at: u64, version2: bool) -> Option<Cff> {249 var top = Dict {};250 var global_at: u64 = 0;251 if (version2) {252 const header = u8_at(&d, at + 2) to u64;253 const top_length = u16_at(&d, at + 3) to u64;254 top = read_dict(&d, at + header, at + header + top_length);255 global_at = at + header + top_length;256 } else {257 const header = u8_at(&d, at + 2) to u64;258 const names = Index::read(&d, at + header, false);259 const tops = Index::read(&d, names.end, false);260 const strings = Index::read(&d, tops.end, false);261 const first = tops.item(&d, 0);262 top = read_dict(&d, first[0], first[1]);263 global_at = strings.end;264 }265 if (top.charstrings == 0) {266 return ::None;267 }268 var cff = Cff {269 .version2 = version2,270 .charstrings = Index::read(&d, at + top.charstrings, version2),271 .global_subrs = Index::read(&d, global_at, version2),272 .dicts = Vector<FontDict>::empty(),273 .select = FontSelect::Single,274 .store = if (top.store != 0) ::Some(at + top.store + 2) else ::None275 };276 if (top.fd_array != 0) {277 const array = Index::read(&d, at + top.fd_array, version2);278 for ([..array.count to u64]) |k| {279 const span = array.item(&d, k);280 cff.dicts.push(private_dict(&d, at, &read_dict(&d, span[0], span[1]), version2));281 }282 if (top.fd_select != 0) {283 const s = at + top.fd_select;284 cff.select = match (u8_at(&d, s)) {285 0 FontSelect::Bytes(s + 1);286 3 FontSelect::Ranges(s + 1);287 4 FontSelect::LongRanges(s + 1);288 else FontSelect::Single;289 };290 }291 } else {292 cff.dicts.push(private_dict(&d, at, &top, version2));293 }294 if (cff.charstrings.count == 0 || cff.dicts.length() == 0) {295 return ::None;296 }297 return ::Some(move cff);298}299300// The private dictionary a font dictionary names, read.301fn private_dict(d: &[u8], table: u64, font: &Dict, version2: bool) -> FontDict {302 const start = table + font.private_at;303 const private = read_dict(&d, start, start + font.private_size);304 return FontDict {305 .subrs = if (private.subrs != 0 && font.private_size != 0) Index::read(306 &d,307 start + private.subrs,308 version2309 ) else Index::read(&d, d.length(), version2),310 .vsindex = private.vsindex311 };312}313314// The font dictionary the glyph draws with.315fn dict_of(self cff: &Cff, d: &[u8], glyph: u32) -> u64 {316 const k = match (cff.select) {317 ::Single 0;318 ::Bytes |at| u8_at(&d, at + glyph to u64) to u64;319 ::Ranges |at| in_ranges(&d, at, glyph, false);320 ::LongRanges |at| in_ranges(&d, at, glyph, true);321 };322 return if (k < cff.dicts.length()) k else 0;323}324325// FDSelect's ranges: a count, then each range's first glyph and326// dictionary, then the glyph past the last range.327fn in_ranges(d: &[u8], at: u64, glyph: u32, long: bool) -> u64 {328 const count = if (long) u32_at(&d, at) to u64 else u16_at(&d, at) to u64;329 const first = if (long) at + 4 else at + 2;330 const size: u64 = if (long) 6 else 3;331 var low: u64 = 0;332 var high = count;333 while (low < high) {334 const middle = (low + high) / 2;335 const range = first + middle * size;336 const start = if (long) u32_at(&d, range) else u16_at(&d, range);337 const next = if (long) u32_at(&d, range + size) else u16_at(&d, range + size);338 if (glyph < start) {339 high = middle;340 } else if (glyph >= next) {341 low = middle + 1;342 } else {343 return if (long) u16_at(&d, range + 4) to u64 else u8_at(&d, range + 2) to u64;344 }345 }346 return 0;347}348349// The glyph's outline at the face's position on its axes (text's350// `Outlines`).351fn draw(self cff: &Cff, face: &Face, glyph: u32, out: &var Outline) {352 cff.draw_at(&face.data(), glyph, &face.cff_scalars.view(), &var out);353}354355// Adds the glyph's contours, at the axes' position whose region scalars356// (variations.alloy) CFF2's blends take; none for the default.357pub fn draw_at(self cff: &Cff, d: &[u8], glyph: u32, scalars: &[f32], out: &var Outline) {358 if (glyph >= cff.charstrings.count) {359 return;360 }361 const dict = &cff.dicts.get(cff.dict_of(&d, glyph));362 var m = Machine {363 .cff = &cff,364 .d = &d,365 .local = &dict.subrs,366 .region_scalars = &scalars,367 .out = &var out,368 .stack = [0.0 : 513],369 .limit = if (cff.version2) 513 else 48370 };371 m.select_variation(dict.vsindex);372 const span = cff.charstrings.item(&d, glyph to u64);373 m.run(span[0], span[1], 0);374 m.close();375}376377// Charstring operators, escaped ones as 1200 + their second byte378const HSTEM: u32 = 1;379const VSTEM: u32 = 3;380const VMOVETO: u32 = 4;381const RLINETO: u32 = 5;382const HLINETO: u32 = 6;383const VLINETO: u32 = 7;384const RRCURVETO: u32 = 8;385const CALLSUBR: u32 = 10;386const RETURN: u32 = 11;387const ENDCHAR: u32 = 14;388const VSINDEX: u32 = 15;389const BLEND: u32 = 16;390const HSTEMHM: u32 = 18;391const HINTMASK: u32 = 19;392const CNTRMASK: u32 = 20;393const RMOVETO: u32 = 21;394const HMOVETO: u32 = 22;395const VSTEMHM: u32 = 23;396const RCURVELINE: u32 = 24;397const RLINECURVE: u32 = 25;398const VVCURVETO: u32 = 26;399const HHCURVETO: u32 = 27;400const CALLGSUBR: u32 = 29;401const VHCURVETO: u32 = 30;402const HVCURVETO: u32 = 31;403const HFLEX: u32 = 1234;404const FLEX: u32 = 1235;405const HFLEX1: u32 = 1236;406const FLEX1: u32 = 1237;407408// How deep subroutines may call.409const MAX_DEPTH: u32 = 10;410411// A charstring being run: its operand stack, pen and hints.412type Machine = struct {413 cff: &Cff,414 d: &[u8],415 local: &Index,416 region_scalars: &[f32],417 out: &var Outline,418 stack: [f32 : 513],419 count: u64 = 0,420 limit: u64,421 x: f32 = 0.0,422 y: f32 = 0.0,423 stems: u32 = 0,424 width_read: bool = false, // CFF's optional width before the first operator clearing the stack425 open: bool = false,426 ended: bool = false,427 blend_regions: u64 = 0, // the regions a blend's operand takes deltas for428 blend_scalars: [f32 : 64] = [0.0 : 64],429};430431// The variation data blends take from now on: its regions' scalars.432fn select_variation(self m: &var Machine, index: u32) {433 m.blend_regions = 0;434 const store = if (m.cff.store is ::Some |s|) s else {435 return;436 };437 const regions = data_regions(&m.d, store, index);438 m.blend_regions = min_count(regions.length(), 64);439 for ([..m.blend_regions]) |k| {440 const region = regions.get(k) to u64;441 m.blend_scalars[k] = if (442 region < m.region_scalars.length()443 ) m.region_scalars[region] else 0.0;444 }445}446447fn push(self m: &var Machine, value: f32) {448 if (m.count < m.limit) {449 m.stack[m.count] = value;450 m.count += 1;451 }452}453454// The operands from the first, past the width CFF may put first when455// the operator takes `expected` (or, odd, an even count of) operands.456fn operands_from(self m: &var Machine, odd_width: bool, expected: u64) -> u64 {457 var first: u64 = 0;458 if (!m.cff.version2 && !m.width_read) {459 const has_width = if (odd_width) m.count % 2 == 1 else m.count > expected;460 if (has_width && m.count > 0) {461 first = 1;462 }463 }464 m.width_read = true;465 return first;466}467468fn close(self m: &var Machine) {469 if (m.open) {470 m.out.ends.push((m.out.points.length() - 1) to u32);471 m.open = false;472 }473}474475fn move_to(self m: &var Machine, dx: f32, dy: f32) {476 m.close();477 m.x += dx;478 m.y += dy;479 m.out.points.push(OutlinePoint { .x = m.x, .y = m.y, .kind = PointKind::On });480 m.open = true;481}482483fn line_to(self m: &var Machine, dx: f32, dy: f32) {484 if (!m.open) {485 m.move_to(0.0, 0.0);486 }487 m.x += dx;488 m.y += dy;489 m.out.points.push(OutlinePoint { .x = m.x, .y = m.y, .kind = PointKind::On });490}491492// A cubic curve by its three steps: to the first control point, the493// second, the end.494fn curve_to(self m: &var Machine, dxa: f32, dya: f32, dxb: f32, dyb: f32, dxc: f32, dyc: f32) {495 if (!m.open) {496 m.move_to(0.0, 0.0);497 }498 const x1 = m.x + dxa;499 const y1 = m.y + dya;500 const x2 = x1 + dxb;501 const y2 = y1 + dyb;502 m.x = x2 + dxc;503 m.y = y2 + dyc;504 m.out.points.push(OutlinePoint { .x = x1, .y = y1, .kind = PointKind::Cubic });505 m.out.points.push(OutlinePoint { .x = x2, .y = y2, .kind = PointKind::Cubic });506 m.out.points.push(OutlinePoint { .x = m.x, .y = m.y, .kind = PointKind::On });507}508509// Runs the charstring's bytes from start to end, then returns: at its510// end, a `return` or an `endchar`.511fn run(self m: &var Machine, start: u64, end: u64, depth: u32) {512 const d = &m.d;513 var p = start;514 while (p < end && !m.ended) {515 const b0 = d[p] to u32;516 if (b0 >= 32 || b0 == 28) {517 // an operand518 if (b0 <= 246) {519 if (b0 == 28) {520 m.push(i16_at(&d, p + 1) to f32);521 p += 3;522 } else {523 m.push((b0 to i32 - 139) to f32);524 p += 1;525 }526 } else if (b0 == 255) {527 m.push((u32_at(&d, p + 1) as i32) to f32 / 65536.0);528 p += 5;529 } else {530 const b1 = u8_at(&d, p + 1) to i32;531 const v = if (b0 <= 250) (b0 to i32 - 247) * 256 + b1 + 108 else -(532 b0 to i32 - 251533 ) * 256 - b1 - 108;534 m.push(v to f32);535 p += 2;536 }537 continue;538 }539 var operator = b0;540 p += 1;541 if (b0 == 12) {542 operator = 1200 + u8_at(&d, p);543 p += 1;544 }545 const s = &m.stack;546 match (operator) {547 HSTEM, VSTEM, HSTEMHM, VSTEMHM {548 const first = m.operands_from(true, 0);549 m.stems += ((m.count - first) / 2) to u32;550 }551 HINTMASK, CNTRMASK {552 // operands before a mask are vertical stems553 const first = m.operands_from(true, 0);554 m.stems += ((m.count - first) / 2) to u32;555 p += ((m.stems + 7) / 8) to u64;556 }557 RMOVETO {558 const first = m.operands_from(false, 2);559 if (m.count >= first + 2) {560 m.move_to(s[first], s[first + 1]);561 }562 }563 HMOVETO {564 const first = m.operands_from(false, 1);565 if (m.count >= first + 1) {566 m.move_to(s[first], 0.0);567 }568 }569 VMOVETO {570 const first = m.operands_from(false, 1);571 if (m.count >= first + 1) {572 m.move_to(0.0, s[first]);573 }574 }575 RLINETO {576 var k: u64 = 0;577 while (k + 2 <= m.count) {578 m.line_to(s[k], s[k + 1]);579 k += 2;580 }581 }582 HLINETO, VLINETO {583 var horizontal = operator == HLINETO;584 for ([..m.count]) |k| {585 if (horizontal) {586 m.line_to(s[k], 0.0);587 } else {588 m.line_to(0.0, s[k]);589 }590 horizontal = !horizontal;591 }592 }593 RRCURVETO {594 var k: u64 = 0;595 while (k + 6 <= m.count) {596 m.curve_to(s[k], s[k + 1], s[k + 2], s[k + 3], s[k + 4], s[k + 5]);597 k += 6;598 }599 }600 RCURVELINE {601 var k: u64 = 0;602 while (k + 8 <= m.count) {603 m.curve_to(s[k], s[k + 1], s[k + 2], s[k + 3], s[k + 4], s[k + 5]);604 k += 6;605 }606 if (k + 2 <= m.count) {607 m.line_to(s[k], s[k + 1]);608 }609 }610 RLINECURVE {611 var k: u64 = 0;612 while (k + 8 <= m.count) {613 m.line_to(s[k], s[k + 1]);614 k += 2;615 }616 if (k + 6 <= m.count) {617 m.curve_to(s[k], s[k + 1], s[k + 2], s[k + 3], s[k + 4], s[k + 5]);618 }619 }620 VVCURVETO {621 var k: u64 = 0;622 var dx: f32 = 0.0;623 if (m.count % 2 == 1) {624 dx = s[0];625 k = 1;626 }627 while (k + 4 <= m.count) {628 m.curve_to(dx, s[k], s[k + 1], s[k + 2], 0.0, s[k + 3]);629 dx = 0.0;630 k += 4;631 }632 }633 HHCURVETO {634 var k: u64 = 0;635 var dy: f32 = 0.0;636 if (m.count % 2 == 1) {637 dy = s[0];638 k = 1;639 }640 while (k + 4 <= m.count) {641 m.curve_to(s[k], dy, s[k + 1], s[k + 2], s[k + 3], 0.0);642 dy = 0.0;643 k += 4;644 }645 }646 HVCURVETO, VHCURVETO {647 var horizontal = operator == HVCURVETO;648 var k: u64 = 0;649 while (k + 4 <= m.count) {650 // the last curve may take a fifth operand651 const last = if (m.count - k == 5) s[k + 4] else 0.0;652 if (horizontal) {653 m.curve_to(s[k], 0.0, s[k + 1], s[k + 2], last, s[k + 3]);654 } else {655 m.curve_to(0.0, s[k], s[k + 1], s[k + 2], s[k + 3], last);656 }657 horizontal = !horizontal;658 k += 4;659 }660 }661 FLEX {662 if (m.count >= 12) {663 m.curve_to(s[0], s[1], s[2], s[3], s[4], s[5]);664 m.curve_to(s[6], s[7], s[8], s[9], s[10], s[11]);665 }666 }667 HFLEX {668 if (m.count >= 7) {669 m.curve_to(s[0], 0.0, s[1], s[2], s[3], 0.0);670 m.curve_to(s[4], 0.0, s[5], -s[2], s[6], 0.0);671 }672 }673 HFLEX1 {674 if (m.count >= 9) {675 m.curve_to(s[0], s[1], s[2], s[3], s[4], 0.0);676 m.curve_to(s[5], 0.0, s[6], s[7], s[8], -(s[1] + s[3] + s[7]));677 }678 }679 FLEX1 {680 if (m.count >= 11) {681 var dx: f32 = 0.0;682 var dy: f32 = 0.0;683 for ([..5 to u64]) |k| {684 dx += s[k * 2];685 dy += s[k * 2 + 1];686 }687 m.curve_to(s[0], s[1], s[2], s[3], s[4], s[5]);688 if (abs_of(dx) > abs_of(dy)) {689 m.curve_to(s[6], s[7], s[8], s[9], s[10], -dy);690 } else {691 m.curve_to(s[6], s[7], s[8], s[9], -dx, s[10]);692 }693 }694 }695 CALLSUBR, CALLGSUBR {696 if (m.count == 0 || depth >= MAX_DEPTH) {697 m.ended = true;698 return;699 }700 m.count -= 1;701 const subrs: &Index = if (operator == CALLSUBR) &m.local else &m.cff.global_subrs;702 const number = clamp(s[m.count], -40000.0, 40000.0) to i32 + subrs.bias();703 if (number >= 0) {704 const span = subrs.item(&d, number to u64);705 m.run(span[0], span[1], depth + 1);706 }707 continue; // the stack carries on708 }709 RETURN {710 return;711 }712 ENDCHAR {713 m.operands_from(false, 0);714 m.close();715 m.ended = true;716 return;717 }718 VSINDEX {719 if (m.count > 0) {720 m.select_variation(whole(s[m.count - 1]) to u32);721 }722 }723 BLEND {724 m.blend();725 continue; // its results are operands726 }727 else {728 // a reserved or arithmetic operator: what follows cannot be read729 if (operator < 32 || operator >= 1238) {730 m.ended = true;731 return;732 }733 }734 }735 m.count = 0;736 }737}738739fn abs_of(v: f32) -> f32 => if (v < 0.0) -v else v;740741// CFF2's blend: n default values, then each one's deltas for the742// variation data's regions, then n; the values move by their deltas743// times the regions' scalars.744fn blend(self m: &var Machine) {745 if (m.count == 0) {746 return;747 }748 const n = whole(m.stack[m.count - 1]);749 const k = m.blend_regions;750 const taken = n * (k + 1) + 1;751 if (taken > m.count) {752 m.count = 0;753 return;754 }755 const base = m.count - taken;756 const deltas = base + n;757 for ([..n]) |i| {758 var value = m.stack[base + i];759 for ([..k]) |j| {760 value += m.stack[deltas + i * k + j] * m.blend_scalars[j];761 }762 m.stack[base + i] = value;763 }764 m.count = base + n;765}