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

Side by Side Diff: trunk/src/ots.cc

Issue 341983012: OTS: Add DoNotDropColorBitmapTables() API. (Closed) Base URL: http://ots.googlecode.com/svn/
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/ots.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ots.h" 5 #include "ots.h"
6 6
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <zlib.h> 8 #include <zlib.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 { "GPOS", ots::ots_gpos_parse, ots::ots_gpos_serialise, 136 { "GPOS", ots::ots_gpos_parse, ots::ots_gpos_serialise,
137 ots::ots_gpos_should_serialise, ots::ots_gpos_free, false }, 137 ots::ots_gpos_should_serialise, ots::ots_gpos_free, false },
138 { "GSUB", ots::ots_gsub_parse, ots::ots_gsub_serialise, 138 { "GSUB", ots::ots_gsub_parse, ots::ots_gsub_serialise,
139 ots::ots_gsub_should_serialise, ots::ots_gsub_free, false }, 139 ots::ots_gsub_should_serialise, ots::ots_gsub_free, false },
140 { "vhea", ots::ots_vhea_parse, ots::ots_vhea_serialise, 140 { "vhea", ots::ots_vhea_parse, ots::ots_vhea_serialise,
141 ots::ots_vhea_should_serialise, ots::ots_vhea_free, false }, 141 ots::ots_vhea_should_serialise, ots::ots_vhea_free, false },
142 { "vmtx", ots::ots_vmtx_parse, ots::ots_vmtx_serialise, 142 { "vmtx", ots::ots_vmtx_parse, ots::ots_vmtx_serialise,
143 ots::ots_vmtx_should_serialise, ots::ots_vmtx_free, false }, 143 ots::ots_vmtx_should_serialise, ots::ots_vmtx_free, false },
144 { "MATH", ots::ots_math_parse, ots::ots_math_serialise, 144 { "MATH", ots::ots_math_parse, ots::ots_math_serialise,
145 ots::ots_math_should_serialise, ots::ots_math_free, false }, 145 ots::ots_math_should_serialise, ots::ots_math_free, false },
146 { "CBDT", ots::ots_cbdt_parse, ots::ots_cbdt_serialise,
147 ots::ots_cbdt_should_serialise, ots::ots_cbdt_free, false },
148 { "CBLC", ots::ots_cblc_parse, ots::ots_cblc_serialise,
149 ots::ots_cblc_should_serialise, ots::ots_cblc_free, false },
146 // TODO(bashi): Support mort, base, and jstf tables. 150 // TODO(bashi): Support mort, base, and jstf tables.
147 { 0, NULL, NULL, NULL, NULL, false }, 151 { 0, NULL, NULL, NULL, NULL, false },
148 }; 152 };
149 153
150 bool ProcessGeneric(ots::OpenTypeFile *header, 154 bool ProcessGeneric(ots::OpenTypeFile *header,
151 uint32_t signature, 155 uint32_t signature,
152 ots::OTSStream *output, 156 ots::OTSStream *output,
153 const uint8_t *data, size_t length, 157 const uint8_t *data, size_t length,
154 const std::vector<OpenTypeTable>& tables, 158 const std::vector<OpenTypeTable>& tables,
155 ots::Buffer& file); 159 ots::Buffer& file);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 if (header->cff) { 554 if (header->cff) {
551 // font with PostScript glyph 555 // font with PostScript glyph
552 if (header->version != Tag("OTTO")) { 556 if (header->version != Tag("OTTO")) {
553 return OTS_FAILURE(); 557 return OTS_FAILURE();
554 } 558 }
555 if (header->glyf || header->loca) { 559 if (header->glyf || header->loca) {
556 // mixing outline formats is not recommended 560 // mixing outline formats is not recommended
557 return OTS_FAILURE(); 561 return OTS_FAILURE();
558 } 562 }
559 } else { 563 } else {
560 if (!header->glyf || !header->loca) { 564 if ((!header->glyf || !header->loca) && (!header->cbdt || !header->cblc)) {
561 // No TrueType glyph found. 565 // No TrueType glyph or color bitmap found.
562 // Note: bitmap-only fonts are not supported.
563 return OTS_FAILURE(); 566 return OTS_FAILURE();
564 } 567 }
565 } 568 }
566 569
567 unsigned num_output_tables = 0; 570 unsigned num_output_tables = 0;
568 for (unsigned i = 0; ; ++i) { 571 for (unsigned i = 0; ; ++i) {
569 if (table_parsers[i].parse == NULL) { 572 if (table_parsers[i].parse == NULL) {
570 break; 573 break;
571 } 574 }
572 575
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return OTS_FAILURE(); 681 return OTS_FAILURE();
679 } 682 }
680 683
681 return true; 684 return true;
682 } 685 }
683 686
684 } // namespace 687 } // namespace
685 688
686 namespace ots { 689 namespace ots {
687 690
691 bool g_drop_color_bitmap_tables = true;
692
688 bool IsValidVersionTag(uint32_t tag) { 693 bool IsValidVersionTag(uint32_t tag) {
689 return tag == Tag("\x00\x01\x00\x00") || 694 return tag == Tag("\x00\x01\x00\x00") ||
690 // OpenType fonts with CFF data have 'OTTO' tag. 695 // OpenType fonts with CFF data have 'OTTO' tag.
691 tag == Tag("OTTO") || 696 tag == Tag("OTTO") ||
692 // Older Mac fonts might have 'true' or 'typ1' tag. 697 // Older Mac fonts might have 'true' or 'typ1' tag.
693 tag == Tag("true") || 698 tag == Tag("true") ||
694 tag == Tag("typ1"); 699 tag == Tag("typ1");
695 } 700 }
696 701
697 void DisableDebugOutput() { 702 void DisableDebugOutput() {
698 g_debug_output = false; 703 g_debug_output = false;
699 } 704 }
700 705
701 void EnableWOFF2() { 706 void EnableWOFF2() {
702 g_enable_woff2 = true; 707 g_enable_woff2 = true;
703 } 708 }
704 709
710 void DoNotDropColorBitmapTables() {
711 g_drop_color_bitmap_tables = false;
712 }
713
705 bool Process(OTSStream *output, const uint8_t *data, size_t length) { 714 bool Process(OTSStream *output, const uint8_t *data, size_t length) {
706 OpenTypeFile header; 715 OpenTypeFile header;
707 if (length < 4) { 716 if (length < 4) {
708 return OTS_FAILURE(); 717 return OTS_FAILURE();
709 } 718 }
710 719
711 bool result; 720 bool result;
712 if (data[0] == 'w' && data[1] == 'O' && data[2] == 'F' && data[3] == 'F') { 721 if (data[0] == 'w' && data[1] == 'O' && data[2] == 'F' && data[3] == 'F') {
713 result = ProcessWOFF(&header, output, data, length); 722 result = ProcessWOFF(&header, output, data, length);
714 } else if (g_enable_woff2 && 723 } else if (g_enable_woff2 &&
(...skipping 27 matching lines...) Expand all
742 va_start(va, format); 751 va_start(va, format);
743 std::vfprintf(stderr, format, va); 752 std::vfprintf(stderr, format, va);
744 va_end(va); 753 va_end(va);
745 std::fprintf(stderr, "\n"); 754 std::fprintf(stderr, "\n");
746 std::fflush(stderr); 755 std::fflush(stderr);
747 } 756 }
748 } 757 }
749 #endif 758 #endif
750 759
751 } // namespace ots 760 } // namespace ots
OLDNEW
« no previous file with comments | « trunk/src/ots.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698