コード例 #1
0
ファイル: SkiaFontWin.cpp プロジェクト: RasterCode/wke
static void setupPaintForFont(HFONT hfont, SkPaint* paint, PlatformContextSkia* pcs)
{
    //  FIXME:
    //  Much of this logic could also happen in
    //  FontCustomPlatformData::fontPlatformData and be cached,
    //  allowing us to avoid talking to GDI at this point.
    //
    LOGFONT info;
    GetObject(hfont, sizeof(info), &info);
    int size = info.lfHeight;
    if (size < 0)
        size = -size; // We don't let GDI dpi-scale us (see SkFontHost_win.cpp).
    paint->setTextSize(SkIntToScalar(size));

    SkTypeface* face = SkCreateTypefaceFromLOGFONT(info);
    paint->setTypeface(face);
    SkSafeUnref(face);

    // turn lfQuality into text flags
    uint32_t textFlags;
    switch (info.lfQuality) {
    case NONANTIALIASED_QUALITY:
        textFlags = 0;
        break;
    case ANTIALIASED_QUALITY:
        textFlags = SkPaint::kAntiAlias_Flag;
        break;
    case CLEARTYPE_QUALITY:
        textFlags = (SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag);
        break;
    default:
        textFlags = getDefaultGDITextFlags();
        break;
    }
    // only allow features that SystemParametersInfo allows
    textFlags &= getDefaultGDITextFlags();

    // do this check after our switch on lfQuality
    if (disableTextLCD(pcs))
        textFlags &= ~SkPaint::kLCDRenderText_Flag;

    // now copy in just the text flags
    uint32_t flags = paint->getFlags();
    flags &= ~(SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag);
    flags |= textFlags;
    paint->setFlags(flags);
}
コード例 #2
0
ファイル: SkiaFontWin.cpp プロジェクト: Xertz/EAWebKit
static void setupPaintForFont(HFONT hfont, SkPaint* paint, PlatformContextSkia* pcs)
{
    //  FIXME:
    //  Much of this logic could also happen in
    //  FontCustomPlatformData::fontPlatformData and be cached,
    //  allowing us to avoid talking to GDI at this point.
    //
    LOGFONT info;
    GetObject(hfont, sizeof(info), &info);
    int size = info.lfHeight;
    if (size < 0)
        size = -size; // We don't let GDI dpi-scale us (see SkFontHost_win.cpp).
    paint->setTextSize(SkIntToScalar(size));

    SkTypeface* face = SkCreateTypefaceFromLOGFONT(info);
    paint->setTypeface(face);
    SkSafeUnref(face);

    uint32_t flags = paint->getFlags();
    // clear our flags initially, and then selectively set them
    // based on the LOGFONT quality
    flags &= SkPaint::kAntiAlias_Flag;
    flags &= SkPaint::kLCDRenderText_Flag;

    switch (info.lfQuality) {
    case NONANTIALIASED_QUALITY:
        break;
    case ANTIALIASED_QUALITY:
        flags |= SkPaint::kAntiAlias_Flag;
        break;
    case CLEARTYPE_QUALITY:
        flags |= SkPaint::kAntiAlias_Flag;
        flags |= SkPaint::kLCDRenderText_Flag;
        break;
    default:
        flags |= getDefaultGDITextFlags();
        break;
    }

    // do this check after our switch on lfQuality
    if (disableTextLCD(pcs))
        flags &= ~SkPaint::kLCDRenderText_Flag;

    paint->setFlags(flags);
}