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

Commit

Permalink
Merge Master
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Dec 1, 2017
2 parents 410415b + 32251ff commit 4cc865f
Show file tree
Hide file tree
Showing 53 changed files with 3,212 additions and 1,660 deletions.
6 changes: 5 additions & 1 deletion _vc2017.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
@echo off

set PROJDIR=%~dp0

for /f "usebackq tokens=*" %%i in (`"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i
)

if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
call "%InstallDir%\Common7\Tools\VsDevCmd.bat"
pushd %PROJDIR%
"%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" /m:%NUMBER_OF_PROCESSORS% /nr:false /nologo /verbosity:minimal %*
)
popd
)
2 changes: 2 additions & 0 deletions include/caryll/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <string.h>
#include <stdbool.h>

#include "ownership.h"

// We assume all T have trivial move constructors.
#define caryll_T(T) \
void (*init)(MODIFY T *); \
Expand Down
3 changes: 2 additions & 1 deletion include/caryll/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
void (*initN)(MODIFY __TV * arr, size_t n); \
void (*initCapN)(MODIFY __TV * arr, size_t n); \
__TV *(*createN)(size_t n); \
void (*fill)(MODIFY __TV * arr, size_t n); \
void (*clear)(MODIFY __TV * arr); \
void (*push)(MODIFY __TV * arr, MOVE __T obj); \
void (*shrinkToFit)(MODIFY __TV * arr); \
__T (*pop)(MODIFY __TV * arr); \
void (*fill)(MODIFY __TV * arr, size_t n); \
void (*disposeItem)(MODIFY __TV * arr, size_t n); \
void (*filterEnv)(MODIFY __TV * arr, bool (*fn)(const __T *x, void *env), void *env); \
void (*sort)(MODIFY __TV * arr, int (*fn)(const __T *a, const __T *b));
Expand Down
1,050 changes: 646 additions & 404 deletions include/dep/uthash.h

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions include/otfcc/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ typedef struct _caryll_font otfcc_Font;

#include "otfcc/glyph-order.h"

#include "otfcc/table/fvar.h"

#include "otfcc/table/head.h"
#include "otfcc/table/glyf.h"
#include "otfcc/table/CFF.h"
Expand All @@ -25,6 +27,7 @@ typedef struct _caryll_font otfcc_Font;
#include "otfcc/table/cvt.h"
#include "otfcc/table/fpgm-prep.h"
#include "otfcc/table/gasp.h"
#include "otfcc/table/VDMX.h"

#include "otfcc/table/LTSH.h"
#include "otfcc/table/VORG.h"
Expand All @@ -45,6 +48,8 @@ typedef enum { FONTTYPE_TTF, FONTTYPE_CFF } otfcc_font_subtype;
struct _caryll_font {
otfcc_font_subtype subtype;

table_fvar *fvar;

table_head *head;
table_hhea *hhea;
table_maxp *maxp;
Expand All @@ -66,6 +71,7 @@ struct _caryll_font {
table_fpgm_prep *prep;
table_cvt *cvt_;
table_gasp *gasp;
table_VDMX *VDMX;

table_LTSH *LTSH;

Expand Down
1 change: 1 addition & 0 deletions include/otfcc/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ typedef struct {
bool stub_cmap4;
bool decimal_cmap;
bool name_glyphs_by_hash;
bool name_glyphs_by_gid;
char *glyph_name_prefix;
otfcc_ILogger *logger;
} otfcc_Options;
Expand Down
18 changes: 16 additions & 2 deletions include/otfcc/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
#include <stdbool.h>
#include <float.h>

typedef int16_t f2dot14;
typedef int32_t f16dot16;
typedef int16_t f2dot14; // 2.14 Fixed number, representing a value between [-1, 1].
typedef int32_t f16dot16; // 16.16 Fixed number, usually used by intermediate coordiantes of a font.
// To deal with implicit deltas in GVAR we must be very careful about it.
// Arithmetic operators saturate towards positive or negative infinity.
// Infinity values short circuit expressions.

typedef uint16_t glyphid_t; // Glyph index
typedef uint16_t glyphclass_t; // Glyph class
Expand All @@ -30,4 +33,15 @@ int16_t otfcc_to_f2dot14(const double x);
double otfcc_from_fixed(const f16dot16 x);
f16dot16 otfcc_to_fixed(const double x);

#define f16dot16_precision 16
#define f16dot16_k (1 << (f16dot16_precision - 1))
#define f16dot16_infinity ((f16dot16)0x7fffffff)
#define f16dot16_negativeIntinity ((f16dot16)0x80000000)

f16dot16 otfcc_f1616_add(f16dot16 a, f16dot16 b);
f16dot16 otfcc_f1616_minus(f16dot16 a, f16dot16 b);
f16dot16 otfcc_f1616_multiply(f16dot16 a, f16dot16 b);
f16dot16 otfcc_f1616_divide(f16dot16 a, f16dot16 b);
f16dot16 otfcc_f1616_muldiv(f16dot16 a, f16dot16 b, f16dot16 c);

#endif
36 changes: 36 additions & 0 deletions include/otfcc/table/VDMX.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef CARYLL_INCLUDE_TABLE_VDMX_H
#define CARYLL_INCLUDE_TABLE_VDMX_H

#include "table-common.h"

typedef struct {
uint16_t yPelHeight;
int16_t yMax;
int16_t yMin;
} vdmx_Record;

extern caryll_ValElementInterface(vdmx_Record) vdmx_iRecord;
typedef caryll_Vector(vdmx_Record) vdmx_Group;
extern caryll_VectorInterface(vdmx_Group, vdmx_Record) vdmx_iGroup;

typedef struct {
uint8_t bCharset;
uint8_t xRatio;
uint8_t yStartRatio;
uint8_t yEndRatio;

vdmx_Group records;
} vdmx_RatioRange;

extern caryll_ElementInterface(vdmx_RatioRange) vdmx_iRatioRange;
typedef caryll_Vector(vdmx_RatioRange) vdmx_RatioRagneList;
extern caryll_VectorInterface(vdmx_RatioRagneList, vdmx_RatioRange) vdmx_iRatioRangeList;

typedef struct {
uint16_t version;
vdmx_RatioRagneList ratios;
} table_VDMX;

extern caryll_RefElementInterface(table_VDMX) table_iVDMX;

#endif
40 changes: 40 additions & 0 deletions include/otfcc/table/fvar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef CARYLL_INCLUDE_TABLE_FVAR_H
#define CARYLL_INCLUDE_TABLE_FVAR_H

#include "table-common.h"
#include "otfcc/vf/vf.h"

// vf_Axis and vf_Axes are defined in vf/vf.h
// fvar_Instance is defined below
typedef struct {
uint16_t subfamilyNameID;
uint16_t flags;
VV coordinates;
uint16_t postScriptNameID;
} fvar_Instance;
extern caryll_ElementInterface(fvar_Instance) fvar_iInstance;
typedef caryll_Vector(fvar_Instance) fvar_InstanceList;
extern caryll_VectorInterface(fvar_InstanceList, fvar_Instance) fvar_iInstanceList;

typedef struct {
sds name;
vq_Region *region;
UT_hash_handle hh;
} fvar_Master;

typedef struct {
uint16_t majorVersion;
uint16_t minorVersion;
vf_Axes axes;
fvar_InstanceList instances;
fvar_Master *masters;
} table_fvar;

extern caryll_ElementInterfaceOf(table_fvar) {
caryll_RT(table_fvar);
const vq_Region *(*registerRegion)(table_fvar * fvar, MOVE vq_Region * region);
const fvar_Master *(*findMasterByRegion)(const table_fvar *fvar, const vq_Region *region);
}
table_iFvar;

#endif
16 changes: 10 additions & 6 deletions include/otfcc/table/glyf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "table-common.h"
#include "head.h"
#include "maxp.h"
#include "fvar.h"

enum GlyphType { SIMPLE, COMPOSITE };

Expand Down Expand Up @@ -52,21 +53,23 @@ typedef enum {
} RefAnchorStatus;

typedef struct {
//// NOTE: this part and below looks like a glyf_Point
VQ x;
VQ y;
// flags
bool roundToGrid;
bool useMyMetrics;
// the glyph being referenced
otfcc_GlyphHandle glyph;
// transformation term
scale_t a;
scale_t b;
scale_t c;
scale_t d;
// position term
// Anchorness term
RefAnchorStatus isAnchored;
shapeid_t inner;
shapeid_t outer;
VQ x;
VQ y;
// flags
bool roundToGrid;
bool useMyMetrics;
} glyf_ComponentReference;
extern caryll_ValElementInterface(glyf_ComponentReference) glyf_iComponentReference;
typedef caryll_Vector(glyf_ComponentReference) glyf_ReferenceList;
Expand Down Expand Up @@ -112,6 +115,7 @@ typedef struct {

// CID FDSelect
otfcc_FDHandle fdSelect;
glyphid_t cid; // Subset CID fonts may need this to represent the original CID entry

// Stats
glyf_GlyphStat stat;
Expand Down
2 changes: 1 addition & 1 deletion include/otfcc/table/hhea.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef struct {
int16_t ascender;
int16_t descender;
int16_t lineGap;
uint16_t advanceWithMax;
uint16_t advanceWidthMax;
int16_t minLeftSideBearing;
int16_t minRightSideBearing;
int16_t xMaxExtent;
Expand Down
21 changes: 21 additions & 0 deletions include/otfcc/vf/axis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef CARYLL_VF_AXIS_H
#define CARYLL_VF_AXIS_H

#include "caryll/element.h"
#include "caryll/vector.h"
#include "otfcc/primitives.h"

typedef struct {
uint32_t tag;
pos_t minValue;
pos_t defaultValue;
pos_t maxValue;
uint16_t flags;
uint16_t axisNameID;
} vf_Axis;

extern caryll_ValElementInterface(vf_Axis) vf_iAxis;
typedef caryll_Vector(vf_Axis) vf_Axes;
extern caryll_VectorInterface(vf_Axes, vf_Axis) vf_iAxes;

#endif
34 changes: 34 additions & 0 deletions include/otfcc/vf/region.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef CARYLL_VF_REGION_H
#define CARYLL_VF_REGION_H

#include "caryll/element.h"
#include "caryll/vector.h"
#include "otfcc/primitives.h"

#include "vv.h"

typedef struct {
pos_t start;
pos_t peak;
pos_t end;
} vq_AxisSpan;

bool vq_AxisSpanIsOne(const vq_AxisSpan *a);

typedef struct {
shapeid_t dimensions;
vq_AxisSpan spans[];
} vq_Region;

vq_Region *vq_createRegion(shapeid_t dimensions);
void vq_deleteRegion(MOVE vq_Region *region);
vq_Region *vq_copyRegion(const vq_Region *region);

int vq_compareRegion(const vq_Region *a, const vq_Region *b);
pos_t vq_regionGetWeight(const vq_Region *r, const VV *v);
void vq_showRegion(const vq_Region *r);

// function macros
#define VQ_REGION_SIZE(n) (sizeof(vq_Region) + sizeof(vq_AxisSpan) * (n))

#endif
1 change: 1 addition & 0 deletions include/otfcc/vf/vf.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
// part as a Ket.

#include "otfcc/vf/vq.h"
#include "otfcc/vf/axis.h"

#endif
29 changes: 4 additions & 25 deletions include/otfcc/vf/vq.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,7 @@
#include "otfcc/primitives.h"
#include "otfcc/handle.h"

extern caryll_ValElementInterface(pos_t) vq_iPosT;
typedef caryll_Vector(pos_t) VV;
extern caryll_VectorInterfaceTypeName(VV) {
caryll_VectorInterfaceTrait(VV, pos_t);
// Monoid instances
VV (*neutral)(tableid_t dimensions);
}
iVV;
// extern caryll_VectorInterface(VV, pos_t) iVV;

typedef struct {
pos_t start;
pos_t peak;
pos_t end;
} vq_AxisSpan;
extern caryll_ElementInterface(vq_AxisSpan) vq_iAxisSpan;
typedef caryll_Vector(vq_AxisSpan) vq_Region;
extern caryll_VectorInterfaceTypeName(vq_Region) {
caryll_VectorInterfaceTrait(vq_Region, vq_AxisSpan);
caryll_Ord(vq_Region);
pos_t (*getWeight)(const vq_Region *r, const VV *vv);
}
vq_iRegion;
#include "region.h"

typedef enum { VQ_STILL = 0, VQ_DELTA = 1 } VQSegType;
typedef struct {
Expand All @@ -38,7 +16,8 @@ typedef struct {
pos_t still;
struct {
pos_t quantity;
vq_Region region;
bool touched;
const vq_Region *region; // non-owning : they are in FVAR
} delta;
} val;
} vq_Segment;
Expand All @@ -48,7 +27,7 @@ extern caryll_ElementInterfaceOf(vq_Segment) {
caryll_Show(vq_Segment);
caryll_Ord(vq_Segment);
vq_Segment (*createStill)(pos_t x);
vq_Segment (*createDelta)(pos_t delta, MOVE vq_Region region);
vq_Segment (*createDelta)(pos_t delta, vq_Region * region);
}
vq_iSegment;
typedef caryll_Vector(vq_Segment) vq_SegList;
Expand Down
18 changes: 18 additions & 0 deletions include/otfcc/vf/vv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef CARYLL_VF_VV_H
#define CARYLL_VF_VV_H

#include "caryll/element.h"
#include "caryll/vector.h"
#include "otfcc/primitives.h"

extern caryll_ValElementInterface(pos_t) vq_iPosT;
typedef caryll_Vector(pos_t) VV;
extern caryll_VectorInterfaceTypeName(VV) {
caryll_VectorInterfaceTrait(VV, pos_t);
// Monoid instances
VV (*neutral)(tableid_t dimensions);
}
iVV;
// extern caryll_VectorInterface(VV, pos_t) iVV;

#endif
Loading

0 comments on commit 4cc865f

Please sign in to comment.