Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2015-06-16 12:49:16 +02:00
|
|
|
* Copyright (C) 2015 Artem Pavlenko
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
// mapnik
|
|
|
|
#include <mapnik/text/face.hpp>
|
|
|
|
#include <mapnik/debug.hpp>
|
|
|
|
|
2016-03-10 01:42:15 +01:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#include <mapnik/warning_ignore.hpp>
|
|
|
|
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include FT_GLYPH_H
|
|
|
|
}
|
|
|
|
|
2016-03-10 01:42:15 +01:00
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
namespace mapnik
|
|
|
|
{
|
|
|
|
|
|
|
|
font_face::font_face(FT_Face face)
|
2014-10-12 02:32:41 +02:00
|
|
|
: face_(face) {}
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
|
|
|
|
bool font_face::set_character_sizes(double size)
|
|
|
|
{
|
2016-03-10 21:45:47 +01:00
|
|
|
return (FT_Set_Char_Size(face_,0,static_cast<FT_F26Dot6>(size * (1<<6)),0,0) == 0);
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
}
|
|
|
|
|
2014-06-12 01:56:55 +02:00
|
|
|
bool font_face::set_unscaled_character_sizes()
|
|
|
|
{
|
2015-07-15 17:46:27 +02:00
|
|
|
return (FT_Set_Char_Size(face_,0,face_->units_per_EM,0,0) == 0);
|
2014-06-12 01:56:55 +02:00
|
|
|
}
|
|
|
|
|
2014-08-05 04:50:16 +02:00
|
|
|
bool font_face::glyph_dimensions(glyph_info & glyph) const
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
{
|
|
|
|
FT_Vector pen;
|
|
|
|
pen.x = 0;
|
|
|
|
pen.y = 0;
|
|
|
|
FT_Set_Transform(face_, 0, &pen);
|
|
|
|
|
2014-08-05 04:50:16 +02:00
|
|
|
if (FT_Load_Glyph(face_, glyph.glyph_index, FT_LOAD_NO_HINTING))
|
|
|
|
{
|
|
|
|
MAPNIK_LOG_ERROR(font_face) << "FT_Load_Glyph failed";
|
|
|
|
return false;
|
|
|
|
}
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
FT_Glyph image;
|
2014-08-05 04:50:16 +02:00
|
|
|
if (FT_Get_Glyph(face_->glyph, &image))
|
|
|
|
{
|
|
|
|
MAPNIK_LOG_ERROR(font_face) << "FT_Get_Glyph failed";
|
|
|
|
return false;
|
|
|
|
}
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
FT_BBox glyph_bbox;
|
2014-06-12 22:16:02 +02:00
|
|
|
FT_Glyph_Get_CBox(image, FT_GLYPH_BBOX_TRUNCATE, &glyph_bbox);
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
FT_Done_Glyph(image);
|
2014-06-17 21:57:11 +02:00
|
|
|
glyph.unscaled_ymin = glyph_bbox.yMin;
|
|
|
|
glyph.unscaled_ymax = glyph_bbox.yMax;
|
|
|
|
glyph.unscaled_advance = face_->glyph->advance.x;
|
|
|
|
glyph.unscaled_line_height = face_->size->metrics.height;
|
2014-08-05 04:50:16 +02:00
|
|
|
return true;
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
font_face::~font_face()
|
|
|
|
{
|
|
|
|
MAPNIK_LOG_DEBUG(font_face) <<
|
|
|
|
"font_face: Clean up face \"" << family_name() <<
|
|
|
|
" " << style_name() << "\"";
|
|
|
|
|
|
|
|
FT_Done_Face(face_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
void font_face_set::add(face_ptr face)
|
|
|
|
{
|
|
|
|
faces_.push_back(face);
|
|
|
|
}
|
|
|
|
|
|
|
|
void font_face_set::set_character_sizes(double size)
|
|
|
|
{
|
|
|
|
for (face_ptr const& face : faces_)
|
|
|
|
{
|
|
|
|
face->set_character_sizes(size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-12 01:56:55 +02:00
|
|
|
void font_face_set::set_unscaled_character_sizes()
|
|
|
|
{
|
|
|
|
for (face_ptr const& face : faces_)
|
|
|
|
{
|
|
|
|
face->set_unscaled_character_sizes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
void stroker::init(double radius)
|
|
|
|
{
|
2016-03-10 21:45:47 +01:00
|
|
|
FT_Stroker_Set(s_, static_cast<FT_Fixed>(radius * (1<<6)),
|
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 09:06:32 +01:00
|
|
|
FT_STROKER_LINECAP_ROUND,
|
|
|
|
FT_STROKER_LINEJOIN_ROUND,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
stroker::~stroker()
|
|
|
|
{
|
|
|
|
MAPNIK_LOG_DEBUG(font_engine_freetype) << "stroker: Destroy stroker=" << s_;
|
|
|
|
|
|
|
|
FT_Stroker_Done(s_);
|
|
|
|
}
|
|
|
|
|
|
|
|
}//ns mapnik
|