Flutter Engine
The Flutter Engine
SkOTTable_glyf.h
Go to the documentation of this file.
1/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkOTTable_glyf_DEFINED
9#define SkOTTable_glyf_DEFINED
10
11#include "src/base/SkEndian.h"
15
16#pragma pack(push, 1)
17
19
21 static const SK_OT_CHAR TAG0 = 'g';
22 static const SK_OT_CHAR TAG1 = 'l';
23 static const SK_OT_CHAR TAG2 = 'y';
24 static const SK_OT_CHAR TAG3 = 'f';
26
27 class Iterator {
28 public:
30 const SkOTTableIndexToLocation& loca,
32 : fGlyf(glyf)
33 , fLoca(loca)
34 , fLocaFormat(locaFormat)
35 , fCurrentGlyph(0)
36 , fCurrentGlyphOffset(0)
37 {
40 }
41
42 void advance(uint16_t num) {
43 fCurrentGlyph += num;
45 fCurrentGlyphOffset =
46 SkEndian_SwapBE16(fLoca.offsets.shortOffset[fCurrentGlyph]) << 1;
47 } else if (fLocaFormat.value == SkOTTableHead::IndexToLocFormat::LongOffsets) {
48 fCurrentGlyphOffset = SkEndian_SwapBE32(fLoca.offsets.longOffset[fCurrentGlyph]);
49 }
50 }
52 uint32_t previousGlyphOffset = fCurrentGlyphOffset;
53 advance(1);
54 if (previousGlyphOffset == fCurrentGlyphOffset) {
55 return nullptr;
56 } else {
57 return reinterpret_cast<SkOTTableGlyphData*>(
58 reinterpret_cast<SK_OT_BYTE*>(&fGlyf) + previousGlyphOffset
59 );
60 }
61 }
62 private:
63 SkOTTableGlyph& fGlyf;
64 const SkOTTableIndexToLocation& fLoca;
66 uint32_t fCurrentGlyph;
67 uint32_t fCurrentGlyphOffset;
68 };
69};
70
72 SK_OT_SHORT numberOfContours; //== -1 Composite, > 0 Simple
77
78 struct Simple {
79 SK_OT_USHORT endPtsOfContours[1/*numberOfContours*/];
80
81 struct Instructions {
83 SK_OT_BYTE data[1/*length*/];
84 };
85
86 union Flags {
87 struct Field {
89 OnCurve,
90 xShortVector,
91 yShortVector,
92 Repeat,
93 xIsSame_xShortVectorPositive,
94 yIsSame_yShortVectorPositive,
95 Reserved6,
96 Reserved7)
98 struct Raw {
107 };
108
109 //xCoordinates
110 //yCoordinates
111 };
112
113 struct Composite {
114 struct Component {
115 union Flags {
116 struct Field {
117 //8-15
119 WE_HAVE_INSTRUCTIONS,
120 USE_MY_METRICS,
121 OVERLAP_COMPOUND,
122 SCALED_COMPONENT_OFFSET,
123 UNSCALED_COMPONENT_OFFSET,
124 Reserved13,
125 Reserved14,
126 Reserved15)
127 //0-7
129 ARG_1_AND_2_ARE_WORDS,
136 WE_HAVE_A_TWO_BY_TWO)
138 struct Raw {
147
153 //Reserved
154 //Reserved
155 //Reserved
160 union Transform {
161 union Matrix {
162 /** !WE_HAVE_A_SCALE & !WE_HAVE_AN_X_AND_Y_SCALE & !WE_HAVE_A_TWO_BY_TWO */
163 struct None { } none;
164 /** WE_HAVE_A_SCALE */
165 struct Scale {
168 /** WE_HAVE_AN_X_AND_Y_SCALE */
169 struct ScaleXY {
173 /** WE_HAVE_A_TWO_BY_TWO */
174 struct TwoByTwo {
180 };
181 /** ARG_1_AND_2_ARE_WORDS & ARGS_ARE_XY_VALUES */
182 struct WordValue {
187 /** !ARG_1_AND_2_ARE_WORDS & ARGS_ARE_XY_VALUES */
188 struct ByteValue {
193 /** ARG_1_AND_2_ARE_WORDS & !ARGS_ARE_XY_VALUES */
194 struct WordIndex {
199 /** !ARG_1_AND_2_ARE_WORDS & !ARGS_ARE_XY_VALUES */
200 struct ByteIndex {
206 } component;//[] last element does not set MORE_COMPONENTS
207
208 /** Comes after the last Component if the last component has WE_HAVE_INSTR. */
211 SK_OT_BYTE data[1/*length*/];
212 };
213 };
214};
215
216#pragma pack(pop)
217
218#endif
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkEndian_SwapBE32(n)
Definition: SkEndian.h:136
#define SkEndian_SwapBE16(n)
Definition: SkEndian.h:135
#define SkTEndian_SwapBE16(n)
Definition: SkEndian.h:142
uint8_t SK_OT_BYTE
uint16_t SK_OT_USHORT
uint32_t SK_OT_ULONG
int8_t SK_OT_CHAR
uint16_t SK_OT_SHORT
uint16_t SK_OT_F2DOT14
uint16_t SK_OT_FWORD
#define SK_OT_BYTE_BITFIELD
Iterator(SkOTTableGlyph &glyf, const SkOTTableIndexToLocation &loca, SkOTTableHead::IndexToLocFormat locaFormat)
void advance(uint16_t num)
SkOTTableGlyphData * next()
SK_OT_BYTE_BITFIELD(WE_HAVE_INSTRUCTIONS, USE_MY_METRICS, OVERLAP_COMPOUND, SCALED_COMPONENT_OFFSET, UNSCALED_COMPONENT_OFFSET, Reserved13, Reserved14, Reserved15) SK_OT_BYTE_BITFIELD(ARG_1_AND_2_ARE_WORDS
SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix
SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix
SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix
SkOTTableGlyphData::Composite::Component::Transform::Matrix matrix
union SkOTTableGlyphData::Composite::Component::Flags flags
union SkOTTableGlyphData::Composite::Component::Transform transform
struct SkOTTableGlyphData::Composite::Component component
static const SK_OT_USHORT xIsSame_xShortVectorPositiveMask
static const SK_OT_USHORT yIsSame_yShortVectorPositiveMask
static const SK_OT_USHORT RepeatMask
static const SK_OT_USHORT OnCurveMask
static const SK_OT_USHORT yShortVectorMask
static const SK_OT_USHORT xShortVectorMask
SK_OT_USHORT endPtsOfContours[1]
SK_OT_SHORT numberOfContours
static const SK_OT_CHAR TAG2
static const SK_OT_ULONG TAG
static const SK_OT_CHAR TAG1
static const SK_OT_CHAR TAG3
static const SK_OT_CHAR TAG0
enum SkOTTableHead::IndexToLocFormat::Value value
union SkOTTableIndexToLocation::Offsets offsets
struct SkOTTableGlyphData::Composite::Component::Flags::Field field
struct SkOTTableGlyphData::Composite::Component::Flags::Raw raw
struct SkOTTableGlyphData::Composite::Component::Transform::Matrix::ScaleXY scaleXY
struct SkOTTableGlyphData::Composite::Component::Transform::Matrix::Scale scale
struct SkOTTableGlyphData::Composite::Component::Transform::Matrix::None none
struct SkOTTableGlyphData::Composite::Component::Transform::Matrix::TwoByTwo twoByTwo
struct SkOTTableGlyphData::Composite::Component::Transform::ByteValue byteValue
struct SkOTTableGlyphData::Composite::Component::Transform::WordValue wordValue
struct SkOTTableGlyphData::Composite::Component::Transform::WordIndex wordIndex
struct SkOTTableGlyphData::Composite::Component::Transform::ByteIndex byteIndex
struct SkOTTableGlyphData::Simple::Flags::Field field
struct SkOTTableGlyphData::Simple::Flags::Raw raw