2014-11-21 09:48:23 +01:00
|
|
|
/*
|
|
|
|
* FreeType integration
|
|
|
|
*
|
|
|
|
* Copyright 2014 Nikolay Sivov for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2014-11-21 09:48:23 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_FT2BUILD_H
|
|
|
|
#include <ft2build.h>
|
2014-12-08 11:24:39 +01:00
|
|
|
#include FT_CACHE_H
|
2014-11-21 09:48:23 +01:00
|
|
|
#include FT_FREETYPE_H
|
2014-12-15 07:39:26 +01:00
|
|
|
#include FT_OUTLINE_H
|
2014-11-21 09:48:23 +01:00
|
|
|
#endif /* HAVE_FT2BUILD_H */
|
|
|
|
|
|
|
|
#include "windef.h"
|
2014-12-08 11:24:39 +01:00
|
|
|
#include "dwrite_2.h"
|
2014-11-21 09:48:23 +01:00
|
|
|
#include "wine/library.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "dwrite_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
|
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
static CRITICAL_SECTION freetype_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
|
|
{
|
|
|
|
0, 0, &freetype_cs,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": freetype_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION freetype_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
2014-11-21 09:48:23 +01:00
|
|
|
static void *ft_handle = NULL;
|
|
|
|
static FT_Library library = 0;
|
2014-12-08 11:24:39 +01:00
|
|
|
static FTC_Manager cache_manager = 0;
|
2015-02-20 11:47:30 +01:00
|
|
|
static FTC_CMapCache cmap_cache = 0;
|
2014-11-21 09:48:23 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
FT_Int major;
|
|
|
|
FT_Int minor;
|
|
|
|
FT_Int patch;
|
|
|
|
} FT_Version_t;
|
|
|
|
|
|
|
|
#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
|
2014-12-08 11:24:39 +01:00
|
|
|
MAKE_FUNCPTR(FT_Done_FreeType);
|
2015-03-13 21:19:18 +01:00
|
|
|
MAKE_FUNCPTR(FT_Get_Kerning);
|
2014-11-21 09:48:23 +01:00
|
|
|
MAKE_FUNCPTR(FT_Init_FreeType);
|
|
|
|
MAKE_FUNCPTR(FT_Library_Version);
|
2014-12-08 11:24:39 +01:00
|
|
|
MAKE_FUNCPTR(FT_Load_Glyph);
|
2014-11-21 09:48:23 +01:00
|
|
|
MAKE_FUNCPTR(FT_New_Memory_Face);
|
2014-12-15 07:39:26 +01:00
|
|
|
MAKE_FUNCPTR(FT_Outline_Transform);
|
2015-02-20 11:47:30 +01:00
|
|
|
MAKE_FUNCPTR(FTC_CMapCache_Lookup);
|
|
|
|
MAKE_FUNCPTR(FTC_CMapCache_New);
|
2014-12-08 11:24:39 +01:00
|
|
|
MAKE_FUNCPTR(FTC_Manager_New);
|
|
|
|
MAKE_FUNCPTR(FTC_Manager_Done);
|
2014-12-09 07:58:14 +01:00
|
|
|
MAKE_FUNCPTR(FTC_Manager_LookupFace);
|
2014-12-08 11:24:39 +01:00
|
|
|
MAKE_FUNCPTR(FTC_Manager_LookupSize);
|
|
|
|
MAKE_FUNCPTR(FTC_Manager_RemoveFaceID);
|
2014-11-21 09:48:23 +01:00
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
static FT_Error face_requester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *face)
|
2014-11-21 09:48:23 +01:00
|
|
|
{
|
2014-12-08 11:24:39 +01:00
|
|
|
IDWriteFontFace *fontface = (IDWriteFontFace*)face_id;
|
|
|
|
IDWriteFontFileStream *stream;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
const void *data_ptr;
|
|
|
|
UINT32 index, count;
|
|
|
|
FT_Error fterror;
|
|
|
|
UINT64 data_size;
|
|
|
|
void *context;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*face = NULL;
|
|
|
|
|
|
|
|
count = 1;
|
|
|
|
hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return FT_Err_Ok;
|
|
|
|
|
|
|
|
hr = get_filestream_from_file(file, &stream);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return FT_Err_Ok;
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_GetFileSize(stream, &data_size);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
fterror = FT_Err_Invalid_Stream_Read;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFontFileStream_ReadFileFragment(stream, &data_ptr, 0, data_size, &context);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
fterror = FT_Err_Invalid_Stream_Read;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
index = IDWriteFontFace_GetIndex(fontface);
|
|
|
|
fterror = pFT_New_Memory_Face(library, data_ptr, data_size, index, face);
|
|
|
|
IDWriteFontFileStream_ReleaseFileFragment(stream, context);
|
|
|
|
|
|
|
|
fail:
|
|
|
|
IDWriteFontFileStream_Release(stream);
|
|
|
|
|
|
|
|
return fterror;
|
|
|
|
}
|
2014-11-21 09:48:23 +01:00
|
|
|
|
|
|
|
BOOL init_freetype(void)
|
|
|
|
{
|
|
|
|
FT_Version_t FT_Version;
|
|
|
|
|
|
|
|
ft_handle = wine_dlopen(SONAME_LIBFREETYPE, RTLD_NOW, NULL, 0);
|
|
|
|
if (!ft_handle) {
|
|
|
|
WINE_MESSAGE("Wine cannot find the FreeType font library.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(ft_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;}
|
2014-12-08 11:24:39 +01:00
|
|
|
LOAD_FUNCPTR(FT_Done_FreeType)
|
2015-03-13 21:19:18 +01:00
|
|
|
LOAD_FUNCPTR(FT_Get_Kerning)
|
2014-11-21 09:48:23 +01:00
|
|
|
LOAD_FUNCPTR(FT_Init_FreeType)
|
|
|
|
LOAD_FUNCPTR(FT_Library_Version)
|
2014-12-08 11:24:39 +01:00
|
|
|
LOAD_FUNCPTR(FT_Load_Glyph)
|
2014-11-21 09:48:23 +01:00
|
|
|
LOAD_FUNCPTR(FT_New_Memory_Face)
|
2014-12-15 07:39:26 +01:00
|
|
|
LOAD_FUNCPTR(FT_Outline_Transform)
|
2015-02-20 11:47:30 +01:00
|
|
|
LOAD_FUNCPTR(FTC_CMapCache_Lookup)
|
|
|
|
LOAD_FUNCPTR(FTC_CMapCache_New)
|
2014-12-08 11:24:39 +01:00
|
|
|
LOAD_FUNCPTR(FTC_Manager_New)
|
|
|
|
LOAD_FUNCPTR(FTC_Manager_Done)
|
2014-12-09 07:58:14 +01:00
|
|
|
LOAD_FUNCPTR(FTC_Manager_LookupFace)
|
2014-12-08 11:24:39 +01:00
|
|
|
LOAD_FUNCPTR(FTC_Manager_LookupSize)
|
|
|
|
LOAD_FUNCPTR(FTC_Manager_RemoveFaceID)
|
2014-11-21 09:48:23 +01:00
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
|
|
|
|
if (pFT_Init_FreeType(&library) != 0) {
|
|
|
|
ERR("Can't init FreeType library\n");
|
|
|
|
wine_dlclose(ft_handle, NULL, 0);
|
|
|
|
ft_handle = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pFT_Library_Version(library, &FT_Version.major, &FT_Version.minor, &FT_Version.patch);
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
/* init cache manager */
|
2015-02-20 11:47:30 +01:00
|
|
|
if (pFTC_Manager_New(library, 0, 0, 0, &face_requester, NULL, &cache_manager) != 0 ||
|
|
|
|
pFTC_CMapCache_New(cache_manager, &cmap_cache) != 0) {
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
ERR("Failed to init FreeType cache\n");
|
2015-02-20 11:47:30 +01:00
|
|
|
pFTC_Manager_Done(cache_manager);
|
2014-12-08 11:24:39 +01:00
|
|
|
pFT_Done_FreeType(library);
|
|
|
|
wine_dlclose(ft_handle, NULL, 0);
|
|
|
|
ft_handle = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-11-21 09:48:23 +01:00
|
|
|
TRACE("FreeType version is %d.%d.%d\n", FT_Version.major, FT_Version.minor, FT_Version.patch);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
sym_not_found:
|
|
|
|
WINE_MESSAGE("Wine cannot find certain functions that it needs from FreeType library.\n");
|
|
|
|
wine_dlclose(ft_handle, NULL, 0);
|
|
|
|
ft_handle = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
void release_freetype(void)
|
2014-11-21 09:48:23 +01:00
|
|
|
{
|
2014-12-08 11:24:39 +01:00
|
|
|
pFTC_Manager_Done(cache_manager);
|
|
|
|
pFT_Done_FreeType(library);
|
|
|
|
}
|
2014-11-21 09:48:23 +01:00
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
void freetype_notify_cacheremove(IDWriteFontFace2 *fontface)
|
|
|
|
{
|
|
|
|
EnterCriticalSection(&freetype_cs);
|
|
|
|
pFTC_Manager_RemoveFaceID(cache_manager, fontface);
|
|
|
|
LeaveCriticalSection(&freetype_cs);
|
|
|
|
}
|
2014-11-21 09:48:23 +01:00
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
HRESULT freetype_get_design_glyph_metrics(IDWriteFontFace2 *fontface, UINT16 unitsperEm, UINT16 glyph, DWRITE_GLYPH_METRICS *ret)
|
|
|
|
{
|
|
|
|
FTC_ScalerRec scaler;
|
|
|
|
FT_Size size;
|
|
|
|
|
|
|
|
scaler.face_id = fontface;
|
|
|
|
scaler.width = unitsperEm;
|
|
|
|
scaler.height = unitsperEm;
|
|
|
|
scaler.pixel = 1;
|
|
|
|
scaler.x_res = 0;
|
|
|
|
scaler.y_res = 0;
|
|
|
|
|
|
|
|
EnterCriticalSection(&freetype_cs);
|
|
|
|
if (pFTC_Manager_LookupSize(cache_manager, &scaler, &size) == 0) {
|
|
|
|
if (pFT_Load_Glyph(size->face, glyph, FT_LOAD_NO_SCALE) == 0) {
|
|
|
|
FT_Glyph_Metrics *metrics = &size->face->glyph->metrics;
|
|
|
|
|
|
|
|
ret->leftSideBearing = metrics->horiBearingX;
|
|
|
|
ret->advanceWidth = metrics->horiAdvance;
|
|
|
|
ret->rightSideBearing = metrics->horiAdvance - metrics->horiBearingX - metrics->width;
|
|
|
|
ret->topSideBearing = metrics->vertBearingY;
|
|
|
|
ret->advanceHeight = metrics->vertAdvance;
|
|
|
|
ret->bottomSideBearing = metrics->vertAdvance - metrics->vertBearingY - metrics->height;
|
|
|
|
ret->verticalOriginY = metrics->height + metrics->vertBearingY;
|
|
|
|
}
|
2014-11-21 09:48:23 +01:00
|
|
|
}
|
2014-12-08 11:24:39 +01:00
|
|
|
LeaveCriticalSection(&freetype_cs);
|
2014-11-21 09:48:23 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-12-09 07:58:14 +01:00
|
|
|
BOOL freetype_is_monospaced(IDWriteFontFace2 *fontface)
|
|
|
|
{
|
|
|
|
BOOL is_monospaced = FALSE;
|
|
|
|
FT_Face face;
|
|
|
|
|
|
|
|
EnterCriticalSection(&freetype_cs);
|
|
|
|
if (pFTC_Manager_LookupFace(cache_manager, fontface, &face) == 0)
|
|
|
|
is_monospaced = FT_IS_FIXED_WIDTH(face);
|
|
|
|
LeaveCriticalSection(&freetype_cs);
|
|
|
|
|
|
|
|
return is_monospaced;
|
|
|
|
}
|
|
|
|
|
2014-12-15 07:39:26 +01:00
|
|
|
static inline void ft_vector_to_d2d_point(const FT_Vector *v, D2D1_POINT_2F *p)
|
|
|
|
{
|
|
|
|
p->x = v->x / 64.0;
|
|
|
|
p->y = v->y / 64.0;
|
|
|
|
}
|
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
/* Convert the quadratic Beziers to cubic Beziers. */
|
|
|
|
static void get_cubic_glyph_outline(const FT_Outline *outline, short point, short first_pt,
|
|
|
|
short contour, FT_Vector *cubic_control)
|
2014-12-15 07:39:26 +01:00
|
|
|
{
|
2015-06-09 23:13:34 +02:00
|
|
|
/*
|
|
|
|
The parametric eqn for a cubic Bezier is, from PLRM:
|
|
|
|
r(t) = at^3 + bt^2 + ct + r0
|
|
|
|
with the control points:
|
|
|
|
r1 = r0 + c/3
|
|
|
|
r2 = r1 + (c + b)/3
|
|
|
|
r3 = r0 + c + b + a
|
|
|
|
|
|
|
|
A quadratic Bezier has the form:
|
|
|
|
p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
|
|
|
|
|
|
|
|
So equating powers of t leads to:
|
|
|
|
r1 = 2/3 p1 + 1/3 p0
|
|
|
|
r2 = 2/3 p1 + 1/3 p2
|
|
|
|
and of course r0 = p0, r3 = p2
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* FIXME: Possible optimization in endpoint calculation
|
|
|
|
if there are two consecutive curves */
|
|
|
|
cubic_control[0] = outline->points[point-1];
|
|
|
|
if (!(outline->tags[point-1] & FT_Curve_Tag_On)) {
|
|
|
|
cubic_control[0].x += outline->points[point].x + 1;
|
|
|
|
cubic_control[0].y += outline->points[point].y + 1;
|
|
|
|
cubic_control[0].x >>= 1;
|
|
|
|
cubic_control[0].y >>= 1;
|
|
|
|
}
|
|
|
|
if (point+1 > outline->contours[contour])
|
|
|
|
cubic_control[3] = outline->points[first_pt];
|
|
|
|
else {
|
|
|
|
cubic_control[3] = outline->points[point+1];
|
|
|
|
if (!(outline->tags[point+1] & FT_Curve_Tag_On)) {
|
|
|
|
cubic_control[3].x += outline->points[point].x + 1;
|
|
|
|
cubic_control[3].y += outline->points[point].y + 1;
|
|
|
|
cubic_control[3].x >>= 1;
|
|
|
|
cubic_control[3].y >>= 1;
|
2014-12-15 07:39:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
/* r1 = 1/3 p0 + 2/3 p1
|
|
|
|
r2 = 1/3 p2 + 2/3 p1 */
|
|
|
|
cubic_control[1].x = (2 * outline->points[point].x + 1) / 3;
|
|
|
|
cubic_control[1].y = (2 * outline->points[point].y + 1) / 3;
|
|
|
|
cubic_control[2] = cubic_control[1];
|
|
|
|
cubic_control[1].x += (cubic_control[0].x + 1) / 3;
|
|
|
|
cubic_control[1].y += (cubic_control[0].y + 1) / 3;
|
|
|
|
cubic_control[2].x += (cubic_control[3].x + 1) / 3;
|
|
|
|
cubic_control[2].y += (cubic_control[3].y + 1) / 3;
|
|
|
|
}
|
2014-12-15 07:39:26 +01:00
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
static inline void set_outline_end_tag(short point, short endpoint, UINT8 *tag)
|
|
|
|
{
|
|
|
|
if (point == endpoint)
|
|
|
|
*tag |= OUTLINE_POINT_END;
|
|
|
|
}
|
2014-12-15 07:39:26 +01:00
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
static short get_outline_data(const FT_Outline *outline, struct glyph_outline *ret)
|
|
|
|
{
|
|
|
|
short contour, point = 0, first_pt, count;
|
2014-12-15 07:39:26 +01:00
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
for (contour = 0, count = 0; contour < outline->n_contours; contour++) {
|
|
|
|
first_pt = point;
|
|
|
|
if (ret) {
|
|
|
|
ft_vector_to_d2d_point(&outline->points[point], &ret->points[count]);
|
|
|
|
ret->tags[count] = OUTLINE_POINT_START;
|
2014-12-15 07:39:26 +01:00
|
|
|
}
|
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
point++;
|
|
|
|
count++;
|
2014-12-15 07:39:26 +01:00
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
while (point <= outline->contours[contour]) {
|
|
|
|
do {
|
|
|
|
if (outline->tags[point] & FT_Curve_Tag_On) {
|
|
|
|
if (ret) {
|
|
|
|
ft_vector_to_d2d_point(&outline->points[point], &ret->points[count]);
|
|
|
|
ret->tags[count] |= OUTLINE_POINT_LINE;
|
|
|
|
set_outline_end_tag(point, outline->contours[contour], &ret->tags[count]);
|
|
|
|
}
|
|
|
|
|
|
|
|
point++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
FT_Vector cubic_control[4];
|
|
|
|
|
|
|
|
get_cubic_glyph_outline(outline, point, first_pt, contour, cubic_control);
|
|
|
|
ft_vector_to_d2d_point(&cubic_control[1], &ret->points[count]);
|
|
|
|
ft_vector_to_d2d_point(&cubic_control[2], &ret->points[count+1]);
|
|
|
|
ft_vector_to_d2d_point(&cubic_control[3], &ret->points[count+2]);
|
|
|
|
ret->tags[count] = OUTLINE_POINT_BEZIER;
|
|
|
|
ret->tags[count+1] = OUTLINE_POINT_BEZIER;
|
|
|
|
ret->tags[count+2] = OUTLINE_POINT_BEZIER;
|
|
|
|
set_outline_end_tag(point, outline->contours[contour], &ret->tags[count+2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
count += 3;
|
|
|
|
point++;
|
|
|
|
}
|
|
|
|
} while (point <= outline->contours[contour] &&
|
|
|
|
(outline->tags[point] & FT_Curve_Tag_On) ==
|
|
|
|
(outline->tags[point-1] & FT_Curve_Tag_On));
|
|
|
|
|
|
|
|
if (point <= outline->contours[contour] &&
|
|
|
|
outline->tags[point] & FT_Curve_Tag_On)
|
|
|
|
{
|
|
|
|
/* This is the closing pt of a bezier, but we've already
|
|
|
|
added it, so just inc point and carry on */
|
|
|
|
point++;
|
2014-12-15 07:39:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
return count;
|
2014-12-15 07:39:26 +01:00
|
|
|
}
|
|
|
|
|
2014-12-15 11:35:03 +01:00
|
|
|
HRESULT freetype_get_glyph_outline(IDWriteFontFace2 *fontface, FLOAT emSize, UINT16 index, USHORT simulations, struct glyph_outline **ret)
|
2014-12-15 07:39:26 +01:00
|
|
|
{
|
|
|
|
FTC_ScalerRec scaler;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
FT_Size size;
|
|
|
|
|
|
|
|
scaler.face_id = fontface;
|
|
|
|
scaler.width = emSize;
|
|
|
|
scaler.height = emSize;
|
|
|
|
scaler.pixel = 1;
|
|
|
|
scaler.x_res = 0;
|
|
|
|
scaler.y_res = 0;
|
|
|
|
|
|
|
|
EnterCriticalSection(&freetype_cs);
|
|
|
|
if (pFTC_Manager_LookupSize(cache_manager, &scaler, &size) == 0) {
|
|
|
|
if (pFT_Load_Glyph(size->face, index, FT_LOAD_DEFAULT) == 0) {
|
|
|
|
FT_Outline *outline = &size->face->glyph->outline;
|
2015-06-09 23:13:34 +02:00
|
|
|
short count;
|
2014-12-15 07:39:26 +01:00
|
|
|
FT_Matrix m;
|
|
|
|
|
2014-12-15 11:35:03 +01:00
|
|
|
m.xx = 1 << 16;
|
|
|
|
m.xy = simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE ? (1 << 16) / 3 : 0;
|
2014-12-15 07:39:26 +01:00
|
|
|
m.yx = 0;
|
2014-12-15 11:35:03 +01:00
|
|
|
m.yy = -(1 << 16); /* flip Y axis */
|
2014-12-15 07:39:26 +01:00
|
|
|
|
|
|
|
pFT_Outline_Transform(outline, &m);
|
|
|
|
|
2015-06-09 23:13:34 +02:00
|
|
|
count = get_outline_data(outline, NULL);
|
|
|
|
hr = new_glyph_outline(count, ret);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
get_outline_data(outline, *ret);
|
2014-12-15 07:39:26 +01:00
|
|
|
(*ret)->advance = size->face->glyph->metrics.horiAdvance >> 6;
|
2015-06-09 23:13:34 +02:00
|
|
|
}
|
2014-12-15 07:39:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&freetype_cs);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-02-05 13:54:05 +01:00
|
|
|
UINT16 freetype_get_glyphcount(IDWriteFontFace2 *fontface)
|
|
|
|
{
|
|
|
|
UINT16 count = 0;
|
|
|
|
FT_Face face;
|
|
|
|
|
|
|
|
EnterCriticalSection(&freetype_cs);
|
|
|
|
if (pFTC_Manager_LookupFace(cache_manager, fontface, &face) == 0)
|
|
|
|
count = face->num_glyphs;
|
|
|
|
LeaveCriticalSection(&freetype_cs);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2015-02-20 11:47:30 +01:00
|
|
|
UINT16 freetype_get_glyphindex(IDWriteFontFace2 *fontface, UINT32 codepoint)
|
|
|
|
{
|
|
|
|
UINT16 glyph;
|
|
|
|
|
|
|
|
EnterCriticalSection(&freetype_cs);
|
|
|
|
glyph = pFTC_CMapCache_Lookup(cmap_cache, fontface, -1, codepoint);
|
|
|
|
LeaveCriticalSection(&freetype_cs);
|
|
|
|
|
|
|
|
return glyph;
|
|
|
|
}
|
|
|
|
|
2015-03-13 20:42:30 +01:00
|
|
|
BOOL freetype_has_kerning_pairs(IDWriteFontFace2 *fontface)
|
|
|
|
{
|
|
|
|
BOOL has_kerning_pairs = FALSE;
|
|
|
|
FT_Face face;
|
|
|
|
|
|
|
|
EnterCriticalSection(&freetype_cs);
|
|
|
|
if (pFTC_Manager_LookupFace(cache_manager, fontface, &face) == 0)
|
|
|
|
has_kerning_pairs = FT_HAS_KERNING(face);
|
|
|
|
LeaveCriticalSection(&freetype_cs);
|
|
|
|
|
|
|
|
return has_kerning_pairs;
|
|
|
|
}
|
|
|
|
|
2015-03-13 21:19:18 +01:00
|
|
|
INT32 freetype_get_kerning_pair_adjustment(IDWriteFontFace2 *fontface, UINT16 left, UINT16 right)
|
|
|
|
{
|
|
|
|
INT32 adjustment = 0;
|
|
|
|
FT_Face face;
|
|
|
|
|
|
|
|
EnterCriticalSection(&freetype_cs);
|
|
|
|
if (pFTC_Manager_LookupFace(cache_manager, fontface, &face) == 0) {
|
|
|
|
FT_Vector kern;
|
|
|
|
if (FT_HAS_KERNING(face)) {
|
|
|
|
pFT_Get_Kerning(face, left, right, FT_KERNING_UNSCALED, &kern);
|
|
|
|
adjustment = kern.x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&freetype_cs);
|
|
|
|
|
|
|
|
return adjustment;
|
|
|
|
}
|
|
|
|
|
2014-11-21 09:48:23 +01:00
|
|
|
#else /* HAVE_FREETYPE */
|
|
|
|
|
|
|
|
BOOL init_freetype(void)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
void release_freetype(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void freetype_notify_cacheremove(IDWriteFontFace2 *fontface)
|
2014-11-21 09:48:23 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-08 11:24:39 +01:00
|
|
|
HRESULT freetype_get_design_glyph_metrics(IDWriteFontFace2 *fontface, UINT16 unitsperEm, UINT16 glyph, DWRITE_GLYPH_METRICS *ret)
|
2014-11-21 09:48:23 +01:00
|
|
|
{
|
2014-12-08 11:24:39 +01:00
|
|
|
return E_NOTIMPL;
|
2014-11-21 09:48:23 +01:00
|
|
|
}
|
|
|
|
|
2014-12-09 07:58:14 +01:00
|
|
|
BOOL freetype_is_monospaced(IDWriteFontFace2 *fontface)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-12-15 11:35:03 +01:00
|
|
|
HRESULT freetype_get_glyph_outline(IDWriteFontFace2 *fontface, FLOAT emSize, UINT16 index, USHORT simulations, struct glyph_outline **ret)
|
2014-12-15 07:39:26 +01:00
|
|
|
{
|
|
|
|
*ret = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2015-02-05 13:54:05 +01:00
|
|
|
UINT16 freetype_get_glyphcount(IDWriteFontFace2 *fontface)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-20 11:47:30 +01:00
|
|
|
UINT16 freetype_get_glyphindex(IDWriteFontFace2 *fontface, UINT32 codepoint)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-13 20:42:30 +01:00
|
|
|
BOOL freetype_has_kerning_pairs(IDWriteFontFace2 *fontface)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-03-13 21:19:18 +01:00
|
|
|
INT32 freetype_get_kerning_pair_adjustment(IDWriteFontFace2 *fontface, UINT16 left, UINT16 right)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-21 09:48:23 +01:00
|
|
|
#endif /* HAVE_FREETYPE */
|