from fontTools.misc.py23 import *
from fontTools.misc import sstruct
from fontTools.misc.textTools import safeEval
from fontTools.misc.fixedTools import (
	ensureVersionIsLong as fi2ve, versionToFixed as ve2fi)
from . import DefaultTable
import math


hheaFormat = """
		>  # big endian
		tableVersion:           L
		ascent:                 h
		descent:                h
		lineGap:                h
		advanceWidthMax:        H
		minLeftSideBearing:     h
		minRightSideBearing:    h
		xMaxExtent:             h
		caretSlopeRise:         h
		caretSlopeRun:          h
		caretOffset:            h
		reserved0:              h
		reserved1:              h
		reserved2:              h
		reserved3:              h
		metricDataFormat:       h
		numberOfHMetrics:       H
"""


class table__h_h_e_a(DefaultTable.DefaultTable):

	# Note: Keep in sync with table__v_h_e_a

	dependencies = ['hmtx', 'glyf', 'CFF ']

	def decompile(self, data, ttFont):
		sstruct.unpack(hheaFormat, data, self)

	def compile(self, ttFont):
		if ttFont.recalcBBoxes and (ttFont.isLoaded('glyf') or ttFont.isLoaded('CFF ')):
			self.recalc(ttFont)
		self.tableVersion = fi2ve(self.tableVersion)
		return sstruct.pack(hheaFormat, self)

	def recalc(self, ttFont):
		if 'hmtx' in ttFont:
			hmtxTable = ttFont['hmtx']
			self.advanceWidthMax = max(adv for adv, _ in hmtxTable.metrics.values())

		boundsWidthDict = {}
		if 'glyf' in ttFont:
			glyfTable = ttFont['glyf']
			for name in ttFont.getGlyphOrder():
				g = glyfTable[name]
				if g.numberOfContours == 0:
					continue
				if g.numberOfContours < 0 and not hasattr(g, "xMax"):
					# Composite glyph without extents set.
					# Calculate those.
					g.recalcBounds(glyfTable)
				boundsWidthDict[name] = g.xMax - g.xMin
		elif 'CFF ' in ttFont:
			topDict = ttFont['CFF '].cff.topDictIndex[0]
			charStrings = topDict.CharStrings
			for name in ttFont.getGlyphOrder():
				cs = charStrings[name]
				bounds = cs.calcBounds(charStrings)
				if bounds is not None:
					boundsWidthDict[name] = int(
						math.ceil(bounds[2]) - math.floor(bounds[0]))

		if boundsWidthDict:
			minLeftSideBearing = float('inf')
			minRightSideBearing = float('inf')
			xMaxExtent = -float('inf')
			for name, boundsWidth in boundsWidthDict.items():
				advanceWidth, lsb = hmtxTable[name]
				rsb = advanceWidth - lsb - boundsWidth
				extent = lsb + boundsWidth
				minLeftSideBearing = min(minLeftSideBearing, lsb)
				minRightSideBearing = min(minRightSideBearing, rsb)
				xMaxExtent = max(xMaxExtent, extent)
			self.minLeftSideBearing = minLeftSideBearing
			self.minRightSideBearing = minRightSideBearing
			self.xMaxExtent = xMaxExtent

		else:  # No glyph has outlines.
			self.minLeftSideBearing = 0
			self.minRightSideBearing = 0
			self.xMaxExtent = 0

	def toXML(self, writer, ttFont):
		formatstring, names, fixes = sstruct.getformat(hheaFormat)
		for name in names:
			value = getattr(self, name)
			if name == "tableVersion":
				value = fi2ve(value)
				value = "0x%08x" % value
			writer.simpletag(name, value=value)
			writer.newline()

	def fromXML(self, name, attrs, content, ttFont):
		if name == "tableVersion":
			setattr(self, name, ve2fi(attrs["value"]))
			return
		setattr(self, name, safeEval(attrs["value"]))

Lib/fontTools/ttLib/tables/_h_h_e_a.py
from fontTools.misc.py23 import *
from fontTools.misc import sstruct
from fontTools.misc.textTools import safeEval
from fontTools.misc.fixedTools import (
	ensureVersionIsLong as fi2ve, versionToFixed as ve2fi)
from . import DefaultTable
import math


hheaFormat = """
		>  # big endian
		tableVersion:           L
		ascent:                 h
		descent:                h
		lineGap:                h
		advanceWidthMax:        H
		minLeftSideBearing:     h
		minRightSideBearing:    h
		xMaxExtent:             h
		caretSlopeRise:         h
		caretSlopeRun:          h
		caretOffset:            h
		reserved0:              h
		reserved1:              h
		reserved2:              h
		reserved3:              h
		metricDataFormat:       h
		numberOfHMetrics:       H
"""


