OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 SkDebugf("Could not run fontstream test because resourcePath not specifi
ed."); | 324 SkDebugf("Could not run fontstream test because resourcePath not specifi
ed."); |
325 return; | 325 return; |
326 } | 326 } |
327 SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc"); | 327 SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc"); |
328 SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str(), 1); | 328 SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str(), 1); |
329 if (!typeface) { | 329 if (!typeface) { |
330 SkDebugf("Could not run fontstream test because test.ttc not found."); | 330 SkDebugf("Could not run fontstream test because test.ttc not found."); |
331 return; | 331 return; |
332 } | 332 } |
333 | 333 |
| 334 typeface = SkTypeface::CreateFromName("Skia", SkTypeface::kNormal); |
| 335 if (!typeface) { |
| 336 SkDebugf("Could not get Skia font."); |
| 337 } |
334 // Create a paint with the typeface we loaded. | 338 // Create a paint with the typeface we loaded. |
335 SkPaint paint; | 339 SkPaint paint; |
336 paint.setColor(SK_ColorGRAY); | 340 paint.setColor(SK_ColorGRAY); |
337 paint.setTextSize(SkIntToScalar(30)); | 341 paint.setTextSize(SkIntToScalar(30)); |
338 SkSafeUnref(paint.setTypeface(typeface)); | 342 SkSafeUnref(paint.setTypeface(typeface)); |
339 | 343 |
340 // Paint some text. | 344 // Paint some text. |
341 SkPictureRecorder recorder; | 345 SkPictureRecorder recorder; |
342 SkIRect canvasRect = SkIRect::MakeWH(kBitmapSize, kBitmapSize); | 346 SkIRect canvasRect = SkIRect::MakeWH(kBitmapSize, kBitmapSize); |
343 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(canvasRect.width())
, | 347 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(canvasRect.width())
, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 521 |
518 // Deserialize picture | 522 // Deserialize picture |
519 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); | 523 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); |
520 SkAutoTUnref<SkPicture> readPict( | 524 SkAutoTUnref<SkPicture> readPict( |
521 SkPicture::CreateFromBuffer(reader)); | 525 SkPicture::CreateFromBuffer(reader)); |
522 REPORTER_ASSERT(reporter, readPict.get()); | 526 REPORTER_ASSERT(reporter, readPict.get()); |
523 } | 527 } |
524 | 528 |
525 TestPictureTypefaceSerialization(reporter); | 529 TestPictureTypefaceSerialization(reporter); |
526 } | 530 } |
OLD | NEW |