Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #include "hmtx.h" |
michael@0 | 6 | |
michael@0 | 7 | #include "hhea.h" |
michael@0 | 8 | #include "maxp.h" |
michael@0 | 9 | |
michael@0 | 10 | // hmtx - Horizontal Metrics |
michael@0 | 11 | // http://www.microsoft.com/typography/otspec/hmtx.htm |
michael@0 | 12 | |
michael@0 | 13 | #define TABLE_NAME "hmtx" |
michael@0 | 14 | |
michael@0 | 15 | namespace ots { |
michael@0 | 16 | |
michael@0 | 17 | bool ots_hmtx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { |
michael@0 | 18 | Buffer table(data, length); |
michael@0 | 19 | OpenTypeHMTX *hmtx = new OpenTypeHMTX; |
michael@0 | 20 | file->hmtx = hmtx; |
michael@0 | 21 | |
michael@0 | 22 | if (!file->hhea || !file->maxp) { |
michael@0 | 23 | return OTS_FAILURE_MSG("Missing hhea or maxp tables in font, needed by hmtx"); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | if (!ParseMetricsTable(file, &table, file->maxp->num_glyphs, |
michael@0 | 27 | &file->hhea->header, &hmtx->metrics)) { |
michael@0 | 28 | return OTS_FAILURE_MSG("Failed to parse hmtx metrics"); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | return true; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | bool ots_hmtx_should_serialise(OpenTypeFile *file) { |
michael@0 | 35 | return file->hmtx != NULL; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | bool ots_hmtx_serialise(OTSStream *out, OpenTypeFile *file) { |
michael@0 | 39 | if (!SerialiseMetricsTable(file, out, &file->hmtx->metrics)) { |
michael@0 | 40 | return OTS_FAILURE_MSG("Failed to serialise htmx metrics"); |
michael@0 | 41 | } |
michael@0 | 42 | return true; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | void ots_hmtx_free(OpenTypeFile *file) { |
michael@0 | 46 | delete file->hmtx; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | } // namespace ots |