diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-11-10 12:08:22 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-11-19 14:05:28 +0200 |
commit | 60a09acf5171de4177cc430e11f39a4372d46693 (patch) | |
tree | 640240cf9c20ba34b0285eb358215054076701b3 /external/glyphy | |
parent | 626bf18d7d4aec975f635b0dfe3894082e7ec487 (diff) |
Add glyphy-windows.h for feeding GLyphy Win32 font data
Change-Id: Iba7ed7d0e889f151c0b3d27de49fd6f14ffcd112
Diffstat (limited to 'external/glyphy')
-rw-r--r-- | external/glyphy/UnpackedTarball_glyphy.mk | 4 | ||||
-rw-r--r-- | external/glyphy/glyphy-windows.patch.1 | 186 |
2 files changed, 190 insertions, 0 deletions
diff --git a/external/glyphy/UnpackedTarball_glyphy.mk b/external/glyphy/UnpackedTarball_glyphy.mk index 8e2244b94451..43a603df8ed2 100644 --- a/external/glyphy/UnpackedTarball_glyphy.mk +++ b/external/glyphy/UnpackedTarball_glyphy.mk @@ -13,4 +13,8 @@ $(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-windows.patch.1 \ +)) + # vim: set noet sw=4 ts=4: diff --git a/external/glyphy/glyphy-windows.patch.1 b/external/glyphy/glyphy-windows.patch.1 new file mode 100644 index 000000000000..d5576ad50eb9 --- /dev/null +++ b/external/glyphy/glyphy-windows.patch.1 @@ -0,0 +1,186 @@ +commit cfc3157868f691b70c2f0a6daa3c387ca6ef42a9 (HEAD -> master, origin/master, origin/HEAD) +Author: Tor Lillqvist <tml@collabora.com> +Date: Tue Nov 10 00:20:42 2015 +0200 + + 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. +--- + src/Makefile.am | 1 + + src/glyphy-windows.h | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 153 insertions(+) + +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 \ +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 |