gfx/ots/src/hmtx.cc

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // Copyright (c) 2009 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.
     5 #include "hmtx.h"
     7 #include "hhea.h"
     8 #include "maxp.h"
    10 // hmtx - Horizontal Metrics
    11 // http://www.microsoft.com/typography/otspec/hmtx.htm
    13 #define TABLE_NAME "hmtx"
    15 namespace ots {
    17 bool ots_hmtx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
    18   Buffer table(data, length);
    19   OpenTypeHMTX *hmtx = new OpenTypeHMTX;
    20   file->hmtx = hmtx;
    22   if (!file->hhea || !file->maxp) {
    23     return OTS_FAILURE_MSG("Missing hhea or maxp tables in font, needed by hmtx");
    24   }
    26   if (!ParseMetricsTable(file, &table, file->maxp->num_glyphs,
    27                          &file->hhea->header, &hmtx->metrics)) {
    28     return OTS_FAILURE_MSG("Failed to parse hmtx metrics");
    29   }
    31   return true;
    32 }
    34 bool ots_hmtx_should_serialise(OpenTypeFile *file) {
    35   return file->hmtx != NULL;
    36 }
    38 bool ots_hmtx_serialise(OTSStream *out, OpenTypeFile *file) {
    39   if (!SerialiseMetricsTable(file, out, &file->hmtx->metrics)) {
    40     return OTS_FAILURE_MSG("Failed to serialise htmx metrics");
    41   }
    42   return true;
    43 }
    45 void ots_hmtx_free(OpenTypeFile *file) {
    46   delete file->hmtx;
    47 }
    49 }  // namespace ots

mercurial