if (lines == null)
lines = getLines;
if (!textMeasureIsUpToDate) {
- using (Surface img = new Surface (IFace.dev, 10, 10)) {
- using (Context gr = new Context (img)) {
- //Cairo.FontFace cf = gr.GetContextFontFace ();
-
- gr.FontFace = Font.Name;
- gr.FontSize = (uint)Font.Size;
- //gr.FontOptions = Interface.FontRenderingOptions;
- //gr.Antialias = Interface.Antialias;
-
- fe = gr.FontExtents;
- te = new TextExtents ();
-
- cachedTextSize.Height = (int)Math.Ceiling ((fe.Ascent+fe.Descent) * Math.Max (1, lines.Count)) + Margin * 2;
-
- try {
- for (int i = 0; i < lines.Count; i++) {
- string l = lines[i].Replace ("\t", new String (' ', Interface.TabSize));
-
- TextExtents tmp = gr.TextExtents (l);
-
- if (tmp.XAdvance > te.XAdvance)
- te = tmp;
- }
- cachedTextSize.Width = (int)Math.Ceiling (te.XAdvance) + Margin * 2;
- textMeasureIsUpToDate = true;
- } catch {
- return -1;
- }
- }
+ using (Context gr = new Context (IFace.surf)) {
+ //Cairo.FontFace cf = gr.GetContextFontFace ();
+
+ gr.FontFace = Font.Name;
+ gr.FontSize = (uint)Font.Size;
+ //gr.FontOptions = Interface.FontRenderingOptions;
+ //gr.Antialias = Interface.Antialias;
+
+ fe = gr.FontExtents;
+ te = new TextExtents ();
+
+ cachedTextSize.Height = (int)Math.Ceiling ((fe.Ascent+fe.Descent) * Math.Max (1, lines.Count)) + Margin * 2;
+
+ try {
+ for (int i = 0; i < lines.Count; i++) {
+ string l = lines[i].Replace ("\t", new String (' ', Interface.TabSize));
+
+ TextExtents tmp = gr.TextExtents (l);
+
+ if (tmp.XAdvance > te.XAdvance)
+ te = tmp;
+ }
+ cachedTextSize.Width = (int)Math.Ceiling (te.XAdvance) + Margin * 2;
+ textMeasureIsUpToDate = true;
+ } catch {
+ return -1;
+ }
}
}