Skip to content

Windows: add shared memory support

vtorri requested to merge vtorri/freetype:vtorri_mmap into master

Add shared memory support on Windows

with this quickly written benchmark :

#include <stdio.h>

#include <windows.h>

#include <ft2build.h>
#include FT_FREETYPE_H

int main()
{
    FT_Library library;
    FT_Face face;
    FT_Error error;
   LARGE_INTEGER count1;
   LARGE_INTEGER count2;
   LARGE_INTEGER freq;

    error = FT_Init_FreeType(&library);
    if (error)
    {
        printf("init fails\n");
        return 0;
    }

    printf("before FT_New_Face call\n");
    QueryPerformanceFrequency(&freq);
    QueryPerformanceCounter(&count1);
    error = FT_New_Face(library, "NotoSansCJK.ttc", 0, &face);
    QueryPerformanceCounter(&count2);
    double t = (double)(count2.QuadPart - count1.QuadPart) / (double)freq.QuadPart;;
    printf("after: %e s.\n", t);
    if (error == FT_Err_Unknown_File_Format)
    {
        printf("unknow format\n");
        return 0;
    }
    if (error)
    {
        printf("new face fails\n");
        return 0;
    }

    printf("num faces: %ld\n", face->num_faces);

    FT_Done_Face(face);
    FT_Done_FreeType(library);

    return 0;
}

FT_New_Face() is taking on my computer and NotoSansCJK.ttc font :

  • 1.495036e-03 seconds with current release
  • 6.624450e-04 seconds with the mmap code

Merge request reports