summaryrefslogtreecommitdiff
path: root/dviware/dvisvgm/src/ttf/VheaTable.cpp
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-01-12 03:01:29 +0000
committerNorbert Preining <norbert@preining.info>2023-01-12 03:01:29 +0000
commit6a7900c93acc16d1bbd2f1e26286c7dd7387e6c0 (patch)
tree76196287351cba68a51934c49468bf1a7846aa76 /dviware/dvisvgm/src/ttf/VheaTable.cpp
parentc1c19023b4b1d43cb874f84df5102b485853e672 (diff)
CTAN sync 202301120301
Diffstat (limited to 'dviware/dvisvgm/src/ttf/VheaTable.cpp')
-rw-r--r--dviware/dvisvgm/src/ttf/VheaTable.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/dviware/dvisvgm/src/ttf/VheaTable.cpp b/dviware/dvisvgm/src/ttf/VheaTable.cpp
new file mode 100644
index 0000000000..d49b76f523
--- /dev/null
+++ b/dviware/dvisvgm/src/ttf/VheaTable.cpp
@@ -0,0 +1,66 @@
+/*************************************************************************
+** VheaTable.cpp **
+** **
+** This file is part of dvisvgm -- a fast DVI to SVG converter **
+** Copyright (C) 2005-2023 Martin Gieseking <martin.gieseking@uos.de> **
+** **
+** This program is free software; you can redistribute it and/or **
+** modify it under the terms of the GNU General Public License as **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program 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 General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#include "VheaTable.hpp"
+#include "TTFWriter.hpp"
+#include "../Font.hpp"
+
+using namespace std;
+using namespace ttf;
+
+
+void VheaTable::write (ostream &os) const {
+ const PhysicalFont &font = ttfWriter()->getFont();
+ double scale = ttfWriter()->unitsPerEmFactor();
+ writeUInt32(os, 0x10000); // table version 1.0
+ writeInt16(os, round(font.ascent()*scale));
+ writeInt16(os, round(-font.descent()*scale));
+ writeInt16(os, 0); // line gap, always 0
+ writeUInt16(os, _advanceHeightMax);
+ writeInt16(os, _minTopSideBearing);
+ writeInt16(os, _minBottomSideBearing);
+ writeInt16(os, _yMaxExtent);
+ writeInt16(os, 1); // caretSlopeRise (1 = vertical)
+ writeInt16(os, 0); // caretSlopeRun (0 = vertical)
+ writeInt16(os, 0); // caretOffset
+ writeInt16(os, 0); // reserved
+ writeInt16(os, 0); // reserved
+ writeInt16(os, 0); // reserved
+ writeInt16(os, 0); // reserved
+ writeInt16(os, 0); // metricDataFormat (always 0)
+ writeUInt16(os, _numberOfVMetrics);
+}
+
+
+void VheaTable::updateYMinMax (uint32_t c, int16_t ymin, int16_t ymax) {
+ const PhysicalFont &font = ttfWriter()->getFont();
+ double extend = font.style() ? font.style()->extend : 1;
+ double scale = ttfWriter()->unitsPerEmFactor();
+ int16_t advance = (c == 0 ? ymax : round(scale*extend*font.vAdvance(c)));
+ _yMaxExtent = max(_yMaxExtent, ymax);
+ _minTopSideBearing = min(_minTopSideBearing, ymin);
+ _minBottomSideBearing = min(_minBottomSideBearing, int16_t(advance-ymax));
+}
+
+
+void VheaTable::updateAdvanceHeight (uint16_t h, uint16_t numberOfVMetrics) {
+ _advanceHeightMax = max(_advanceHeightMax, h);
+ _numberOfVMetrics = numberOfVMetrics;
+}