f
This commit is contained in:
parent
df49cc4b01
commit
28067d6979
1 changed files with 4 additions and 4 deletions
|
@ -164,7 +164,7 @@ proc stroke(ctx: Context, image: Image, path: Path) =
|
||||||
ctx.layer.applyOpacity(ctx.globalAlpha)
|
ctx.layer.applyOpacity(ctx.globalAlpha)
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
|
|
||||||
proc createFont(ctx: Context): Font =
|
proc newFont(ctx: Context): Font =
|
||||||
if ctx.font == "":
|
if ctx.font == "":
|
||||||
raise newException(PixieError, "No font has been set on this Context")
|
raise newException(PixieError, "No font has been set on this Context")
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ proc createFont(ctx: Context): Font =
|
||||||
result.size = ctx.fontSize
|
result.size = ctx.fontSize
|
||||||
|
|
||||||
proc fillText(ctx: Context, image: Image, text: string, at: Vec2) =
|
proc fillText(ctx: Context, image: Image, text: string, at: Vec2) =
|
||||||
let font = ctx.createFont()
|
let font = newFont(ctx)
|
||||||
|
|
||||||
# Canvas positions text relative to the alphabetic baseline by default
|
# Canvas positions text relative to the alphabetic baseline by default
|
||||||
var at = at
|
var at = at
|
||||||
|
@ -201,7 +201,7 @@ proc fillText(ctx: Context, image: Image, text: string, at: Vec2) =
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
|
|
||||||
proc strokeText(ctx: Context, image: Image, text: string, at: Vec2) =
|
proc strokeText(ctx: Context, image: Image, text: string, at: Vec2) =
|
||||||
let font = ctx.createFont()
|
let font = newFont(ctx)
|
||||||
|
|
||||||
# Canvas positions text relative to the alphabetic baseline by default
|
# Canvas positions text relative to the alphabetic baseline by default
|
||||||
var at = at
|
var at = at
|
||||||
|
@ -434,7 +434,7 @@ proc measureText*(ctx: Context, text: string): TextMetrics =
|
||||||
## Returns a TextMetrics object that contains information about the measured
|
## Returns a TextMetrics object that contains information about the measured
|
||||||
## text (such as its width, for example).
|
## text (such as its width, for example).
|
||||||
let
|
let
|
||||||
font = ctx.createFont()
|
font = newFont(ctx)
|
||||||
bounds = typeset(font, text).computeBounds()
|
bounds = typeset(font, text).computeBounds()
|
||||||
result.width = bounds.x
|
result.width = bounds.x
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue