aboutsummaryrefslogtreecommitdiffstats
path: root/samplecode/SampleTypeface.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:36 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:36 -0800
commit6eb364108744656fcd23a96a478aa772cd4e85bc (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /samplecode/SampleTypeface.cpp
parenta23c4e24d873b11674987f97f1946e1c4d97e782 (diff)
downloadexternal_skia-6eb364108744656fcd23a96a478aa772cd4e85bc.zip
external_skia-6eb364108744656fcd23a96a478aa772cd4e85bc.tar.gz
external_skia-6eb364108744656fcd23a96a478aa772cd4e85bc.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'samplecode/SampleTypeface.cpp')
-rw-r--r--samplecode/SampleTypeface.cpp91
1 files changed, 0 insertions, 91 deletions
diff --git a/samplecode/SampleTypeface.cpp b/samplecode/SampleTypeface.cpp
deleted file mode 100644
index 94023b7..0000000
--- a/samplecode/SampleTypeface.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "SampleCode.h"
-#include "SkView.h"
-#include "SkCanvas.h"
-#include "SkTypeface.h"
-#include "SkPath.h"
-#include "SkRegion.h"
-#include "SkShader.h"
-#include "SkUtils.h"
-#include "Sk1DPathEffect.h"
-#include "SkCornerPathEffect.h"
-#include "SkPathMeasure.h"
-#include "SkRandom.h"
-#include "SkColorPriv.h"
-#include "SkColorFilter.h"
-#include "SkDither.h"
-
-static const struct {
- const char* fName;
- SkTypeface::Style fStyle;
-} gFaces[] = {
- { NULL, SkTypeface::kNormal },
- { NULL, SkTypeface::kBold },
- { "serif", SkTypeface::kNormal },
- { "serif", SkTypeface::kBold },
- { "serif", SkTypeface::kItalic },
- { "serif", SkTypeface::kBoldItalic },
- { "monospace", SkTypeface::kNormal }
-};
-
-static const int gFaceCount = SK_ARRAY_COUNT(gFaces);
-
-class TypefaceView : public SkView {
- SkTypeface* fFaces[gFaceCount];
-
-public:
- TypefaceView() {
- for (int i = 0; i < gFaceCount; i++) {
- fFaces[i] = SkTypeface::Create(gFaces[i].fName, gFaces[i].fStyle);
- }
- }
-
- virtual ~TypefaceView() {
- for (int i = 0; i < gFaceCount; i++) {
- fFaces[i]->safeUnref();
- }
- }
-
-protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "Typefaces");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- void drawBG(SkCanvas* canvas) {
- canvas->drawColor(0xFFDDDDDD);
- }
-
- virtual void onDraw(SkCanvas* canvas) {
- this->drawBG(canvas);
-
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setTextSize(SkIntToScalar(30));
-
- const char* text = "Hamburgefons";
- const size_t textLen = strlen(text);
-
- SkScalar x = SkIntToScalar(10);
- SkScalar dy = paint.getFontMetrics(NULL);
- SkScalar y = dy;
-
- for (int i = 0; i < gFaceCount; i++) {
- paint.setTypeface(fFaces[i]);
- canvas->drawText(text, textLen, x, y, paint);
- y += dy;
- }
- }
-
-private:
- typedef SkView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new TypefaceView; }
-static SkViewRegister reg(MyFactory);
-