diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:36 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:36 -0800 |
commit | 6eb364108744656fcd23a96a478aa772cd4e85bc (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /samplecode/SampleTypeface.cpp | |
parent | a23c4e24d873b11674987f97f1946e1c4d97e782 (diff) | |
download | external_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.cpp | 91 |
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); - |