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

Side by Side Diff: src/pdf/SkPDFFont.cpp

Issue 2241683005: SkPDF: unify drawText and drawPosText (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: compile on win Created 4 years, 4 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
« src/pdf/SkPDFDevice.cpp ('K') | « src/pdf/SkPDFFont.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 /* 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
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(uint16_t* glyphIDs, int numGlyphs) { 501 int SkPDFFont::glyphsToPDFFontEncoding(SkGlyphID* glyphIDs, int numGlyphs) const {
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
520 // static 534 // static
521 SkPDFFont* SkPDFFont::GetFontResource(SkPDFCanon* canon, 535 SkPDFFont* SkPDFFont::GetFontResource(SkPDFCanon* canon,
522 SkTypeface* typeface, 536 SkTypeface* typeface,
523 uint16_t glyphID) { 537 uint16_t glyphID) {
524 SkASSERT(canon); 538 SkASSERT(canon);
525 const uint32_t fontID = SkTypeface::UniqueID(typeface); 539 const uint32_t fontID = SkTypeface::UniqueID(typeface);
526 SkPDFFont* relatedFont; 540 SkPDFFont* relatedFont;
527 if (SkPDFFont* pdfFont = canon->findFont(fontID, glyphID, &relatedFont)) { 541 if (SkPDFFont* pdfFont = canon->findFont(fontID, glyphID, &relatedFont)) {
528 return SkRef(pdfFont); 542 return SkRef(pdfFont);
529 } 543 }
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 } 1297 }
1284 return *canon->fCanEmbedTypeface.set(id, canEmbed); 1298 return *canon->fCanEmbedTypeface.set(id, canEmbed);
1285 } 1299 }
1286 1300
1287 void SkPDFFont::drop() { 1301 void SkPDFFont::drop() {
1288 fTypeface = nullptr; 1302 fTypeface = nullptr;
1289 fFontInfo = nullptr; 1303 fFontInfo = nullptr;
1290 fDescriptor = nullptr; 1304 fDescriptor = nullptr;
1291 this->SkPDFDict::drop(); 1305 this->SkPDFDict::drop();
1292 } 1306 }
OLDNEW
« src/pdf/SkPDFDevice.cpp ('K') | « src/pdf/SkPDFFont.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698