578 {
583 SkASSERT(lastGlyphID >= firstGlyphID);
584
585
586 while (lastGlyphID > firstGlyphID && !subset.
has(lastGlyphID)) {
587 --lastGlyphID;
588 }
589 int unitsPerEm;
594 SkScalar xHeight = strike->getFontMetrics().fXHeight;
597
599 : strikeSpec;
600
603
605 font.insertName(
"Subtype",
"Type3");
606
610
613
615
616
618 SkASSERT(lastGlyphID >= firstGlyphID);
619 int glyphCount = lastGlyphID - firstGlyphID + 2;
620
621 encDiffs->reserve(glyphCount + 1);
622 encDiffs->appendInt(0);
623
625 widthArray->reserve(glyphCount);
626
628
629 std::vector<std::pair<SkGlyphID, SkPDFIndirectReference>> imageGlyphs;
630 for (
SkGlyphID gID : SingleByteGlyphIdIterator(firstGlyphID, lastGlyphID)) {
631 bool skipGlyph = gID != 0 && !subset.
has(gID);
635 if (skipGlyph) {
636 characterName.
set(
"g0");
637 } else {
638 characterName.
printf(
"g%X", gID);
639 const SkGlyph* pathGlyph = metricsAndPaths.glyph(gID);
640 const SkGlyph* drawableGlyph = metricsAndDrawables.glyph(gID);
642 glyphBBox = pathGlyph->
iRect();
643 bbox.
join(glyphBBox);
650 canvas.translate(-glyphBBox.
fLeft, -glyphBBox.
fTop);
651 canvas.drawDrawable(drawable);
653 doc, glyphDevice->content(),
655 glyphDevice->makeResourceDict(),
657 imageGlyphs.emplace_back(gID, xobject);
659 content.writeText(
" 0 d0\n1 0 0 1 0 0 cm\n/X");
662 }
else if (path && !
path->isEmpty()) {
663 setGlyphWidthAndBoundingBox(pathGlyph->
advanceX(), glyphBBox, &
content);
666 } else {
667 auto pimg =
to_image(gID, &smallGlyphs);
668 if (!pimg.fImage) {
669 setGlyphWidthAndBoundingBox(pathGlyph->
advanceX(), glyphBBox, &
content);
670 } else {
681 AppendScalar((pimg.fImage->height() + pimg.fOffset.y()) * bitmapScale,
686 }
687 }
689 content.detachAsStream(), doc));
690 }
691 encDiffs->appendName(std::move(characterName));
692 widthArray->appendScalar(advance);
693 }
694
695 if (!imageGlyphs.empty()) {
697 for (const auto& pair : imageGlyphs) {
699 }
701 d1->insertObject("XObject", std::move(d0));
702 font.insertObject(
"Resources", std::move(d1));
703 }
704
705 encoding->insertObject("Differences", std::move(encDiffs));
706 font.insertInt(
"FirstChar", 0);
707 font.insertInt(
"LastChar", lastGlyphID - firstGlyphID + 1);
708
709
710
711
712
717
718 font.insertName(
"CIDToGIDMap",
"Identity");
719
723 &subset,
724 false,
725 firstGlyphID,
726 lastGlyphID);
729 font.insertObject(
"Widths", std::move(widthArray));
730 font.insertObject(
"Encoding", std::move(encoding));
731 font.insertObject(
"CharProcs", std::move(charProcs));
732
734}
SkPDFIndirectReference SkPDFSerializeImage(const SkImage *img, SkPDFDocument *doc, int encodingQuality)
SkStrikeSpec make_small_strike(const SkTypeface &typeface)
static SkPDFIndirectReference type3_descriptor(SkPDFDocument *doc, const SkTypeface *typeface, SkScalar xHeight)
static ImageAndOffset to_image(SkGlyphID gid, SkBulkGlyphMetricsAndImages *smallGlyphs)
static constexpr float kBitmapFontSize
#define SkScalarInvert(x)
SK_API SkString static SkString SkStringPrintf()
const SkPath * path() const
SkScalar advanceX() const
SkDrawable * drawable() const
static SkMatrix Translate(SkScalar dx, SkScalar dy)
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
SkPDFIndirectReference indirectReference() const
SkGlyphID lastGlyphID() const
SkGlyphID firstGlyphID() const
const SkPDFGlyphUse & glyphUsage() const
SkTypeface * typeface() const
bool has(SkGlyphID gid) const
@ kFill_Style
set to fill geometry
sk_sp< SkStrike > findOrCreateStrike() const
static SkStrikeSpec MakePDFVector(const SkTypeface &typeface, int *size)
void printf(const char format[],...) SK_PRINTF_LIKE(2
void set(const SkString &src)
const char * c_str() const
union flutter::testing::@2838::KeyboardChange::@76 content
std::unique_ptr< SkPDFArray > MatrixToArray(const SkMatrix &matrix)
void EmitPath(const SkPath &path, SkPaint::Style paintStyle, bool doConsumeDegerates, SkWStream *content, SkScalar tolerance=0.25f)
void PaintPath(SkPaint::Style style, SkPathFillType fill, SkWStream *content)
void AppendScalar(SkScalar value, SkWStream *stream)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
constexpr int32_t top() const
constexpr SkISize size() const
constexpr int32_t bottom() const
constexpr int32_t height() const
constexpr int32_t right() const
int32_t fTop
smaller y-axis bounds
void join(const SkIRect &r)
static constexpr SkIRect MakeEmpty()
constexpr int32_t width() const
int32_t fLeft
smaller x-axis bounds
constexpr int32_t left() const