Skip to content

Commit

Permalink
Update celiagg backend to use 2.0.0 API (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwiggins authored Feb 26, 2021
1 parent b5d22c9 commit 0066b29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ci/edmtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

dependencies = {
"apptools",
"celiagg^=1.0.3",
"celiagg^=2.0.0",
"coverage",
"Cython",
"fonttools",
Expand Down
18 changes: 9 additions & 9 deletions kiva/celiagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
constants.EOF_FILL_STROKE: agg.DrawingMode.DrawEofFillStroke,
}
text_modes = {
constants.TEXT_FILL: agg.TextDrawingMode.TextDrawFill,
constants.TEXT_FILL: agg.TextDrawingMode.TextDrawRaster,
constants.TEXT_STROKE: agg.TextDrawingMode.TextDrawStroke,
constants.TEXT_FILL_STROKE: agg.TextDrawingMode.TextDrawFillStroke,
constants.TEXT_INVISIBLE: agg.TextDrawingMode.TextDrawInvisible,
Expand Down Expand Up @@ -611,7 +611,7 @@ def normalize_image(img):
def select_font(self, name, size, textEncoding):
""" Set the font for the current graphics context.
"""
self.font = agg.Font(name, size, agg.FontCacheType.RasterFontCache)
self.font = agg.Font(name, size)

def set_font(self, font):
""" Set the font for the current graphics context.
Expand All @@ -625,7 +625,7 @@ def set_font_size(self, size):
return

font = self.font
self.select_font(font.filepath, size, font.cache_type)
self.select_font(font.filepath, size)

def set_character_spacing(self, spacing):
msg = "set_character_spacing not implemented on celiagg yet."
Expand Down Expand Up @@ -674,6 +674,7 @@ def show_text(self, text, point=None):
self.font,
transform,
self.canvas_state,
fill=self.fill_paint,
stroke=self.stroke_paint,
)

Expand All @@ -692,7 +693,8 @@ def get_text_extent(self, text):
if self.font is None:
raise RuntimeError("get_text_extent called before setting a font!")

x1, x2 = 0.0, self.font.width(text)
font_cache = self.gc.font_cache
x1, x2 = 0.0, font_cache.width(self.font, text)
y1, y2 = 0.0, self.font.height
return x1, y1, x2, y2

Expand Down Expand Up @@ -801,13 +803,11 @@ def get_empty_path(self):

def draw_path_at_points(self, points, path, mode=constants.FILL_STROKE):
""" Draw a path object at many different points.
XXX: This is currently broken for some reason
"""
shape = agg.ShapeAtPoints(path.path, points)
self.canvas_state.drawing_mode = draw_modes[mode]
self.gc.draw_shape(
shape,
self.gc.draw_shape_at_points(
path.path,
points,
self.transform,
self.canvas_state,
stroke=self.stroke_paint,
Expand Down

0 comments on commit 0066b29

Please sign in to comment.