---
title: "font_modify"

doc_type: static
doc_category: static
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/sline/filter/font-modify'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/sline/filter/font-modify.md'
---

# font_modify


    修改字体对象的指定属性，并返回新的字体对象。

    支持的属性及其有效值如下所示：
| **属性** | **有效值** | **说明** |  
|---------|-----------|---------|  
| **`style`** | `"normal"` | 将字体转换为常规（非斜体）变体。 |  
|  | `"italic"` | 将字体转换为斜体变体（如果可用）。 |  
|  | `"oblique"` | 将字体转换为倾斜体变体（对于斜体和倾斜体，SHOPLINE 字体通常仅支持其中的一种，不能同时支持）。 |  
| **`weight`** | `100`–`900`（以100为间隔） | 调整字重至指定值（如 `400` 为常规，`700` 为加粗）。 |  
|  | `"normal"` | `weight: 400` 的简写。 |  
|  | `"bold"` | `weight: 700` 的简写。 |  
|  | `"+/-N"`（如 `"+200"`） | 在当前字重上增加/减少 `N`（如 `400` → `600`）。 |  
|  | `"lighter"` | 根据 CSS 规则降低字重（如 `700` → `400`）。 |  
|  | `"bolder"` | 根据 CSS 规则提高字重（如 `400` → `700`）。 |  




    
`font | font_modify(key, value)` 返回一个 [`font`](https://developer.shopline.com/zh-hans-cn/docs/sline/object/font.md) 对象。
    



    
## 必选参数

        
            - `font` [`font`](https://developer.shopline.com/zh-hans-cn/docs/sline/object/font.md)：给定的 font 对象。
        
            - `key` `string`：要修改的属性。
        
            - `value` `string`：新的属性值。
        
    





    
## 例子

        
            

            


            

            
<SlineExample path={'/'} objects={ 
    [""] 
}>
```sline
Original weight: {{ settings.sort_title_font.weight }}

{{#var lighterFont = settings.sort_title_font | font_modify("weight", "lighter") /}}

h2 {
  font-weight: {{ lighterFont.weight }};
}

```
</SlineExample>
            
        
    
