小编Taw*_*wah的帖子

如何将文本转换为路径?

我试图将文本转换为曲线和路径,例如:

Text ='欢迎来到python'

我正在尝试将此文本转换为路径.此外,我试图将此路径信息作为点列表.

我想将文本存储为SVG文件中的路径.

就像在adobe illustrator中将文本转换为轮廓时一样.

我试过这个例子,但这不是我想要的: cairo例子

import cairo

def text_extent(font, font_size, text, *args, **kwargs):
    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 0, 0)
    ctx = cairo.Context(surface)
    ctx.select_font_face(font, *args, **kwargs)
    ctx.set_font_size(font_size)
    return ctx.text_extents(text)

text='Example'
font="Sans"
font_size=55.0
font_args=[cairo.FONT_SLANT_NORMAL]
(x_bearing, y_bearing, text_width, text_height,
 x_advance, y_advance) = text_extent(font, font_size, text, *font_args)
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(text_width), int(text_height))
ctx = cairo.Context(surface)
ctx.select_font_face(font, *font_args)
ctx.set_font_size(font_size)
ctx.move_to(-x_bearing, -y_bearing)
ctx.text_path(text)
ctx.set_source_rgb(0.47, 0.47, 0.47)
ctx.fill_preserve()
ctx.set_source_rgb(1, 0, 0)
ctx.set_line_width(1.5)
ctx.stroke()

surface.write_to_png("/tmp/out.png")
Run Code Online (Sandbox Code Playgroud)

python text path curves

10
推荐指数
1
解决办法
1921
查看次数

Angular 2 - Beta 16 @ViewChild,loadNextToLocation试图动态加载另一个组件吗?

我正在尝试动态加载另一个组件,它之前正在工作但是当更新到beta 16时它停止了.我阅读了更改日志并更改了我的代码,但仍未成功.

我登录到控制台我从@ViewChild得到的东西我想得到一个ViewContainerRef,但是我得到的ElementRef会导致错误.怎么解决这个问题

请查看我的控制台日志的代码和屏幕截图 在此输入图像描述

export class ChildWindowComponent implements OnInit{
public contentType: Type;
public childProps: ChildWindowVm;


@Output() okActionEvent = new EventEmitter<any>();
@Output() cancelActionEvent = new EventEmitter<any>();

@ViewChild('childContentPlace') childContentPlace: ViewContainerRef;
constructor(private dcl: DynamicComponentLoader) {
    console.log(this.childContentPlace);
}

ngAfterViewInit() {
    console.log(this.childContentPlace);

    this.dcl.loadNextToLocation(this.contentType, this.childContentPlace).then((tempComp) => {
        tempComp.instance.childVm = this.childProps.childContent;
    });
}

ngOnInit() {

}

okClicked(e:any) {
    this.okActionEvent.emit(null);

}
cancelClicked(e:any) {
    this.cancelActionEvent.emit(null);
}
Run Code Online (Sandbox Code Playgroud)

}

HTML代码

<div>
<div class="child-window-block" >

</div>
<div class="child-window child-window-size" [style.width.px]="childProps.width" [style.height.px]="childProps.height" [style.top.px]="childProps.top" [style.left.px]="childProps.left">
    <div class="display-flex flex-direction-col fill-parent">
        <div [style.height.px]="childProps.titleHeight">
            <div class="child-window-header display-flex …
Run Code Online (Sandbox Code Playgroud)

viewchild angular

4
推荐指数
1
解决办法
912
查看次数

Flex 高度在 Chrome 中不起作用

为了更好地查看问题,请在 Firefox 和 chrome 上的 html 代码下运行并查看差异。

该代码适用于所有浏览器,但不适用于 Chrome。问题是当您将 display 设置为flexflex-directionto column,并将其中一个 flex 项设置flex-grow为 1 时。此 flex 项的内容不能将高度设置为 100%。

你能帮我在不使用 JavaScript 或 css Calc 函数的情况下解决问题吗?因为在实际项目中,事情远比这复杂得多。

h1 {
  margin: 0;
  padding: 0;
  color: white;
}

div {
  font-size: 38px;
  color: white;
}
Run Code Online (Sandbox Code Playgroud)
<body style="margin: 0; padding: 0;">
  <div style="height: 100vh; background: royalblue;">
    <div style="display: flex; flex-direction: column; height: 100%;">
      <div style="background: rosybrown; flex-grow: 0;">
        This is first flex item
      </div>
      <div style="flex-grow: 1; background-color: …
Run Code Online (Sandbox Code Playgroud)

css google-chrome flexbox

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

css ×1

curves ×1

flexbox ×1

google-chrome ×1

path ×1

python ×1

text ×1

viewchild ×1