custom font (<font>, font-[name])
This commit is contained in:
@@ -238,10 +238,24 @@ static func parse_utility_class_internal(rule: CSSRule, utility_name: String) ->
|
||||
rule.properties["font-bold"] = true
|
||||
return
|
||||
|
||||
# Handle font mono
|
||||
# Handle font family
|
||||
if utility_name == "font-sans":
|
||||
rule.properties["font-family"] = "sans-serif"
|
||||
return
|
||||
if utility_name == "font-serif":
|
||||
rule.properties["font-family"] = "serif"
|
||||
return
|
||||
if utility_name == "font-mono":
|
||||
rule.properties["font-family"] = "monospace"
|
||||
rule.properties["font-mono"] = true
|
||||
return
|
||||
|
||||
var reserved_font_styles = ["font-sans", "font-serif", "font-mono", "font-bold", "font-italic"]
|
||||
# Handle custom font families like font-roboto
|
||||
if utility_name.begins_with("font-") and not utility_name in reserved_font_styles:
|
||||
var font_name = utility_name.substr(5) # after 'font-'
|
||||
rule.properties["font-family"] = font_name
|
||||
return
|
||||
|
||||
# Handle font style italic
|
||||
if utility_name == "font-italic":
|
||||
|
||||
@@ -12,8 +12,8 @@ class HTMLElement:
|
||||
func _init(tag: String = ""):
|
||||
tag_name = tag
|
||||
|
||||
func get_attribute(name_: String) -> String:
|
||||
return attributes.get(name_, "")
|
||||
func get_attribute(name_: String, default: String = "") -> String:
|
||||
return attributes.get(name_, default)
|
||||
|
||||
func has_attribute(name_: String) -> bool:
|
||||
return attributes.has(name_)
|
||||
@@ -293,6 +293,17 @@ func get_icon() -> String:
|
||||
var icon_element = find_first("icon")
|
||||
return icon_element.get_attribute("src")
|
||||
|
||||
func process_fonts() -> void:
|
||||
var font_elements = find_all("font")
|
||||
|
||||
for font_element in font_elements:
|
||||
var name = font_element.get_attribute("name")
|
||||
var src = font_element.get_attribute("src")
|
||||
var weight = font_element.get_attribute("weight", "400")
|
||||
|
||||
if name and src:
|
||||
FontManager.register_font(name, src, weight)
|
||||
|
||||
func get_meta_content(name_: String) -> String:
|
||||
var meta_elements = find_all("meta", "name")
|
||||
for element in meta_elements:
|
||||
|
||||
Reference in New Issue
Block a user