PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/gfx/ots/src/vmtx.cc

http://github.com/zpao/v8monkey
C++ | 52 lines | 32 code | 13 blank | 7 comment | 7 complexity | 7469a7eb174bcf8a8f0d14d68c89d87b 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 "vmtx.h"
  5. #include "gsub.h"
  6. #include "maxp.h"
  7. #include "vhea.h"
  8. // vmtx - Vertical Metrics Table
  9. // http://www.microsoft.com/opentype/otspec/vmtx.htm
  10. namespace ots {
  11. bool ots_vmtx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
  12. Buffer table(data, length);
  13. OpenTypeVMTX *vmtx = new OpenTypeVMTX;
  14. file->vmtx = vmtx;
  15. if (!file->vhea || !file->maxp) {
  16. return OTS_FAILURE();
  17. }
  18. if (!ParseMetricsTable(&table, file->maxp->num_glyphs,
  19. &file->vhea->header, &vmtx->metrics)) {
  20. return OTS_FAILURE();
  21. }
  22. return true;
  23. }
  24. bool ots_vmtx_should_serialise(OpenTypeFile *file) {
  25. // vmtx should serialise when vhea and GSUB are preserved.
  26. // See the comment in ots_vhea_should_serialise().
  27. return file->vmtx != NULL && file->vhea != NULL &&
  28. ots_gsub_should_serialise(file);
  29. }
  30. bool ots_vmtx_serialise(OTSStream *out, OpenTypeFile *file) {
  31. if (!SerialiseMetricsTable(out, &file->vmtx->metrics)) {
  32. return OTS_FAILURE();
  33. }
  34. return true;
  35. }
  36. void ots_vmtx_free(OpenTypeFile *file) {
  37. delete file->vmtx;
  38. }
  39. } // namespace ots