summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-06-15 10:46:15 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2018-06-18 12:27:01 +0000
commitf4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43 (patch)
tree7c6044fd3a17a2665841959dac9b3b2110b27924 /src/libnrtype
parentRun clang-tidy’s modernize-use-override pass. (diff)
downloadinkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.tar.gz
inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.zip
Run clang-tidy’s modernize-use-nullptr pass.
This replaces all NULL or 0 with nullptr when assigned to or returned as a pointer.
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/FontFactory.cpp58
-rw-r--r--src/libnrtype/FontInstance.cpp52
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp38
-rw-r--r--src/libnrtype/Layout-TNG-Input.cpp8
-rw-r--r--src/libnrtype/Layout-TNG-OutIter.cpp6
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp14
-rw-r--r--src/libnrtype/Layout-TNG.cpp2
-rw-r--r--src/libnrtype/Layout-TNG.h8
-rw-r--r--src/libnrtype/OpenTypeUtil.cpp14
-rw-r--r--src/libnrtype/font-lister.cpp18
10 files changed, 109 insertions, 109 deletions
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index f09bd3df3..eac18a76e 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -58,7 +58,7 @@ bool font_descr_equal::operator()( PangoFontDescription *const&a, PangoFontDesc
//if ( pango_font_description_equal(a,b) ) return true;
char const *fa = sp_font_description_get_family(a);
char const *fb = sp_font_description_get_family(b);
- if ( ( fa && fb == NULL ) || ( fb && fa == NULL ) ) return false;
+ if ( ( fa && fb == nullptr ) || ( fb && fa == nullptr ) ) return false;
if ( fa && fb && strcmp(fa,fb) != 0 ) return false;
if ( pango_font_description_get_style(a) != pango_font_description_get_style(b) ) return false;
if ( pango_font_description_get_variant(a) != pango_font_description_get_variant(b) ) return false;
@@ -227,11 +227,11 @@ static void FactorySubstituteFunc(FcPattern *pattern,gpointer /*data*/)
#endif
-font_factory *font_factory::lUsine = NULL;
+font_factory *font_factory::lUsine = nullptr;
font_factory *font_factory::Default(void)
{
- if ( lUsine == NULL ) lUsine = new font_factory;
+ if ( lUsine == nullptr ) lUsine = new font_factory;
return lUsine;
}
@@ -256,7 +256,7 @@ font_factory::font_factory(void) :
pango_ft2_font_map_set_default_substitute(PANGO_FT2_FONT_MAP(fontServer),
FactorySubstituteFunc,
this,
- NULL);
+ nullptr);
#endif
// TEMP
@@ -282,7 +282,7 @@ font_factory::~font_factory(void)
if (loadedPtr) {
FaceMapType* tmp = static_cast<FaceMapType*>(loadedPtr);
delete tmp;
- loadedPtr = 0;
+ loadedPtr = nullptr;
}
}
@@ -305,7 +305,7 @@ Glib::ustring font_factory::ConstructFontSpecification(PangoFontDescription *fon
char * copyAsString = pango_font_description_to_string(copy);
pangoString = copyAsString;
g_free(copyAsString);
- copyAsString = 0;
+ copyAsString = nullptr;
pango_font_description_free(copy);
@@ -388,7 +388,7 @@ Glib::ustring font_factory::GetUIStyleString(PangoFontDescription const *fontDes
char *fontDescrAsString = pango_font_description_to_string(fontDescrCopy);
style = fontDescrAsString;
g_free(fontDescrAsString);
- fontDescrAsString = 0;
+ fontDescrAsString = nullptr;
pango_font_description_free(fontDescrCopy);
}
@@ -433,7 +433,7 @@ static bool ustringPairSort(std::pair<PangoFontFamily*, Glib::ustring> const& fi
void font_factory::GetUIFamilies(std::vector<PangoFontFamily *>& out)
{
// Gather the family names as listed by Pango
- PangoFontFamily** families = NULL;
+ PangoFontFamily** families = nullptr;
int numFamilies = 0;
pango_font_map_list_families(fontServer, &families, &numFamilies);
@@ -443,11 +443,11 @@ void font_factory::GetUIFamilies(std::vector<PangoFontFamily *>& out)
for (int currentFamily = 0; currentFamily < numFamilies; ++currentFamily) {
const char* displayName = pango_font_family_get_name(families[currentFamily]);
- if (displayName == 0 || *displayName == '\0') {
+ if (displayName == nullptr || *displayName == '\0') {
std::cerr << "font_factory::GetUIFamilies: Missing displayName! " << std::endl;
continue;
}
- if (!g_utf8_validate(displayName, -1, 0)) {
+ if (!g_utf8_validate(displayName, -1, nullptr)) {
// TODO: can can do anything about this or does it always indicate broken fonts that should not be used?
std::cerr << "font_factory::GetUIFamilies: Illegal characters in displayName. ";
std::cerr << "Ignoring font '" << displayName << "'" << std::endl;
@@ -465,11 +465,11 @@ void font_factory::GetUIFamilies(std::vector<PangoFontFamily *>& out)
GList* font_factory::GetUIStyles(PangoFontFamily * in)
{
- GList* ret = NULL;
+ GList* ret = nullptr;
// Gather the styles for this family
- PangoFontFace** faces = NULL;
+ PangoFontFace** faces = nullptr;
int numFaces = 0;
- if (in == NULL) {
+ if (in == nullptr) {
std::cerr << "font_factory::GetUIStyles(): PangoFontFamily is NULL" << std::endl;
return ret;
}
@@ -482,7 +482,7 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in)
// description to get the UI family and face strings
const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]);
// std::cout << "Display Name: " << displayName << std::endl;
- if (displayName == NULL || *displayName == '\0') {
+ if (displayName == nullptr || *displayName == '\0') {
std::cerr << "font_factory::GetUIStyles: Missing displayName! " << std::endl;
continue;
}
@@ -562,7 +562,7 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in)
font_instance* font_factory::FaceFromStyle(SPStyle const *style)
{
- font_instance *font = NULL;
+ font_instance *font = nullptr;
g_assert(style);
@@ -599,7 +599,7 @@ font_instance *font_factory::FaceFromDescr(char const *family, char const *style
font_instance* font_factory::FaceFromPangoString(char const *pangoString)
{
- font_instance *fontInstance = NULL;
+ font_instance *fontInstance = nullptr;
g_assert(pangoString);
@@ -610,7 +610,7 @@ font_instance* font_factory::FaceFromPangoString(char const *pangoString)
PangoFontDescription *descr = pango_font_description_from_string(pangoString);
if (descr) {
- if (sp_font_description_get_family(descr) != NULL) {
+ if (sp_font_description_get_family(descr) != nullptr) {
fontInstance = Face(descr);
}
pango_font_description_free(descr);
@@ -622,7 +622,7 @@ font_instance* font_factory::FaceFromPangoString(char const *pangoString)
font_instance* font_factory::FaceFromFontSpecification(char const *fontSpecification)
{
- font_instance *font = NULL;
+ font_instance *font = nullptr;
g_assert(fontSpecification);
@@ -645,16 +645,16 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail)
pango_font_description_set_size(descr, (int) (fontSize*PANGO_SCALE)); // mandatory huge size (hinting workaround)
#endif
- font_instance *res = NULL;
+ font_instance *res = nullptr;
FaceMapType& loadedFaces = *static_cast<FaceMapType*>(loadedPtr);
if ( loadedFaces.find(descr) == loadedFaces.end() ) {
// not yet loaded
- PangoFont *nFace = NULL;
+ PangoFont *nFace = nullptr;
// workaround for bug #1025565.
// fonts without families blow up Pango.
- if (sp_font_description_get_family(descr) != NULL) {
+ if (sp_font_description_get_family(descr) != nullptr) {
nFace = pango_font_map_load_font(fontServer,fontContext,descr);
}
else {
@@ -672,12 +672,12 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail)
res->descr = pango_font_description_copy(descr);
res->parent = this;
res->InstallFace(nFace);
- if ( res->pFont == NULL ) {
+ if ( res->pFont == nullptr ) {
// failed to install face -> bitmap font
// printf("face failed\n");
- res->parent = NULL;
+ res->parent = nullptr;
delete res;
- res = NULL;
+ res = nullptr;
if ( canFail ) {
char *tc = pango_font_description_to_string(descr);
PANGO_DEBUG("falling back from %s to 'sans-serif' because InstallFace failed\n",tc);
@@ -749,7 +749,7 @@ void font_factory::UnrefFace(font_instance *who)
void font_factory::AddInCache(font_instance *who)
{
- if ( who == NULL ) return;
+ if ( who == nullptr ) return;
for (int i = 0;i < nbEnt;i++) ents[i].age *= 0.9;
for (int i = 0;i < nbEnt;i++) {
if ( ents[i].f == who ) {
@@ -794,10 +794,10 @@ void font_factory::AddFontsDir(char const *utf8dir)
# ifdef WIN32
dir = g_win32_locale_filename_from_utf8(utf8dir);
# else
- dir = g_filename_from_utf8(utf8dir, -1, NULL, NULL, NULL);
+ dir = g_filename_from_utf8(utf8dir, -1, nullptr, nullptr, nullptr);
# endif
- FcConfig *conf = NULL;
+ FcConfig *conf = nullptr;
# if PANGO_VERSION_CHECK(1,38,0)
conf = pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer));
# endif
@@ -826,10 +826,10 @@ void font_factory::AddFontFile(char const *utf8file)
# ifdef WIN32
file = g_win32_locale_filename_from_utf8(utf8file);
# else
- file = g_filename_from_utf8(utf8file, -1, NULL, NULL, NULL);
+ file = g_filename_from_utf8(utf8file, -1, nullptr, nullptr, nullptr);
# endif
- FcConfig *conf = NULL;
+ FcConfig *conf = nullptr;
# if PANGO_VERSION_CHECK(1,38,0)
conf = pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer));
# endif
diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp
index 667478924..619e78929 100644
--- a/src/libnrtype/FontInstance.cpp
+++ b/src/libnrtype/FontInstance.cpp
@@ -103,14 +103,14 @@ static int ft2_cubic_to(FT_Vector const *control1, FT_Vector const *control2, FT
*/
font_instance::font_instance(void) :
- pFont(0),
- descr(0),
+ pFont(nullptr),
+ descr(nullptr),
refCount(0),
- parent(0),
+ parent(nullptr),
nbGlyph(0),
maxGlyph(0),
- glyphs(0),
- theFace(0)
+ glyphs(nullptr),
+ theFace(nullptr)
{
//printf("font instance born\n");
_ascent = _ascent_max = 0.8;
@@ -133,23 +133,23 @@ font_instance::~font_instance(void)
{
if ( parent ) {
parent->UnrefFace(this);
- parent = 0;
+ parent = nullptr;
}
//printf("font instance death\n");
if ( pFont ) {
FreeTheFace();
g_object_unref(pFont);
- pFont = 0;
+ pFont = nullptr;
}
if ( descr ) {
pango_font_description_free(descr);
- descr = 0;
+ descr = nullptr;
}
// if ( theFace ) FT_Done_Face(theFace); // owned by pFont. don't touch
- theFace = 0;
+ theFace = nullptr;
for (int i=0;i<nbGlyph;i++) {
if ( glyphs[i].pathvector ) {
@@ -158,7 +158,7 @@ font_instance::~font_instance(void)
}
if ( glyphs ) {
free(glyphs);
- glyphs = 0;
+ glyphs = nullptr;
}
nbGlyph = 0;
maxGlyph = 0;
@@ -185,7 +185,7 @@ void font_instance::Unref(void)
void font_instance::InitTheFace()
{
- if (theFace == NULL && pFont != NULL) {
+ if (theFace == nullptr && pFont != nullptr) {
#ifdef USE_PANGO_WIN32
@@ -229,7 +229,7 @@ void font_instance::InitTheFace()
Glib::ustring variations(var);
- FT_MM_Var* mmvar = NULL;
+ FT_MM_Var* mmvar = nullptr;
FT_Multi_Master mmtype;
if (FT_HAS_MULTIPLE_MASTERS( theFace ) && // Font has variables
FT_Get_MM_Var(theFace, &mmvar) == 0 && // We found the data
@@ -298,7 +298,7 @@ void font_instance::FreeTheFace()
#else
pango_fc_font_unlock_face(PANGO_FC_FONT(pFont));
#endif
- theFace=NULL;
+ theFace=nullptr;
}
void font_instance::InstallFace(PangoFont* iFace)
@@ -307,7 +307,7 @@ void font_instance::InstallFace(PangoFont* iFace)
return;
}
pFont=iFace;
- iFace = NULL;
+ iFace = nullptr;
InitTheFace();
@@ -316,13 +316,13 @@ void font_instance::InstallFace(PangoFont* iFace)
if ( pFont ) {
g_object_unref(pFont);
}
- pFont=NULL;
+ pFont=nullptr;
}
}
bool font_instance::IsOutlineFont(void)
{
- if ( pFont == NULL ) {
+ if ( pFont == nullptr ) {
return false;
}
InitTheFace();
@@ -364,7 +364,7 @@ static inline Geom::Point pointfx_to_nrpoint(const POINTFX &p, double scale)
void font_instance::LoadGlyph(int glyph_id)
{
- if ( pFont == NULL ) {
+ if ( pFont == nullptr ) {
return;
}
InitTheFace();
@@ -382,7 +382,7 @@ void font_instance::LoadGlyph(int glyph_id)
glyphs=(font_glyph*)realloc(glyphs,maxGlyph*sizeof(font_glyph));
}
font_glyph n_g;
- n_g.pathvector=NULL;
+ n_g.pathvector=nullptr;
n_g.bbox[0]=n_g.bbox[1]=n_g.bbox[2]=n_g.bbox[3]=0;
n_g.h_advance = 0;
n_g.v_advance = 0;
@@ -537,11 +537,11 @@ void font_instance::LoadGlyph(int glyph_id)
bool font_instance::FontMetrics(double &ascent,double &descent,double &xheight)
{
- if ( pFont == NULL ) {
+ if ( pFont == nullptr ) {
return false;
}
InitTheFace();
- if ( theFace == NULL ) {
+ if ( theFace == nullptr ) {
return false;
}
@@ -555,11 +555,11 @@ bool font_instance::FontMetrics(double &ascent,double &descent,double &xheight)
bool font_instance::FontDecoration( double &underline_position, double &underline_thickness,
double &linethrough_position, double &linethrough_thickness)
{
- if ( pFont == NULL ) {
+ if ( pFont == nullptr ) {
return false;
}
InitTheFace();
- if ( theFace == NULL ) {
+ if ( theFace == nullptr ) {
return false;
}
#ifdef USE_PANGO_WIN32
@@ -591,11 +591,11 @@ bool font_instance::FontSlope(double &run, double &rise)
run = 0.0;
rise = 1.0;
- if ( pFont == NULL ) {
+ if ( pFont == nullptr ) {
return false;
}
InitTheFace();
- if ( theFace == NULL ) {
+ if ( theFace == nullptr ) {
return false;
}
@@ -610,7 +610,7 @@ bool font_instance::FontSlope(double &run, double &rise)
}
TT_HoriHeader *hhea = (TT_HoriHeader*)FT_Get_Sfnt_Table(theFace, ft_sfnt_hhea);
- if (hhea == NULL) {
+ if (hhea == nullptr) {
return false;
}
run = hhea->caret_Slope_Run;
@@ -654,7 +654,7 @@ Geom::PathVector* font_instance::PathVector(int glyph_id)
} else {
no = id_to_no[glyph_id];
}
- if ( no < 0 ) return NULL;
+ if ( no < 0 ) return nullptr;
return glyphs[no].pathvector;
}
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index 20b07d84b..e9cf22e31 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -83,7 +83,7 @@ class Layout::Calculator
bool in_sub_flow;
Layout *sub_flow; // this is only set for the first input item in a sub-flow
- InputItemInfo() : in_sub_flow(false), sub_flow(NULL) {}
+ InputItemInfo() : in_sub_flow(false), sub_flow(nullptr) {}
/* fixme: I don't like the fact that InputItemInfo etc. use the default copy constructor and
* operator= (and thus don't involve incrementing reference counts), yet they provide a free method
@@ -95,7 +95,7 @@ class Layout::Calculator
{
if (sub_flow) {
delete sub_flow;
- sub_flow = NULL;
+ sub_flow = nullptr;
}
}
};
@@ -106,7 +106,7 @@ class Layout::Calculator
PangoItem *item;
font_instance *font;
- PangoItemInfo() : item(NULL), font(NULL) {}
+ PangoItemInfo() : item(nullptr), font(nullptr) {}
/* fixme: I don't like the fact that InputItemInfo etc. use the default copy constructor and
* operator= (and thus don't involve incrementing reference counts), yet they provide a free method
@@ -118,11 +118,11 @@ class Layout::Calculator
{
if (item) {
pango_item_free(item);
- item = NULL;
+ item = nullptr;
}
if (font) {
font->Unref();
- font = NULL;
+ font = nullptr;
}
}
};
@@ -151,12 +151,12 @@ class Layout::Calculator
unsigned char_index_in_para; /// the index of the first character in this span in the paragraph, for looking up char_attributes
SVGLength x, y, dx, dy, rotate; // these are reoriented copies of the <tspan> attributes. We change span when we encounter one.
- UnbrokenSpan() : glyph_string(NULL) {}
+ UnbrokenSpan() : glyph_string(nullptr) {}
void free()
{
if (glyph_string)
pango_glyph_string_free(glyph_string);
- glyph_string = NULL;
+ glyph_string = nullptr;
}
};
@@ -691,7 +691,7 @@ void Layout::Calculator::_outputLine(ParagraphInfo const &para,
new_span.direction = para.pango_items[unbroken_span.pango_item_index].item->analysis.level & 1 ? RIGHT_TO_LEFT : LEFT_TO_RIGHT;
new_span.input_stream_first_character = Glib::ustring::const_iterator(unbroken_span.input_stream_first_character.base() + it_span->start.char_byte);
} else { // a control code
- new_span.font = NULL;
+ new_span.font = nullptr;
new_span.font_size = new_span.line_height.emSize();
new_span.direction = para.direction;
}
@@ -1091,7 +1091,7 @@ void Layout::Calculator::_buildPangoItemizationForPara(ParagraphInfo *para) con
// create the font_instance
font_instance *font = text_source->styleGetFontInstance();
- if (font == NULL)
+ if (font == nullptr)
continue; // bad news: we'll have to ignore all this text because we know of no font to render it
PangoAttribute *attribute_font_description = pango_attr_font_desc_new(font->descr);
@@ -1119,19 +1119,19 @@ void Layout::Calculator::_buildPangoItemizationForPara(ParagraphInfo *para) con
TRACE(("whole para: \"%s\"\n", para_text.data()));
TRACE(("%d input sources used\n", input_index - para->first_input_index));
// do the pango_itemize()
- GList *pango_items_glist = NULL;
+ GList *pango_items_glist = nullptr;
para->direction = LEFT_TO_RIGHT; // CSS default
if (_flow._input_stream[para->first_input_index]->Type() == TEXT_SOURCE) {
Layout::InputStreamTextSource const *text_source = static_cast<Layout::InputStreamTextSource *>(_flow._input_stream[para->first_input_index]);
para->direction = (text_source->style->direction.computed == SP_CSS_DIRECTION_LTR) ? LEFT_TO_RIGHT : RIGHT_TO_LEFT;
PangoDirection pango_direction = (text_source->style->direction.computed == SP_CSS_DIRECTION_LTR) ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL;
- pango_items_glist = pango_itemize_with_base_dir(_pango_context, pango_direction, para_text.data(), 0, para_text.bytes(), attributes_list, NULL);
+ pango_items_glist = pango_itemize_with_base_dir(_pango_context, pango_direction, para_text.data(), 0, para_text.bytes(), attributes_list, nullptr);
}
- if( pango_items_glist == NULL ) {
+ if( pango_items_glist == nullptr ) {
// Type wasn't TEXT_SOURCE or direction was not set.
- pango_items_glist = pango_itemize(_pango_context, para_text.data(), 0, para_text.bytes(), attributes_list, NULL);
+ pango_items_glist = pango_itemize(_pango_context, para_text.data(), 0, para_text.bytes(), attributes_list, nullptr);
}
pango_attr_list_unref(attributes_list);
@@ -1139,7 +1139,7 @@ void Layout::Calculator::_buildPangoItemizationForPara(ParagraphInfo *para) con
// convert the GList to our vector<> and make the font_instance for each PangoItem at the same time
para->pango_items.reserve(g_list_length(pango_items_glist));
TRACE(("para itemizes to %d sections\n", g_list_length(pango_items_glist)));
- for (GList *current_pango_item = pango_items_glist ; current_pango_item != NULL ; current_pango_item = current_pango_item->next) {
+ for (GList *current_pango_item = pango_items_glist ; current_pango_item != nullptr ; current_pango_item = current_pango_item->next) {
PangoItemInfo new_item;
new_item.item = (PangoItem*)current_pango_item->data;
PangoFontDescription *font_description = pango_font_describe(new_item.item->analysis.font);
@@ -1151,7 +1151,7 @@ void Layout::Calculator::_buildPangoItemizationForPara(ParagraphInfo *para) con
// and get the character attributes on everything
para->char_attributes.resize(para_text.length() + 1);
- pango_get_log_attrs(para_text.data(), para_text.bytes(), -1, NULL, &*para->char_attributes.begin(), para->char_attributes.size());
+ pango_get_log_attrs(para_text.data(), para_text.bytes(), -1, nullptr, &*para->char_attributes.begin(), para->char_attributes.size());
TRACE(("end para itemize, direction = %d\n", para->direction));
}
@@ -1325,7 +1325,7 @@ unsigned Layout::Calculator::_buildSpansForPara(ParagraphInfo *para) const
g_assert( span_start_byte_in_source < text_source->text->bytes() );
g_assert( span_start_byte_in_source + new_span.text_bytes <= text_source->text->bytes() );
g_assert( memchr(text_source->text->data() + span_start_byte_in_source, '\0', static_cast<size_t>(new_span.text_bytes))
- == NULL );
+ == nullptr );
/* Notes as of 4/29/13. Pango_shape is not generating English language ligatures, but it is generating
them for Hebrew (and probably other similar languages). In the case observed 3 unicode characters (a base
@@ -1470,7 +1470,7 @@ unsigned Layout::Calculator::_buildSpansForPara(ParagraphInfo *para) const
bool Layout::Calculator::_goToNextWrapShape()
{
delete _scanline_maker;
- _scanline_maker = NULL;
+ _scanline_maker = nullptr;
_current_shape_index++;
if (_current_shape_index == _flow._input_wrap_shapes.size()) return false;
_scanline_maker = new ShapeScanlineMaker(_flow._input_wrap_shapes[_current_shape_index].shape, _block_progression);
@@ -1811,7 +1811,7 @@ bool Layout::Calculator::calculate()
continue;
}
}
- if (_scanline_maker == NULL)
+ if (_scanline_maker == nullptr)
break; // we're trying to flow past the last wrap shape
// Break things up into little pango units with unique direction, gravity, etc.
@@ -1865,7 +1865,7 @@ bool Layout::Calculator::calculate()
// we need a span just for the para if it's either an empty last para or a break in the middle
Layout::Span new_span;
if (_flow._spans.empty()) {
- new_span.font = NULL;
+ new_span.font = nullptr;
new_span.font_size = line_box_height.emSize();
new_span.line_height = line_box_height;
new_span.x_end = 0.0;
diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp
index 6100fa262..c5ea9b03a 100644
--- a/src/libnrtype/Layout-TNG-Input.cpp
+++ b/src/libnrtype/Layout-TNG-Input.cpp
@@ -46,7 +46,7 @@ void Layout::appendText(Glib::ustring const &text,
Glib::ustring::const_iterator text_begin,
Glib::ustring::const_iterator text_end)
{
- if (style == NULL) return;
+ if (style == nullptr) return;
InputStreamTextSource *new_source = new InputStreamTextSource;
@@ -187,9 +187,9 @@ Layout::Alignment Layout::InputStreamTextSource::styleGetAlignment(Layout::Direc
}
if (this_style->text_anchor.set)
return text_anchor_to_alignment(this_style->text_anchor.computed, para_direction);
- if (this_style->object == NULL || this_style->object->parent == NULL) break;
+ if (this_style->object == nullptr || this_style->object->parent == nullptr) break;
this_style = this_style->object->parent->style;
- if (this_style == NULL) break;
+ if (this_style == nullptr) break;
}
return para_direction == LEFT_TO_RIGHT ? LEFT : RIGHT;
}
@@ -197,7 +197,7 @@ Layout::Alignment Layout::InputStreamTextSource::styleGetAlignment(Layout::Direc
font_instance *Layout::InputStreamTextSource::styleGetFontInstance() const
{
PangoFontDescription *descr = styleGetFontDescription();
- if (descr == NULL) return NULL;
+ if (descr == nullptr) return nullptr;
font_instance *res = (font_factory::Default())->Face(descr);
pango_font_description_free(descr);
return res;
diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp
index 8c29b7dbc..e28c9b168 100644
--- a/src/libnrtype/Layout-TNG-OutIter.cpp
+++ b/src/libnrtype/Layout-TNG-OutIter.cpp
@@ -309,7 +309,7 @@ Geom::Rect Layout::characterBoundingBox(iterator const &it, double *rotation) co
double midpoint_offset = _characters[char_index].span(this).x_start + _characters[char_index].x + cluster_half_width;
int unused = 0;
Path::cut_position *midpoint_otp = const_cast<Path*>(_path_fitted)->CurvilignToPosition(1, &midpoint_offset, unused);
- if (midpoint_offset >= 0.0 && midpoint_otp != NULL && midpoint_otp[0].piece >= 0) {
+ if (midpoint_offset >= 0.0 && midpoint_otp != nullptr && midpoint_otp[0].piece >= 0) {
Geom::Point midpoint;
Geom::Point tangent;
Span const &span = _characters[char_index].span(this);
@@ -461,7 +461,7 @@ void Layout::queryCursorShape(iterator const &it, Geom::Point &position, double
// as far as I know these functions are const, they're just not marked as such
Path::cut_position *path_parameter_list = const_cast<Path*>(_path_fitted)->CurvilignToPosition(1, &x_on_path, unused);
Path::cut_position path_parameter;
- if (path_parameter_list != NULL && path_parameter_list[0].piece >= 0)
+ if (path_parameter_list != nullptr && path_parameter_list[0].piece >= 0)
path_parameter = path_parameter_list[0];
else {
path_parameter.piece = _path_fitted->descr_cmd.size() - 1;
@@ -534,7 +534,7 @@ void Layout::queryCursorShape(iterator const &it, Geom::Point &position, double
void Layout::getSourceOfCharacter(iterator const &it, void **source_cookie, Glib::ustring::iterator *text_iterator) const
{
if (it._char_index == _characters.size()) {
- *source_cookie = NULL;
+ *source_cookie = nullptr;
return;
}
InputStreamItem *stream_item = _input_stream[_spans[_characters[it._char_index].in_span].in_input_stream_item];
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp
index 884c1a319..b9171d27b 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -90,12 +90,12 @@ void Layout::_clearOutputObjects()
_spans.clear();
_characters.clear();
_glyphs.clear();
- _path_fitted = NULL;
+ _path_fitted = nullptr;
}
void Layout::FontMetrics::set(font_instance *font)
{
- if( font != NULL ) {
+ if( font != nullptr ) {
ascent = font->GetTypoAscent();
descent = font->GetTypoDescent();
xheight = font->GetXHeight();
@@ -487,7 +487,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const
glyph_index++;
}
} while (glyph_index < _glyphs.size()
- && _path_fitted == NULL
+ && _path_fitted == nullptr
&& (font_matrix * glyph_matrix.inverse()).isIdentity()
&& _characters[_glyphs[glyph_index].in_character].in_span == this_span_index);
@@ -689,7 +689,7 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path)
if (_characters.empty()) {
int unused = 0;
Path::cut_position *point_otp = const_cast<Path&>(path).CurvilignToPosition(1, &offset, unused);
- if (offset >= 0.0 && point_otp != NULL && point_otp[0].piece >= 0) {
+ if (offset >= 0.0 && point_otp != nullptr && point_otp[0].piece >= 0) {
Geom::Point point;
Geom::Point tangent;
const_cast<Path&>(path).PointAndTangentAt(point_otp[0].piece, point_otp[0].t, point, tangent);
@@ -738,16 +738,16 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path)
double midpoint_offset = (start_offset + end_offset) * 0.5;
// as far as I know these functions are const, they're just not marked as such
Path::cut_position *midpoint_otp = const_cast<Path&>(path).CurvilignToPosition(1, &midpoint_offset, unused);
- if (midpoint_offset >= 0.0 && midpoint_otp != NULL && midpoint_otp[0].piece >= 0) {
+ if (midpoint_offset >= 0.0 && midpoint_otp != nullptr && midpoint_otp[0].piece >= 0) {
Geom::Point midpoint;
Geom::Point tangent;
const_cast<Path&>(path).PointAndTangentAt(midpoint_otp[0].piece, midpoint_otp[0].t, midpoint, tangent);
if (start_offset >= 0.0 && end_offset >= 0.0) {
Path::cut_position *start_otp = const_cast<Path&>(path).CurvilignToPosition(1, &start_offset, unused);
- if (start_otp != NULL && start_otp[0].piece >= 0) {
+ if (start_otp != nullptr && start_otp[0].piece >= 0) {
Path::cut_position *end_otp = const_cast<Path&>(path).CurvilignToPosition(1, &end_offset, unused);
- if (end_otp != NULL && end_otp[0].piece >= 0) {
+ if (end_otp != nullptr && end_otp[0].piece >= 0) {
bool on_same_subpath = true;
for (size_t i = 0 ; i < path.pts.size() ; i++) {
if (path.pts[i].piece <= start_otp[0].piece) continue;
diff --git a/src/libnrtype/Layout-TNG.cpp b/src/libnrtype/Layout-TNG.cpp
index 8b0889188..b3386926a 100644
--- a/src/libnrtype/Layout-TNG.cpp
+++ b/src/libnrtype/Layout-TNG.cpp
@@ -18,7 +18,7 @@ const double Layout::LINE_HEIGHT_NORMAL = 1.25;
Layout::Layout() :
_input_truncated(0),
- _path_fitted(NULL)
+ _path_fitted(nullptr)
{
textLength._set = false;
textLengthMultiplier = 1;
diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h
index c33d14630..6db6c1221 100644
--- a/src/libnrtype/Layout-TNG.h
+++ b/src/libnrtype/Layout-TNG.h
@@ -255,7 +255,7 @@ public:
to process.
*/
void appendText(Glib::ustring const &text, SPStyle *style, void *source_cookie, OptionalTextTagAttrs const *optional_attributes, unsigned optional_attributes_offset, Glib::ustring::const_iterator text_begin, Glib::ustring::const_iterator text_end);
- inline void appendText(Glib::ustring const &text, SPStyle *style, void *source_cookie, OptionalTextTagAttrs const *optional_attributes = NULL, unsigned optional_attributes_offset = 0)
+ inline void appendText(Glib::ustring const &text, SPStyle *style, void *source_cookie, OptionalTextTagAttrs const *optional_attributes = nullptr, unsigned optional_attributes_offset = 0)
{appendText(text, style, source_cookie, optional_attributes, optional_attributes_offset, text.begin(), text.end());}
/** Control codes are metadata in the text stream to signify items
@@ -532,7 +532,7 @@ public:
parameter is set to point to the actual character, otherwise
\a text_iterator is unaltered. */
// TODO FIXME a void* cookie is a very unsafe design, and C++ makes it unnecessary.
- void getSourceOfCharacter(iterator const &it, void **source_cookie, Glib::ustring::iterator *text_iterator = NULL) const;
+ void getSourceOfCharacter(iterator const &it, void **source_cookie, Glib::ustring::iterator *text_iterator = nullptr) const;
/** For latin text, the left side of the character, on the baseline */
Geom::Point characterAnchorPoint(iterator const &it) const;
@@ -550,7 +550,7 @@ public:
/** Returns the box extents (not ink extents) of the given character.
The centre of rotation is at the horizontal centre of the box on the
text baseline. */
- Geom::Rect characterBoundingBox(iterator const &it, double *rotation = NULL) const;
+ Geom::Rect characterBoundingBox(iterator const &it, double *rotation = nullptr) const;
/** Basically uses characterBoundingBox() on all the characters from
\a start to \a end and returns the union of these boxes. The return value
@@ -951,7 +951,7 @@ public:
friend class Layout;
// this is just so you can create uninitialised iterators - don't actually try to use one
iterator() :
- _parent_layout(NULL),
+ _parent_layout(nullptr),
_glyph_index(-1),
_char_index(0),
_cursor_moving_vertically(false),
diff --git a/src/libnrtype/OpenTypeUtil.cpp b/src/libnrtype/OpenTypeUtil.cpp
index 1398a4857..25e4f7094 100644
--- a/src/libnrtype/OpenTypeUtil.cpp
+++ b/src/libnrtype/OpenTypeUtil.cpp
@@ -71,10 +71,10 @@ void readOpenTypeGsubTable (const FT_Face ft_face,
tables.clear();
// Use Harfbuzz, Pango's equivalent calls are deprecated.
- auto const hb_face = hb_ft_face_create(ft_face, NULL);
+ auto const hb_face = hb_ft_face_create(ft_face, nullptr);
// First time to get size of array
- auto script_count = hb_ot_layout_table_get_script_tags(hb_face, HB_OT_TAG_GSUB, 0, NULL, NULL);
+ auto script_count = hb_ot_layout_table_get_script_tags(hb_face, HB_OT_TAG_GSUB, 0, nullptr, nullptr);
auto const hb_scripts = g_new(hb_tag_t, script_count + 1);
// Second time to fill array (this two step process was not necessary with Pango).
@@ -82,7 +82,7 @@ void readOpenTypeGsubTable (const FT_Face ft_face,
for(unsigned int i = 0; i < script_count; ++i) {
// std::cout << " Script: " << extract_tag(&hb_scripts[i]) << std::endl;
- auto language_count = hb_ot_layout_script_get_language_tags(hb_face, HB_OT_TAG_GSUB, i, 0, NULL, NULL);
+ auto language_count = hb_ot_layout_script_get_language_tags(hb_face, HB_OT_TAG_GSUB, i, 0, nullptr, nullptr);
if(language_count > 0) {
auto const hb_languages = g_new(hb_tag_t, language_count + 1);
@@ -90,7 +90,7 @@ void readOpenTypeGsubTable (const FT_Face ft_face,
for(unsigned int j = 0; j < language_count; ++j) {
// std::cout << " Language: " << extract_tag(&hb_languages[j]) << std::endl;
- auto feature_count = hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i, j, 0, NULL, NULL);
+ auto feature_count = hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i, j, 0, nullptr, nullptr);
auto const hb_features = g_new(hb_tag_t, feature_count + 1);
hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i, j, 0, &feature_count, hb_features);
@@ -110,7 +110,7 @@ void readOpenTypeGsubTable (const FT_Face ft_face,
// std::cout << " Language: " << " (dflt)" << std::endl;
auto feature_count = hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i,
HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
- 0, NULL, NULL);
+ 0, nullptr, nullptr);
auto const hb_features = g_new(hb_tag_t, feature_count + 1);
hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i,
HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
@@ -250,7 +250,7 @@ void readOpenTypeFvarAxes(const FT_Face ft_face,
std::map<Glib::ustring, OTVarAxis>& axes) {
#if FREETYPE_MAJOR *10000 + FREETYPE_MINOR*100 + FREETYPE_MICRO >= 20701
- FT_MM_Var* mmvar = NULL;
+ FT_MM_Var* mmvar = nullptr;
FT_Multi_Master mmtype;
if (FT_HAS_MULTIPLE_MASTERS( ft_face ) && // Font has variables
FT_Get_MM_Var( ft_face, &mmvar) == 0 && // We found the data
@@ -285,7 +285,7 @@ void readOpenTypeFvarNamed(const FT_Face ft_face,
std::map<Glib::ustring, OTVarInstance>& named) {
#if FREETYPE_MAJOR *10000 + FREETYPE_MINOR*100 + FREETYPE_MICRO >= 20701
- FT_MM_Var* mmvar = NULL;
+ FT_MM_Var* mmvar = nullptr;
FT_Multi_Master mmtype;
if (FT_HAS_MULTIPLE_MASTERS( ft_face ) && // Font has variables
FT_Get_MM_Var( ft_face, &mmvar) == 0 && // We found the data
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 8c50f47d4..efbb9e3a9 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -58,7 +58,7 @@ FontLister::FontLister()
font_list_store->freeze_notify();
/* Create default styles for use when font-family is unknown on system. */
- default_styles = g_list_append(NULL, new StyleNames("Normal"));
+ default_styles = g_list_append(nullptr, new StyleNames("Normal"));
default_styles = g_list_append(default_styles, new StyleNames("Italic"));
default_styles = g_list_append(default_styles, new StyleNames("Bold"));
default_styles = g_list_append(default_styles, new StyleNames("Bold Italic"));
@@ -71,7 +71,7 @@ FontLister::FontLister()
for (size_t i = 0; i < familyVector.size(); ++i) {
const char* displayName = sp_font_family_get_name(familyVector[i]);
- if (displayName == 0 || *displayName == '\0') {
+ if (displayName == nullptr || *displayName == '\0') {
continue;
}
@@ -605,7 +605,7 @@ std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family(Glib::ustrin
// 2. Select best valid style match to old style.
// For finding style list, use list of first family in font-family list.
- GList *styles = NULL;
+ GList *styles = nullptr;
Gtk::TreeModel::iterator iter = font_list_store->get_iter("0");
while (iter != font_list_store->children().end()) {
@@ -624,7 +624,7 @@ std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family(Glib::ustrin
// Newly typed in font-family may not yet be in list... use default list.
// TODO: if font-family is list, check if first family in list is on system
// and set style accordingly.
- if (styles == NULL) {
+ if (styles == nullptr) {
styles = default_styles;
}
@@ -980,9 +980,9 @@ static gint compute_distance(const PangoFontDescription *a, const PangoFontDescr
// to another font-family with Bold style.
gboolean font_description_better_match(PangoFontDescription *target, PangoFontDescription *old_desc, PangoFontDescription *new_desc)
{
- if (old_desc == NULL)
+ if (old_desc == nullptr)
return true;
- if (new_desc == NULL)
+ if (new_desc == nullptr)
return false;
int old_distance = compute_distance(target, old_desc);
@@ -1027,7 +1027,7 @@ Glib::ustring FontLister::get_best_style_match(Glib::ustring family, Glib::ustri
}
PangoFontDescription *target = pango_font_description_from_string(fontspec.c_str());
- PangoFontDescription *best = NULL;
+ PangoFontDescription *best = nullptr;
//font_description_dump( target );
@@ -1100,7 +1100,7 @@ bool font_lister_separator_func(const Glib::RefPtr<Gtk::TreeModel>& model,
// Needed until Text toolbar updated
gboolean font_lister_separator_func2(GtkTreeModel *model, GtkTreeIter *iter, gpointer /*data*/)
{
- gchar *text = 0;
+ gchar *text = nullptr;
gtk_tree_model_get(model, iter, 0, &text, -1); // Column 0: FontList.family
return (text && strcmp(text, "#") == 0);
}
@@ -1139,7 +1139,7 @@ void font_lister_cell_data_func2(GtkCellLayout * /*cell_layout*/,
GtkTreeIter iter;
gboolean valid;
- gchar *family = 0;
+ gchar *family = nullptr;
gboolean onSystem = true;
gboolean found = false;
for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);