From 57c85eec491e07949497fa67edc7c76eafde7471 Mon Sep 17 00:00:00 2001
From: PBS <pbs3141@gmail.com>
Date: Sun, 24 Apr 2022 10:35:03 +0900
Subject: [PATCH] Remove deprecated USE_PANGO_WIN32

All functions in pangowin32.h have been marked deprecated. In addition,
the Inkscape code that was using it has been #ifdef'd out since 2004.
---
 .../internal/cairo-render-context.cpp         |  19 --
 src/libnrtype/FontFactory.cpp                 |  28 --
 src/libnrtype/FontFactory.h                   |  26 +-
 src/libnrtype/FontInstance.cpp                | 261 ++----------------
 src/libnrtype/Layout-TNG-Input.cpp            |  17 --
 src/libnrtype/OpenTypeUtil.cpp                |   8 -
 src/libnrtype/font-instance.h                 |   4 -
 7 files changed, 24 insertions(+), 339 deletions(-)

diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index ba3bd695bc1..cb7d76940a4 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -49,9 +49,6 @@
 #include "object/sp-clippath.h"
 
 #include "util/units.h"
-#ifdef _WIN32
-#include "libnrtype/FontFactory.h" // USE_PANGO_WIN32
-#endif
 
 #include "cairo-renderer.h"
 #include "extension/system.h"
@@ -1833,21 +1830,6 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_ma
 
     FcPattern *fc_pattern = nullptr;
 
-#ifdef USE_PANGO_WIN32
-# ifdef CAIRO_HAS_WIN32_FONT
-    LOGFONTA *lfa = pango_win32_font_logfont(font);
-    LOGFONTW lfw;
-
-    ZeroMemory(&lfw, sizeof(LOGFONTW));
-    memcpy(&lfw, lfa, sizeof(LOGFONTA));
-    MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, lfa->lfFaceName, LF_FACESIZE, lfw.lfFaceName, LF_FACESIZE);
-
-    if(font_face == NULL) {
-        font_face = cairo_win32_font_face_create_for_logfontw(&lfw);
-        font_table[fonthash] = font_face;
-    }
-# endif
-#else
 # ifdef CAIRO_HAS_FT_FONT
     PangoFcFont *fc_font = PANGO_FC_FONT(font);
     fc_pattern = fc_font->font_pattern;
@@ -1856,7 +1838,6 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_ma
         font_table[fonthash] = font_face;
     }
 # endif
-#endif
 
     cairo_save(_cr);
     cairo_set_font_face(_cr, font_face);
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index ac12ec78100..9ce51c27e5b 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -220,7 +220,6 @@ static void noop(...) {}
 
 
 ///////////////////// FontFactory
-#ifndef USE_PANGO_WIN32
 // the substitute function to tell fontconfig to enforce outline fonts
 static void FactorySubstituteFunc(FcPattern *pattern,gpointer /*data*/)
 {
@@ -229,7 +228,6 @@ static void FactorySubstituteFunc(FcPattern *pattern,gpointer /*data*/)
     //FcPatternGetString(pattern, "FC_FAMILY",0, &fam);
     //printf("subst_f on %s\n",fam);
 }
-#endif
 
 FontFactory &FontFactory::get()
 {
@@ -241,18 +239,11 @@ FontFactory::FontFactory() :
     nbEnt(0), // Note: this "ents" cache only keeps fonts from being unreffed, does not speed up access
     maxEnt(32),
     ents(static_cast<font_entry*>(g_malloc(maxEnt*sizeof(font_entry)))),
-#ifdef USE_PANGO_WIN32
-    fontServer(pango_win32_font_map_for_display()),
-    pangoFontCache(pango_win32_font_map_get_font_cache(fontServer)),
-    hScreenDC(pango_win32_get_dc()),
-#else
     fontServer(pango_ft2_font_map_new()),
-#endif
     fontContext(pango_font_map_create_context(fontServer)),
     fontSize(512),
     loadedPtr(new FaceMapType())
 {
-#ifndef USE_PANGO_WIN32
     pango_ft2_font_map_set_resolution(PANGO_FT2_FONT_MAP(fontServer),
                                       72, 72);
 #if PANGO_VERSION_CHECK(1,48,0)
@@ -263,8 +254,6 @@ FontFactory::FontFactory() :
                                               FactorySubstituteFunc,
                                               this,
                                               nullptr);
-#endif
-
 }
 
 FontFactory::~FontFactory()
