mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
feat: support element fontWeight desc
This commit is contained in:
parent
1206369874
commit
be4e0efa71
4 changed files with 6 additions and 4 deletions
|
|
@ -198,9 +198,9 @@ class Context implements TypeContext {
|
|||
}
|
||||
}
|
||||
|
||||
setFont(opts: { fontSize: number, fontFamily?: string, fontWeight?: string }): void {
|
||||
setFont(opts: { fontSize: number, fontFamily?: string, fontWeight?: 'bold' }): void {
|
||||
const strList: string[] = [];
|
||||
if (opts.fontWeight) {
|
||||
if (opts.fontWeight === 'bold') {
|
||||
strList.push(`${opts.fontWeight}`);
|
||||
}
|
||||
strList.push(`${this._doSize(opts.fontSize || 12)}px`);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ const data = {
|
|||
fontSize: 20,
|
||||
color: "#333333",
|
||||
text: "生活就像海洋,只有意志坚强的人,才能到达彼岸。",
|
||||
fontFamily: "",
|
||||
fontFamily: '',
|
||||
fontWeight: 'bold',
|
||||
borderRadius: 20,
|
||||
borderWidth: 2,
|
||||
borderColor: "#bd0b64",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export function drawText(
|
|||
ctx.setFillStyle(elem.desc.color);
|
||||
ctx.setTextBaseline('top');
|
||||
ctx.setFont({
|
||||
fontWeight: desc.fontWeight,
|
||||
fontSize: desc.fontSize,
|
||||
fontFamily: desc.fontFamily
|
||||
});
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ type TypeElemDescText = {
|
|||
color: string;
|
||||
fontSize: number;
|
||||
lineHeight?: number;
|
||||
// fontWeight?: string;
|
||||
fontWeight?: 'bold' | '';
|
||||
fontFamily?: string;
|
||||
textAlign?: 'center' | 'left' | 'right';
|
||||
bgColor: string;
|
||||
|
|
|
|||
Loading…
Reference in a new issue