summaryrefslogtreecommitdiffstats
path: root/modules/woff2/src/normalize.cc
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-11-14 10:02:36 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-14 10:02:36 +0100
commit36975f3865948f3faa959fe386e58b22783bd379 (patch)
tree890182161b3e522f45f966574425d85972bff4a5 /modules/woff2/src/normalize.cc
parent787b4fe586456565c2dda457ad81f1dd420e9249 (diff)
downloadUXP-36975f3865948f3faa959fe386e58b22783bd379.tar
UXP-36975f3865948f3faa959fe386e58b22783bd379.tar.gz
UXP-36975f3865948f3faa959fe386e58b22783bd379.tar.lz
UXP-36975f3865948f3faa959fe386e58b22783bd379.tar.xz
UXP-36975f3865948f3faa959fe386e58b22783bd379.zip
Issue #1288 - Part 3: Update woff2 component to 1.0.2
Diffstat (limited to 'modules/woff2/src/normalize.cc')
-rw-r--r--modules/woff2/src/normalize.cc36
1 files changed, 14 insertions, 22 deletions
diff --git a/modules/woff2/src/normalize.cc b/modules/woff2/src/normalize.cc
index b538b91a8..6685e0875 100644
--- a/modules/woff2/src/normalize.cc
+++ b/modules/woff2/src/normalize.cc
@@ -1,18 +1,10 @@
-// Copyright 2013 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Glyph normalization
+/* Copyright 2013 Google Inc. All Rights Reserved.
+
+ Distributed under MIT license.
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+*/
+
+/* Glyph normalization */
#include "./normalize.h"
@@ -52,7 +44,7 @@ bool WriteNormalizedLoca(int index_fmt, int num_glyphs, Font* font) {
loca_table->buffer.resize(Round4(num_glyphs + 1) * glyph_sz);
loca_table->length = (num_glyphs + 1) * glyph_sz;
- uint8_t* glyf_dst = &glyf_table->buffer[0];
+ uint8_t* glyf_dst = num_glyphs ? &glyf_table->buffer[0] : NULL;
uint8_t* loca_dst = &loca_table->buffer[0];
uint32_t glyf_offset = 0;
size_t loca_offset = 0;
@@ -78,16 +70,13 @@ bool WriteNormalizedLoca(int index_fmt, int num_glyphs, Font* font) {
}
glyf_offset += glyf_dst_size;
}
- if (glyf_offset == 0) {
- return false;
- }
StoreLoca(index_fmt, glyf_offset, &loca_offset, loca_dst);
glyf_table->buffer.resize(glyf_offset);
- glyf_table->data = &glyf_table->buffer[0];
+ glyf_table->data = glyf_offset ? &glyf_table->buffer[0] : NULL;
glyf_table->length = glyf_offset;
- loca_table->data = &loca_table->buffer[0];
+ loca_table->data = loca_offset ? &loca_table->buffer[0] : NULL;
return true;
}
@@ -107,7 +96,10 @@ bool MakeEditableBuffer(Font* font, int tableTag) {
int sz = Round4(table->length);
table->buffer.resize(sz);
uint8_t* buf = &table->buffer[0];
- memcpy(buf, table->data, sz);
+ memcpy(buf, table->data, table->length);
+ if (PREDICT_FALSE(sz > table->length)) {
+ memset(buf + table->length, 0, sz - table->length);
+ }
table->data = buf;
return true;
}