DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (5b81998bb7ab)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
// Copyright (c) 2010 Mozilla Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "graphite.h"

// Support for preserving (NOT sanitizing) the Graphite tables

namespace ots {

// 'Silf'
bool ots_silf_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
  Buffer table(data, length);

  OpenTypeSILF *silf = new OpenTypeSILF;
  file->silf = silf;

  if (!table.Skip(length)) {
    return OTS_FAILURE();
  }

  silf->data = data;
  silf->length = length;
  return true;
}

bool ots_silf_should_serialise(OpenTypeFile *file) {
  return file->preserve_graphite && file->silf;
}

bool ots_silf_serialise(OTSStream *out, OpenTypeFile *file) {
  const OpenTypeSILF *silf = file->silf;

  if (!out->Write(silf->data, silf->length)) {
    return OTS_FAILURE();
  }

  return true;
}

void ots_silf_free(OpenTypeFile *file) {
  delete file->silf;
}

// 'Sill'
bool ots_sill_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
  Buffer table(data, length);

  OpenTypeSILL *sill = new OpenTypeSILL;
  file->sill = sill;

  if (!table.Skip(length)) {
    return OTS_FAILURE();
  }

  sill->data = data;
  sill->length = length;
  return true;
}

bool ots_sill_should_serialise(OpenTypeFile *file) {
  return file->preserve_graphite && file->sill;
}

bool ots_sill_serialise(OTSStream *out, OpenTypeFile *file) {
  const OpenTypeSILL *sill = file->sill;

  if (!out->Write(sill->data, sill->length)) {
    return OTS_FAILURE();
  }

  return true;
}

void ots_sill_free(OpenTypeFile *file) {
  delete file->sill;
}

// 'Gloc'
bool ots_gloc_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
  Buffer table(data, length);

  OpenTypeGLOC *gloc = new OpenTypeGLOC;
  file->gloc = gloc;

  if (!table.Skip(length)) {
    return OTS_FAILURE();
  }

  gloc->data = data;
  gloc->length = length;
  return true;
}

bool ots_gloc_should_serialise(OpenTypeFile *file) {
  return file->preserve_graphite && file->gloc;
}

bool ots_gloc_serialise(OTSStream *out, OpenTypeFile *file) {
  const OpenTypeGLOC *gloc = file->gloc;

  if (!out->Write(gloc->data, gloc->length)) {
    return OTS_FAILURE();
  }

  return true;
}

void ots_gloc_free(OpenTypeFile *file) {
  delete file->gloc;
}

// 'Glat'
bool ots_glat_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
  Buffer table(data, length);

  OpenTypeGLAT *glat = new OpenTypeGLAT;
  file->glat = glat;

  if (!table.Skip(length)) {
    return OTS_FAILURE();
  }

  glat->data = data;
  glat->length = length;
  return true;
}

bool ots_glat_should_serialise(OpenTypeFile *file) {
  return file->preserve_graphite && file->glat;
}

bool ots_glat_serialise(OTSStream *out, OpenTypeFile *file) {
  const OpenTypeGLAT *glat = file->glat;

  if (!out->Write(glat->data, glat->length)) {
    return OTS_FAILURE();
  }

  return true;
}

void ots_glat_free(OpenTypeFile *file) {
  delete file->glat;
}

// 'Feat'
bool ots_feat_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
  Buffer table(data, length);

  OpenTypeFEAT *feat = new OpenTypeFEAT;
  file->feat = feat;

  if (!table.Skip(length)) {
    return OTS_FAILURE();
  }

  feat->data = data;
  feat->length = length;
  return true;
}

bool ots_feat_should_serialise(OpenTypeFile *file) {
  return file->preserve_graphite && file->feat;
}

bool ots_feat_serialise(OTSStream *out, OpenTypeFile *file) {
  const OpenTypeFEAT *feat = file->feat;

  if (!out->Write(feat->data, feat->length)) {
    return OTS_FAILURE();
  }

  return true;
}

void ots_feat_free(OpenTypeFile *file) {
  delete file->feat;
}

}  // namespace ots