Skip to content

Commit

Permalink
Implement reading/writing font info and sources
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Mar 18, 2024
1 parent 18eb28e commit a9783a5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/fontra_rcjk/backend_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Any, Awaitable, Callable

from fontra.core.classes import (
Font,
FontInfo,
GlobalAxis,
GlobalDiscreteAxis,
Expand Down Expand Up @@ -135,7 +136,7 @@ async def taskFunc():
self._getMiscFontItemsTask = asyncio.create_task(taskFunc())
await self._getMiscFontItemsTask

async def _getDesignspace(self):
async def _getDesignspace(self) -> Font:
await self._getMiscFontItems()
designspace = self._tempFontItemsCache["designspace"]
self._updateDefaultLocation(designspace)
Expand All @@ -146,23 +147,28 @@ def _updateDefaultLocation(self, designspace):
self._defaultLocation = mapLocationFromUserToSource(userLoc, designspace.axes)

async def getFontInfo(self) -> FontInfo:
return FontInfo()
designspace = await self._getDesignspace()
return deepcopy(designspace.fontInfo)

async def putFontInfo(self, fontInfo: FontInfo):
pass
designspace = await self._getDesignspace()
designspace.fontInfo = deepcopy(fontInfo)
await self._writeDesignspace(designspace)

async def getSources(self) -> dict[str, GlobalSource]:
return {}
designspace = await self._getDesignspace()
return deepcopy(designspace.sources)

async def putSources(self, sources: dict[str, GlobalSource]) -> None:
pass
designspace = await self._getDesignspace()
designspace.sources = deepcopy(sources)
await self._writeDesignspace(designspace)

async def getGlobalAxes(self) -> list[GlobalAxis | GlobalDiscreteAxis]:
designspace = await self._getDesignspace()
return deepcopy(designspace.axes)

async def putGlobalAxes(self, axes: list[GlobalAxis | GlobalDiscreteAxis]) -> None:
await self._getMiscFontItems()
designspace = await self._getDesignspace()
designspace.axes = deepcopy(axes)
self._updateDefaultLocation(designspace)
Expand Down

0 comments on commit a9783a5

Please sign in to comment.