-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Divide Font descriptions into FreeType and Win32.
The Font class is still available and won't break existing code, but now the code is more explicit about what a Font object describes.
- Loading branch information
Showing
14 changed files
with
276 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,15 @@ | |
# | ||
# Authors: Erik Hvatum <[email protected]> | ||
# John Wiggins | ||
import sys | ||
|
||
from . import _celiagg | ||
from ._celiagg import ( | ||
AggError, BSpline, BlendMode, DrawingMode, Font, FontCache, | ||
GradientSpread, GradientUnits, GraphicsState, Image, InnerJoin, | ||
LineCap, LineJoin, LinearGradientPaint, Path, PatternPaint, PatternStyle, | ||
PixelFormat, RadialGradientPaint, Rect, ShapeAtPoints, SolidPaint, | ||
TextDrawingMode, Transform, | ||
AggError, BSpline, BlendMode, DrawingMode, FontCache, FontWeight, | ||
FreeTypeFont, GradientSpread, GradientUnits, GraphicsState, Image, | ||
InnerJoin, LineCap, LineJoin, LinearGradientPaint, Path, PatternPaint, | ||
PatternStyle, PixelFormat, RadialGradientPaint, Rect, ShapeAtPoints, | ||
SolidPaint, TextDrawingMode, Transform, Win32Font, | ||
) | ||
|
||
# Query the library | ||
|
@@ -43,6 +44,12 @@ def example_font(): | |
""" | ||
import pkg_resources | ||
|
||
# Windows GDI font selection uses names and not file paths. | ||
# Our included font could be added to the system fonts using | ||
# `AddFontResourceEx`, but that's beyond the scope of this function. | ||
if sys.platform in ('win32', 'cygwin'): | ||
return 'Segoe UI' | ||
|
||
return pkg_resources.resource_filename( | ||
'celiagg', 'data/Montserrat-Regular.ttf' | ||
) | ||
|
@@ -53,15 +60,22 @@ def example_font(): | |
'HAS_TEXT', 'example_font', | ||
|
||
'AggError', 'BlendMode', 'BSpline', 'DrawingMode', 'Font', 'FontCache', | ||
'GradientSpread', 'GradientUnits', 'GraphicsState', 'Image', 'InnerJoin', | ||
'LinearGradientPaint', 'LineCap', 'LineJoin', 'RadialGradientPaint', | ||
'Path', 'PatternPaint', 'PatternStyle', 'PixelFormat', 'Rect', | ||
'ShapeAtPoints', 'SolidPaint', 'TextDrawingMode', 'Transform', | ||
'FontWeight', 'FreeTypeFont', 'GradientSpread', 'GradientUnits', | ||
'GraphicsState', 'Image', 'InnerJoin', 'LinearGradientPaint', 'LineCap', | ||
'LineJoin', 'RadialGradientPaint', 'Path', 'PatternPaint', 'PatternStyle', | ||
'PixelFormat', 'Rect', 'ShapeAtPoints', 'SolidPaint', 'TextDrawingMode', | ||
'Transform', 'Win32Font', | ||
|
||
'CanvasG8', 'CanvasGA16', 'CanvasRGB24', 'CanvasRGBA32', 'CanvasBGRA32', | ||
'CanvasRGBA128', | ||
] | ||
|
||
# Select the correct font class for the platform | ||
if sys.platform in ('win32', 'cygwin'): | ||
Font = Win32Font | ||
else: | ||
Font = FreeTypeFont | ||
|
||
# Keep a font cache for callers that don't want to mess with it | ||
__global_font_cache = None | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.