Skip to content

Commit

Permalink
Add type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Dec 16, 2023
1 parent 28cc28b commit 7842da7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fontra/core/glyphnames.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
GLYPHDATA = None


def _getGlyphData():
def _getGlyphData() -> GlyphData:
global GLYPHDATA
if GLYPHDATA is None:
from importlib.resources import files
Expand All @@ -14,7 +14,7 @@ def _getGlyphData():
return GLYPHDATA


def getSuggestedGlyphName(codePoint):
def getSuggestedGlyphName(codePoint: int) -> str:
data = _getGlyphData()
uniStr = f"{codePoint:04X}"
info = data.unicodes.get(uniStr)
Expand All @@ -23,7 +23,7 @@ def getSuggestedGlyphName(codePoint):
return "uni" + uniStr if len(uniStr) == 4 else "u" + uniStr


def getUnicodeFromGlyphName(glyphName):
def getUnicodeFromGlyphName(glyphName: str) -> int | None:
data = _getGlyphData()

info = data.names.get(glyphName)
Expand All @@ -45,7 +45,7 @@ def getUnicodeFromGlyphName(glyphName):
codePoint = int(uniStr, 16)
except ValueError:
pass
if codePoint > 0x10FFFF:
if codePoint is not None and codePoint > 0x10FFFF:
codePoint = None

return codePoint

0 comments on commit 7842da7

Please sign in to comment.