update to ref font
This commit is contained in:
parent
3832fb3227
commit
f696fce6b0
3 changed files with 16 additions and 14 deletions
15
README.md
15
README.md
|
@ -127,19 +127,20 @@ image.fillText(font.typeset(text, bounds = vec2(180, 180)), vec2(10, 10))
|
|||
### Text spans
|
||||
[examples/text_spans.nim](examples/text_spans.nim)
|
||||
```nim
|
||||
let font = readFont("tests/fonts/Ubuntu-Regular_1.ttf")
|
||||
let typeface = readTypeface("tests/fonts/Ubuntu-Regular_1.ttf")
|
||||
|
||||
proc style(font: Font, size: float32, color: ColorRGBA): Font =
|
||||
result = font
|
||||
proc newFont(typeface: Typeface, size: float32, color: ColorRGBA): Font =
|
||||
result = newFont(typeface)
|
||||
result.size = size
|
||||
result.paint.color = color
|
||||
|
||||
let spans = @[
|
||||
newSpan("verb [with object] ", font.style(12, rgba(200, 200, 200, 255))),
|
||||
newSpan("strallow\n", font.style(36, rgba(0, 0, 0, 255))),
|
||||
newSpan("\nstral·low\n", font.style(13, rgba(0, 127, 244, 255))),
|
||||
newSpan("verb [with object] ",
|
||||
typeface.newFont(12, rgba(200, 200, 200, 255))),
|
||||
newSpan("strallow\n", typeface.newFont(36, rgba(0, 0, 0, 255))),
|
||||
newSpan("\nstral·low\n", typeface.newFont(13, rgba(0, 127, 244, 255))),
|
||||
newSpan("\n1. free (something) from restrictive restrictions \"the regulations are intended to strallow changes in public policy\" ",
|
||||
font.style(14, rgba(80, 80, 80, 255)))
|
||||
typeface.newFont(14, rgba(80, 80, 80, 255)))
|
||||
]
|
||||
|
||||
image.fillText(typeset(spans, bounds = vec2(180, 180)), vec2(10, 10))
|
||||
|
|
|
@ -3,19 +3,20 @@ import pixie
|
|||
let image = newImage(200, 200)
|
||||
image.fill(rgba(255, 255, 255, 255))
|
||||
|
||||
let font = readFont("tests/fonts/Ubuntu-Regular_1.ttf")
|
||||
let typeface = readTypeface("tests/fonts/Ubuntu-Regular_1.ttf")
|
||||
|
||||
proc style(font: Font, size: float32, color: ColorRGBA): Font =
|
||||
result = font
|
||||
proc newFont(typeface: Typeface, size: float32, color: ColorRGBA): Font =
|
||||
result = newFont(typeface)
|
||||
result.size = size
|
||||
result.paint.color = color
|
||||
|
||||
let spans = @[
|
||||
newSpan("verb [with object] ", font.style(12, rgba(200, 200, 200, 255))),
|
||||
newSpan("strallow\n", font.style(36, rgba(0, 0, 0, 255))),
|
||||
newSpan("\nstral·low\n", font.style(13, rgba(0, 127, 244, 255))),
|
||||
newSpan("verb [with object] ",
|
||||
typeface.newFont(12, rgba(200, 200, 200, 255))),
|
||||
newSpan("strallow\n", typeface.newFont(36, rgba(0, 0, 0, 255))),
|
||||
newSpan("\nstral·low\n", typeface.newFont(13, rgba(0, 127, 244, 255))),
|
||||
newSpan("\n1. free (something) from restrictive restrictions \"the regulations are intended to strallow changes in public policy\" ",
|
||||
font.style(14, rgba(80, 80, 80, 255)))
|
||||
typeface.newFont(14, rgba(80, 80, 80, 255)))
|
||||
]
|
||||
|
||||
image.fillText(typeset(spans, bounds = vec2(180, 180)), vec2(10, 10))
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Loading…
Reference in a new issue