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

Side by Side Diff: Source/platform/fonts/opentype/OpenTypeSanitizer.cpp

Issue 774253008: ots::EnableWOFF is no longer part of new OTS repo (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 29 matching lines...) Expand all
40 PassRefPtr<SharedBuffer> OpenTypeSanitizer::sanitize() 40 PassRefPtr<SharedBuffer> OpenTypeSanitizer::sanitize()
41 { 41 {
42 if (!m_buffer) 42 if (!m_buffer)
43 return nullptr; 43 return nullptr;
44 44
45 // This is the largest web font size which we'll try to transcode. 45 // This is the largest web font size which we'll try to transcode.
46 static const size_t maxWebFontSize = 30 * 1024 * 1024; // 30 MB 46 static const size_t maxWebFontSize = 30 * 1024 * 1024; // 30 MB
47 if (m_buffer->size() > maxWebFontSize) 47 if (m_buffer->size() > maxWebFontSize)
48 return nullptr; 48 return nullptr;
49 49
50 ots::EnableWOFF2();
51
52 // A transcoded font is usually smaller than an original font. 50 // A transcoded font is usually smaller than an original font.
53 // However, it can be slightly bigger than the original one due to 51 // However, it can be slightly bigger than the original one due to
54 // name table replacement and/or padding for glyf table. 52 // name table replacement and/or padding for glyf table.
55 // 53 //
56 // With WOFF fonts, however, we'll be decompressing, so the result can be 54 // With WOFF fonts, however, we'll be decompressing, so the result can be
57 // much larger than the original. 55 // much larger than the original.
58 56
59 ots::ExpandingMemoryStream output(m_buffer->size(), maxWebFontSize); 57 ots::ExpandingMemoryStream output(m_buffer->size(), maxWebFontSize);
60 if (!ots::Process(&output, reinterpret_cast<const uint8_t*>(m_buffer->data() ), m_buffer->size())) 58 if (!ots::Process(&output, reinterpret_cast<const uint8_t*>(m_buffer->data() ), m_buffer->size()))
61 return nullptr; 59 return nullptr;
62 60
63 const size_t transcodeLen = output.Tell(); 61 const size_t transcodeLen = output.Tell();
64 return SharedBuffer::create(static_cast<unsigned char*>(output.get()), trans codeLen); 62 return SharedBuffer::create(static_cast<unsigned char*>(output.get()), trans codeLen);
65 } 63 }
66 64
67 bool OpenTypeSanitizer::supportsFormat(const String& format) 65 bool OpenTypeSanitizer::supportsFormat(const String& format)
68 { 66 {
69 return equalIgnoringCase(format, "woff") || equalIgnoringCase(format, "woff2 "); 67 return equalIgnoringCase(format, "woff") || equalIgnoringCase(format, "woff2 ");
70 } 68 }
71 69
72 } // namespace blink 70 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698