<commit_before>/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"
#include "SkGradientShader.h"

#include "SkTypeface.h"
#include "SkImageDecoder.h"
static void load_bm(SkBitmap* bm) {
//    SkImageDecoder::DecodeFile("/skia/trunk/books.jpg", bm);

    bm->setConfig(SkBitmap::kARGB_8888_Config, 160, 120);
    bm->allocPixels();
    SkCanvas canvas(*bm);
    canvas.drawColor(SK_ColorWHITE);

    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setSubpixelText(true);
    paint.setTextSize(17);

    paint.setTypeface(SkTypeface::CreateFromName("Times", SkTypeface::kNormal))->unref();
    canvas.drawText("Hamburgefons", 12, 10, 25, paint);
    paint.setTypeface(SkTypeface::CreateFromName("Times", SkTypeface::kItalic))->unref();
    canvas.drawText("Hamburgefons", 12, 10, 50, paint);
    paint.setTypeface(SkTypeface::CreateFromName("Times", SkTypeface::kBold))->unref();
    canvas.drawText("Hamburgefons", 12, 10, 75, paint);
    paint.setTypeface(SkTypeface::CreateFromName("Times", SkTypeface::kBoldItalic))->unref();
    canvas.drawText("Hamburgefons", 12, 10, 100, paint);
}

static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
    SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()),
                                   SkIntToScalar(bm.height()));
    mat.mapRect(&bounds);
    return SkSize::Make(bounds.width(), bounds.height());
}

static void draw_col(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
                     SkScalar dx) {
    SkPaint paint;

    SkAutoCanvasRestore acr(canvas, true);

    canvas->drawBitmapMatrix(bm, mat, &paint);

    paint.setFilterBitmap(true);
    canvas->translate(dx, 0);
    canvas->drawBitmapMatrix(bm, mat, &paint);

    paint.setFlags(paint.getFlags() | SkPaint::kBicubicFilterBitmap_Flag);
    canvas->translate(dx, 0);
    canvas->drawBitmapMatrix(bm, mat, &paint);
}<commit_msg>don't unref() null (from typeface::create) you gunky<commit_after>/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"
#include "SkGradientShader.h"

#include "SkTypeface.h"
#include "SkImageDecoder.h"

static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style style) {
    SkSafeUnref(paint->setTypeface(SkTypeface::CreateFromName(name, style)));
}

static void load_bm(SkBitmap* bm) {
//    SkImageDecoder::DecodeFile("/skia/trunk/books.jpg", bm);

    bm->setConfig(SkBitmap::kARGB_8888_Config, 160, 120);
    bm->allocPixels();
    SkCanvas canvas(*bm);
    canvas.drawColor(SK_ColorWHITE);

    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setSubpixelText(true);
    paint.setTextSize(17);

    setTypeface(&paint, "Times", SkTypeface::kNormal);
    canvas.drawText("Hamburgefons", 12, 10, 25, paint);
    setTypeface(&paint, "Times", SkTypeface::kBold);
    canvas.drawText("Hamburgefons", 12, 10, 50, paint);
    setTypeface(&paint, "Times", SkTypeface::kItalic);
    canvas.drawText("Hamburgefons", 12, 10, 75, paint);
    setTypeface(&paint, "Times", SkTypeface::kBoldItalic);
    canvas.drawText("Hamburgefons", 12, 10, 100, paint);
}

static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
    SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()),
                                   SkIntToScalar(bm.height()));
    mat.mapRect(&bounds);
    return SkSize::Make(bounds.width(), bounds.height());
}

static void draw_col(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
                     SkScalar dx) {
    SkPaint paint;

    SkAutoCanvasRestore acr(canvas, true);

    canvas->drawBitmapMatrix(bm, mat, &paint);

    paint.setFilterBitmap(true);
    canvas->translate(dx, 0);
    canvas->drawBitmapMatrix(bm, mat, &paint);

    paint.setFlags(paint.getFlags() | SkPaint::kBicubicFilterBitmap_Flag);
    canvas->translate(dx, 0);
    canvas->drawBitmapMatrix(bm, mat, &paint);
}
{'fraction_non_alphanumeric': 0.14776377563627377, 'fraction_numerical': 0.02125030887076847, 'mean_word_length': 4.263979193758128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5068205', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1370, 'n_words': 275}