summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/FontFactory.cpp1
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp2
-rw-r--r--src/libnrtype/font-lister.cpp2
-rw-r--r--src/libnrtype/nr-type-primitives.cpp151
-rw-r--r--src/libnrtype/nr-type-primitives.h21
5 files changed, 100 insertions, 77 deletions
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index d052eeb42..c8f5e1fef 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -392,6 +392,7 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in)
return ret;
}
+
font_instance* font_factory::FaceFromStyle(SPStyle const *style)
{
font_instance *font = NULL;
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index 973db0165..7eb53446f 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -854,6 +854,8 @@ void Layout::Calculator::BrokenSpan::setZero()
end_glyph_index = start_glyph_index = 0;
ends_with_whitespace = false;
each_whitespace_width = 0.0;
+ letter_spacing = 0.0;
+ word_spacing = 0.0;
}
template<typename T> void Layout::Calculator::ParagraphInfo::free_sequence(T &seq)
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 39c557cc6..fad06cd00 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -650,7 +650,7 @@ void FontLister::fill_css(SPCSSAttr *css, Glib::ustring fontspec)
break;
#if PANGO_VERSION_CHECK(1,36,6)
case PANGO_WEIGHT_SEMILIGHT:
- sp_repr_css_set_property (css, "font-weight", "350");
+ sp_repr_css_set_property(css, "font-weight", "350");
break;
#endif
case PANGO_WEIGHT_BOOK:
diff --git a/src/libnrtype/nr-type-primitives.cpp b/src/libnrtype/nr-type-primitives.cpp
index 63a3abcc5..3ad4a3771 100644
--- a/src/libnrtype/nr-type-primitives.cpp
+++ b/src/libnrtype/nr-type-primitives.cpp
@@ -1,6 +1,4 @@
-#define __NR_TYPE_PRIMITIVES_C__
-
-/*
+/**
* Typeface and script library
*
* Authors:
@@ -12,26 +10,27 @@
/* This should be enough for approximately 10000 fonts */
#define NR_DICTSIZE 2777
-#include <stdlib.h>
+#include <cstdlib>
#include <string.h>
#include <glib.h>
+
#include "nr-type-primitives.h"
/**
* An entry in a list of key->value pairs
*/
struct NRTDEntry {
- NRTDEntry *next;
- const gchar *key;
- void *val;
+ NRTDEntry *next;
+ const gchar *key;
+ void *val;
};
/**
* Type Dictionary, consisting of size number of key-value entries
*/
struct NRTypeDict {
- unsigned int size;
- NRTDEntry **entries;
+ unsigned int size;
+ NRTDEntry **entries;
};
static NRTDEntry *nr_td_entry_new (void);
@@ -42,17 +41,17 @@ static NRTDEntry *nr_td_entry_new (void);
void
nr_name_list_release (NRNameList *list)
{
- if (list->destructor) {
- list->destructor (list);
- }
+ if (list->destructor) {
+ list->destructor (list);
+ }
}
void
nr_style_list_release (NRStyleList *list)
{
- if (list->destructor) {
- list->destructor (list);
- }
+ if (list->destructor) {
+ list->destructor (list);
+ }
}
/**
@@ -62,18 +61,18 @@ nr_style_list_release (NRStyleList *list)
NRTypeDict *
nr_type_dict_new (void)
{
- NRTypeDict *td;
- int i;
+ NRTypeDict *td;
+ int i;
- td = g_new (NRTypeDict, 1);
+ td = g_new (NRTypeDict, 1);
- td->size = NR_DICTSIZE;
- td->entries = g_new (NRTDEntry *, td->size);
- for (i = 0; i < NR_DICTSIZE; i++) {
- td->entries[i] = NULL;
- }
+ td->size = NR_DICTSIZE;
+ td->entries = g_new (NRTDEntry *, td->size);
+ for (i = 0; i < NR_DICTSIZE; i++) {
+ td->entries[i] = NULL;
+ }
- return td;
+ return td;
}
/**
@@ -82,15 +81,15 @@ nr_type_dict_new (void)
static unsigned int
nr_str_hash (const gchar *p)
{
- unsigned int h;
+ unsigned int h;
- h = *p;
+ h = *p;
- if (h != 0) {
- for (p += 1; *p; p++) h = (h << 5) - h + *p;
- }
+ if (h != 0) {
+ for (p += 1; *p; p++) h = (h << 5) - h + *p;
+ }
- return h;
+ return h;
}
/**
@@ -99,25 +98,25 @@ nr_str_hash (const gchar *p)
void
nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val)
{
- if (key) {
- NRTDEntry *tde;
- unsigned int hval;
-
- hval = nr_str_hash (key) % td->size;
-
- for (tde = td->entries[hval]; tde; tde = tde->next) {
- if (!strcmp (key, tde->key)) {
- tde->val = val;
- return;
- }
- }
-
- tde = nr_td_entry_new ();
- tde->next = td->entries[hval];
- tde->key = key;
- tde->val = val;
- td->entries[hval] = tde;
- }
+ if (key) {
+ NRTDEntry *tde;
+ unsigned int hval;
+
+ hval = nr_str_hash (key) % td->size;
+
+ for (tde = td->entries[hval]; tde; tde = tde->next) {
+ if (!strcmp (key, tde->key)) {
+ tde->val = val;
+ return;
+ }
+ }
+
+ tde = nr_td_entry_new ();
+ tde->next = td->entries[hval];
+ tde->key = key;
+ tde->val = val;
+ td->entries[hval] = tde;
+ }
}
/**
@@ -126,16 +125,16 @@ nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val)
void *
nr_type_dict_lookup (NRTypeDict *td, const gchar *key)
{
- if (key) {
- NRTDEntry *tde;
- unsigned int hval;
- hval = nr_str_hash (key) % td->size;
- for (tde = td->entries[hval]; tde; tde = tde->next) {
- if (!strcmp (key, tde->key)) return tde->val;
- }
- }
-
- return NULL;
+ if (key) {
+ NRTDEntry *tde;
+ unsigned int hval;
+ hval = nr_str_hash (key) % td->size;
+ for (tde = td->entries[hval]; tde; tde = tde->next) {
+ if (!strcmp (key, tde->key)) return tde->val;
+ }
+ }
+
+ return NULL;
}
#define NR_TDE_BLOCK_SIZE 32
@@ -148,20 +147,30 @@ static NRTDEntry *nr_tde_free_list;
static NRTDEntry *
nr_td_entry_new (void)
{
- NRTDEntry *tde;
+ NRTDEntry *tde;
- if (!nr_tde_free_list) {
- int i;
- nr_tde_free_list = g_new (NRTDEntry, NR_TDE_BLOCK_SIZE);
- for (i = 0; i < (NR_TDE_BLOCK_SIZE - 1); i++) {
- nr_tde_free_list[i].next = nr_tde_free_list + i + 1;
- }
- nr_tde_free_list[i].next = NULL;
- }
+ if (!nr_tde_free_list) {
+ int i;
+ nr_tde_free_list = g_new (NRTDEntry, NR_TDE_BLOCK_SIZE);
+ for (i = 0; i < (NR_TDE_BLOCK_SIZE - 1); i++) {
+ nr_tde_free_list[i].next = nr_tde_free_list + i + 1;
+ }
+ nr_tde_free_list[i].next = NULL;
+ }
- tde = nr_tde_free_list;
- nr_tde_free_list = tde->next;
+ tde = nr_tde_free_list;
+ nr_tde_free_list = tde->next;
- return tde;
+ return tde;
}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/libnrtype/nr-type-primitives.h b/src/libnrtype/nr-type-primitives.h
index 9bb181c4b..863803433 100644
--- a/src/libnrtype/nr-type-primitives.h
+++ b/src/libnrtype/nr-type-primitives.h
@@ -1,12 +1,12 @@
-#ifndef __NR_TYPE_PRIMITIVES_H__
-#define __NR_TYPE_PRIMITIVES_H__
+#ifndef SEEN_NR_TYPE_PRIMITIVES_H
+#define SEEN_NR_TYPE_PRIMITIVES_H
-/*
+/**
* Typeface and script library
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
- * g++ port: Nathan Hurst <njh@mail.csse.monash.edu.au>
+ * c++ port: Nathan Hurst <njh@mail.csse.monash.edu.au>
*
* This code is in public domain
*/
@@ -47,4 +47,15 @@ void nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val);
void *nr_type_dict_lookup (NRTypeDict *td, const gchar *key);
-#endif
+#endif // !SEEN_NR_TYPE_PRIMITIVES_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :