- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试在使用 pango 构建的绘图中标记 y 轴。
我无法将文本定向为沿 y 轴垂直向上。
代码的相关部分是:
#include <gtkmm.h>
Pango::FontDescription font;
cr->save(); // where cr is Glib::RefPtr<Cairo::Context> const &
cr->set_source_rgba(1.0,1.0,1.0,0.5);
font.set_family("Monospace");
font.set_style(Pango::STYLE_ITALIC);
font.set_weight(Pango::WEIGHT_BOLD);
font.set_absolute_size(20);
Glib::RefPtr<Pango::Layout> x_axis_label = this->create_pango_layout("x-axis label");
x_axis_label->set_font_description(font);
cr->move_to(0.38,0.465);
x_axis_label->show_in_cairo_context(cr);
// so far so good, renders as expected
// now trying to render the y-axis label
Glib::RefPtr<Pango::Context> t_y_axis_label_ctxt = x_axis_label->get_context();
Pango::Matrix p_matrix;
// apply some transformation
p_matrix.xx = 0.0;
p_matrix.xy = 1.0;
p_matrix.yx = 1.0;
p_matrix.yy = 0.0;
p_matrix.x0 = 0.0;
p_matrix.y0 = 0.0;
t_y_axis_label_ctxt->set_matrix(p_matrix);
Glib::RefPtr<Pango::Layout> y_axis_label = Pango::Layout::create(t_y_axis_label_ctxt);
y_axis_label->set_text("y-axis label"); // if this line of code is omitted I would expect, at least the text "x-axis label" to be rendered. But this does not happen.
y_axis_label->set_font_description(font);
cr->move_to(0.0,0.0);
y_axis_label->show_in_cairo_context(cr); // renders no output
cr->restore();
我怀疑问题与我从 x 轴标签中检索到的上下文有关,而预期的复制行为并未出现。
最佳答案
您确定要旋转 Pango 上下文吗?我相信功能是在开罗时代之前引入的;现在你只需旋转 Cairo 上下文,例如:
cr->save();
cr->rotate_degrees(90);
Glib::RefPtr<Pango::Layout> y_axis_label = this->create_pango_layout("y-axis label");
y_axis_label->set_font_description(font);
cr->move_to(...); // wherever you wanna put it
y_axis_label->show_in_cairo_context(cr);
cr->restore();
如果您仍然没有看到任何东西,请确保您没有将标签移出可见区域。
关于C++ pango 文本方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19109299/
我正在使用 Pango 来排版梵文。考虑由梵文字母 U、梵文字母 MA、梵文符号 VIRAMA、梵文字母 KA、梵文字母 NA、梵文符号 VIRAMA、梵文字母 CHA、梵文元音符号 AU 组成的字符
我正在尝试在使用 pango 构建的绘图中标记 y 轴。 我无法将文本定向为沿 y 轴垂直向上。 代码的相关部分是: #include Pango::FontDescription font;
我有一个代码使用Cairo和 Pango创建图像: #include #include #include #define IMAGE_WIDTH 650 #define IMAGE_HEIGHT 1
我有一个使用 pango 的文本框实现。如果我在从右到左的脚本中放置一个以单词开头的字符串,后跟一个空格,然后在从左到右的脚本中放置单词,则 pango 使用的自动换行会变得困惑(使用 PANGO_W
我想要一个左对齐标签,其中包含一些粗体文本,但使用以下代码(不返回错误)未设置对齐方式...有人知道吗? (python2.7、gtk2.24) label=gtk.Label(""+text+"")
我正在尝试将标签添加到 GTK3 窗口,然后设置标签的字体大小。这是我的尝试: #include static void add_label (GtkWidget* window, gchar *t
第一次海报; Stack Overflow 天使的长期崇拜者。 我在 Pango 控制的跨度文本中遇到颜色问题。 长版: 我正在更新一个旧的 UI 程序,它具有带有 GTK、XML(由 Glade 编
我正在使用 pangomm 渲染一些文本,但我使用的字体没有部分文本的字形(在这种情况下,有一些日语和英语混合在一起)。 Pango 似乎使用后备字体正确呈现文本。 如何确定将哪种字体用作备用字体?
我正在使用 GTK Sharp 为我的应用开发一些 GUI。 看看这段代码: Pango.FontDescription fontdesc = new Pango.FontDescription();
我觉得我可能会错过 Pango 的一些东西。 API 中的几乎所有内容似乎都适合显示静态文本,除了在特定位置绘制/移动光标的两个函数除外,这表明可能有一种内置的方式来实现编辑文本。 例如,要用鼠标标记
我的程序有一个 gtk.TreeView,它显示一个 gtk.ListStore。 gtk.ListStore 包含这样的字符串: ""+site_title+""+"\n"+URL URL 显然是一
Cabal 在尝试安装 pango 时失败,提示它找不到 pkg-config。 peauters:~ $ sudo cabal install pango -v Password: Reading
我正在尝试在 ubuntu 上构建 gtk+1.3,但在配置过程中出现错误, ld: cannot find -lpango 我尝试安装大量 pango 库,但仍未安装,所以我不确定该怎么做。我一直在
根据 this documentation , Pango 能够处理一些便利标签,如 粗体,或 为斜体。 但是,没有什么可以换行的,比如常用的 .有没有办法让 Pango 能够处理换行? 最佳答案 通
启动使用Pango库的任何内容时出现此错误。我正在使用Kubuntu 9.10。我已经在libgtk * libcairo * libpango *和fontconfig上完成了'sudo apt-g
我正在构建 firefox 的定制源代码。当我要构建 firefox 时,出现以下错误,提示“没有 pango 包错误”。我该如何解决这个错误。 最佳答案 如果您使用的是 Ubuntu 18.04 或
我正在使用 librsvg 将 SVG 文件渲染到开罗上下文。之后,我使用 Pango “手动”在顶部渲染一些文本。 渲染 SVG 时,我收到 Pango 警告,指出它无法加载字体: “无法加载字体“
我正在构建 firefox 的定制源代码。当我要构建 firefox 时,出现以下错误,提示“没有 pango 包错误”。我该如何解决这个错误。 最佳答案 如果您使用的是 Ubuntu 18.04 或
我在让 Pango Cairo 自动换行时遇到问题。下面是一些演示代码。我将布局的宽度设置为与红色矩形相同,因此我希望它环绕到红色矩形。实际上,它只是在每一行上放置一个单词,就好像宽度设置得很小一样。
我需要 pyCairo 做的是: 生成一个大小为 100x100 的图像,其中包含一些文本和来自文件系统的图像作为背景 文本应位于文本环绕大小为 20x20 且左下角位于 (40,40) 的框中。 保
我是一名优秀的程序员,十分优秀!