-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
110 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package xyz.cssxsh.skia | ||
|
||
import org.jetbrains.skia.* | ||
|
||
public fun Canvas.draw(block: Canvas.() -> Unit): Canvas { | ||
val index = save() | ||
block.invoke(this) | ||
return restoreToCount(saveCount = index) | ||
} | ||
|
||
public fun Surface.canvas(block: Canvas.() -> Unit): Canvas { | ||
return canvas.draw(block) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package xyz.cssxsh.skia | ||
|
||
import org.jetbrains.skia.* | ||
|
||
public fun FontMgr.makeFamilies(): Map<String, FontStyleSet> { | ||
val count = familiesCount | ||
if (count == 0) return emptyMap() | ||
val families: MutableMap<String, FontStyleSet> = HashMap() | ||
|
||
for (index in 0 until count) { | ||
val name = getFamilyName(index) | ||
val styles = makeStyleSet(index) ?: throw NoSuchElementException("${this}: ${index}.${name}") | ||
families[name] = styles | ||
} | ||
|
||
return families | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters