Created
November 12, 2018 20:11
-
-
Save davelab6/fb0783aaef3afbe40a322b70be4daa43 to your computer and use it in GitHub Desktop.
Revisions
-
be5invis revised this gist
Dec 17, 2017 . 1 changed file with 64 additions and 120 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,128 +1,72 @@ GLYPH DATA ========== - Glyph flag - Metric data - Outline data - Extra data segments OUTLINE DATA ============ Outline data of a glyph is recorded in this manner: - Length of items (points and inclusions) - Number of VF tuples - Item flags - Static dX - Static dY - Variable deltas - Contour mask (optional, decided by glyph flag) Item flag list: One byte for each glyph item (point OR inclusion) - Points : 0 . . . . . . . - --- --- --- S ZT XT YT - S : Start of a contour; - ZT : Point type - 00 : On knot - 01 : Quadratic off knot - 10 : Leading cubic off-knot - 11 : Trailing cubic off-knot - XT & YT : Coordinate type of static outline - 00 : Zero - 01 : Short integer - 10 : Positive byte or Fraction - 11 : Negative byte or Fraction - Includes : 1 . . . . . . . - --- --- --- G R XT YT - G : Include a glyph rather than a fragment - R : Reserved (for rounding and hinting?) Including a glyph or a fragment into the font. Inclusion simply copies outline data of the part being included, with an extra X and Y shift being added into it. The X and Y shift could be polymorphic, and they are added to all the touched points in the included component. Static dX and dY coordinate: - For points, depending on the XT or YT: - For XT/YT = 00, the data is not needed. - For XT/YT = 01, the data is two bytes long and represents a big-endian signed short. - For XT/YT = 10 or 11, the data is interpreted as this: Let c be the result of read one byte. if c != 0 then return (XT/YT == 10) ? c : -c else let f = read four bytes and decode it as a unsigned Q16.16 return (XT/YT == 10) ? f : -f - For inclusion, there would always two bytes for dX, representing the ID of the componet being included; There could be an extra shift value, and its form is defined by the XT/YT. Variable X and Y deltas: - Use the current GVAR mechanism. For each tuple, untouched points are interpolated with an IUP. Contour Mask: - A bit field to describe whether a contour would be disabled during rasterization. Useful for color glyphs. -
be5invis created this gist
Dec 10, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,128 @@ Notation +----+ +=========+ | | One Byte | | Multiple bytes +----+ +=========+ 0 1 +--------+--------+ |00001000|00000010| +--------+--------+ ^ ^ | | | + less significant byte = 2 + more significant byte = 8 × 256 +--.--.--.--.--.--.--.--+ | : : : : : : : | Bits in one byte +--'--'--'--'--'--'--'--+ Contour Layer +---+---+=========+===========+===========+======================+ |nPoints| Flags | XData | YData | Poly Data | +---+---+=========+===========+===========+======================+ Flags array Array of flags for each point in the outline. See below for details regarding the number of flag array elements. +--.--.--.--.--.--.--.--+ - - - - - - - - - - - - + |SC:RP: XT : YT : ZT | Repeat Number (RP = 1) | +--'--'--'--'--'--'--'--+ - - - - - - - - - - - - + + ZT : The type of this point. The valid numbers are: - 00 : On-curve point - 01 : Quadratic off-curve point - 10 : Cubic beginning off-curve point - 11 : Cubic ending off-curve point + XT and YT : The type of dX and dY data. The valid numbers are: - 00 : The dX or dY is zero. No bytes needed. - 01 : The dX or dY is encoded with two bytes, as a signed short. - 10 : The dX or dY is encoded with one byte, as a byte, and the sign of this entry is positive. - 11 : The dX or dY is encoded with one byte, as a byte, and the sign of this entry is negative. + SC : This point is a beginning point of a contour. Only points with ZT = 00 or ZT = 01 could set this flag to on. + RP : Repeat this flag for N additional points, while N is provided in the next byte. XData and YData Contour point X and Y coordinates. See below for details regarding the number of coordinate array elements. Coordinate for the first point is relative to (0,0); others are relative to previous point. Poly Data +----+----+===========+==================================+ | Header | Masters | Packed per-master variation data | +----+----+===========+==================================+ + Header : A packed field with: +---.-.-.-.-.-.-.-+-.-.-.-.-.-.-.-+ |LMN: Number of masters | +---'-'-'-'-'-'-'-+-'-'-'-'-'-'-'-+ - LMN : Whether the master indeces in the "Masters" segment being uint32s. - Number of masters : A 15-bit unsigned integer indicating the number of masters for this layer. + Masters : An array of uint16 or uint32s (determined by the LMN field in the Header), representing master IDs + Shared points : Optional (determined by SPZ). When present, a PointList is placed here to indicate the points being affected by variations. + Packed per-master variation data: +===============+==============+==============+==============+ | Point numbers | X delta data | Y delta data | Link data | +===============+==============+==============+==============+ For "Point numbers", "X delta data" and "Y delta data", See the current definition in GVAR, however the "Point number" list now indicates the points that its "whether touch" flag being flipped in this master. The "Link data" is used to represent "early" linking/IPs. +----+----+=======================+ | nTerms | Link/IP Reclord list | +----+----+=======================+ Link/IP Reclord +-.-.-.-.-.-.-.-+----+----+------+------+... |0:Y: nFollow-1 | refPtid | followPtId ... (Linking) +-'-'-'-'-'-'-'-+----+----+------+------+... ^ | }-- Link/Interpolate X coordinate (0) or Y coordinate (1) | v +-.-.-.-.-.-.-.-+----+----+----+----+------+------+... |1:Y: nFollow-1 | rupPtid | rdnPtid | followPtId ... (Interpolate) +-'-'-'-'-'-'-'-+----+----+----+----+------+------+... An IUP is performed after reading each tuple. Reference Layer |<-- Optional -->| +----+----+-------+--+--+--+--+--+--+--+--+--+--+--+--+===============+ | GID | Flags | X | Y | a | b | c | d | Ref Poly data | +----+----+-------+--+--+--+--+--+--+--+--+--+--+--+--+===============+ + GID : The index of reference + Flags : +---.---.---.---.---.---.---.---+ | RESERVED :TFM:RND| +---'---'---'---'---'---'---'---+ - TFM : Whether the transformation terms (a, b, c, d) are provided. - RND : Whether round this reference to grid. - Ref Poly data : Identical to contour poly data, excluding: - IUP mechanism. - The point numbers entries are useless, since we are always modifying the point attaches this reference.