Home | History | Annotate | Download | only in test
      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/table/truetype/glyph_table.h"
     20 #include "test/serialization_test.h"
     21 
     22 namespace sfntly {
     23 
     24 // We spot check only glyph id 33.
     25 const int32_t GLYPH33_OFFSET = 0xAC8;
     26 const int32_t GLYPH33_LENGTH = 40;
     27 const int32_t GLYPH33_XMIN = 92;
     28 const int32_t GLYPH33_YMIN = 20;
     29 const int32_t GLYPH33_XMAX = 797;
     30 const int32_t GLYPH33_YMAX = 1235;
     31 
     32 // TODO(arthurhsu): Tuffy does not have composite glyphs.  Need better testing.
     33 static bool VerifyGLYF(Table* table) {
     34   GlyphTablePtr glyf_table = down_cast<GlyphTable*>(table);
     35   if (glyf_table == NULL) {
     36     return false;
     37   }
     38 
     39   GlyphPtr glyf;
     40   glyf.Attach(glyf_table->GetGlyph(GLYPH33_OFFSET, GLYPH33_LENGTH));
     41   if (glyf == NULL) {
     42     return false;
     43   }
     44 
     45   EXPECT_EQ(glyf->XMin(), GLYPH33_XMIN);
     46   EXPECT_EQ(glyf->YMin(), GLYPH33_YMIN);
     47   EXPECT_EQ(glyf->XMax(), GLYPH33_XMAX);
     48   EXPECT_EQ(glyf->YMax(), GLYPH33_YMAX);
     49 
     50   return true;
     51 }
     52 
     53 bool VerifyGLYF(Table* original, Table* target) {
     54   EXPECT_TRUE(VerifyGLYF(original));
     55   EXPECT_TRUE(VerifyGLYF(target));
     56   return true;
     57 }
     58 
     59 }  // namespace sfntly
     60