mattintosh note

どこかのエンジニアモドキの備忘録

macOS 上の Wine で FontSmoothingGamma を検証する

0x3e8 (1000) 〜 0x898 (2200) まで 400 刻みでテスト。なお、初期値の 0x0 は 0x578 (1400) と同じとして扱われる。

等倍

f:id:mattintosh4:20190529112015p:plain
"FontSmoothingGamma"=DWORD:0x000003e8 (1000)

f:id:mattintosh4:20190529111739p:plain
"FontSmoothingGamma"=DWORD:0x00000578 (1400)

f:id:mattintosh4:20190529112703p:plain
"FontSmoothingGamma"=DWORD:0x00000708 (1800)

f:id:mattintosh4:20190529112145p:plain
"FontSmoothingGamma"=DWORD:0x00000898 (2200)

部分拡大

f:id:mattintosh4:20190529112233p:plain
"FontSmoothingGamma"=DWORD:0x000003e8 (1000)

f:id:mattintosh4:20190529112322p:plain
"FontSmoothingGamma"=DWORD:0x00000578 (1400)

f:id:mattintosh4:20190529112845p:plain
"FontSmoothingGamma"=DWORD:0x00000708 (1800)

f:id:mattintosh4:20190529112409p:plain
"FontSmoothingGamma"=DWORD:0x00000898 (2200)

macOS - テキストエディット

f:id:mattintosh4:20190529114144p:plain
macOS - テキストエディット

f:id:mattintosh4:20190529114249p:plain
macOS - テキストエディット

0x4b0 (1200) 相当くらいかな?🤔

その後

FT_LOAD_TARGET_XXXXX とか弄ってみて macOSアンチエイリアスに近くはなった(FT_LOAD_TARGET_XXXXX が効いているかどうかはわからない)。次回のリリースに反映させる予定。

f:id:mattintosh4:20190529232201p:plain

なお、Wine の FontSmoothingGamma に関するソースは 4.0.1 時点では下記の通り。

dlls/gdi32/freetype.c

static struct font_gamma_ramp *get_font_gamma_ramp( void )
{
    static const WCHAR desktopW[] = { 'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
                                      'D','e','s','k','t','o','p',0 };
    static const WCHAR smoothing_gamma[] = { 'F','o','n','t','S','m','o','o','t','h','i','n','g',
                                             'G','a','m','m','a',0 };
    const DWORD gamma_default = 1400;
    struct font_gamma_ramp *ramp;
    DWORD  i, gamma;
    HKEY key;

    ramp = HeapAlloc( GetProcessHeap(), 0, sizeof(*ramp) );
    if ( ramp == NULL) return NULL;

    gamma = gamma_default;
    if (RegOpenKeyW( HKEY_CURRENT_USER, desktopW, &key ) == ERROR_SUCCESS)
    {
        if (get_key_value( key, smoothing_gamma, &gamma ) || gamma == 0)
            gamma = gamma_default;
        RegCloseKey( key );

        gamma = min( max( gamma, 1000 ), 2200 );
    }

    /* Calibrating the difference between the registry value and the Wine gamma value.
       This looks roughly similar to Windows Native with the same registry value.
       MS GDI seems to be rasterizing the outline at a different rate than FreeType. */
    gamma = 1000 * gamma / 1400;

    for (i = 0; i < 256; i++)
    {
        ramp->encode[i] = pow( i / 255., 1000. / gamma ) * 255. + .5;
        ramp->decode[i] = pow( i / 255., gamma / 1000. ) * 255. + .5;
    }

    ramp->gamma = gamma;
    TRACE("gamma %d\n", ramp->gamma);

    return ramp;
}