• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "gtest/gtest.h"
18 #include "sfntly/font.h"
19 #include "sfntly/math/fixed1616.h"
20 #include "sfntly/table/core/maximum_profile_table.h"
21 #include "test/serialization_test.h"
22 
23 namespace sfntly {
24 
25 const int32_t MAXP_NUM_GLYPHS = 1502;
26 const int32_t MAXP_MAX_POINTS = 181;
27 const int32_t MAXP_MAX_CONTOURS = 9;
28 const int32_t MAXP_MAX_COMPOSITE_POINTS = 172;
29 const int32_t MAXP_MAX_COMPOSITE_CONTOURS = 5;
30 const int32_t MAXP_MAX_ZONES = 2;
31 const int32_t MAXP_MAX_TWILIGHT_POINTS = 0;
32 const int32_t MAXP_MAX_STORAGE = 1;
33 const int32_t MAXP_MAX_FUNCTION_DEFS = 1;
34 const int32_t MAXP_MAX_INSTR_DEFS = 0;
35 const int32_t MAXP_MAX_STACK_ELEMENTS = 64;
36 const int32_t MAXP_MAX_INSTR_SIZE = 46;
37 const int32_t MAXP_MAX_COMPONENT_ELEMENTS = 4;
38 const int32_t MAXP_MAX_COMPONENT_DEPTH = 3;
39 
VerifyMAXP(Table * table)40 static bool VerifyMAXP(Table* table) {
41   MaximumProfileTablePtr maxp = down_cast<MaximumProfileTable*>(table);
42   if (maxp == NULL) {
43     return false;
44   }
45 
46   EXPECT_EQ(maxp->TableVersion(), Fixed1616::Fixed(1, 0));
47   EXPECT_EQ(maxp->NumGlyphs(), MAXP_NUM_GLYPHS);
48   EXPECT_EQ(maxp->MaxPoints(), MAXP_MAX_POINTS);
49   EXPECT_EQ(maxp->MaxContours(), MAXP_MAX_CONTOURS);
50   EXPECT_EQ(maxp->MaxCompositePoints(), MAXP_MAX_COMPOSITE_POINTS);
51   EXPECT_EQ(maxp->MaxCompositeContours(), MAXP_MAX_COMPOSITE_CONTOURS);
52   EXPECT_EQ(maxp->MaxZones(), MAXP_MAX_ZONES);
53   EXPECT_EQ(maxp->MaxTwilightPoints(), MAXP_MAX_TWILIGHT_POINTS);
54   EXPECT_EQ(maxp->MaxStorage(), MAXP_MAX_STORAGE);
55   EXPECT_EQ(maxp->MaxFunctionDefs(), MAXP_MAX_FUNCTION_DEFS);
56   // TODO(arthurhsu): maxInstructionDefs observed in Microsoft TTF report.
57   //                  Check with stuartg and see if this is a miss.
58   EXPECT_EQ(maxp->MaxStackElements(), MAXP_MAX_STACK_ELEMENTS);
59   EXPECT_EQ(maxp->MaxSizeOfInstructions(), MAXP_MAX_INSTR_SIZE);
60   EXPECT_EQ(maxp->MaxComponentElements(), MAXP_MAX_COMPONENT_ELEMENTS);
61   EXPECT_EQ(maxp->MaxComponentDepth(), MAXP_MAX_COMPONENT_DEPTH);
62 
63   return true;
64 }
65 
VerifyMAXP(Table * original,Table * target)66 bool VerifyMAXP(Table* original, Table* target) {
67   EXPECT_TRUE(VerifyMAXP(original));
68   EXPECT_TRUE(VerifyMAXP(target));
69   return true;
70 }
71 
72 }  // namespace sfntly
73