Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 Tips & FAQ | 1 Tips & FAQ |
| 2 ========== | 2 ========== |
| 3 | 3 |
| 4 + [Gyp Options](#gypdefines) | 4 + [Gyp Options](#gypdefines) |
| 5 + [Bitmap Subsetting](#bitmap-subsetting) | 5 + [Bitmap Subsetting](#bitmap-subsetting) |
| 6 + [Capture a `.skp` file on a web page in Chromium](#skp-capture) | 6 + [Capture a `.skp` file on a web page in Chromium](#skp-capture) |
| 7 + [How to add hardware acceleration in Skia](#hw-acceleration) | 7 + [How to add hardware acceleration in Skia](#hw-acceleration) |
| 8 + [Does Skia support Font hinting?](#font-hinting) | 8 + [Does Skia support Font hinting?](#font-hinting) |
| 9 + [Does Skia shape text (kerning)?](#kerning) | 9 + [Does Skia shape text (kerning)?](#kerning) |
| 10 + [How do I add drop shadow on text?](#text-shadow) | |
| 10 | 11 |
| 11 * * * | 12 * * * |
| 12 | 13 |
| 13 <span id="gypdefines"></span> | 14 <span id="gypdefines"></span> |
| 14 | 15 |
| 15 Gyp Options | 16 Gyp Options |
| 16 ----------- | 17 ----------- |
| 17 | 18 |
| 18 When running `sync-and-gyp`, the `GYP_DEFINES` environment variable can | 19 When running `sync-and-gyp`, the `GYP_DEFINES` environment variable can |
| 19 be used to change Skia’s compile-time settings, using a | 20 be used to change Skia’s compile-time settings, using a |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 <span id="kerning"></span> | 160 <span id="kerning"></span> |
| 160 | 161 |
| 161 Does Skia shape text (kerning)? | 162 Does Skia shape text (kerning)? |
| 162 ------------------------------- | 163 ------------------------------- |
| 163 | 164 |
| 164 No. Skia provides interfaces to draw glyphs, but does not implement a | 165 No. Skia provides interfaces to draw glyphs, but does not implement a |
| 165 text shaper. Skia's client's often use | 166 text shaper. Skia's client's often use |
| 166 [HarfBuzz](http://www.freedesktop.org/wiki/Software/HarfBuzz/) to | 167 [HarfBuzz](http://www.freedesktop.org/wiki/Software/HarfBuzz/) to |
| 167 generate the glyphs and their positions, including kerning. | 168 generate the glyphs and their positions, including kerning. |
| 168 | 169 |
| 170 * * * | |
| 171 | |
| 172 <span id="text-shadow"></span> | |
| 173 | |
| 174 How do I add drop shadow on text? | |
| 175 --------------------------------- | |
| 176 | |
| 177 <!--?prettify lang=cc?--> | |
| 178 | |
| 179 void draw(SkCanvas* canvas) { | |
| 180 const char text[] = "Skia"; | |
| 181 const SkScalar radius = 1.0f; | |
| 182 const SkScalar xDrop = 2.0f; | |
| 183 const SkScalar yDrop = 2.0f; | |
| 184 const SkScalar x = 4.0f; | |
| 185 const SkScalar y = 26.0f; | |
| 186 const SkScalar textSize = 24.0f; | |
|
jcgregorio
2016/04/25 16:46:23
The resulting image is kind of small, can you incr
hal.canary
2016/04/25 17:08:58
Done.
| |
| 187 const uint8_t blurAlpha = 127; | |
| 188 canvas->drawColor(SK_ColorWHITE); | |
| 189 SkPaint paint; | |
| 190 paint.setAntiAlias(true); | |
| 191 paint.setTextSize(textSize); | |
| 192 SkPaint blur(paint); | |
| 193 blur.setAlpha(blurAlpha); | |
| 194 blur.setMaskFilter(SkBlurMaskFilter::Make( | |
| 195 kNormal_SkBlurStyle, | |
| 196 SkBlurMaskFilter::ConvertRadiusToSigma(radius), 0)); | |
| 197 canvas->drawText(text, strlen(text), | |
| 198 x + xDrop, y + yDrop, blur); | |
| 199 canvas->drawText(text, strlen(text), | |
| 200 x, y, paint); | |
| 201 } | |
| 202 | |
| 203 <a href='https://fiddle.skia.org/c/@text_shadow'><img src='https://fiddle.skia.o rg/i/@text_shadow_raster.png'></a> | |
| 204 | |
| 169 <div style="margin-bottom:99%"></div> | 205 <div style="margin-bottom:99%"></div> |
| OLD | NEW |