Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from googlefonts/glyph-fbs
Browse files Browse the repository at this point in the history
schemas: add glyph.fbs and plist.fbs
  • Loading branch information
anthrotype authored Dec 1, 2021
2 parents 9b27f66 + 94fbb6e commit 6898614
Show file tree
Hide file tree
Showing 26 changed files with 4,207 additions and 3,728 deletions.
61 changes: 61 additions & 0 deletions schemas/plist.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/PropertyLists/
namespace FlatFont.Plist;

union Type {
Integer,
Real,
String,
Boolean,
Data,
Date,
Dict,
Array,
}

// can't have vectors of unions in python or rust (only c++) so I define a table
// that contains the union
table Plist {
value: Type (required);
}

// can't use struct because 'only tables can be union elements' in python flatbuffers
table Integer {
value: int;
}

table Real {
value: float;
}

table String {
value: string (required);
}

table Boolean {
value: bool;
}

table Data {
value: [ubyte] (required);
}

// xml plist date conforms to a subset of ISO 8601:
// YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'
table Date {
value: string (required);
}

table Dict {
value: [DictItem] (required);
}

table DictItem {
key: string (required, key);
value: Plist (required);
}

table Array {
values: [Plist] (required);
}

root_type Plist;
14 changes: 3 additions & 11 deletions schemas/ufo/fontinfo.fbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//namespace FlatFont.Ufo;
include "misc.fbs"; // for Guideline

namespace FlatFont.Ufo;

/// https://unifiedfontobject.org/versions/ufo3/fontinfo.plist/
table FontInfo {
Expand Down Expand Up @@ -236,14 +238,4 @@ table WoffMetadataExtensionValue {
}


table Guideline {
x: float;
y: float;
angle: float;
name: string;
color: string;
identifier: string;
}


root_type FontInfo;
60 changes: 60 additions & 0 deletions schemas/ufo/glyph.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
include "misc.fbs"; // for Guideline and Transform
include "../plist.fbs";

namespace FlatFont.Ufo;

/// https://unifiedfontobject.org/versions/ufo3/glyphs/glif/
table Glyph {
name: string (required, key);
width: float;
height: float;
unicodes: [uint];
image: Image;
lib: Plist.Dict;
note: string;
anchors: [Anchor];
components: [Component];
contours: [Contour];
guidelines: [Guideline];
}

/// https://unifiedfontobject.org/versions/ufo3/glyphs/glif/#image
table Image {
fileName: string;
transformation: Transform;
color: string;
}

/// https://unifiedfontobject.org/versions/ufo3/glyphs/glif/#anchor
table Anchor {
x: float;
y: float;
name: string;
color: string;
identifier: string;
}

/// https://unifiedfontobject.org/versions/ufo3/glyphs/glif/#component
table Component {
baseGlyph: string;
transformation: Transform;
identifier: string;
}

/// https://unifiedfontobject.org/versions/ufo3/glyphs/glif/#contour
table Contour {
points: [Point];
identifier: string;
}

/// https://unifiedfontobject.org/versions/ufo3/glyphs/glif/#point
table Point {
x: float;
y: float;
type: string;
smooth: bool;
name: string;
identifier: string;
}

root_type Glyph;
19 changes: 19 additions & 0 deletions schemas/ufo/misc.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace FlatFont.Ufo;

table Guideline {
x: float;
y: float;
angle: float;
name: string;
color: string;
identifier: string;
}

table Transform {
xScale: float = 1;
xyScale: float = 0;
yxScale: float = 0;
yScale: float = 1;
xOffset: float = 0;
yOffset: float = 0;
}
Loading

0 comments on commit 6898614

Please sign in to comment.