@@ -275,11 +264,7 @@ FontFactory::~FontFactory()
     if ( ents ) g_free(ents);
 
     g_object_unref(fontServer);
-#ifdef USE_PANGO_WIN32
-    pango_win32_shutdown_display();
-#else
     //pango_ft2_shutdown_display();
-#endif
     //g_object_unref(fontContext);
 
     if (loadedPtr) {
@@ -642,12 +627,7 @@ font_instance* FontFactory::FaceFromFontSpecification(char const *fontSpecificat
 
 font_instance *FontFactory::Face(PangoFontDescription *descr, bool canFail)
 {
-#ifdef USE_PANGO_WIN32
-    // damn Pango fudges the size, so we need to unfudge. See source of pango_win32_font_map_init()
-    pango_font_description_set_size(descr, (int) (fontSize*PANGO_SCALE*72/GetDeviceCaps(pango_win32_get_dc(),LOGPIXELSY))); // mandatory huge size (hinting workaround)
-#else
     pango_font_description_set_size(descr, (int) (fontSize*PANGO_SCALE)); // mandatory huge size (hinting workaround)
-#endif
 
     font_instance *res = nullptr;
 
@@ -803,9 +783,6 @@ void font_factory::AddFontFilesWin32(char const * directory_path )
 
 void FontFactory::AddFontsDir(char const *utf8dir)
 {
-#ifdef USE_PANGO_WIN32
-    g_info("Adding additional font directories only supported for fontconfig backend.");
-#else
     if (!Inkscape::IO::file_test(utf8dir, G_FILE_TEST_IS_DIR)) {
         g_info("Fonts dir '%s' does not exist and will be ignored.", utf8dir);
         return;
@@ -830,14 +807,10 @@ void FontFactory::AddFontsDir(char const *utf8dir)
     }
 
     g_free(dir);
-#endif
 }
 
 void FontFactory::AddFontFile(char const *utf8file)
 {
-#ifdef USE_PANGO_WIN32
-    g_info("Adding additional font only supported for fontconfig backend.");
-#else
     if (!Inkscape::IO::file_test(utf8file, G_FILE_TEST_IS_REGULAR)) {
         g_warning("Font file '%s' does not exist and will be ignored.", utf8file);
         return;
@@ -861,7 +834,6 @@ void FontFactory::AddFontFile(char const *utf8file)
     }
 
     g_free(file);
-#endif
 }
 
 /*
diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h
index 85f61ad22ec..adc9489adde 100644
--- a/src/libnrtype/FontFactory.h
+++ b/src/libnrtype/FontFactory.h
@@ -7,35 +7,21 @@
  * Copyright (C) 2018 Authors
  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
  */
-/*
- *  FontFactory.h
- *  testICU
- *
- */
 
-#ifndef my_font_factory
-#define my_font_factory
+#ifndef LIBNRTYPE_FONTFACTORY_H
+#define LIBNRTYPE_FONTFACTORY_H
 
 #include <functional>
 #include <algorithm>
 #include <utility>
 
-#ifdef _WIN32
-//#define USE_PANGO_WIN32 // disable for Bug 165665
-#endif
-
 #include <pango/pango.h>
 #include "style.h"
 
 /* Freetype */
-#ifdef USE_PANGO_WIN32
-#include <pango/pangowin32.h>
-#else
 #include <pango/pangoft2.h>
 #include <ft2build.h>
 #include FT_FREETYPE_H
-#endif
-
 
 class font_instance;
 
@@ -94,10 +80,6 @@ public:
     // Pango data.  Backend-specific structures are cast to these opaque types.
     PangoFontMap *fontServer;
     PangoContext *fontContext;
-#ifdef USE_PANGO_WIN32
-    PangoWin32FontCache *pangoFontCache;
-    HDC hScreenDC;
-#endif
     double fontSize; /**< The huge fontsize used as workaround for hinting.
                       *   Different between freetype and win32. */
 
@@ -186,9 +168,7 @@ private:
     // UIStringToPangoStringMap fontStringMap;
 };
 
-
-#endif /* my_font_factory */
-
+#endif // LIBNRTYPE_FONTFACTORY_H
 
 /*
   Local Variables:
diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp
index e17d5935dc9..059449d0303 100644
--- a/src/libnrtype/FontInstance.cpp
+++ b/src/libnrtype/FontInstance.cpp
@@ -39,7 +39,6 @@
 
 #include "display/cairo-utils.h"  // Inkscape::Pixbuf
 
-#ifndef USE_PANGO_WIN32
 /*
  * Outline extraction
  */
@@ -98,9 +97,6 @@ static int ft2_cubic_to(FT_Vector const *control1, FT_Vector const *control2, FT
     user->last = p;
     return 0;
 }
-#endif
-
-/* *** END #if HACK *** */
 
 /*
  *
@@ -185,19 +181,6 @@ void font_instance::InitTheFace(bool loadgsub)
         if (theFace) {
             theFace = nullptr;
         }
-#ifdef USE_PANGO_WIN32
-
-        LOGFONT *lf=pango_win32_font_logfont(pFont);
-        g_assert(lf != NULL);
-        theFace = pango_win32_font_cache_load(parent->pangoFontCache,lf);
-        g_free(lf);
-
-        XFORM identity = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
-        SetWorldTransform(parent->hScreenDC, &identity);
-        SetGraphicsMode(parent->hScreenDC, GM_COMPATIBLE);
-        SelectObject(parent->hScreenDC,theFace);
-
-#else
 
         hb_font_t* hb_font = pango_font_get_hb_font(pFont); // Pango owns hb_font.
 
@@ -298,35 +281,18 @@ void font_instance::InitTheFace(bool loadgsub)
         }
 
 #endif // FreeType
-#endif // !USE_PANGO_WIN32
 
        FindFontMetrics();
     }
-    
-#ifdef USE_PANGO_WIN32
-    // Someone (probably pango or cairo) sets the world transform during initialization and does not reset it.
-    // Work around this by explicitly setting it again (even if the font is already initialized)
-    XFORM identity = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
-    SetWorldTransform(parent->hScreenDC, &identity);
-    SetGraphicsMode(parent->hScreenDC, GM_COMPATIBLE);
-    SelectObject(parent->hScreenDC,theFace);
-#endif
-
 }
 
 void font_instance::FreeTheFace()
 {
-#ifdef USE_PANGO_WIN32
-    SelectObject(parent->hScreenDC,GetStockObject(SYSTEM_FONT));
-    pango_win32_font_cache_unload(parent->pangoFontCache,theFace);
-#else
-
 #if HB_VERSION_ATLEAST(2,6,5)
     hb_ft_font_unlock_face(hb_font_copy);
     hb_font_destroy(hb_font_copy);
 #else
     pango_fc_font_unlock_face(PANGO_FC_FONT(pFont));
-#endif
 #endif
     theFace=nullptr;
 }
@@ -356,56 +322,36 @@ bool font_instance::IsOutlineFont()
         return false;
     }
     InitTheFace();
-#ifdef USE_PANGO_WIN32
-    TEXTMETRIC tm;
-    return GetTextMetrics(parent->hScreenDC,&tm) && tm.tmPitchAndFamily&(TMPF_TRUETYPE|TMPF_DEVICE);
-#else
     return FT_IS_SCALABLE(theFace);
-#endif
 }
 
 int font_instance::MapUnicodeChar(gunichar c)
 {
     int res = 0;
-    if ( pFont  ) {
-#ifdef USE_PANGO_WIN32
-        res = pango_win32_font_get_glyph_index(pFont, c);
-#else
+    if (pFont) {
         if (!theFace) {
             std::cerr << "Face not properly initialized (should not happen)" << std::endl;
         }
-        if ( c > 0xf0000 ) {
+        if (c > 0xf0000) {
             res = CLAMP(c, 0xf0000, 0x1fffff) - 0xf0000;
         } else {
             res = FT_Get_Char_Index(theFace, c);
         }
-#endif
     }
     return res;
 }
 
-
-#ifdef USE_PANGO_WIN32
-static inline Geom::Point pointfx_to_nrpoint(const POINTFX &p, double scale)
-{
-    return Geom::Point(*(long*)&p.x / 65536.0 * scale,
-                     *(long*)&p.y / 65536.0 * scale);
-}
-#endif
-
 void font_instance::LoadGlyph(int glyph_id)
 {
-    if ( pFont == nullptr ) {
+    if (!pFont) {
         return;
     }
     InitTheFace();
-#ifndef USE_PANGO_WIN32
-    if ( !FT_IS_SCALABLE(theFace) ) {
+    if (!FT_IS_SCALABLE(theFace)) {
         return; // bitmap font
     }
-#endif
 
-    if ( id_to_no.find(glyph_id) == id_to_no.end() ) {
+    if (id_to_no.find(glyph_id) == id_to_no.end()) {
         Geom::PathBuilder path_builder;
 
         if ( nbGlyph >= maxGlyph ) {
@@ -419,92 +365,8 @@ void font_instance::LoadGlyph(int glyph_id)
         n_g.v_advance = 0;
         n_g.h_width = 0;
         n_g.v_width = 0;
-        bool   doAdd=false;
-
-#ifdef USE_PANGO_WIN32
-
-#ifndef GGO_UNHINTED         // For compatibility with old SDKs.
-#define GGO_UNHINTED 0x0100
-#endif
+        bool doAdd = false;
 
-        MAT2 identity = {{0,1},{0,0},{0,0},{0,1}};
-        OUTLINETEXTMETRIC otm;
-        GetOutlineTextMetrics(parent->hScreenDC, sizeof(otm), &otm);
-        GLYPHMETRICS metrics;
-        DWORD bufferSize=GetGlyphOutline (parent->hScreenDC, glyph_id, GGO_GLYPH_INDEX | GGO_NATIVE | GGO_UNHINTED, &metrics, 0, NULL, &identity);
-        double scale=1.0/parent->fontSize;
-        n_g.h_advance = metrics.gmCellIncX          * scale;
-        n_g.v_advance = otm.otmTextMetrics.tmHeight * scale;
-        n_g.h_width   = metrics.gmBlackBoxX         * scale;
-        n_g.v_width   = metrics.gmBlackBoxY         * scale;
-        if ( bufferSize == GDI_ERROR) {
-            // shit happened
-        } else if ( bufferSize == 0) {
-            // character has no visual representation, but is valid (eg whitespace)
-            doAdd=true;
-        } else {
-            char *buffer = new char[bufferSize];
-            if ( GetGlyphOutline (parent->hScreenDC, glyph_id, GGO_GLYPH_INDEX | GGO_NATIVE | GGO_UNHINTED, &metrics, bufferSize, buffer, &identity) <= 0 ) {
-                // shit happened
-            } else {
-                // Platform SDK is rubbish, read KB87115 instead
-                DWORD polyOffset=0;
-                while ( polyOffset < bufferSize ) {
-                    TTPOLYGONHEADER const *polyHeader=(TTPOLYGONHEADER const *)(buffer+polyOffset);
-                    if (polyOffset+polyHeader->cb > bufferSize) break;
-
-                    if (polyHeader->dwType == TT_POLYGON_TYPE) {
-                        path_builder.moveTo(pointfx_to_nrpoint(polyHeader->pfxStart, scale));
-                        DWORD curveOffset=polyOffset+sizeof(TTPOLYGONHEADER);
-
-                        while ( curveOffset < polyOffset+polyHeader->cb ) {
-                            TTPOLYCURVE const *polyCurve=(TTPOLYCURVE const *)(buffer+curveOffset);
-                            POINTFX const *p=polyCurve->apfx;
-                            POINTFX const *endp=p+polyCurve->cpfx;
-
-                            switch (polyCurve->wType) {
-                            case TT_PRIM_LINE:
-                                while ( p != endp )
-                                    path_builder.lineTo(pointfx_to_nrpoint(*p++, scale));
-                                break;
-
-                            case TT_PRIM_QSPLINE:
-                                {
-                                    g_assert(polyCurve->cpfx >= 2);
-
-                                    // The list of points specifies one or more control points and ends with the end point.
-                                    // The intermediate points (on the curve) are the points between the control points.
-                                    Geom::Point this_control = pointfx_to_nrpoint(*p++, scale);
-                                    while ( p+1 != endp ) { // Process all "midpoints" (all points except the last)
-                                        Geom::Point new_control = pointfx_to_nrpoint(*p++, scale);
-                                        path_builder.quadTo(this_control, (new_control+this_control)/2);
-                                        this_control = new_control;
-                                    }
-                                    Geom::Point end = pointfx_to_nrpoint(*p++, scale);
-                                    path_builder.quadTo(this_control, end);
-                                }
-                                break;
-
-                            case 3:  // TT_PRIM_CSPLINE
-                                g_assert(polyCurve->cpfx % 3 == 0);
-                                while ( p != endp ) {
-                                    path_builder.curveTo(pointfx_to_nrpoint(p[0], scale),
-                                                         pointfx_to_nrpoint(p[1], scale),
-                                                         pointfx_to_nrpoint(p[2], scale));
-                                    p += 3;
-                                }
-                                break;
-                            }
-                            curveOffset += sizeof(TTPOLYCURVE)+sizeof(POINTFX)*(polyCurve->cpfx-1);
-                        }
-                    }
-                    polyOffset += polyHeader->cb;
-                }
-                doAdd=true;
-            }
-            delete [] buffer;
-        }
-#else
         if (FT_Load_Glyph (theFace, glyph_id, FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)) {
             // shit happened
         } else {
@@ -537,12 +399,12 @@ void font_instance::LoadGlyph(int glyph_id)
                 FT2GeomData user(path_builder, 1.0/((double)theFace->units_per_EM));
                 FT_Outline_Decompose (&theFace->glyph->outline, &ft2_outline_funcs, &user);
             }
-            doAdd=true;
+            doAdd = true;
         }
-#endif
+
         path_builder.flush();
 
-        if ( doAdd ) {
+        if (doAdd) {
             Geom::PathVector pv = path_builder.peek();
             // close all paths
             for (auto & i : pv) {
@@ -586,25 +448,14 @@ 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 == nullptr ) {
+    if (!pFont) {
         return false;
     }
     InitTheFace();
-    if ( theFace == nullptr ) {
-        return false;
-    }
-#ifdef USE_PANGO_WIN32
-    OUTLINETEXTMETRIC otm;
-    if ( !GetOutlineTextMetrics(parent->hScreenDC,sizeof(otm),&otm) ) {
+    if (!theFace) {
         return false;
     }
-    double scale=1.0/parent->fontSize;
-    underline_position    = fabs(otm.otmsUnderscorePosition *scale);
-    underline_thickness   = fabs(otm.otmsUnderscoreSize     *scale);
-    linethrough_position  = fabs(otm.otmsStrikeoutPosition  *scale);
-    linethrough_thickness = fabs(otm.otmsStrikeoutSize      *scale);
-#else
-    if ( theFace->units_per_EM == 0 ) {
+    if (theFace->units_per_EM == 0) {
         return false; // bitmap font
     }
     underline_position    = fabs(((double)theFace->underline_position )/((double)theFace->units_per_EM));
@@ -612,41 +463,33 @@ bool font_instance::FontDecoration( double &underline_position,   double &underl
     // there is no specific linethrough information, mock it up from other font fields
     linethrough_position  = fabs(((double)theFace->ascender / 3.0     )/((double)theFace->units_per_EM));
     linethrough_thickness = fabs(((double)theFace->underline_thickness)/((double)theFace->units_per_EM));
-#endif
     return true;
 }
 
-
 bool font_instance::FontSlope(double &run, double &rise)
 {
     run = 0.0;
     rise = 1.0;
 
-    if ( pFont == nullptr ) {
+    if (!pFont) {
         return false;
     }
     InitTheFace();
-    if ( theFace == nullptr ) {
+    if (!theFace) {
         return false;
     }
 
-#ifdef USE_PANGO_WIN32
-    OUTLINETEXTMETRIC otm;
-    if ( !GetOutlineTextMetrics(parent->hScreenDC,sizeof(otm),&otm) ) return false;
-    run=otm.otmsCharSlopeRun;
-    rise=otm.otmsCharSlopeRise;
-#else
-    if ( !FT_IS_SCALABLE(theFace) ) {
+    if (!FT_IS_SCALABLE(theFace)) {
         return false; // bitmap font
     }
 
     TT_HoriHeader *hhea = (TT_HoriHeader*)FT_Get_Sfnt_Table(theFace, ft_sfnt_hhea);
-    if (hhea == nullptr) {
+    if (!hhea) {
         return false;
     }
     run = hhea->caret_Slope_Run;
     rise = hhea->caret_Slope_Rise;
-#endif
+
     return true;
 }
 
@@ -838,72 +681,10 @@ void font_instance::FindFontMetrics() {
     //   http://microsoft.public.win32.programmer.gdi.narkive.com/LV6k4BDh/msdn-documentation-outlinetextmetrics-clarification
     // The otmAscent and otmDescent values are the maximum ascent and maximum descent of all the
     // glyphs in a font.
-    if ( theFace ) {
-
-#ifdef USE_PANGO_WIN32
-        OUTLINETEXTMETRIC otm;
-        if ( GetOutlineTextMetrics(parent->hScreenDC,sizeof(otm),&otm) ) {
-            double scale=1.0/parent->fontSize;
-            _ascent      = fabs(otm.otmMacAscent  * scale);
-            _descent     = fabs(otm.otmMacDescent * scale);
-            _xheight     = fabs(otm.otmsXHeight    * scale);
-            _ascent_max  = fabs(otm.otmAscent     * scale);
-            _descent_max = fabs(otm.otmDescent    * scale);
-            _design_units = parent->fontSize;
-
-            // In CSS em size is ascent + descent... which should be 1. If not,
-            // adjust so it is.
-            double em = _ascent + _descent;
-            if( em > 0 ) {
-                _ascent /= em;
-                _descent /= em;
-            }
+    if (theFace) {
+        if (theFace->units_per_EM != 0) {  // If zero then it's a bitmap font.
 
-            // May not be necessary but if OS/2 table missing or not version 2 or higher,
-            // xheight might be zero.
-            if( _xheight == 0.0 ) {
-                _xheight = 0.5;
-            }
-
-            // Baselines defined relative to  alphabetic.
-            _baselines[ SP_CSS_BASELINE_IDEOGRAPHIC      ] = -_descent;      // Recommendation
-            _baselines[ SP_CSS_BASELINE_HANGING          ] = 0.8 * _ascent;  // Guess
-            _baselines[ SP_CSS_BASELINE_MATHEMATICAL     ] = 0.8 * _xheight; // Guess
-            _baselines[ SP_CSS_BASELINE_CENTRAL          ] = 0.5 - _descent; // Definition
-            _baselines[ SP_CSS_BASELINE_MIDDLE           ] = 0.5 * _xheight; // Definition
-            _baselines[ SP_CSS_BASELINE_TEXT_BEFORE_EDGE ] = _ascent;        // Definition
-            _baselines[ SP_CSS_BASELINE_TEXT_AFTER_EDGE  ] = -_descent;      // Definition
-
-
-            MAT2 identity = {{0,1},{0,0},{0,0},{0,1}};
-            GLYPHMETRICS metrics;
-            int retval;
-
-            // Better math baseline:
-            // Try center of minus sign
-            retval =  GetGlyphOutline (parent->hScreenDC, 0x2212, GGO_NATIVE | GGO_UNHINTED, &metrics, 0, NULL, &identity);
-            // If no minus sign, try hyphen
-            if( retval <= 0 )
-                retval =  GetGlyphOutline (parent->hScreenDC, '-', GGO_NATIVE | GGO_UNHINTED, &metrics, 0, NULL, &identity);
-
-            if( retval > 0 ) {
-                double math = (metrics.gmptGlyphOrigin.y + 0.5 * metrics.gmBlackBoxY) * scale;
-                _baselines[ SP_CSS_BASELINE_MATHEMATICAL ] = math;
-            }
-
-            // Find hanging baseline... assume it is at top of 'म'.
-            retval =  GetGlyphOutline (parent->hScreenDC, 0x092E, GGO_NATIVE | GGO_UNHINTED, &metrics, 0, NULL, &identity);
-            if( retval > 0 ) {
-                double hanging = metrics.gmptGlyphOrigin.y * scale;
-                _baselines[ SP_CSS_BASELINE_MATHEMATICAL ] = hanging;
-            }
-        }
-
-#else
-
-        if ( theFace->units_per_EM != 0 ) {  // If zero then it's a bitmap font.
-
-            TT_OS2*  os2 = (TT_OS2*)FT_Get_Sfnt_Table( theFace, ft_sfnt_os2 );       
+            TT_OS2* os2 = (TT_OS2*)FT_Get_Sfnt_Table( theFace, ft_sfnt_os2 );
             if( os2 ) {
                 _ascent  = fabs(((double)os2->sTypoAscender) / ((double)theFace->units_per_EM));
                 _descent = fabs(((double)os2->sTypoDescender)/ ((double)theFace->units_per_EM));
@@ -983,7 +764,7 @@ void font_instance::FindFontMetrics() {
                 FT_Done_Glyph(aglyph);
             }
         }
-#endif
+
         // const gchar *family = pango_font_description_get_family(descr);
         // std::cout << "Font: " << (family?family:"null") << std::endl;
         // std::cout << "  ascent:      " << _ascent      << std::endl;
diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp
index ad83ce85649..0b5560885f6 100644
--- a/src/libnrtype/Layout-TNG-Input.cpp
+++ b/src/libnrtype/Layout-TNG-Input.cpp
@@ -209,26 +209,9 @@ PangoFontDescription *Layout::InputStreamTextSource::styleGetFontDescription() c
     PangoFontDescription *descr = ink_font_description_from_style( style );
 
     // Font size not yet set
-#ifdef USE_PANGO_WIN32
-
-    // Damn Pango fudges the size, so we need to unfudge. See source of pango_win32_font_map_init()
-    pango_font_description_set_size(descr,
-        (int) ((font_factory::Default())->fontSize*PANGO_SCALE*72 / GetDeviceCaps(pango_win32_get_dc(),LOGPIXELSY))
-    );
-
-    // We unset stretch on Win32, because pango-win32 has no concept of it
-    // (Windows doesn't really provide any useful field it could use).
-    // If we did set stretch, then any text with a font-stretch attribute would
-    // end up falling back to a default.
-    pango_font_description_unset_fields(descr, PANGO_FONT_MASK_STRETCH);
-
-#else
-
     // mandatory huge size (hinting workaround)
     pango_font_description_set_size(descr, FontFactory::get().fontSize * PANGO_SCALE);
 
-#endif
-
     return descr;
 }
 
diff --git a/src/libnrtype/OpenTypeUtil.cpp b/src/libnrtype/OpenTypeUtil.cpp
index 9d3576dfad2..bf372bc55f5 100644
--- a/src/libnrtype/OpenTypeUtil.cpp
+++ b/src/libnrtype/OpenTypeUtil.cpp
@@ -8,8 +8,6 @@
  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
  */
 
-#ifndef USE_PANGO_WIN32
-
 #include "OpenTypeUtil.h"
 
 
@@ -372,10 +370,6 @@ void readOpenTypeSVGTable(hb_font_t* hb_font,
     }
 
     // OpenType fonts use Big Endian
-#if 0
-    uint16_t version = ((data[0] & 0xff) <<  8) +  (data[1] & 0xff);
-    // std::cout << "Version: " << version << std::endl;
-#endif
     uint32_t offset  = ((data[2] & 0xff) << 24) + ((data[3] & 0xff) << 16) + ((data[4] & 0xff) << 8) + (data[5] & 0xff);
 
     // std::cout << "Offset: "  << offset << std::endl;
@@ -433,8 +427,6 @@ void readOpenTypeSVGTable(hb_font_t* hb_font,
     }
 }
 
-#endif /* !USE_PANGO_WIND32    */
-
 /*
   Local Variables:
   mode:c++
diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h
index b6214cd7ab0..6ed9a1417e8 100644
--- a/src/libnrtype/font-instance.h
+++ b/src/libnrtype/font-instance.h
@@ -120,15 +120,11 @@ private:
 
     // Temp: make public
 public:
-#ifdef USE_PANGO_WIN32
-    HFONT                 theFace = nullptr;
-#else
     // we need to keep around an rw copy of the (read-only) hb font to extract the freetype face
     hb_font_t*            hb_font_copy = nullptr;
     FT_Face               theFace = nullptr;
                 // it's a pointer in fact; no worries to ref/unref it, pango does its magic
                 // as long as pFont is valid, theFace is too
-#endif
 
 private:
     // Font metrics in em-box units
-- 
GitLab

