gfx/ots/src/cvt.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.

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 "cvt.h"
michael@0 6
michael@0 7 // cvt - Control Value Table
michael@0 8 // http://www.microsoft.com/typography/otspec/cvt.htm
michael@0 9
michael@0 10 #define TABLE_NAME "cvt"
michael@0 11
michael@0 12 namespace ots {
michael@0 13
michael@0 14 bool ots_cvt_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
michael@0 15 Buffer table(data, length);
michael@0 16
michael@0 17 OpenTypeCVT *cvt = new OpenTypeCVT;
michael@0 18 file->cvt = cvt;
michael@0 19
michael@0 20 if (length >= 128 * 1024u) {
michael@0 21 return OTS_FAILURE_MSG("Length (%d) > 120K"); // almost all cvt tables are less than 4k bytes.
michael@0 22 }
michael@0 23
michael@0 24 if (length % 2 != 0) {
michael@0 25 return OTS_FAILURE_MSG("Uneven cvt length (%d)", length);
michael@0 26 }
michael@0 27
michael@0 28 if (!table.Skip(length)) {
michael@0 29 return OTS_FAILURE_MSG("Length too high");
michael@0 30 }
michael@0 31
michael@0 32 cvt->data = data;
michael@0 33 cvt->length = length;
michael@0 34 return true;
michael@0 35 }
michael@0 36
michael@0 37 bool ots_cvt_should_serialise(OpenTypeFile *file) {
michael@0 38 if (!file->glyf) {
michael@0 39 return false; // this table is not for CFF fonts.
michael@0 40 }
michael@0 41 return g_transcode_hints && file->cvt;
michael@0 42 }
michael@0 43
michael@0 44 bool ots_cvt_serialise(OTSStream *out, OpenTypeFile *file) {
michael@0 45 const OpenTypeCVT *cvt = file->cvt;
michael@0 46
michael@0 47 if (!out->Write(cvt->data, cvt->length)) {
michael@0 48 return OTS_FAILURE_MSG("Failed to write CVT table");
michael@0 49 }
michael@0 50
michael@0 51 return true;
michael@0 52 }
michael@0 53
michael@0 54 void ots_cvt_free(OpenTypeFile *file) {
michael@0 55 delete file->cvt;
michael@0 56 }
michael@0 57
michael@0 58 } // namespace ots

mercurial