-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'experimental/freetype' into autobuild/freetype
- Loading branch information
Showing
16 changed files
with
490 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//****************************************************************************** | ||
/// | ||
/// @file platform/unix/osfontresolver.cpp | ||
/// | ||
/// Unix-specific implementation of the @ref pov_base::OSFontResolver class. | ||
/// | ||
/// @copyright | ||
/// @parblock | ||
/// | ||
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. | ||
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. | ||
/// | ||
/// POV-Ray is free software: you can redistribute it and/or modify | ||
/// it under the terms of the GNU Affero General Public License as | ||
/// published by the Free Software Foundation, either version 3 of the | ||
/// License, or (at your option) any later version. | ||
/// | ||
/// POV-Ray 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 Affero General Public License for more details. | ||
/// | ||
/// You should have received a copy of the GNU Affero General Public License | ||
/// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
/// | ||
/// ---------------------------------------------------------------------------- | ||
/// | ||
/// POV-Ray is based on the popular DKB raytracer version 2.12. | ||
/// DKBTrace was originally written by David K. Buck. | ||
/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. | ||
/// | ||
/// @endparblock | ||
/// | ||
//****************************************************************************** | ||
|
||
// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) | ||
#include "osfontresolver.h" | ||
|
||
// POV-Ray header files (parser module) | ||
#include "parser/parsertypes.h" | ||
|
||
// this must be the last file included | ||
#include "base/povdebug.h" | ||
|
||
namespace pov_base | ||
{ | ||
|
||
using namespace pov_parser; | ||
|
||
class UnixFontResolver final : public FontResolver | ||
{ | ||
public: | ||
virtual FontReferencePtr GetFont(const UCS2String& name, FontStyle style) override; | ||
}; | ||
|
||
FontReferencePtr UnixFontResolver::GetFont(const UCS2String& name, FontStyle style) | ||
{ | ||
return nullptr; | ||
} | ||
|
||
FontResolver& OSGetFontResolver() | ||
{ | ||
thread_local UnixFontResolver fontResolverInstance; | ||
return fontResolverInstance; | ||
} | ||
|
||
} // end of namespace pov_base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//****************************************************************************** | ||
/// | ||
/// @file platform/unix/osfontresolver.h | ||
/// | ||
/// Unix-specific declaration of the @ref pov_base::OSFontResolver class. | ||
/// | ||
/// @copyright | ||
/// @parblock | ||
/// | ||
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. | ||
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. | ||
/// | ||
/// POV-Ray is free software: you can redistribute it and/or modify | ||
/// it under the terms of the GNU Affero General Public License as | ||
/// published by the Free Software Foundation, either version 3 of the | ||
/// License, or (at your option) any later version. | ||
/// | ||
/// POV-Ray 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 Affero General Public License for more details. | ||
/// | ||
/// You should have received a copy of the GNU Affero General Public License | ||
/// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
/// | ||
/// ---------------------------------------------------------------------------- | ||
/// | ||
/// POV-Ray is based on the popular DKB raytracer version 2.12. | ||
/// DKBTrace was originally written by David K. Buck. | ||
/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. | ||
/// | ||
/// @endparblock | ||
/// | ||
//****************************************************************************** | ||
|
||
#ifndef POVRAY_UNIX_OSFONTRESOLVER_H | ||
#define POVRAY_UNIX_OSFONTRESOLVER_H | ||
|
||
#include "base/configbase.h" | ||
|
||
namespace pov_parser | ||
{ | ||
class FontResolver; | ||
} | ||
|
||
namespace pov_base | ||
{ | ||
pov_parser::FontResolver& OSGetFontResolver(); | ||
} | ||
|
||
#endif // POVRAY_UNIX_OSFONTRESOLVER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
//****************************************************************************** | ||
/// | ||
/// @file platform/windows/osfontresolver.cpp | ||
/// | ||
/// Windows-specific implementation of the @ref pov_base::OSFontResolver class. | ||
/// | ||
/// @copyright | ||
/// @parblock | ||
/// | ||
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. | ||
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. | ||
/// | ||
/// POV-Ray is free software: you can redistribute it and/or modify | ||
/// it under the terms of the GNU Affero General Public License as | ||
/// published by the Free Software Foundation, either version 3 of the | ||
/// License, or (at your option) any later version. | ||
/// | ||
/// POV-Ray 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 Affero General Public License for more details. | ||
/// | ||
/// You should have received a copy of the GNU Affero General Public License | ||
/// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
/// | ||
/// ---------------------------------------------------------------------------- | ||
/// | ||
/// POV-Ray is based on the popular DKB raytracer version 2.12. | ||
/// DKBTrace was originally written by David K. Buck. | ||
/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. | ||
/// | ||
/// @endparblock | ||
/// | ||
//****************************************************************************** | ||
|
||
// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) | ||
#include "osfontresolver.h" | ||
|
||
// C++ standard header files | ||
#include <vector> | ||
|
||
// platform-specific library headers | ||
#include <windows.h> | ||
|
||
// POV-Ray header files (parser module) | ||
#include "parser/font.h" | ||
#include "parser/parsertypes.h" | ||
|
||
// this must be the last file included | ||
#include "base/povdebug.h" | ||
|
||
namespace pov_base | ||
{ | ||
|
||
using namespace pov_parser; | ||
|
||
class WindowsFontResolver final : public FontResolver | ||
{ | ||
public: | ||
virtual FontReferencePtr GetFont(const UCS2String& name, FontStyle style) override; | ||
}; | ||
|
||
FontReferencePtr WindowsFontResolver::GetFont(const UCS2String& name, FontStyle style) | ||
{ | ||
if (name.length() >= LF_FACESIZE) | ||
// Too long to be a valid system font name. | ||
return nullptr; | ||
|
||
char* buffer = nullptr; | ||
|
||
HDC hdc = CreateCompatibleDC(nullptr); | ||
if (hdc == nullptr) | ||
; // TODO throw tantrum | ||
|
||
bool bold = ((style & FontStyle::kBold) != FontStyle::kRegular); | ||
bool italic = ((style & FontStyle::kItalic) != FontStyle::kRegular); | ||
int weight = (bold ? 700 : 400); | ||
|
||
HFONT fontHandle = CreateFontW( | ||
0, // cHeight | ||
0, // cWidth | ||
0, // cEscapement | ||
0, // cOrientation | ||
(int)weight, // cWeight | ||
(DWORD)italic, // bItalic | ||
FALSE, // bUnderline | ||
FALSE, // bStrikeOut | ||
DEFAULT_CHARSET, // iCharSet | ||
OUT_DEFAULT_PRECIS, // iOutPrecision | ||
CLIP_DEFAULT_PRECIS, // iClipPrecision | ||
DEFAULT_QUALITY, // iQuality | ||
DEFAULT_PITCH | FF_DONTCARE, // iPitchAndFamily | ||
(LPCWSTR)name.c_str() // pszFaceName | ||
); | ||
|
||
SelectObject(hdc, fontHandle); | ||
auto size = ::GetFontData(hdc, 0, 0, nullptr, 0); | ||
|
||
if (size == 0) | ||
return nullptr; | ||
|
||
buffer = new char[size]; | ||
if (GetFontData(hdc, 0, 0, buffer, size) != size) | ||
{ | ||
delete[] buffer; | ||
return nullptr; | ||
} | ||
|
||
DeleteDC(hdc); | ||
|
||
return std::make_shared<BufferedFontFile>(buffer, size, BufferedFontFile::Mode::kTransferOwnership); | ||
} | ||
|
||
FontResolver& OSGetFontResolver() | ||
{ | ||
thread_local WindowsFontResolver fontResolverInstance; | ||
return fontResolverInstance; | ||
} | ||
|
||
} // end of namespace pov_base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//****************************************************************************** | ||
/// | ||
/// @file platform/windows/osfontresolver.h | ||
/// | ||
/// Windows-specific declaration of the @ref pov_base::OSFontResolver class. | ||
/// | ||
/// @copyright | ||
/// @parblock | ||
/// | ||
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. | ||
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. | ||
/// | ||
/// POV-Ray is free software: you can redistribute it and/or modify | ||
/// it under the terms of the GNU Affero General Public License as | ||
/// published by the Free Software Foundation, either version 3 of the | ||
/// License, or (at your option) any later version. | ||
/// | ||
/// POV-Ray 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 Affero General Public License for more details. | ||
/// | ||
/// You should have received a copy of the GNU Affero General Public License | ||
/// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
/// | ||
/// ---------------------------------------------------------------------------- | ||
/// | ||
/// POV-Ray is based on the popular DKB raytracer version 2.12. | ||
/// DKBTrace was originally written by David K. Buck. | ||
/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. | ||
/// | ||
/// @endparblock | ||
/// | ||
//****************************************************************************** | ||
|
||
#ifndef POVRAY_WINDOWS_OSFONTRESOLVER_H | ||
#define POVRAY_WINDOWS_OSFONTRESOLVER_H | ||
|
||
#include "base/configbase.h" | ||
|
||
namespace pov_parser | ||
{ | ||
class FontResolver; | ||
} | ||
|
||
namespace pov_base | ||
{ | ||
pov_parser::FontResolver& OSGetFontResolver(); | ||
} | ||
|
||
#endif // POVRAY_WINDOWS_OSFONTRESOLVER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.