| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkData.h" | 8 #include "SkData.h" |
| 9 #include "SkGlyphCache.h" | 9 #include "SkGlyphCache.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 return true; | 491 return true; |
| 492 } | 492 } |
| 493 return (fFontInfo->fFlags & | 493 return (fFontInfo->fFlags & |
| 494 SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag) == 0; | 494 SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag) == 0; |
| 495 } | 495 } |
| 496 | 496 |
| 497 bool SkPDFFont::hasGlyph(uint16_t id) { | 497 bool SkPDFFont::hasGlyph(uint16_t id) { |
| 498 return (id >= fFirstGlyphID && id <= fLastGlyphID) || id == 0; | 498 return (id >= fFirstGlyphID && id <= fLastGlyphID) || id == 0; |
| 499 } | 499 } |
| 500 | 500 |
| 501 int SkPDFFont::glyphsToPDFFontEncoding(SkGlyphID* glyphIDs, int numGlyphs) const
{ | 501 int SkPDFFont::glyphsToPDFFontEncoding(uint16_t* glyphIDs, int numGlyphs) { |
| 502 // A font with multibyte glyphs will support all glyph IDs in a single font. | 502 // A font with multibyte glyphs will support all glyph IDs in a single font. |
| 503 if (this->multiByteGlyphs()) { | 503 if (this->multiByteGlyphs()) { |
| 504 return numGlyphs; | 504 return numGlyphs; |
| 505 } | 505 } |
| 506 | 506 |
| 507 for (int i = 0; i < numGlyphs; i++) { | 507 for (int i = 0; i < numGlyphs; i++) { |
| 508 if (glyphIDs[i] == 0) { | 508 if (glyphIDs[i] == 0) { |
| 509 continue; | 509 continue; |
| 510 } | 510 } |
| 511 if (glyphIDs[i] < fFirstGlyphID || glyphIDs[i] > fLastGlyphID) { | 511 if (glyphIDs[i] < fFirstGlyphID || glyphIDs[i] > fLastGlyphID) { |
| 512 return i; | 512 return i; |
| 513 } | 513 } |
| 514 glyphIDs[i] -= (fFirstGlyphID - 1); | 514 glyphIDs[i] -= (fFirstGlyphID - 1); |
| 515 } | 515 } |
| 516 | 516 |
| 517 return numGlyphs; | 517 return numGlyphs; |
| 518 } | 518 } |
| 519 | 519 |
| 520 int SkPDFFont::glyphsToPDFFontEncodingCount(const SkGlyphID* glyphIDs, | |
| 521 int numGlyphs) const { | |
| 522 if (this->multiByteGlyphs()) { // A font with multibyte glyphs will | |
| 523 return numGlyphs; // support all glyph IDs in a single font. | |
| 524 } | |
| 525 for (int i = 0; i < numGlyphs; i++) { | |
| 526 if (glyphIDs[i] != 0 && | |
| 527 (glyphIDs[i] < fFirstGlyphID || glyphIDs[i] > fLastGlyphID)) { | |
| 528 return i; | |
| 529 } | |
| 530 } | |
| 531 return numGlyphs; | |
| 532 } | |
| 533 | |
| 534 // static | 520 // static |
| 535 SkPDFFont* SkPDFFont::GetFontResource(SkPDFCanon* canon, | 521 SkPDFFont* SkPDFFont::GetFontResource(SkPDFCanon* canon, |
| 536 SkTypeface* typeface, | 522 SkTypeface* typeface, |
| 537 uint16_t glyphID) { | 523 uint16_t glyphID) { |
| 538 SkASSERT(canon); | 524 SkASSERT(canon); |
| 539 const uint32_t fontID = SkTypeface::UniqueID(typeface); | 525 const uint32_t fontID = SkTypeface::UniqueID(typeface); |
| 540 SkPDFFont* relatedFont; | 526 SkPDFFont* relatedFont; |
| 541 if (SkPDFFont* pdfFont = canon->findFont(fontID, glyphID, &relatedFont)) { | 527 if (SkPDFFont* pdfFont = canon->findFont(fontID, glyphID, &relatedFont)) { |
| 542 return SkRef(pdfFont); | 528 return SkRef(pdfFont); |
| 543 } | 529 } |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 } | 1283 } |
| 1298 return *canon->fCanEmbedTypeface.set(id, canEmbed); | 1284 return *canon->fCanEmbedTypeface.set(id, canEmbed); |
| 1299 } | 1285 } |
| 1300 | 1286 |
| 1301 void SkPDFFont::drop() { | 1287 void SkPDFFont::drop() { |
| 1302 fTypeface = nullptr; | 1288 fTypeface = nullptr; |
| 1303 fFontInfo = nullptr; | 1289 fFontInfo = nullptr; |
| 1304 fDescriptor = nullptr; | 1290 fDescriptor = nullptr; |
| 1305 this->SkPDFDict::drop(); | 1291 this->SkPDFDict::drop(); |
| 1306 } | 1292 } |
| OLD | NEW |