Exemplo n.º 1
0
    TextBoxView() {
#if defined(SK_BUILD_FOR_WIN) && defined(SK_FONTHOST_WIN_GDI)
        LOGFONT lf;
        sk_bzero(&lf, sizeof(lf));
        lf.lfHeight = 9;
        SkTypeface* tf0 = SkCreateTypefaceFromLOGFONT(lf);
        lf.lfHeight = 12;
        SkTypeface* tf1 = SkCreateTypefaceFromLOGFONT(lf);
        // we assert that different sizes should not affect which face we get
        SkASSERT(tf0 == tf1);
        tf0->unref();
        tf1->unref();
#endif
    }
Exemplo n.º 2
0
SkTypeface* ScaledFontWin::GetSkTypeface()
{
  if (!mTypeface) {
    mTypeface = SkCreateTypefaceFromLOGFONT(mLogFont);
  }
  return mTypeface;
}
SkTypeface* CreateTypefaceFromHFont(HFONT hfont, int* size, int* lfQuality)
{
    LOGFONT info;
    GetObject(hfont, sizeof(info), &info);
    if (size) {
        int height = info.lfHeight;
        if (height < 0)
            height = -height;
        *size = height;
    }
    if (lfQuality)
        *lfQuality = info.lfQuality;
    return SkCreateTypefaceFromLOGFONT(info);
}
Exemplo n.º 4
0
PassRefPtr<SkTypeface> CreateTypefaceFromHFont(HFONT hfont, int* size, int* paintTextFlags)
{
    LOGFONT info;
    GetObject(hfont, sizeof(info), &info);
    if (size) {
        int height = info.lfHeight;
        if (height < 0)
            height = -height;
        *size = height;
    }
    if (paintTextFlags)
        *paintTextFlags = computePaintTextFlags(info);
    return adoptRef(SkCreateTypefaceFromLOGFONT(info));
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
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);
}