diff options
Diffstat (limited to 'external')
-rw-r--r-- | external/Module_external.mk | 1 | ||||
-rw-r--r-- | external/glyphy/ExternalPackage_glyphy.mk | 22 | ||||
-rw-r--r-- | external/glyphy/ExternalProject_glyphy.mk | 38 | ||||
-rw-r--r-- | external/glyphy/Makefile | 7 | ||||
-rw-r--r-- | external/glyphy/Module_glyphy.mk | 21 | ||||
-rw-r--r-- | external/glyphy/README | 3 | ||||
-rw-r--r-- | external/glyphy/UnpackedTarball_glyphy.mk | 21 | ||||
-rw-r--r-- | external/glyphy/glyphy-upstream.patch.1 | 211 | ||||
-rw-r--r-- | external/glyphy/glyphy-windows.patch.1 | 776 |
9 files changed, 0 insertions, 1100 deletions
diff --git a/external/Module_external.mk b/external/Module_external.mk index 2089546b6429..3b54b52ade88 100644 --- a/external/Module_external.mk +++ b/external/Module_external.mk @@ -46,7 +46,6 @@ $(eval $(call gb_Module_add_moduledirs,external,\ $(call gb_Helper_optional,FREETYPE,freetype) \ $(call gb_Helper_optional,GLEW,glew) \ $(call gb_Helper_optional,GLM,glm) \ - $(call gb_Helper_optional,GLYPHY,glyphy) \ $(call gb_Helper_optional,GRAPHITE,graphite) \ $(call gb_Helper_optional,HARFBUZZ,harfbuzz) \ $(call gb_Helper_optional,HSQLDB,hsqldb) \ diff --git a/external/glyphy/ExternalPackage_glyphy.mk b/external/glyphy/ExternalPackage_glyphy.mk deleted file mode 100644 index b4a32fccc082..000000000000 --- a/external/glyphy/ExternalPackage_glyphy.mk +++ /dev/null @@ -1,22 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_ExternalPackage_ExternalPackage,glyphy,glyphy)) - -$(eval $(call gb_ExternalPackage_use_external_project,glyphy,glyphy)) - -ifeq ($(OS),MACOSX) -$(eval $(call gb_ExternalPackage_add_file,glyphy,$(LIBO_LIB_FOLDER)/libglyphy.dylib,src/.libs/libglyphy.dylib)) -else ifeq ($(OS),WNT) -# We build a static archive with MSVC, so nothing to add -else ifeq ($(DISABLE_DYNLOADING),) -$(eval $(call gb_ExternalPackage_add_file,glyphy,$(LIBO_LIB_FOLDER)/libglyphy.so.0,src/.libs/libglyphy.so.0.0.0)) -endif - -# vim: set noet sw=4 ts=4: diff --git a/external/glyphy/ExternalProject_glyphy.mk b/external/glyphy/ExternalProject_glyphy.mk deleted file mode 100644 index 624318784d57..000000000000 --- a/external/glyphy/ExternalProject_glyphy.mk +++ /dev/null @@ -1,38 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_ExternalProject_ExternalProject,glyphy)) - -$(eval $(call gb_ExternalProject_use_autoconf,glyphy,build)) - -$(eval $(call gb_ExternalProject_register_targets,glyphy,\ - build \ -)) - -$(eval $(call gb_ExternalProject_use_externals,glyphy, \ - glew \ -)) - -$(call gb_ExternalProject_get_state_target,glyphy,build) : - $(call gb_ExternalProject_run,build,\ - $(if $(filter MSC,$(COM)),CPPFLAGS=-D_USE_MATH_DEFINES) \ - MAKE=$(MAKE) ./configure \ - --with-pic \ - $(if $(DISABLE_DYNLOADING), \ - --enable-static --disable-shared \ - , \ - --enable-shared --disable-static \ - ) \ - $(if $(filter MACOSX,$(OS)),--prefix=/@.__________________________________________________OOO) \ - $(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \ - && $(if $(verbose),V=1) \ - $(MAKE) \ - ) - -# vim: set noet sw=4 ts=4: diff --git a/external/glyphy/Makefile b/external/glyphy/Makefile deleted file mode 100644 index e4968cf85fb6..000000000000 --- a/external/glyphy/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- - -module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) - -include $(module_directory)/../../solenv/gbuild/partial_build.mk - -# vim: set noet sw=4 ts=4: diff --git a/external/glyphy/Module_glyphy.mk b/external/glyphy/Module_glyphy.mk deleted file mode 100644 index 6228bba24de7..000000000000 --- a/external/glyphy/Module_glyphy.mk +++ /dev/null @@ -1,21 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_Module_Module,glyphy)) - -$(eval $(call gb_Module_add_targets,glyphy,\ - UnpackedTarball_glyphy \ -)) - -$(eval $(call gb_Module_add_targets,glyphy,\ - ExternalPackage_glyphy \ - ExternalProject_glyphy \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/external/glyphy/README b/external/glyphy/README deleted file mode 100644 index 7d6445c9dc0d..000000000000 --- a/external/glyphy/README +++ /dev/null @@ -1,3 +0,0 @@ -GLyphy is a text renderer that uses OpenGL - -https://github.com/behdad/glyphy diff --git a/external/glyphy/UnpackedTarball_glyphy.mk b/external/glyphy/UnpackedTarball_glyphy.mk deleted file mode 100644 index 08512b9a761f..000000000000 --- a/external/glyphy/UnpackedTarball_glyphy.mk +++ /dev/null @@ -1,21 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_UnpackedTarball_UnpackedTarball,glyphy)) - -$(eval $(call gb_UnpackedTarball_set_tarball,glyphy,$(GLYPHY_TARBALL))) - -$(eval $(call gb_UnpackedTarball_set_patchlevel,glyphy,1)) - -$(eval $(call gb_UnpackedTarball_add_patches,glyphy,\ - external/glyphy/glyphy-upstream.patch.1 \ - external/glyphy/glyphy-windows.patch.1 \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/external/glyphy/glyphy-upstream.patch.1 b/external/glyphy/glyphy-upstream.patch.1 deleted file mode 100644 index f898918f4c8f..000000000000 --- a/external/glyphy/glyphy-upstream.patch.1 +++ /dev/null @@ -1,211 +0,0 @@ -From d6d6c61c8d0e336c34ba3f5d9adbe923ffa1cbe3 Mon Sep 17 00:00:00 2001 -From: Behdad Esfahbod <behdad@behdad.org> -Date: Thu, 6 Aug 2015 15:34:38 +0100 -Subject: [PATCH 2/6] Implement more robust winding-direction algorithm - -Fixes 'p' in Comic Sans Bold for example. That font has many -self-intersecting contours. The one in 'p' was causing complete -winding direction reversal using old algorithm. Implement area-based -algorithm. ---- - src/glyphy-outline.cc | 67 ++++++++++----------------------------------------- - 1 file changed, 13 insertions(+), 54 deletions(-) - -diff --git a/src/glyphy-outline.cc b/src/glyphy-outline.cc -index 3543f3b..ef71247 100644 ---- a/src/glyphy-outline.cc -+++ b/src/glyphy-outline.cc -@@ -55,65 +55,24 @@ winding (const glyphy_arc_endpoint_t *endpoints, - /* - * Algorithm: - * -- * - Find the lowest-x part of the contour, -- * - If the point is an endpoint: -- * o compare the angle of the incoming and outgoing edges of that point -- * to find out whether it's CW or CCW, -- * - Otherwise, compare the y of the two endpoints of the arc with lowest-x point. -- * -- * Note: -- * -- * We can use a simpler algorithm here: Act as if arcs are lines, then use the -- * triangle method to calculate the signed area of the contour and get the sign. -- * It should work for all cases we care about. The only case failing would be -- * that of two endpoints and two arcs. But we can even special-case that. -+ * - Approximate arcs with triangles passing through the mid- and end-points, -+ * - Calculate the area of the contour, -+ * - Return sign. - */ - -- unsigned int corner = 1; -- for (unsigned int i = 2; i < num_endpoints; i++) -- if (endpoints[i].p.x < endpoints[corner].p.x || -- (endpoints[i].p.x == endpoints[corner].p.x && -- endpoints[i].p.y < endpoints[corner].p.y)) -- corner = i; -- -- double min_x = endpoints[corner].p.x; -- int winner = -1; -- Point p0 (0, 0); -- for (unsigned int i = 0; i < num_endpoints; i++) { -- const glyphy_arc_endpoint_t &endpoint = endpoints[i]; -- if (endpoint.d == GLYPHY_INFINITY || endpoint.d == 0 /* arcs only, not lines */) { -- p0 = endpoint.p; -- continue; -- } -- Arc arc (p0, endpoint.p, endpoint.d); -- p0 = endpoint.p; -+ double area = 0; -+ for (unsigned int i = 1; i < num_endpoints; i++) -+ { -+ const glyphy_point_t &p0 = endpoints[i - 1].p; -+ const glyphy_point_t &p1 = endpoints[i].p; -+ double d = endpoints[i].d; - -- Point c = arc.center (); -- double r = arc.radius (); -- if (c.x - r < min_x && arc.wedge_contains_point (c - Vector (r, 0))) { -- min_x = c.x - r; -- winner = i; -- } -- } -+ assert (d != GLYPHY_INFINITY); - -- if (winner == -1) -- { -- // Corner is lowest-x. Find the tangents of the two arcs connected to the -- // corner and compare the tangent angles to get contour direction. -- const glyphy_arc_endpoint_t ethis = endpoints[corner]; -- const glyphy_arc_endpoint_t eprev = endpoints[corner - 1]; -- const glyphy_arc_endpoint_t enext = endpoints[corner < num_endpoints - 1 ? corner + 1 : 1]; -- double in = (-Arc (eprev.p, ethis.p, ethis.d).tangents ().second).angle (); -- double out = (+Arc (ethis.p, enext.p, enext.d).tangents ().first ).angle (); -- return out > in; -+ area += p0.x*p1.y - p0.y*p1.x; -+ area -= .5 * d * ((p1.x-p0.x)*(p1.x-p0.x) + (p1.y-p0.y)*(p1.y-p0.y)); - } -- else -- { -- // Easy. -- return endpoints[winner].d < 0; -- } -- -- return false; -+ return area < 0; - } - - --- -2.5.0 - -From 644c5bab6e7f0e5af8f42fa7a8075372716c66d3 Mon Sep 17 00:00:00 2001 -From: Behdad Esfahbod <behdad@behdad.org> -Date: Thu, 6 Aug 2015 15:49:37 +0100 -Subject: [PATCH 3/6] Start handling fully-degenerate curves - ---- - src/glyphy-arcs-bezier.hh | 7 +++++++ - src/glyphy-geometry.hh | 4 ++++ - 2 files changed, 11 insertions(+) - -diff --git a/src/glyphy-arcs-bezier.hh b/src/glyphy-arcs-bezier.hh -index ab729cb..32b7c8c 100644 ---- a/src/glyphy-arcs-bezier.hh -+++ b/src/glyphy-arcs-bezier.hh -@@ -103,6 +103,13 @@ class ArcsBezierApproximatorSpringSystem - double *perror, - unsigned int max_segments = 100) - { -+ /* Handle fully-degenerate cases. */ -+ Vector v1 (b.p1 - b.p0); -+ Vector v2 (b.p2 - b.p0); -+ Vector v3 (b.p3 - b.p0); -+ if (fabs (v1.cross(v2)) < GLYPHY_EPSILON && fabs (v2.cross(v3)) < GLYPHY_EPSILON) -+ ;//TODO -+ - std::vector<double> t; - std::vector<double> e; - double max_e, min_e; -diff --git a/src/glyphy-geometry.hh b/src/glyphy-geometry.hh -index f5f6003..3c60856 100644 ---- a/src/glyphy-geometry.hh -+++ b/src/glyphy-geometry.hh -@@ -99,6 +99,7 @@ struct Vector { - inline const Vector normal (void) const; /* ortho().normalized() */ - inline double angle (void) const; - -+ inline double cross (const Vector &other) const; - inline const Vector rebase (const Vector &bx, const Vector &by) const; - inline const Vector rebase (const Vector &bx) const; - -@@ -345,6 +346,9 @@ inline double Vector::angle (void) const { - return atan2 (dy, dx); - } - -+inline double Vector::cross (const Vector &other) const { -+ return dx * other.dy - dy * other.dx; -+} - inline const Vector Vector::rebase (const Vector &bx, - const Vector &by) const { - return Vector (*this * bx, *this * by); --- -2.5.0 - -From 5667ab11a3d5f57bb89c4e8970d26b940d36964a Mon Sep 17 00:00:00 2001 -From: Behdad Esfahbod <behdad@behdad.org> -Date: Thu, 6 Aug 2015 15:51:15 +0100 -Subject: [PATCH 4/6] Simplify winding() - ---- - src/glyphy-outline.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/glyphy-outline.cc b/src/glyphy-outline.cc -index ef71247..7fded28 100644 ---- a/src/glyphy-outline.cc -+++ b/src/glyphy-outline.cc -@@ -69,8 +69,8 @@ winding (const glyphy_arc_endpoint_t *endpoints, - - assert (d != GLYPHY_INFINITY); - -- area += p0.x*p1.y - p0.y*p1.x; -- area -= .5 * d * ((p1.x-p0.x)*(p1.x-p0.x) + (p1.y-p0.y)*(p1.y-p0.y)); -+ area += Vector(p0).cross (Vector(p1)); -+ area -= .5 * d * (Point(p1) - Point(p0)).len2 (); - } - return area < 0; - } --- -2.5.0 - -From 16fa0a713295a76f3075e6732007dca2dd38d11e Mon Sep 17 00:00:00 2001 -From: Behdad Esfahbod <behdad@behdad.org> -Date: Thu, 6 Aug 2015 16:00:19 +0100 -Subject: [PATCH 5/6] Better handle fully-degenerate curves - ---- - src/glyphy-arcs-bezier.hh | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/src/glyphy-arcs-bezier.hh b/src/glyphy-arcs-bezier.hh -index 32b7c8c..ac210c0 100644 ---- a/src/glyphy-arcs-bezier.hh -+++ b/src/glyphy-arcs-bezier.hh -@@ -108,7 +108,14 @@ class ArcsBezierApproximatorSpringSystem - Vector v2 (b.p2 - b.p0); - Vector v3 (b.p3 - b.p0); - if (fabs (v1.cross(v2)) < GLYPHY_EPSILON && fabs (v2.cross(v3)) < GLYPHY_EPSILON) -- ;//TODO -+ { -+ /* Curve has no area. If endpoints are NOT the same, replace with single -+ * line segment. Otherwise fully skip. */ -+ arcs.clear (); -+ if (b.p0 != b.p1) -+ arcs.push_back (Arc (b.p0, b.p1, 0)); -+ return; -+ } - - std::vector<double> t; - std::vector<double> e; --- -2.5.0 - diff --git a/external/glyphy/glyphy-windows.patch.1 b/external/glyphy/glyphy-windows.patch.1 deleted file mode 100644 index 99f7bccc5c14..000000000000 --- a/external/glyphy/glyphy-windows.patch.1 +++ /dev/null @@ -1,776 +0,0 @@ -From cfc3157868f691b70c2f0a6daa3c387ca6ef42a9 Mon Sep 17 00:00:00 2001 -From: Tor Lillqvist <tml@collabora.com> -Date: Tue, 10 Nov 2015 00:20:42 +0200 -Subject: [PATCH 1/3] Port glyphy-demo to Windows - -You will need glew and freeglut to build and run it. - -I have a VS solution for glyphy-demo, but did not commit that as I did -not bother to do it "properly", with different projects for the -library and the demo executable, Release and Debug configurations etc. ---- - demo/demo-buffer.cc | 11 ++++ - demo/demo-common.h | 6 ++ - demo/demo-font.cc | 131 +++++++++++++++++++++++++++++++++++--------- - demo/demo-font.h | 21 ++++++- - demo/demo-view.cc | 3 +- - demo/glyphy-demo.cc | 134 ++++++++++++++++++++++++++++++++++++++++++++- - src/Makefile.am | 1 + - src/glyphy-windows.h | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 8 files changed, 429 insertions(+), 30 deletions(-) - create mode 100755 src/glyphy-windows.h - -diff --git a/demo/demo-buffer.cc b/demo/demo-buffer.cc -index 698f4ee..8ce5b34 100644 ---- a/demo/demo-buffer.cc -+++ b/demo/demo-buffer.cc -@@ -106,7 +106,11 @@ demo_buffer_add_text (demo_buffer_t *buffer, - demo_font_t *font, - double font_size) - { -+#ifndef _WIN32 - FT_Face face = demo_font_get_face (font); -+#else -+ HDC hdc = demo_font_get_face (font); -+#endif - glyphy_point_t top_left = buffer->cursor; - buffer->cursor.y += font_size /* * font->ascent */; - unsigned int unicode; -@@ -138,7 +142,14 @@ demo_buffer_add_text (demo_buffer_t *buffer, - continue; - } - -+#ifndef _WIN32 - unsigned int glyph_index = FT_Get_Char_Index (face, unicode); -+#else -+ wchar_t wc = unicode; /* FIXME: What about non-BMP chars? */ -+ WORD glyph_index; -+ if (GetGlyphIndicesW (hdc, &wc, 1, &glyph_index, GGI_MARK_NONEXISTING_GLYPHS) == GDI_ERROR) -+ die ("GetGlyphIndicesW failed"); -+#endif - glyph_info_t gi; - demo_font_lookup_glyph (font, glyph_index, &gi); - -diff --git a/demo/demo-common.h b/demo/demo-common.h -index dd0feb9..da56a88 100644 ---- a/demo/demo-common.h -+++ b/demo/demo-common.h -@@ -44,6 +44,12 @@ - # define HAVE_GLUT 1 - #endif - -+#ifdef _WIN32 -+# define HAVE_GL 1 -+# define HAVE_GLEW 1 -+# define HAVE_GLUT 1 -+#endif -+ - /* Get Glew out of the way. */ - #ifdef HAVE_GLEW - # include <GL/glew.h> -diff --git a/demo/demo-font.cc b/demo/demo-font.cc -index 4ed4b53..b43b1e3 100644 ---- a/demo/demo-font.cc -+++ b/demo/demo-font.cc -@@ -22,19 +22,30 @@ - - #include "demo-font.h" - -+#ifndef _WIN32 - #include <glyphy-freetype.h> -+#endif - --#include <ext/hash_map> -- --using namespace __gnu_cxx; /* This is ridiculous */ -+#ifdef _WIN32 -+#include <glyphy-windows.h> -+#endif - -+#include <map> -+#include <vector> - --typedef hash_map<unsigned int, glyph_info_t> glyph_cache_t; -+typedef std::map<unsigned int, glyph_info_t> glyph_cache_t; - - struct demo_font_t { - unsigned int refcount; - -+#ifndef _WIN32 - FT_Face face; -+#endif -+ -+#ifdef _WIN32 -+ HDC face; /* A memory DC that has the font instance selected into it */ -+#endif -+ - glyph_cache_t *glyph_cache; - demo_atlas_t *atlas; - glyphy_arc_accumulator_t *acc; -@@ -48,7 +59,13 @@ struct demo_font_t { - }; - - demo_font_t * --demo_font_create (FT_Face face, -+demo_font_create ( -+#ifndef _WIN32 -+ FT_Face face, -+#endif -+#ifdef _WIN32 -+ HDC face, -+#endif - demo_atlas_t *atlas) - { - demo_font_t *font = (demo_font_t *) calloc (1, sizeof (demo_font_t)); -@@ -88,7 +105,12 @@ demo_font_destroy (demo_font_t *font) - } - - -+#ifndef _WIN32 - FT_Face -+#endif -+#ifdef _WIN32 -+HDC -+#endif - demo_font_get_face (demo_font_t *font) - { - return font->face; -@@ -103,27 +125,28 @@ demo_font_get_atlas (demo_font_t *font) - - static glyphy_bool_t - accumulate_endpoint (glyphy_arc_endpoint_t *endpoint, -- vector<glyphy_arc_endpoint_t> *endpoints) -+ std::vector<glyphy_arc_endpoint_t> *endpoints) - { - endpoints->push_back (*endpoint); - return true; - } - - static void --encode_ft_glyph (demo_font_t *font, -- unsigned int glyph_index, -- double tolerance_per_em, -- glyphy_rgba_t *buffer, -- unsigned int buffer_len, -- unsigned int *output_len, -- unsigned int *nominal_width, -- unsigned int *nominal_height, -- glyphy_extents_t *extents, -- double *advance) -+encode_glyph (demo_font_t *font, -+ unsigned int glyph_index, -+ double tolerance_per_em, -+ glyphy_rgba_t *buffer, -+ unsigned int buffer_len, -+ unsigned int *output_len, -+ unsigned int *nominal_width, -+ unsigned int *nominal_height, -+ glyphy_extents_t *extents, -+ double *advance) - { - /* Used for testing only */ - #define SCALE (1. * (1 << 0)) - -+#ifndef _WIN32 - FT_Face face = font->face; - if (FT_Err_Ok != FT_Load_Glyph (face, - glyph_index, -@@ -141,7 +164,7 @@ encode_ft_glyph (demo_font_t *font, - unsigned int upem = face->units_per_EM; - double tolerance = upem * tolerance_per_em; /* in font design units */ - double faraway = double (upem) / (MIN_FONT_SIZE * M_SQRT2); -- vector<glyphy_arc_endpoint_t> endpoints; -+ std::vector<glyphy_arc_endpoint_t> endpoints; - - glyphy_arc_accumulator_reset (font->acc); - glyphy_arc_accumulator_set_tolerance (font->acc, tolerance); -@@ -151,6 +174,55 @@ encode_ft_glyph (demo_font_t *font, - - if (FT_Err_Ok != glyphy_freetype(outline_decompose) (&face->glyph->outline, font->acc)) - die ("Failed converting glyph outline to arcs"); -+#endif -+ -+#ifdef _WIN32 -+ HDC hdc = font->face; -+ -+ GLYPHMETRICS glyph_metrics; -+ MAT2 matrix; -+ -+ matrix.eM11.value = 1; -+ matrix.eM11.fract = 0; -+ matrix.eM12.value = 0; -+ matrix.eM12.fract = 0; -+ matrix.eM21.value = 0; -+ matrix.eM21.fract = 0; -+ matrix.eM22.value = 1; -+ matrix.eM22.fract = 0; -+ -+ DWORD size = GetGlyphOutlineW (hdc, glyph_index, GGO_NATIVE|GGO_GLYPH_INDEX, &glyph_metrics, 0, NULL, &matrix); -+ if (size == GDI_ERROR) -+ die ("GetGlyphOutlineW failed"); -+ std::vector<char> buf(size); -+ size = GetGlyphOutlineW (hdc, glyph_index, GGO_NATIVE|GGO_GLYPH_INDEX, &glyph_metrics, size, buf.data(), &matrix); -+ if (size == GDI_ERROR) -+ die ("GetGlyphOutlineW failed"); -+ -+ size = GetGlyphOutlineW (hdc, glyph_index, GGO_METRICS|GGO_GLYPH_INDEX, &glyph_metrics, 0, NULL, &matrix); -+ if (size == GDI_ERROR) -+ die ("GetGlyphOutlineW failed"); -+ -+ OUTLINETEXTMETRICW outline_text_metric; -+ if (!GetOutlineTextMetricsW (hdc, sizeof (OUTLINETEXTMETRICW), &outline_text_metric)) -+ die ("GetOutlineTextMetricsW failed"); -+ -+ unsigned int upem = outline_text_metric.otmEMSquare; -+ double tolerance = upem * tolerance_per_em; /* in font design units */ -+ double faraway = double (upem) / (MIN_FONT_SIZE * M_SQRT2); -+ std::vector<glyphy_arc_endpoint_t> endpoints; -+ -+ fprintf(stderr, "upem=%u tolerance=%f faraway=%f\n", upem, tolerance, faraway); -+ -+ glyphy_arc_accumulator_reset (font->acc); -+ glyphy_arc_accumulator_set_tolerance (font->acc, tolerance); -+ glyphy_arc_accumulator_set_callback (font->acc, -+ (glyphy_arc_endpoint_accumulator_callback_t) accumulate_endpoint, -+ &endpoints); -+ -+ if (0 != glyphy_windows(outline_decompose) ((TTPOLYGONHEADER *) buf.data(), buf.size(), font->acc)) -+ die ("Failed converting glyph outline to arcs"); -+#endif - - assert (glyphy_arc_accumulator_get_error (font->acc) <= tolerance); - -@@ -192,7 +264,14 @@ encode_ft_glyph (demo_font_t *font, - glyphy_extents_scale (extents, 1. / upem, 1. / upem); - glyphy_extents_scale (extents, SCALE, SCALE); - -+#ifndef _WIN32 - *advance = face->glyph->metrics.horiAdvance / (double) upem; -+#endif -+ -+#ifdef _WIN32 -+ *advance = glyph_metrics.gmCellIncX / (double) upem; /* ??? */ -+ fprintf(stderr, "======> Advance: %f\n", *advance); -+#endif - - if (0) - LOGI ("gid%3u: endpoints%3d; err%3g%%; tex fetch%4.1f; mem%4.1fkb\n", -@@ -217,15 +296,15 @@ _demo_font_upload_glyph (demo_font_t *font, - glyphy_rgba_t buffer[4096 * 16]; - unsigned int output_len; - -- encode_ft_glyph (font, -- glyph_index, -- TOLERANCE, -- buffer, ARRAY_LEN (buffer), -- &output_len, -- &glyph_info->nominal_w, -- &glyph_info->nominal_h, -- &glyph_info->extents, -- &glyph_info->advance); -+ encode_glyph (font, -+ glyph_index, -+ TOLERANCE, -+ buffer, ARRAY_LEN (buffer), -+ &output_len, -+ &glyph_info->nominal_w, -+ &glyph_info->nominal_h, -+ &glyph_info->extents, -+ &glyph_info->advance); - - glyph_info->is_empty = glyphy_extents_is_empty (&glyph_info->extents); - if (!glyph_info->is_empty) -diff --git a/demo/demo-font.h b/demo/demo-font.h -index ddc45ed..d4e75ff 100644 ---- a/demo/demo-font.h -+++ b/demo/demo-font.h -@@ -22,9 +22,17 @@ - #include "demo-common.h" - #include "demo-atlas.h" - -+#ifndef _WIN32 - #include <ft2build.h> - #include FT_FREETYPE_H -+#endif - -+#ifdef _WIN32 -+#include <windows.h> -+#define DEFAULT_FONT "Calibri" -+#undef near -+#undef far -+#endif - - typedef struct { - glyphy_extents_t extents; -@@ -40,7 +48,13 @@ typedef struct { - typedef struct demo_font_t demo_font_t; - - demo_font_t * --demo_font_create (FT_Face face, -+demo_font_create ( -+#ifndef _WIN32 -+ FT_Face face, -+#endif -+#ifdef _WIN32 -+ HDC hdc, -+#endif - demo_atlas_t *atlas); - - demo_font_t * -@@ -50,7 +64,12 @@ void - demo_font_destroy (demo_font_t *font); - - -+#ifndef _WIN32 - FT_Face -+#endif -+#ifdef _WIN32 -+HDC -+#endif - demo_font_get_face (demo_font_t *font); - - demo_atlas_t * -diff --git a/demo/demo-view.cc b/demo/demo-view.cc -index b60fc24..fee3e23 100644 ---- a/demo/demo-view.cc -+++ b/demo/demo-view.cc -@@ -27,8 +27,9 @@ extern "C" { - #include "matrix4x4.h" - } - -+#ifndef _WIN32 - #include <sys/time.h> -- -+#endif - - struct demo_view_t { - unsigned int refcount; -diff --git a/demo/glyphy-demo.cc b/demo/glyphy-demo.cc -index cf412cc..bc71dff 100644 ---- a/demo/glyphy-demo.cc -+++ b/demo/glyphy-demo.cc -@@ -20,14 +20,15 @@ - #include <config.h> - #endif - -+#ifndef _WIN32 - #include <libgen.h> -+#include <unistd.h> -+#endif - #include <stdio.h> - #include <string.h> --#include <unistd.h> - #include <ctype.h> - #include <stdlib.h> - -- - #include "demo-buffer.h" - #include "demo-font.h" - #include "demo-view.h" -@@ -39,6 +40,90 @@ static demo_buffer_t *buffer; - #define WINDOW_W 700 - #define WINDOW_H 700 - -+#ifdef _WIN32 -+ -+static int isroot(const char *path) -+{ -+ return ((strlen(path) == 1 && path[0] == '/') || -+ (strlen(path) == 3 && isalpha(path[0]) && path[1] == ':' && (path[2] == '/' || path[2] == '\\'))); -+} -+ -+static char *basename(char *path) -+{ -+ if (path == NULL || *path == '\0') -+ return "."; -+ -+ while ((path[strlen(path)-1] == '/' || -+ path[strlen(path)-1] == '\\') && -+ !isroot(path)) -+ path[strlen(path)-1] = '\0'; -+ -+ if (isroot(path)) -+ return path; -+ -+ char *slash = strrchr(path, '/'); -+ char *backslash = strrchr(path, '\\'); -+ -+ if (slash != NULL && (backslash == NULL || backslash < slash)) -+ return slash + 1; -+ else if (backslash != NULL && (slash == NULL || slash < backslash)) -+ return backslash + 1; -+ else -+ return path; -+} -+ -+static int opterr = 1; -+static int optind = 1; -+static int optopt; -+static char *optarg; -+ -+static int getopt(int argc, char *argv[], char *opts) -+{ -+ static int sp = 1; -+ int c; -+ char *cp; -+ -+ if (sp == 1) { -+ if (optind >= argc || -+ argv[optind][0] != '-' || argv[optind][1] == '\0') -+ return EOF; -+ else if (!strcmp(argv[optind], "--")) { -+ optind++; -+ return EOF; -+ } -+ } -+ optopt = c = argv[optind][sp]; -+ if (c == ':' || !(cp = strchr(opts, c))) { -+ fprintf(stderr, ": illegal option -- %c\n", c); -+ if (argv[optind][++sp] == '\0') { -+ optind++; -+ sp = 1; -+ } -+ return '?'; -+ } -+ if (*++cp == ':') { -+ if (argv[optind][sp+1] != '\0') -+ optarg = &argv[optind++][sp+1]; -+ else if(++optind >= argc) { -+ fprintf(stderr, ": option requires an argument -- %c\n", c); -+ sp = 1; -+ return '?'; -+ } else -+ optarg = argv[optind++]; -+ sp = 1; -+ } else { -+ if (argv[optind][++sp] == '\0') { -+ sp = 1; -+ optind++; -+ } -+ optarg = NULL; -+ } -+ -+ return c; -+} -+ -+#endif -+ - static void - reshape_func (int width, int height) - { -@@ -161,6 +246,7 @@ main (int argc, char** argv) - vu = demo_view_create (st); - demo_view_print_help (vu); - -+#ifndef _WIN32 - FT_Library ft_library; - FT_Init_FreeType (&ft_library); - FT_Face ft_face; -@@ -173,6 +259,42 @@ main (int argc, char** argv) - if (!ft_face) - die ("Failed to open font file"); - demo_font_t *font = demo_font_create (ft_face, demo_glstate_get_atlas (st)); -+#endif -+ -+#ifdef _WIN32 -+ HDC hdc = CreateCompatibleDC (GetDC (NULL)); -+ if (hdc == NULL) -+ die ("GetDC or CreateCompatibleDC failed"); -+ -+ /* First create an instance of the font at size 10 to get the OUTLINETEXTMETRIC from which to get -+ * the font's em unit. Then, to get an unmodified not grid-fitted glyph outline, create it anew at -+ * that size. That is as the doc for GetGlyphOutline() suggests. -+ */ -+ HFONT hfont = CreateFontA(10, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FF_DONTCARE, font_path); -+ if (hfont == NULL) -+ die ("CreateFontA failed"); -+ -+ HFONT old_hfont = (HFONT) SelectObject (hdc, hfont); -+ if (old_hfont == NULL) -+ die ("SelectObject failed"); -+ -+ OUTLINETEXTMETRICW outline_text_metric; -+ if (!GetOutlineTextMetricsW (hdc, sizeof (OUTLINETEXTMETRICW), &outline_text_metric)) -+ die ("GetOutlineTextMetricsW failed"); -+ -+ SelectObject (hdc, old_hfont); -+ -+ hfont = CreateFontA (outline_text_metric.otmEMSquare, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FF_DONTCARE, font_path); -+ if (hfont == NULL) -+ die ("CreateFontA failed"); -+ -+ old_hfont = (HFONT) SelectObject (hdc, hfont); -+ if (old_hfont == NULL) -+ die ("SelectObject failed"); -+ -+ demo_font_t *font = demo_font_create (hdc, demo_glstate_get_atlas (st)); -+ -+#endif - - buffer = demo_buffer_create (); - glyphy_point_t top_left = {0, 0}; -@@ -187,8 +309,16 @@ main (int argc, char** argv) - demo_buffer_destroy (buffer); - demo_font_destroy (font); - -+#ifndef _WIN32 - FT_Done_Face (ft_face); - FT_Done_FreeType (ft_library); -+#endif -+ -+#ifdef _WIN32 -+ SelectObject (hdc, old_hfont); -+ DeleteObject (hfont); -+ DeleteDC (hdc); -+#endif - - demo_view_destroy (vu); - demo_glstate_destroy (st); -diff --git a/src/Makefile.am b/src/Makefile.am -index 004afd3..ecb76e0 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -32,6 +32,7 @@ libglyphy_la_SOURCES = \ - PUBLICHEADERS = \ - glyphy.h \ - glyphy-freetype.h \ -+ glyphy-windows.h \ - $(NULL) - SHADERS = \ - glyphy-common.glsl \ ---- a/src/Makefile.in -+++ b/src/Makefile.in -@@ -32,6 +32,7 @@ libglyphy_la_SOURCES = \ - PUBLICHEADERS = \ - glyphy.h \ - glyphy-freetype.h \ -+ glyphy-windows.h \ - $(NULL) - - SHADERS = \ -diff --git a/src/glyphy-windows.h b/src/glyphy-windows.h -new file mode 100755 -index 0000000..b3c11c8 ---- /dev/null -+++ b/src/glyphy-windows.h -@@ -0,0 +1,152 @@ -+/* -+ * Copyright 2012 Google, Inc. All Rights Reserved. -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ * -+ * Google Author(s): Behdad Esfahbod, Maysum Panju -+ */ -+ -+/* Intentionally doesn't have include guards */ -+ -+#include "glyphy.h" -+ -+#include <windows.h> -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+ -+#ifndef GLYPHY_WINDOWS__PREFIX -+#define GLYPHY_WINDOWS_PREFIX glyphy_windows_ -+#endif -+ -+#ifndef glyphy_windows -+#define glyphy_windows(name) GLYPHY_PASTE (GLYPHY_WINDOWS_PREFIX, name) -+#endif -+ -+static double fixed_to_double(FIXED f) -+{ -+ return f.value + f.fract / double(0x10000); -+} -+ -+static int -+glyphy_windows(move_to) (const POINTFX *to, -+ glyphy_arc_accumulator_t *acc) -+{ -+ glyphy_point_t p1 = {fixed_to_double(to->x), fixed_to_double(to->y)}; -+ glyphy_arc_accumulator_close_path (acc); -+ glyphy_arc_accumulator_move_to (acc, &p1); -+ return glyphy_arc_accumulator_successful (acc) ? 0 : -1; -+} -+ -+static int -+glyphy_windows(line_to) (const POINTFX *to, -+ glyphy_arc_accumulator_t *acc) -+{ -+ glyphy_point_t p1 = {fixed_to_double(to->x), fixed_to_double(to->y)}; -+ glyphy_arc_accumulator_line_to (acc, &p1); -+ return glyphy_arc_accumulator_successful (acc) ? 0 : -1; -+} -+ -+static int -+glyphy_windows(conic_to) (const POINTFX *control, -+ const glyphy_point_t *p2, -+ glyphy_arc_accumulator_t *acc) -+{ -+ glyphy_point_t p1 = {fixed_to_double(control->x), fixed_to_double(control->y)}; -+ glyphy_arc_accumulator_conic_to (acc, &p1, p2); -+ return glyphy_arc_accumulator_successful (acc) ? 0 : -1; -+} -+ -+/* See https://support.microsoft.com/en-us/kb/87115 */ -+ -+static int -+glyphy_windows(outline_decompose) (const TTPOLYGONHEADER *outline, -+ size_t outline_size, -+ glyphy_arc_accumulator_t *acc) -+{ -+ const TTPOLYGONHEADER *polygon = outline; -+ const TTPOLYGONHEADER *outline_end = (const TTPOLYGONHEADER*) ((char *)outline + outline_size); -+ -+ int polygon_count = 0; -+ while (polygon < outline_end) -+ { -+ if (((char *)polygon + polygon->cb) > (char *) outline_end) -+ die ("TTPOLYGONHEADER record too large for enclosing data"); -+ -+ assert(polygon->dwType == TT_POLYGON_TYPE); -+ -+ if (glyphy_windows(move_to) (&polygon->pfxStart, acc) == -1) -+ return -1; -+ -+ const TTPOLYCURVE *curve = (const TTPOLYCURVE*) (polygon + 1); -+ const TTPOLYCURVE *curve_end = (const TTPOLYCURVE*) ((char *)polygon + polygon->cb); -+ int curve_count = 0; -+ while (curve < curve_end) -+ { -+ if (((char *) &curve->apfx[curve->cpfx]) > (char *) curve_end) -+ die ("TTPOLYCURVE record too large for enclosing TTPOLYGONHEADER\n"); -+ -+ switch (curve->wType) -+ { -+ case TT_PRIM_LINE: -+ { -+ int i; -+ for (i = 0; i < curve->cpfx; i++) { -+ if (glyphy_windows(line_to) (&curve->apfx[i], acc) == -1) -+ return -1; -+ } -+ -+ /* A final TT_PRIM_LINE in a contour automatically closes to the contour start */ -+ if ((const TTPOLYCURVE *) ((char *) &curve->apfx[curve->cpfx]) == curve_end) -+ if (glyphy_windows(line_to) (&polygon->pfxStart, acc) == -1) -+ return -1; -+ } -+ break; -+ case TT_PRIM_QSPLINE: -+ { -+ int i = 0; -+ while (i < curve->cpfx) { -+ const POINTFX *control = &curve->apfx[i]; -+ i++; -+ const POINTFX *p2 = &curve->apfx[i]; -+ glyphy_point_t p2pt = {fixed_to_double(p2->x), fixed_to_double(p2->y)}; -+ if (i == curve->cpfx - 1) { -+ i++; -+ } else { -+ p2pt.x = (p2pt.x + fixed_to_double(control->x)) / 2; -+ p2pt.y = (p2pt.y + fixed_to_double(control->y)) / 2; -+ } -+ if (glyphy_windows(conic_to) (control, &p2pt, acc) == -1) -+ return -1; -+ } -+ /* If the last point of the contour was not the start point, draw a closing line to it */ -+ if ((const TTPOLYCURVE *) ((char *) &curve->apfx[curve->cpfx]) == curve_end) -+ if (glyphy_windows(line_to) (&polygon->pfxStart, acc) == -1) -+ return -1; -+ } -+ break; -+ default: -+ die ("Unexpected record in TTPOLYCURVE"); -+ } -+ curve = (const TTPOLYCURVE *) ((char *) &curve->apfx[curve->cpfx]); -+ } -+ polygon = (const TTPOLYGONHEADER *) curve_end; -+ } -+ return 0; -+} -+ -+#ifdef __cplusplus -+} -+#endif --- -2.4.3 - -From 6d4196a2dc59324d14d3d4d721929e851277da97 Mon Sep 17 00:00:00 2001 -From: Tor Lillqvist <tml@collabora.com> -Date: Tue, 10 Nov 2015 13:35:17 +0200 -Subject: [PATCH 2/3] Bin leftover printf - ---- - demo/demo-font.cc | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/demo/demo-font.cc b/demo/demo-font.cc -index b43b1e3..c28778e 100644 ---- a/demo/demo-font.cc -+++ b/demo/demo-font.cc -@@ -212,8 +212,6 @@ encode_glyph (demo_font_t *font, - double faraway = double (upem) / (MIN_FONT_SIZE * M_SQRT2); - std::vector<glyphy_arc_endpoint_t> endpoints; - -- fprintf(stderr, "upem=%u tolerance=%f faraway=%f\n", upem, tolerance, faraway); -- - glyphy_arc_accumulator_reset (font->acc); - glyphy_arc_accumulator_set_tolerance (font->acc, tolerance); - glyphy_arc_accumulator_set_callback (font->acc, -@@ -270,7 +268,6 @@ encode_glyph (demo_font_t *font, - - #ifdef _WIN32 - *advance = glyph_metrics.gmCellIncX / (double) upem; /* ??? */ -- fprintf(stderr, "======> Advance: %f\n", *advance); - #endif - - if (0) --- -2.4.3 - -From 45ad6c9336e78b0fc5aeec4cd7d602333751a93f Mon Sep 17 00:00:00 2001 -From: Tor Lillqvist <tml@collabora.com> -Date: Thu, 19 Nov 2015 15:31:04 +0200 -Subject: [PATCH] Bin two initialized but unused variables - ---- - src/glyphy-windows.h | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/src/glyphy-windows.h b/src/glyphy-windows.h -index b3c11c8..5912073 100644 ---- a/src/glyphy-windows.h -+++ b/src/glyphy-windows.h -@@ -79,7 +79,6 @@ glyphy_windows(outline_decompose) (const TTPOLYGONHEADER *outline, - const TTPOLYGONHEADER *polygon = outline; - const TTPOLYGONHEADER *outline_end = (const TTPOLYGONHEADER*) ((char *)outline + outline_size); - -- int polygon_count = 0; - while (polygon < outline_end) - { - if (((char *)polygon + polygon->cb) > (char *) outline_end) -@@ -92,7 +91,6 @@ glyphy_windows(outline_decompose) (const TTPOLYGONHEADER *outline, - - const TTPOLYCURVE *curve = (const TTPOLYCURVE*) (polygon + 1); - const TTPOLYCURVE *curve_end = (const TTPOLYCURVE*) ((char *)polygon + polygon->cb); -- int curve_count = 0; - while (curve < curve_end) - { - if (((char *) &curve->apfx[curve->cpfx]) > (char *) curve_end) --- -2.5.0 - |