• 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/horizontal_header_table.h"
21 #include "test/serialization_test.h"
22 
23 namespace sfntly {
24 
25 const int32_t HHEA_ASCENDER = 2023;
26 const int32_t HHEA_DESCENDER = -648;
27 const int32_t HHEA_LINE_GAP = 93;
28 const int32_t HHEA_ADVANCE_WIDTH_MAX = 2753;
29 const int32_t HHEA_MIN_LSB = -968;
30 const int32_t HHEA_MIN_RSB = -411;
31 const int32_t HHEA_X_MAX_EXTENT = 2628;
32 const int32_t HHEA_METRIC_DATA_FORMAT = 0;
33 const int32_t HHEA_NUM_METRICS = 1499;
34 
VerifyHHEA(Table * table)35 static bool VerifyHHEA(Table* table) {
36   HorizontalHeaderTablePtr hhea = down_cast<HorizontalHeaderTable*>(table);
37   if (hhea == NULL) {
38     return false;
39   }
40 
41   EXPECT_EQ(hhea->TableVersion(), Fixed1616::Fixed(1, 0));
42   EXPECT_EQ(hhea->Ascender(), HHEA_ASCENDER);
43   EXPECT_EQ(hhea->Descender(), HHEA_DESCENDER);
44   EXPECT_EQ(hhea->AdvanceWidthMax(), HHEA_ADVANCE_WIDTH_MAX);
45   EXPECT_EQ(hhea->MinLeftSideBearing(), HHEA_MIN_LSB);
46   EXPECT_EQ(hhea->MinRightSideBearing(), HHEA_MIN_RSB);
47   EXPECT_EQ(hhea->XMaxExtent(), HHEA_X_MAX_EXTENT);
48   // TODO(arthurhsu): CaretSlopeRise() not tested
49   // TODO(arthurhsu): CaretSlopeRun() not tested
50   // TODO(arthurhsu): CaretOffset() not tested
51   EXPECT_EQ(hhea->MetricDataFormat(), HHEA_METRIC_DATA_FORMAT);
52   EXPECT_EQ(hhea->NumberOfHMetrics(), HHEA_NUM_METRICS);
53 
54   return true;
55 }
56 
VerifyHHEA(Table * original,Table * target)57 bool VerifyHHEA(Table* original, Table* target) {
58   EXPECT_TRUE(VerifyHHEA(original));
59   EXPECT_TRUE(VerifyHHEA(target));
60   return true;
61 }
62 
63 }  // namespace sfntly
64