[m-rev.] [PATCH 07/11] mercury_cairo: Add set_default_font_face.

Peter Wang novalazy at gmail.com
Fri Sep 4 12:00:55 AEST 2015


extras/graphics/mercury_cairo/cairo.m:
extras/graphics/mercury_cairo/cairo.text.m:
	Add `set_default_font_face'.
---
 extras/graphics/mercury_cairo/cairo.m      |  4 +---
 extras/graphics/mercury_cairo/cairo.text.m | 10 ++++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/extras/graphics/mercury_cairo/cairo.m b/extras/graphics/mercury_cairo/cairo.m
index c5b249a..bfc995e 100644
--- a/extras/graphics/mercury_cairo/cairo.m
+++ b/extras/graphics/mercury_cairo/cairo.m
@@ -820,9 +820,7 @@ create_context(Surface, Context, !IO) :-
     % Make sure that the cached font face object is set to
     % a meaningful value.  (See the comments in the implementation
     % of {get,set}_font_face for details.)
-    cairo.text.toy_font_face_create("",
-        slant_normal, weight_normal, ToyFF, !IO),
-    cairo.text.set_font_face(Context, ToyFF, !IO).
+    cairo.text.set_default_font_face(Context, !IO).
 
 :- pred create_context_2(S::in, context(S)::out,
     io::di, io::uo) is det <= surface(S).
diff --git a/extras/graphics/mercury_cairo/cairo.text.m b/extras/graphics/mercury_cairo/cairo.text.m
index f6af5e3..95adf77 100644
--- a/extras/graphics/mercury_cairo/cairo.text.m
+++ b/extras/graphics/mercury_cairo/cairo.text.m
@@ -102,6 +102,11 @@
 :- pred set_font_face(context(S)::in, F::in, io::di, io::uo) is det
     <= font_face(F).
 
+    % text.set_default_font_face(Context, !IO):
+    % Replace the current font face for Context with the default font face.
+    %
+:- pred set_default_font_face(context(S)::in, io::di, io::uo) is det.
+
     % text.get_font_face(Context, FontFace, !IO):
     % FontFace is the current font face for Context.
     %
@@ -245,6 +250,11 @@ set_font_face(Context, FF, !IO) :-
     Ctxt->mcairo_cached_font_face = CachedFF;
 ").
 
+set_default_font_face(Context, !IO) :-
+    cairo.text.toy_font_face_create("",
+        slant_normal, weight_normal, ToyFF, !IO),
+    cairo.text.set_font_face(Context, ToyFF, !IO).
+
 get_font_face(Context, FF, !IO) :-
     get_cached_font_face(Context, CachedFF, !IO),
     % TODO: we should have a sanity check that cairo's current
-- 
2.1.2




More information about the reviews mailing list