25 "/CIDInit /ProcSet findresource begin\n"
34 const char* kSysInfo =
36 "<< /Registry (Adobe)\n"
45 const char* kTypeInfoHeader =
46 "/CMapName /Adobe-Identity-UCS def\n"
48 "1 begincodespacerange\n";
59 const char kFooter[] =
61 "CMapName currentdict /CMap defineresource pop\n"
94 for (
size_t i = 0;
i < bfchar.size();
i += 100) {
99 for (
int j = 0; j <
count; ++j) {
114 for (
size_t i = 0;
i < bfrange.size();
i += 100) {
119 for (
int j = 0; j <
count; ++j) {
161 bool multiByteGlyphs,
165 if (!multiByteGlyphs) {
166 glyphOffset = firstGlyphID - 1;
169 std::vector<BFChar> bfcharEntries;
170 std::vector<BFRange> bfrangeEntries;
172 BFRange currentRangeEntry = {0, 0, 0};
173 bool rangeEmpty =
true;
174 const int limit = (
int)lastGlyphID + 1 - glyphOffset;
176 for (
int i = firstGlyphID - glyphOffset;
i < limit + 1; ++
i) {
178 bool inSubset =
i < limit && (subset ==
nullptr || subset->
has(gid));
184 i == currentRangeEntry.fEnd + 1 &&
185 i >> 8 == currentRangeEntry.fStart >> 8 &&
187 glyphToUnicode[gid] ==
188 currentRangeEntry.fUnicode +
i - currentRangeEntry.fStart;
189 if (!inSubset || !inRange) {
190 if (currentRangeEntry.fEnd > currentRangeEntry.fStart) {
191 bfrangeEntries.push_back(currentRangeEntry);
193 bfcharEntries.push_back({currentRangeEntry.fStart, currentRangeEntry.fUnicode});
199 currentRangeEntry.fEnd =
i;
201 currentRangeEntry.fStart =
i;
202 currentRangeEntry.fUnicode = glyphToUnicode[gid];
217 bool multiByteGlyphs,
223 firstGlyphID, lastGlyphID);
static void append_cmap_footer(SkDynamicMemoryWStream *cmap)
static void append_tounicode_header(SkDynamicMemoryWStream *cmap, bool multibyte)
std::unique_ptr< SkStreamAsset > SkPDFMakeToUnicodeCmap(const SkUnichar *glyphToUnicode, const SkPDFGlyphUse *subset, bool multiByteGlyphs, SkGlyphID firstGlyphID, SkGlyphID lastGlyphID)
static void write_glyph(SkDynamicMemoryWStream *cmap, bool multiByte, SkGlyphID gid)
void SkPDFAppendCmapSections(const SkUnichar *glyphToUnicode, const SkPDFGlyphUse *subset, SkDynamicMemoryWStream *cmap, bool multiByteGlyphs, SkGlyphID firstGlyphID, SkGlyphID lastGlyphID)
static void append_bfrange_section(const std::vector< BFRange > &bfrange, bool multiByte, SkDynamicMemoryWStream *cmap)
static void append_bfchar_section(const std::vector< BFChar > &bfchar, bool multiByte, SkDynamicMemoryWStream *cmap)
constexpr int SkToInt(S x)
constexpr uint8_t SkToU8(S x)
std::unique_ptr< SkStreamAsset > detachAsStream()
bool has(SkGlyphID gid) const
bool writeDecAsText(int32_t)
bool writeText(const char text[])
static float min(float r, float g, float b)
void WriteUInt8(SkWStream *wStream, uint8_t value)
void WriteUInt16BE(SkWStream *wStream, uint16_t value)
void WriteUTF16beHex(SkWStream *wStream, SkUnichar utf32)