PageRenderTime 79ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/gfx/ots/src/vhea.cc

http://github.com/zpao/v8monkey
C++ | 56 lines | 35 code | 13 blank | 8 comment | 9 complexity | da51f1ea9ab08df1ee4aded278c2f849 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, AGPL-1.0, LGPL-2.1, BSD-3-Clause, GPL-2.0, JSON, Apache-2.0, 0BSD
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "vhea.h"
  5. #include "gsub.h"
  6. #include "head.h"
  7. #include "maxp.h"
  8. // vhea - Vertical Header Table
  9. // http://www.microsoft.com/opentype/otspec/vhea.htm
  10. namespace ots {
  11. bool ots_vhea_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
  12. Buffer table(data, length);
  13. OpenTypeVHEA *vhea = new OpenTypeVHEA;
  14. file->vhea = vhea;
  15. if (!table.ReadU32(&vhea->header.version)) {
  16. return OTS_FAILURE();
  17. }
  18. if (vhea->header.version != 0x00010000 &&
  19. vhea->header.version != 0x00011000) {
  20. return OTS_FAILURE();
  21. }
  22. if (!ParseMetricsHeader(file, &table, &vhea->header)) {
  23. return OTS_FAILURE();
  24. }
  25. return true;
  26. }
  27. bool ots_vhea_should_serialise(OpenTypeFile *file) {
  28. // vhea should'nt serialise when vmtx doesn't exist.
  29. // Firefox developer pointed out that vhea/vmtx should serialise iff GSUB is
  30. // preserved. See http://crbug.com/77386
  31. return file->vhea != NULL && file->vmtx != NULL &&
  32. ots_gsub_should_serialise(file);
  33. }
  34. bool ots_vhea_serialise(OTSStream *out, OpenTypeFile *file) {
  35. if (!SerialiseMetricsHeader(out, &file->vhea->header)) {
  36. return OTS_FAILURE();
  37. }
  38. return true;
  39. }
  40. void ots_vhea_free(OpenTypeFile *file) {
  41. delete file->vhea;
  42. }
  43. } // namespace ots