Ejemplo n.º 1
0
json_value *caryll_gpos_mark_to_ligature_to_json(otl_subtable *st) {
	subtable_gpos_mark_to_ligature *subtable = &(st->gpos_mark_to_ligature);
	json_value *_subtable = json_object_new(3);
	json_value *_marks = json_object_new(subtable->marks->numGlyphs);
	json_value *_bases = json_object_new(subtable->bases->numGlyphs);
	for (uint16_t j = 0; j < subtable->marks->numGlyphs; j++) {
		json_value *_mark = json_object_new(3);
		sds markClassName =
		    sdscatfmt(sdsempty(), "ac_%i", subtable->markArray->records[j].markClass);
		json_object_push(_mark, "class",
		                 json_string_new_length((uint32_t)sdslen(markClassName), markClassName));
		sdsfree(markClassName);
		json_object_push(_mark, "x", json_integer_new(subtable->markArray->records[j].anchor.x));
		json_object_push(_mark, "y", json_integer_new(subtable->markArray->records[j].anchor.y));
		json_object_push(_marks, subtable->marks->glyphs[j].name, preserialize(_mark));
	}
	for (uint16_t j = 0; j < subtable->bases->numGlyphs; j++) {
		mark_to_ligature_base *base = subtable->ligArray[j];
		json_value *_base = json_array_new(base->componentCount);
		for (uint16_t k = 0; k < base->componentCount; k++) {
			json_value *_bk = json_object_new(subtable->classCount);
			for (uint16_t m = 0; m < subtable->classCount; m++) {
				if (base->anchors[k][m].present) {
					json_value *_anchor = json_object_new(2);
					json_object_push(_anchor, "x", json_integer_new(base->anchors[k][m].x));
					json_object_push(_anchor, "y", json_integer_new(base->anchors[k][m].y));
					sds markClassName = sdscatfmt(sdsempty(), "ac_%i", m);
					json_object_push_length(_bk, (uint32_t)sdslen(markClassName), markClassName,
					                        _anchor);
					sdsfree(markClassName);
				}
			}
			json_array_push(_base, _bk);
		}
		json_object_push(_bases, subtable->bases->glyphs[j].name, preserialize(_base));
	}
	json_object_push(_subtable, "classCount", json_integer_new(subtable->classCount));
	json_object_push(_subtable, "marks", _marks);
	json_object_push(_subtable, "bases", _bases);
	return _subtable;
}
Ejemplo n.º 2
0
json_value *json_string_new(const json_char *buf) {
	return json_string_new_length(strlen(buf), buf);
}