Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into releases
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Apr 18, 2016
2 parents b76a377 + 35a3f07 commit 339193f
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 2,841 deletions.
2 changes: 1 addition & 1 deletion premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ workspace "otfcc"
'_CARYLL_USE_PRE_SERIALIZED',
'MAIN_VER=0',
"SECONDARY_VER=1",
"PATCH_VER=2"
"PATCH_VER=3"
}

location "build"
Expand Down
1 change: 1 addition & 0 deletions src/cli/otfccdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ int main(int argc, char *argv[]) {
inPath, (sfnt->count - 1));
exit(EXIT_FAILURE);
}
if (show_time) push_stopwatch("Read Input SFNT", &begin);
}

caryll_font *font;
Expand Down
6 changes: 6 additions & 0 deletions src/fontops/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ void caryll_stat_glyf(caryll_font *font) {
if (thatstat.yMin < ymin) ymin = thatstat.yMin;
if (thatstat.yMax > ymax) ymax = thatstat.yMax;
}
font->head->xMin = xmin;
font->head->xMax = xmax;
font->head->yMin = ymin;
font->head->yMax = ymax;
free(stated);
}

Expand Down Expand Up @@ -416,6 +420,8 @@ void caryll_font_stat_OS_2(caryll_font *font, caryll_dump_options *dumpopts) {
}
void caryll_font_stat(caryll_font *font, caryll_dump_options *dumpopts) {
if (font->glyf && font->head) caryll_stat_glyf(font);
if (font->glyf && font->maxp) { font->maxp->numGlyphs = font->glyf->numberGlyphs; }
if (font->glyf && font->post) { font->post->maxMemType42 = font->glyf->numberGlyphs; }
if (font->glyf && font->maxp && font->maxp->version == 0x10000) caryll_stat_maxp(font);
if (font->fpgm && font->maxp && font->fpgm->length > font->maxp->maxSizeOfInstructions) {
font->maxp->maxSizeOfInstructions = font->fpgm->length;
Expand Down
20 changes: 11 additions & 9 deletions src/support/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
#define __STDC_FORMAT_MACROS
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "base64.h"
#include "buffer.h"
#include <extern/json-builder.h>
#include <extern/json.h>
#include <extern/sds.h>
#include <extern/uthash.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <extern/sds.h>
#include <extern/uthash.h>
#include <extern/json.h>
#include <extern/json-builder.h>
#include "buffer.h"
#include "base64.h"


#ifdef _MSC_VER
#define INLINE __forceinline /* use __forceinline (VC++ specific) */
Expand Down Expand Up @@ -284,6 +285,7 @@ static INLINE json_value *preserialize(MOVE json_value *x) {
}

static INLINE void *__caryll_allocate(size_t n, unsigned long line) {
if (!n) return NULL;
void *p = malloc(n);
if (!p) {
fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n);
Expand Down
1 change: 0 additions & 1 deletion src/tables/glyf.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ static INLINE json_value *glyf_glyph_instructions_to_json(glyf_glyph *g,
}
static INLINE json_value *glyf_glyph_to_json(glyf_glyph *g, caryll_dump_options *dumpopts) {
json_value *glyph = json_object_new(7);
json_object_push(glyph, "name", json_string_new_length(sdslen(g->name), g->name));
json_object_push(glyph, "advanceWidth", json_integer_new(g->advanceWidth));
if (dumpopts->has_vertical_metrics) {
json_object_push(glyph, "advanceHeight", json_integer_new(g->advanceHeight));
Expand Down
2 changes: 1 addition & 1 deletion src/tables/maxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

table_maxp *caryll_new_maxp() {
table_maxp *maxp = calloc(1, sizeof(table_maxp));
maxp->version = 0x00001000;
maxp->version = 0x00010000;
return maxp;
}

Expand Down
10 changes: 10 additions & 0 deletions src/tables/name.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ table_name *caryll_name_from_json(json_value *root, caryll_dump_options *dumpopt
for (uint32_t j = 0; j < table->u.array.length; j++) {
if (table->u.array.values[j] && table->u.array.values[j]->type == json_object) {
json_value *record = table->u.array.values[j];
if (!json_obj_get_type(record, "platformID", json_integer))
fprintf(stderr, "Missing or invalid platformID for name entry %d\n", j);
if (!json_obj_get_type(record, "encodingID", json_integer))
fprintf(stderr, "Missing or invalid encodingID for name entry %d\n", j);
if (!json_obj_get_type(record, "languageID", json_integer))
fprintf(stderr, "Missing or invalid languageID for name entry %d\n", j);
if (!json_obj_get_type(record, "nameID", json_integer))
fprintf(stderr, "Missing or invalid nameID for name entry %d\n", j);
if (!json_obj_get_type(record, "nameString", json_string))
fprintf(stderr, "Missing or invalid nameString for name entry %d\n", j);
if (json_obj_get_type(record, "platformID", json_integer) &&
json_obj_get_type(record, "encodingID", json_integer) &&
json_obj_get_type(record, "languageID", json_integer) &&
Expand Down
22 changes: 14 additions & 8 deletions src/tables/otl/GDEF.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ table_GDEF *caryll_new_GDEF() {
NEW(gdef);
gdef->glyphClassDef = NULL;
gdef->ligCarets = NULL;
gdef->markAttachClassDef = NULL;
return gdef;
}

Expand Down Expand Up @@ -71,13 +72,17 @@ table_GDEF *caryll_read_GDEF(caryll_packet packet) {
data, tableLength, ligCaretOffset + read_16u(data + ligCaretOffset));
if (!cov || cov->numGlyphs != read_16u(data + ligCaretOffset + 2)) goto FAIL;
checkLength(ligCaretOffset + 4 + cov->numGlyphs * 2);
gdef->ligCarets->coverage = cov;

NEW_N(gdef->ligCarets->carets, cov->numGlyphs);
for (uint16_t j = 0; j < cov->numGlyphs; j++) {
gdef->ligCarets->carets[j] = readLigCaretRecord(
data, tableLength,
ligCaretOffset + read_16u(data + ligCaretOffset + 4 + j * 2));
if (cov->numGlyphs) {
gdef->ligCarets->coverage = cov;
NEW_N(gdef->ligCarets->carets, cov->numGlyphs);
for (uint16_t j = 0; j < cov->numGlyphs; j++) {
gdef->ligCarets->carets[j] = readLigCaretRecord(
data, tableLength,
ligCaretOffset + read_16u(data + ligCaretOffset + 4 + j * 2));
}
} else {
caryll_delete_coverage(cov);
FREE(gdef->ligCarets);
}
}
uint16_t markAttachDefOffset = read_16u(data + 10);
Expand Down Expand Up @@ -172,7 +177,8 @@ table_GDEF *caryll_GDEF_from_json(json_value *root, caryll_dump_options *dumpopt
if ((table = json_obj_get_type(root, "GDEF", json_object))) {
gdef = caryll_new_GDEF();
gdef->glyphClassDef = caryll_classdef_from_json(json_obj_get(table, "glyphClassDef"));
gdef->markAttachClassDef = caryll_classdef_from_json(json_obj_get(table, "markAttachClassDef"));
gdef->markAttachClassDef =
caryll_classdef_from_json(json_obj_get(table, "markAttachClassDef"));
gdef->ligCarets = ligCaretFromJson(json_obj_get(table, "ligCarets"));
}
return gdef;
Expand Down
34 changes: 18 additions & 16 deletions src/tables/otl/classdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ otl_classdef *caryll_raad_classdef(font_file_pointer data, uint32_t tableLength,
if (format == 1 && tableLength >= offset + 6) {
uint16_t startGID = read_16u(data + offset + 2);
uint16_t count = read_16u(data + offset + 4);
if (tableLength >= offset + 6 + count * 2) {
if (count && tableLength >= offset + 6 + count * 2) {
cd->numGlyphs = count;
NEW_N(cd->glyphs, count);
NEW_N(cd->classes, count);
Expand Down Expand Up @@ -64,22 +64,24 @@ otl_classdef *caryll_raad_classdef(font_file_pointer data, uint32_t tableLength,
}
HASH_SORT(hash, by_covIndex);
cd->numGlyphs = HASH_COUNT(hash);
NEW_N(cd->glyphs, cd->numGlyphs);
NEW_N(cd->classes, cd->numGlyphs);
{
uint16_t j = 0;
uint16_t maxclass = 0;
coverage_entry *e, *tmp;
HASH_ITER(hh, hash, e, tmp) {
cd->glyphs[j].gid = e->gid;
cd->glyphs[j].name = NULL;
cd->classes[j] = e->covIndex;
if (e->covIndex > maxclass) maxclass = e->covIndex;
HASH_DEL(hash, e);
free(e);
j++;
if (cd->numGlyphs) {
NEW_N(cd->glyphs, cd->numGlyphs);
NEW_N(cd->classes, cd->numGlyphs);
{
uint16_t j = 0;
uint16_t maxclass = 0;
coverage_entry *e, *tmp;
HASH_ITER(hh, hash, e, tmp) {
cd->glyphs[j].gid = e->gid;
cd->glyphs[j].name = NULL;
cd->classes[j] = e->covIndex;
if (e->covIndex > maxclass) maxclass = e->covIndex;
HASH_DEL(hash, e);
free(e);
j++;
}
cd->maxclass = maxclass;
}
cd->maxclass = maxclass;
}
return cd;
}
Expand Down
44 changes: 24 additions & 20 deletions src/tables/otl/coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ otl_coverage *caryll_read_coverage(font_file_pointer data, uint32_t tableLength,
}
HASH_SORT(hash, by_covIndex);
coverage->numGlyphs = HASH_COUNT(hash);
NEW_N(coverage->glyphs, coverage->numGlyphs);
{
uint16_t j = 0;
coverage_entry *e, *tmp;
HASH_ITER(hh, hash, e, tmp) {
coverage->glyphs[j].gid = e->gid;
coverage->glyphs[j].name = NULL;
HASH_DEL(hash, e);
free(e);
j++;
if (coverage->numGlyphs) {
NEW_N(coverage->glyphs, coverage->numGlyphs);
{
uint16_t j = 0;
coverage_entry *e, *tmp;
HASH_ITER(hh, hash, e, tmp) {
coverage->glyphs[j].gid = e->gid;
coverage->glyphs[j].name = NULL;
HASH_DEL(hash, e);
free(e);
j++;
}
}
}
break;
Expand All @@ -73,16 +75,18 @@ otl_coverage *caryll_read_coverage(font_file_pointer data, uint32_t tableLength,
}
HASH_SORT(hash, by_covIndex);
coverage->numGlyphs = HASH_COUNT(hash);
NEW_N(coverage->glyphs, coverage->numGlyphs);
{
uint16_t j = 0;
coverage_entry *e, *tmp;
HASH_ITER(hh, hash, e, tmp) {
coverage->glyphs[j].gid = e->gid;
coverage->glyphs[j].name = NULL;
HASH_DEL(hash, e);
free(e);
j++;
if (coverage->numGlyphs) {
NEW_N(coverage->glyphs, coverage->numGlyphs);
{
uint16_t j = 0;
coverage_entry *e, *tmp;
HASH_ITER(hh, hash, e, tmp) {
coverage->glyphs[j].gid = e->gid;
coverage->glyphs[j].name = NULL;
HASH_DEL(hash, e);
free(e);
j++;
}
}
}
break;
Expand Down
1 change: 0 additions & 1 deletion src/tables/otl/gpos-mark-to-single.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ json_value *caryll_gpos_mark_to_single_to_json(otl_subtable *st) {
}
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;
Expand Down
Loading

0 comments on commit 339193f

Please sign in to comment.