diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-09-09 21:15:05 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-09-09 21:15:05 +0000 |
| commit | bff5da8f40ab650dafa8f8a2b24a0a8d386df98c (patch) | |
| tree | 99f3aa3d60390f09148e33d3a235e51b37291b5a /src | |
| parent | Update .po files (diff) | |
| download | inkscape-bff5da8f40ab650dafa8f8a2b24a0a8d386df98c.tar.gz inkscape-bff5da8f40ab650dafa8f8a2b24a0a8d386df98c.zip | |
Load GPOS table only when selecting font features tab to speedup font usage
Diffstat (limited to 'src')
| -rw-r--r-- | src/libnrtype/FontInstance.cpp | 17 | ||||
| -rw-r--r-- | src/libnrtype/font-instance.h | 7 | ||||
| -rw-r--r-- | src/ui/dialog/text-edit.cpp | 17 | ||||
| -rw-r--r-- | src/ui/dialog/text-edit.h | 1 |
4 files changed, 33 insertions, 9 deletions
diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 2253b49c8..5a3d5aa9f 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -113,7 +113,8 @@ font_instance::font_instance() : maxGlyph(0), glyphs(nullptr), theFace(nullptr), - fontHasSVG(false) + fontHasSVG(false), + fulloaded(false) { //printf("font instance born\n"); _ascent = _ascent_max = 0.8; @@ -186,10 +187,12 @@ void font_instance::Unref() } } -void font_instance::InitTheFace() +void font_instance::InitTheFace(bool loadgsub) { - if (theFace == nullptr && pFont != nullptr) { - + if (pFont != nullptr && (theFace == nullptr || (loadgsub && !fulloaded))) { + if (theFace) { + theFace = nullptr; + } #ifdef USE_PANGO_WIN32 LOGFONT *lf=pango_win32_font_logfont(pFont); @@ -213,8 +216,10 @@ void font_instance::InitTheFace() #endif #ifndef USE_PANGO_WIN32 - - readOpenTypeGsubTable( theFace, openTypeTables ); + if (loadgsub) { + readOpenTypeGsubTable( theFace, openTypeTables ); + fulloaded = true; + } readOpenTypeFvarAxes( theFace, openTypeVarAxes ); readOpenTypeSVGTable( theFace, openTypeSVGGlyphs ); diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index 0dc9c40d0..b30652bdd 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -47,8 +47,12 @@ public: // common glyph definitions for all the rasterfonts std::map<int, int> id_to_no; int nbGlyph, maxGlyph; + font_glyph* glyphs; + // font is loaded with GSUB in 2 pass + bool fulloaded; + // Map of OpenType tables found in font. std::map<Glib::ustring, OTSubstitution> openTypeTables; @@ -71,7 +75,7 @@ public: void InstallFace(PangoFont* iFace); // utility; should reset the pFont field if loading failed // in case the PangoFont is a bitmap font, for example. that way, the calling function // will be able to check the validity of the font before installing it in loadedFaces - void InitTheFace(); + void InitTheFace(bool loadgsub = false); int MapUnicodeChar(gunichar c); // calls the relevant unicode->glyph index function void LoadGlyph(int glyph_id); // the main backend-dependent function @@ -124,7 +128,6 @@ public: #endif private: - // Font metrics in em-box units double _ascent; // Typographic ascent. double _descent; // Typographic descent. diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index e0faa68ed..4550d8ade 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -41,6 +41,7 @@ extern "C" { #include "text-editing.h" #include "verbs.h" +#include <libnrtype/FontFactory.h> #include <libnrtype/font-instance.h> #include <libnrtype/font-lister.h> @@ -160,7 +161,7 @@ TextEdit::TextEdit() close_button.signal_clicked().connect(sigc::bind(_signal_response.make_slot(), GTK_RESPONSE_CLOSE)); fontChangedConn = font_selector.connectChanged (sigc::mem_fun(*this, &TextEdit::onFontChange)); fontFeaturesChangedConn = font_features.connectChanged(sigc::mem_fun(*this, &TextEdit::onChange)); - + notebook.signal_switch_page().connect(sigc::mem_fun(*this, &TextEdit::onFontFeatures)); desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &TextEdit::setTargetDesktop) ); deskTrack.connect(GTK_WIDGET(gobj())); @@ -475,6 +476,20 @@ void TextEdit::onApply() blocked = false; } +void TextEdit::onFontFeatures(Gtk::Widget * widgt, int pos) +{ + if (pos == 1) { + Glib::ustring fontspec = font_selector.get_fontspec(); + if (!fontspec.empty()) { + font_instance *res = font_factory::Default()->FaceFromFontSpecification(fontspec.c_str()); + if (res && !res->fulloaded) { + res->InitTheFace(true); + font_features.update_opentype(fontspec); + } + } + } +} + void TextEdit::onChange() { if (blocked) { diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h index cef6ddfea..7a40c774f 100644 --- a/src/ui/dialog/text-edit.h +++ b/src/ui/dialog/text-edit.h @@ -93,6 +93,7 @@ protected: * @param self pointer to the current instance of the dialog. */ void onChange (); + void onFontFeatures (Gtk::Widget * widgt, int pos); static void onTextChange (GtkTextBuffer *text_buffer, TextEdit *self); /** |