class table__h_h_e_a(DefaultTable.DefaultTable):

	# Note: Keep in sync with table__v_h_e_a

	dependencies = ['hmtx', 'glyf', 'CFF ']

	# OpenType spec renamed these, add aliases for compatibility
	@property
	def ascender(self): return self.ascent

	@ascender.setter
	def ascender(self,value): self.ascent = value

	@property
	def descender(self): return self.descent

	@descender.setter
	def descender(self,value): self.descent = value

	def decompile(self, data, ttFont):
		sstruct.unpack(hheaFormat, data, self)

	def compile(self, ttFont):
		if ttFont.recalcBBoxes and (ttFont.isLoaded('glyf') or ttFont.isLoaded('CFF ')):
			self.recalc(ttFont)
		self.tableVersion = fi2ve(self.tableVersion)
		return sstruct.pack(hheaFormat, self)

	def recalc(self, ttFont):
		if 'hmtx' in ttFont:
			hmtxTable = ttFont['hmtx']
			self.advanceWidthMax = max(adv for adv, _ in hmtxTable.metrics.values())

		boundsWidthDict = {}
		if 'glyf' in ttFont:
			glyfTable = ttFont['glyf']
			for name in ttFont.getGlyphOrder():
				g = glyfTable[name]
				if g.numberOfContours == 0:
					continue
				if g.numberOfContours < 0 and not hasattr(g, "xMax"):
					# Composite glyph without extents set.
					# Calculate those.
					g.recalcBounds(glyfTable)
				boundsWidthDict[name] = g.xMax - g.xMin
		elif 'CFF ' in ttFont:
			topDict = ttFont['CFF '].cff.topDictIndex[0]
			charStrings = topDict.CharStrings
			for name in ttFont.getGlyphOrder():
				cs = charStrings[name]
				bounds = cs.calcBounds(charStrings)
				if bounds is not None:
					boundsWidthDict[name] = int(
						math.ceil(bounds[2]) - math.floor(bounds[0]))

		if boundsWidthDict:
			minLeftSideBearing = float('inf')
			minRightSideBearing = float('inf')
			xMaxExtent = -float('inf')
			for name, boundsWidth in boundsWidthDict.items():
				advanceWidth, lsb = hmtxTable[name]
				rsb = advanceWidth - lsb - boundsWidth
				extent = lsb + boundsWidth
				minLeftSideBearing = min(minLeftSideBearing, lsb)
				minRightSideBearing = min(minRightSideBearing, rsb)
				xMaxExtent = max(xMaxExtent, extent)
			self.minLeftSideBearing = minLeftSideBearing
			self.minRightSideBearing = minRightSideBearing
			self.xMaxExtent = xMaxExtent

		else:  # No glyph has outlines.
			self.minLeftSideBearing = 0
			self.minRightSideBearing = 0
			self.xMaxExtent = 0

	def toXML(self, writer, ttFont):
		formatstring, names, fixes = sstruct.getformat(hheaFormat)
		for name in names:
			value = getattr(self, name)
			if name == "tableVersion":
				value = fi2ve(value)
				value = "0x%08x" % value
			writer.simpletag(name, value=value)
			writer.newline()

	def fromXML(self, name, attrs, content, ttFont):
		if name == "tableVersion":
			setattr(self, name, ve2fi(attrs["value"]))
			return
		setattr(self, name, safeEval(attrs["value"]))

Lib/fontTools/ttLib/tables/_h_h_e_a.py
diff --git a/Lib/fontTools/ttLib/tables/_h_h_e_a.py b/Lib/fontTools/ttLib/tables/_h_h_e_a.py
index 2520fb3b76..0f5ec51d9d 100644
--- a/Lib/fontTools/ttLib/tables/_h_h_e_a.py
+++ b/Lib/fontTools/ttLib/tables/_h_h_e_a.py
@@ -35,6 +35,19 @@ class table__h_h_e_a(DefaultTable.DefaultTable):
 
 	dependencies = ['hmtx', 'glyf', 'CFF ']
 
+	# OpenType spec renamed these, add aliases for compatibility
+	@property
+	def ascender(self): return self.ascent
+
+	@ascender.setter
+	def ascender(self,value): self.ascent = value
+
+	@property
+	def descender(self): return self.descent
+
+	@descender.setter
+	def descender(self,value): self.descent = value
+
 	def decompile(self, data, ttFont):
 		sstruct.unpack(hheaFormat, data, self)
 
diff --git a/Tests/ttLib/tables/_h_h_e_a_test.py b/Tests/ttLib/tables/_h_h_e_a_test.py
index eb457dee2c..5c03b2073a 100644
--- a/Tests/ttLib/tables/_h_h_e_a_test.py
+++ b/Tests/ttLib/tables/_h_h_e_a_test.py
@@ -126,6 +126,13 @@ def test_toXML_version_as_float(self):
             len([r for r in captor.records
                  if "Table version value is a float" in r.msg]) == 1)
 
+    def test_aliases(self):
+        hhea = self.font['hhea']
+        self.assertEqual(hhea.ascent, hhea.ascender)
+        self.assertEqual(hhea.descent, hhea.descender)
+        hhea.ascender = 800
+        self.assertEqual(hhea.ascent, 800)
+        hhea.ascent = 750
 
 class HheaDecompileOrFromXMLTest(unittest.TestCase):
 

ascender and ascent
The [opentype spec ](https://docs.microsoft.com/en-gb/typography/opentype/spec/hhea) calls the first two substantive entries in the `hhea` table "`ascender`" and "`descender`". fonttools calls them "`ascent`" and "`descent`".

This was surprising! Maybe it's too late to change then but can we at least have an alias?
