Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional cross-platform outline rendering mode #451

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c5d4e18
fontgoggles.misc.plotter as abstraction above direct use of CocoaPen …
stenson Oct 13, 2024
6ab0e28
abstract out all mac-specific code from fontgoggles/font
stenson Oct 13, 2024
40e0ec2
return a RecordingPen from pathFromGlyph
stenson Oct 13, 2024
2828b01
button up Plotter class as single entry point
stenson Oct 14, 2024
ea05cf2
add a test for noCocoa mode
stenson Oct 14, 2024
5885f0a
more extensive test
stenson Oct 14, 2024
fb7a92f
pass in sys.stderr.write
stenson Oct 14, 2024
b7a40ef
delete non-test version of this file
stenson Oct 14, 2024
80050f2
move AppKit call to plotter
stenson Oct 14, 2024
49ead8c
fontgoggles.misc.plotter -> fontgoggles.misc.platform
stenson Oct 14, 2024
7341e09
move library requirements into setup.py
stenson Oct 21, 2024
efd022e
wrap build_lib.sh call with platform check so we don't run on non-mac
stenson Oct 29, 2024
fa56b6a
Merge branch 'justvanrossum:master' into master
stenson Oct 29, 2024
08a5ab8
use draw_glyph_with_pen instead of custom drawfuncs
stenson Nov 23, 2024
5b07f18
uncomment uharfbuzz line for conflict
stenson Nov 23, 2024
c4f2ff5
uncomment uharfbuzz line for conflict
stenson Nov 23, 2024
5be6bb6
Merge remote-tracking branch 'upstream/master'
stenson Nov 23, 2024
637fb2f
update setup.py version of uharfbuzz
stenson Nov 23, 2024
cbe8cd3
disable turbo for now
stenson Dec 7, 2024
6347a73
reenable Turbo/build_lib.sh in setup but wrap with a try
stenson Dec 11, 2024
343669e
PR feedback: unpin setup requires, black format new files, remove Pla…
stenson Dec 11, 2024
4d26863
pin ufo2ft and note both pins
stenson Dec 12, 2024
b3e04bd
Merge remote-tracking branch 'upstream/master'
stenson Dec 21, 2024
aac8609
unpin ufo2ft
stenson Dec 21, 2024
c41f35a
Merge remote-tracking branch 'upstream/master'
stenson Jan 12, 2025
0da76d9
Merge remote-tracking branch 'upstream/master'
stenson Jan 17, 2025
0d2eb09
copy numpy 10.14 pin from requirements.txt
stenson Jan 17, 2025
ebad85f
PlatformCocoa and PlatformGeneric
stenson Jan 17, 2025
244bab9
black format platform.py
stenson Jan 17, 2025
04cb905
normalize two PenWrapper calls
stenson Jan 17, 2025
5e2747b
back to ..misc.platform import platform with SimpleNamespace
stenson Jan 17, 2025
dd11df3
get rid of PenWrapper
stenson Jan 17, 2025
5d9792c
leave out the path Pen init argument
stenson Jan 17, 2025
96daaab
fix and test getUseCocoa
stenson Jan 19, 2025
04bc761
simplify initial platform update
stenson Jan 19, 2025
520529e
no need to global platform in setUseCocoa
stenson Jan 20, 2025
70f9c47
require python>=3.10 in setup for usage as a library, since SimpleNam…
stenson Jan 23, 2025
40b2bed
deleted used USE_COCOA variable
stenson Jan 26, 2025
7811558
turns out CocoaPen can be imported on non-cocoa platforms, so changed…
stenson Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Lib/fontgoggles/misc/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def drawCOLRv1Glyph(colorFont, glyphName, colorPalette, defaultColor):
palette=colorPalette,
textColor=defaultColor,
)

Pen = CocoaPen


Expand Down Expand Up @@ -82,11 +82,11 @@ def convertColor(c):
@staticmethod
def drawCOLRv1Glyph(colorFont, glyphName, colorPalette, defaultColor):
raise NotImplementedError()

class Pen(RecordingPen):
def __init__(self, glyphSet): # to match CocoaPen constructor
def __init__(self, glyphSet): # to match CocoaPen constructor
super().__init__()

@property
def path(self):
return self
Expand All @@ -99,12 +99,12 @@ def path(self):


def setUseCocoa(onOff):
global platform
global platform, _platform
stenson marked this conversation as resolved.
Show resolved Hide resolved
if onOff:
assert CAN_COCOA
_platform = PlatformCocoa if onOff else PlatformGeneric
platform.__dict__.update(**_platform.__dict__)


def getUseCocoa():
return platform is PlatformCocoa
return _platform is PlatformCocoa
6 changes: 5 additions & 1 deletion Tests/test_noCocoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from asyncio import run
from fontgoggles.font import getOpener
from fontgoggles.misc.textInfo import TextInfo
from fontgoggles.misc.platform import platform, setUseCocoa
from fontgoggles.misc.platform import setUseCocoa, getUseCocoa
from testSupport import getFontPath
from fontTools.pens.recordingPen import RecordingPen

Expand Down Expand Up @@ -31,13 +31,17 @@ def getDrawings(path):

return glyphDrawings

assert getUseCocoa() == True

for font_path in font_paths:
glyphDrawings = getDrawings(font_path)
for g in glyphDrawings:
assert "NSBezierPath" in str(type(g.path))

setUseCocoa(False)

assert getUseCocoa() == False

for font_path in font_paths:
glyphDrawings = getDrawings(font_path)
for g in glyphDrawings:
Expand Down