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 "SkPDFDevice.h" | 8 #include "SkPDFDevice.h" |
9 | 9 |
10 #include "SkAnnotationKeys.h" | 10 #include "SkAnnotationKeys.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 SkMatrix ident; | 91 SkMatrix ident; |
92 ident.reset(); | 92 ident.reset(); |
93 SkAutoGlyphCache autoCache(paint, nullptr, &ident); | 93 SkAutoGlyphCache autoCache(paint, nullptr, &ident); |
94 SkGlyphCache* cache = autoCache.getCache(); | 94 SkGlyphCache* cache = autoCache.getCache(); |
95 | 95 |
96 const char* start = reinterpret_cast<const char*>(glyphs); | 96 const char* start = reinterpret_cast<const char*>(glyphs); |
97 const char* stop = reinterpret_cast<const char*>(glyphs + len); | 97 const char* stop = reinterpret_cast<const char*>(glyphs + len); |
98 SkFixed xAdv = 0, yAdv = 0; | 98 SkScalar xAdv = 0, yAdv = 0; |
99 | 99 |
100 // TODO(vandebo): This probably needs to take kerning into account. | 100 // TODO(vandebo): This probably needs to take kerning into account. |
101 while (start < stop) { | 101 while (start < stop) { |
102 const SkGlyph& glyph = glyphCacheProc(cache, &start); | 102 const SkGlyph& glyph = glyphCacheProc(cache, &start); |
103 xAdv += glyph.fAdvanceX; | 103 xAdv += SkFloatToScalar(glyph.fAdvanceX); |
104 yAdv += glyph.fAdvanceY; | 104 yAdv += SkFloatToScalar(glyph.fAdvanceY); |
105 }; | 105 }; |
106 if (paint.getTextAlign() == SkPaint::kLeft_Align) { | 106 if (paint.getTextAlign() == SkPaint::kLeft_Align) { |
107 return; | 107 return; |
108 } | 108 } |
109 | 109 |
110 SkScalar xAdj = SkFixedToScalar(xAdv); | |
111 SkScalar yAdj = SkFixedToScalar(yAdv); | |
112 if (paint.getTextAlign() == SkPaint::kCenter_Align) { | 110 if (paint.getTextAlign() == SkPaint::kCenter_Align) { |
113 xAdj = SkScalarHalf(xAdj); | 111 xAdv = SkScalarHalf(xAdv); |
114 yAdj = SkScalarHalf(yAdj); | 112 yAdv = SkScalarHalf(yAdv); |
115 } | 113 } |
116 *x = *x - xAdj; | 114 *x = *x - xAdv; |
117 *y = *y - yAdj; | 115 *y = *y - yAdv; |
118 } | 116 } |
119 | 117 |
120 static int max_glyphid_for_typeface(SkTypeface* typeface) { | 118 static int max_glyphid_for_typeface(SkTypeface* typeface) { |
121 SkAutoResolveDefaultTypeface autoResolve(typeface); | 119 SkAutoResolveDefaultTypeface autoResolve(typeface); |
122 typeface = autoResolve.get(); | 120 typeface = autoResolve.get(); |
123 return typeface->countGlyphs() - 1; | 121 return typeface->countGlyphs() - 1; |
124 } | 122 } |
125 | 123 |
126 typedef SkAutoSTMalloc<128, uint16_t> SkGlyphStorage; | 124 typedef SkAutoSTMalloc<128, uint16_t> SkGlyphStorage; |
127 | 125 |
(...skipping 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2274 sk_sp<SkData> encodedImage(image->refEncodedData()); | 2272 sk_sp<SkData> encodedImage(image->refEncodedData()); |
2275 if (!encodedImage) { | 2273 if (!encodedImage) { |
2276 fDocument->serialize(pdfimage); | 2274 fDocument->serialize(pdfimage); |
2277 } | 2275 } |
2278 #endif | 2276 #endif |
2279 fDocument->canon()->addPDFBitmap(image->uniqueID(), pdfimage.get()); | 2277 fDocument->canon()->addPDFBitmap(image->uniqueID(), pdfimage.get()); |
2280 } | 2278 } |
2281 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), | 2279 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), |
2282 &content.entry()->fContent); | 2280 &content.entry()->fContent); |
2283 } | 2281 } |
OLD | NEW |