[Libreoffice-commits] core.git: Branch 'feature/glyphy' - 8 commits - external/glyphy include/vcl RepositoryExternal.mk vcl/generic vcl/inc vcl/quartz vcl/source vcl/win windows/soffice.sln windows/soffice.vcxproj
Tor Lillqvist
tml at collabora.com
Mon Nov 16 11:20:15 PST 2015
RepositoryExternal.mk | 9 +
external/glyphy/UnpackedTarball_glyphy.mk | 4
external/glyphy/glyphy-windows.patch.1 | 186 ++++++++++++++++++++++++++++++
include/vcl/opengl/OpenGLContext.hxx | 1
include/vcl/opengl/OpenGLHelper.hxx | 4
vcl/generic/glyphs/gcach_ftyp.cxx | 3
vcl/generic/print/genpspgraphics.cxx | 1
vcl/inc/outfont.hxx | 1
vcl/quartz/ctfonts.cxx | 1
vcl/source/opengl/OpenGLContext.cxx | 10 +
vcl/source/opengl/OpenGLHelper.cxx | 7 -
vcl/source/outdev/font.cxx | 1
vcl/win/source/gdi/salgdi3.cxx | 1
windows/soffice.sln | 18 ++
windows/soffice.vcxproj | 84 +++++++++++++
15 files changed, 324 insertions(+), 7 deletions(-)
New commits:
commit f19af5f2580139e5591dca422f8a5d45c6b15078
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Nov 16 20:48:50 2015 +0200
Add ImplFontMetricData::mbTrueTypeFont
Indicates that the font truly is a TrueType one (FT_IS_SFNT in
FreeType, TMPF_TRUETYPE in Win32).
Change-Id: Ic9dbf5e5239ae2ca597c454091fc36073a3b19cc
diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx
index 11d53c7..ce92f6d 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -636,7 +636,8 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, long& rFactor ) const
{
static_cast<ImplFontAttributes&>(rTo) = mpFontInfo->GetFontAttributes();
- rTo.mbScalableFont = true;
+ rTo.mbScalableFont = true; // FIXME: Shouldn't this check FT_IS_SCALABLE( maFaceFT )?
+ rTo.mbTrueTypeFont = FT_IS_SFNT( maFaceFT ) != 0;
rTo.mbDevice = true;
rTo.mbKernableFont = FT_HAS_KERNING( maFaceFT ) != 0;
rTo.mnOrientation = GetFontSelData().mnOrientation;
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index 1ff761c..87a581a 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -923,6 +923,7 @@ void GenPspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int )
static_cast<ImplFontAttributes&>(*pMetric) = aDFA;
pMetric->mbDevice = aDFA.mbDevice;
pMetric->mbScalableFont = true;
+ pMetric->mbTrueTypeFont = false; // FIXME, needed?
pMetric->mnOrientation = m_pPrinterGfx->GetFontAngle();
pMetric->mnSlant = 0;
diff --git a/vcl/inc/outfont.hxx b/vcl/inc/outfont.hxx
index 0becf0a..c3efdba 100644
--- a/vcl/inc/outfont.hxx
+++ b/vcl/inc/outfont.hxx
@@ -182,6 +182,7 @@ public: // TODO: hide members behind accessor methods
int meFamilyType; // Font Family Type
bool mbDevice; // Flag for Device Fonts
bool mbScalableFont;
+ bool mbTrueTypeFont;
bool mbKernableFont;
bool mbFullstopCentered;
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index e5faad9..4d0ffdd 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -136,6 +136,7 @@ void CoreTextStyle::GetFontMetric( ImplFontMetricData& rMetric ) const
// all CoreText fonts are scalable
rMetric.mbScalableFont = true;
+ rMetric.mbTrueTypeFont = true; // Not sure, but this field is used only for Windows so far
rMetric.mbKernableFont = true;
}
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 22567de..966cba6 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1746,6 +1746,7 @@ ImplFontMetricData::ImplFontMetricData( const FontSelectPattern& rFontSelData )
, mnMinKashida( 0 )
, meFamilyType(FAMILY_DONTKNOW)
, mbScalableFont(false)
+ , mbTrueTypeFont(false)
, mbFullstopCentered(false)
, mnUnderlineSize( 0 )
, mnUnderlineOffset( 0 )
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index fbb3b87..9412799 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -1596,6 +1596,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLe
// device dependent font attributes
pMetric->mbDevice = (aWinMetric.tmPitchAndFamily & TMPF_DEVICE) != 0;
pMetric->mbScalableFont = (aWinMetric.tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE)) != 0;
+ pMetric->mbTrueTypeFont = (aWinMetric.tmPitchAndFamily & TMPF_TRUETYPE) != 0;
if( pMetric->mbScalableFont )
{
// check if there are kern pairs
commit dad3c324ce742e7e7af5a39c83c22f25544f2dad
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Nov 16 20:39:17 2015 +0200
If SAL_WARN() does nothing, no point in CHECK_GL_ERROR() either
Earlier, CHECK_GL_ERROR() always called OpenGLHelper::checkGLError(),
and that function looks up the OpenGL error status using glGetError(),
which might be fairly non-trivial, and outputs any error using
SAL_WARN(). In a "production" build where SAL_WARN() is a no-op
anyway, that is fairly pointless.
Change-Id: I2d044bff6128a8ac7739020f8e414d7d3615e8d5
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 437b435..6c95f18 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -99,7 +99,11 @@ public:
#endif
};
+#ifdef SAL_LOG_WARN
#define CHECK_GL_ERROR() OpenGLHelper::checkGLError(__FILE__, __LINE__)
+#else
+#define CHECK_GL_ERROR() do { } while (false)
+#endif
#endif
commit 3315f70ba3a48fd8fb7bb8922c2d07f21743d059
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Nov 16 20:31:58 2015 +0200
Add OpenGLContext::UseNoProgram()
Will be useful in cases where there is some external library code that uses
shaders outside of our OpenGLContext.
Change-Id: I59c57e3225f55d13e69b6a9b7c0db1a7487c586d
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index a0484fe..26db139 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -212,6 +212,7 @@ public:
// retrieve a program from the cache or compile/link it
OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
OpenGLProgram* UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
+ void UseNoProgram();
/// Is this GL context the current context ?
bool isCurrent();
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index f389f88..57cae58 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1698,4 +1698,14 @@ OpenGLProgram* OpenGLContext::UseProgram( const OUString& rVertexShader, const O
return mpCurrentProgram;
}
+void OpenGLContext::UseNoProgram()
+{
+ if( mpCurrentProgram == NULL )
+ return;
+
+ mpCurrentProgram = NULL;
+ glUseProgram( 0 );
+ CHECK_GL_ERROR();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3e1c3e47bebe2787c431b1a4fac71913b71f2ef1
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Nov 16 20:16:32 2015 +0200
Use correct GLyphy library file name in the MSVC case
Change-Id: I77b55e796c35d1a186fecfddc6a109ded7d54064
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 193926d..86d167d 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -304,10 +304,15 @@ $(call gb_LinkTarget_set_include,$(1),\
$$(INCLUDE) \
)
+ifeq ($(COM),MSC)
+$(call gb_LinkTarget_add_libs,$(1),\
+ $(call gb_UnpackedTarball_get_dir,glyphy)/src/.libs/libglyphy.lib \
+)
+else
$(call gb_LinkTarget_add_libs,$(1),\
-L$(call gb_UnpackedTarball_get_dir,glyphy)/src/.libs -lglyphy \
)
-
+endif
endef
endif # SYSTEM_GLYPHY
commit b3ba32ab29b0229ecc1db97a54bdf7bae24c751a
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Nov 16 20:16:32 2015 +0200
The GLyphy headers in its tarball are in "src", there is no "include"
Change-Id: I77b55e796c35d1a186fecfddc6a109ded7d54064
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 9cadb13..193926d 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -300,7 +300,7 @@ define gb_LinkTarget__use_glyphy
$(call gb_LinkTarget_use_package,$(1),glyphy)
$(call gb_LinkTarget_set_include,$(1),\
- -I$(call gb_UnpackedTarball_get_dir,glyphy/include) \
+ -I$(call gb_UnpackedTarball_get_dir,glyphy/src) \
$$(INCLUDE) \
)
commit 722ee4becd716d52da3ee2890b3f1c357463836a
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Nov 13 18:47:11 2015 +0200
OpenGL error codes are defined in hex, so show them as such
Change-Id: I1f7fd98b243c49bfd90060b297bb2391cb102bb3
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index a051245..04d7bb9 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -695,11 +695,10 @@ void OpenGLHelper::checkGLError(const char* pFile, size_t nLine)
break;
}
const char* sError = OpenGLHelper::GLErrorString(glErr);
+ if (!sError)
+ sError = "no message available";
- if (sError)
- SAL_WARN("vcl.opengl", "GL Error #" << glErr << "(" << sError << ") in File " << pFile << " at line: " << nLine);
- else
- SAL_WARN("vcl.opengl", "GL Error #" << glErr << " (no message available) in File " << pFile << " at line: " << nLine);
+ SAL_WARN("vcl.opengl", "GL Error " << std::hex << std::setw(4) << std::setfill('0') << glErr << std::dec << std::setw(0) << std::setfill(' ') << " (" << sError << ") in file " << pFile << " at line " << nLine);
// tdf#93798 - apitrace appears to sometimes cause issues with an infinite loop here.
if (++nErrors >= 8)
commit 1c04818c4c6bf57955f5b6a3f92873963268c7a1
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Nov 12 18:41:47 2015 +0200
Add a trivial VS solution with a single project to run soffice.bin
Change-Id: I9cb3007af1dd9bff653584ad3f82f917649ce8c0
diff --git a/windows/soffice.sln b/windows/soffice.sln
new file mode 100755
index 0000000..0691dc9
--- /dev/null
+++ b/windows/soffice.sln
@@ -0,0 +1,18 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "soffice", "soffice.vcxproj", "{4A0AC252-760E-4C2B-A408-C79CBA182370}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4A0AC252-760E-4C2B-A408-C79CBA182370}.Debug|Win32.ActiveCfg = Debug|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/windows/soffice.vcxproj b/windows/soffice.vcxproj
new file mode 100755
index 0000000..69ca725
--- /dev/null
+++ b/windows/soffice.vcxproj
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{4A0AC252-760E-4C2B-A408-C79CBA182370}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>soffice</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>..\instdir\program</OutDir>
+ <IntDir />
+ <TargetExt>.bin</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
commit 16b4acb504d3b4468a97604507a36d5fc42266ba
Author: Tor Lillqvist <tml at collabora.com>
Date: Tue Nov 10 12:08:22 2015 +0200
Add glyphy-windows.h for feeding GLyphy Win32 font data
Change-Id: Iba7ed7d0e889f151c0b3d27de49fd6f14ffcd112
diff --git a/external/glyphy/UnpackedTarball_glyphy.mk b/external/glyphy/UnpackedTarball_glyphy.mk
index 8e2244b..43a603d 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 0000000..d5576ad
--- /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 at 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
More information about the Libreoffice-commits
mailing list