-
Notifications
You must be signed in to change notification settings - Fork 28
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
7 changed files
with
57 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Scarpe.app do | ||
font "fonts/Pacifico.ttf" | ||
para "Hello yayyy" | ||
end |
Binary file not shown.
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class Scarpe | ||
class Font < Scarpe::Widget | ||
display_properties :font | ||
|
||
def initialize(font) | ||
@font = font | ||
super | ||
|
||
create_display_widget | ||
end | ||
end | ||
end |
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 |
---|---|---|
|
@@ -30,3 +30,4 @@ | |
require_relative "text_widget" | ||
require_relative "link" | ||
require_relative "line" | ||
require_relative "font" |
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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../base64" | ||
|
||
class Scarpe | ||
class WebviewFont < WebviewWidget | ||
include Base64 | ||
attr_accessor :font | ||
|
||
def initialize(properties) | ||
@font = properties[:font] | ||
puts "font: #{@font}" | ||
super | ||
end | ||
|
||
def element | ||
puts @font | ||
HTML.render do |h| | ||
h.link(href: @font, rel: "stylesheet") | ||
h.style do | ||
<<~CSS | ||
@font-face { | ||
font-family: Pacifico; | ||
src: url("data:font/truetype;base64,#{encode_file_to_base64(@font)}") format('truetype'); | ||
} | ||
* { | ||
font-family: Pacifico; | ||
} | ||
CSS | ||
end | ||
# Rest of the HTML code for the element | ||
end | ||
end | ||
end | ||
end |
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