Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: src/ots.h

Issue 658573004: Updating to new OTS repo from https://github.com/khaledhosny/ots.git (Closed) Base URL: https://chromium.googlesource.com/external/ots@master
Patch Set: Adding Colored Emoji changes from external/git repo Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« .gitmodules ('K') | « src/os2.cc ('k') | src/ots.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ots.h
diff --git a/src/ots.h b/src/ots.h
old mode 100644
new mode 100755
index 1db48d51736bcd114ed2bcb5f49210f15eb16b64..13999d56e602f0a557131ae017708bdae402afc0
--- a/src/ots.h
+++ b/src/ots.h
@@ -29,30 +29,37 @@ namespace ots {
bool Failure(const char *f, int l, const char *fn);
#endif
-#if defined(_MSC_VER)
-// MSVC supports C99 style variadic macros.
-#define OTS_WARNING(format, ...)
-#else
-// GCC
-#if defined(OTS_DEBUG)
-#define OTS_WARNING(format, args...) \
- ots::Warning(__FILE__, __LINE__, format, ##args)
-void Warning(const char *f, int l, const char *format, ...)
- __attribute__((format(printf, 3, 4)));
-#else
-#define OTS_WARNING(format, args...)
-#endif
-#endif
+// All OTS_FAILURE_* macros ultimately evaluate to 'false', just like the original
+// message-less OTS_FAILURE(), so that the current parser will return 'false' as
+// its result (indicating a failure).
-// Define OTS_NO_TRANSCODE_HINTS (i.e., g++ -DOTS_NO_TRANSCODE_HINTS) if you
-// want to omit TrueType hinting instructions and variables in glyf, fpgm, prep,
-// and cvt tables.
-#if defined(OTS_NO_TRANSCODE_HINTS)
-const bool g_transcode_hints = false;
+#if defined(_MSC_VER) || !defined(OTS_DEBUG)
+#define OTS_MESSAGE_(level,otf_,...) \
+ (otf_)->context->Message(level,__VA_ARGS__)
#else
-const bool g_transcode_hints = true;
+#define OTS_MESSAGE_(level,otf_,...) \
+ OTS_FAILURE(), \
+ (otf_)->context->Message(level,__VA_ARGS__)
#endif
+// Generate a simple message
+#define OTS_FAILURE_MSG_(otf_,...) \
+ (OTS_MESSAGE_(0,otf_,__VA_ARGS__), false)
+
+#define OTS_WARNING_MSG_(otf_,...) \
+ OTS_MESSAGE_(1,otf_,__VA_ARGS__)
+
+// Generate a message with an associated table tag
+#define OTS_FAILURE_MSG_TAG_(otf_,msg_,tag_) \
+ (OTS_MESSAGE_(0,otf_,"%4.4s: %s", tag_, msg_), false)
+
+// Convenience macros for use in files that only handle a single table tag,
+// defined as TABLE_NAME at the top of the file; the 'file' variable is
+// expected to be the current OpenTypeFile pointer.
+#define OTS_FAILURE_MSG(...) OTS_FAILURE_MSG_(file, TABLE_NAME ": " __VA_ARGS__)
+
+#define OTS_WARNING(...) OTS_WARNING_MSG_(file, TABLE_NAME ": " __VA_ARGS__)
+
// -----------------------------------------------------------------------------
// Buffer helper class
//
@@ -62,8 +69,8 @@ const bool g_transcode_hints = true;
// -----------------------------------------------------------------------------
class Buffer {
public:
- Buffer(const uint8_t *buffer, size_t len)
- : buffer_(buffer),
+ Buffer(const uint8_t *buf, size_t len)
+ : buffer_(buf),
length_(len),
offset_(0) { }
@@ -71,7 +78,7 @@ class Buffer {
return Read(NULL, n_bytes);
}
- bool Read(uint8_t *buffer, size_t n_bytes) {
+ bool Read(uint8_t *buf, size_t n_bytes) {
if (n_bytes > 1024 * 1024 * 1024) {
return OTS_FAILURE();
}
@@ -79,8 +86,8 @@ class Buffer {
(offset_ > length_ - n_bytes)) {
return OTS_FAILURE();
}
- if (buffer) {
- std::memcpy(buffer, buffer_ + offset_, n_bytes);
+ if (buf) {
+ std::memcpy(buf, buffer_ + offset_, n_bytes);
}
offset_ += n_bytes;
return true;
@@ -183,8 +190,6 @@ template<typename T> T Round2(T value) {
bool IsValidVersionTag(uint32_t tag);
#define FOR_EACH_TABLE_TYPE \
- F(cbdt, CBDT) \
- F(cblc, CBLC) \
F(cff, CFF) \
F(cmap, CMAP) \
F(cvt, CVT) \
@@ -229,6 +234,8 @@ struct OpenTypeFile {
uint16_t entry_selector;
uint16_t range_shift;
+ OTSContext *context;
+
#define F(name, capname) OpenType##capname *name;
FOR_EACH_TABLE_TYPE
#undef F
« .gitmodules ('K') | « src/os2.cc ('k') | src/ots.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698