Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 영화리뷰
- Flutter code generator
- Flutter
- Class Modifier
- Flutter Json
- VariableFont
- 뒤로가기 버튼
- 햄스터사육장
- 골든햄스터
- Riverpod
- 햄쨩일기
- Indexed Stack
- flutter tutorial
- 플러터 튜토리얼 플러그인
- Flutter textstyle
- 햄쨩
- 네이티브 VS 크로스플랫폼
- 플러터
- 햄스터 계란
- Json Serializable
- flutter tutorial coach mark
- 햄스터
- opentype-font
- flutter 2.8
- 햄스터 사막모래
- gorouter
- 햄스터케이지
- 플러터 2.8
- Flutter Freezed
- Flutter variablefont
Archives
- Today
- Total
통조림
[Flutter]Variable Font 본문
여러 곳에서 많이 사용되고 있는 Pretendard와 같이 Variable을 지원하는 폰트스타일이 존재한다.
Variable기능을 사용함으로 Flutter 코드 안에서 다음과 같은 태그를 제어할 수 있게 된다.
- wght : font-weight
- wdth : font-stretch
- sint : 기울기
- ital : 이텔릭체
- opsz : 옵티컬 사이즈
Flutter안에서의 사용방법은 다음과 같다.
Font Import
먼저 정해진 asset경로에 폰트를 넣어주고 yaml파일에 선언해준다.
fonts:
- family: Pretendard
fonts:
- asset: assets/fonts/PretendardVariable.ttf
TextStyle 문서참고
TextStyle클래스 정의문서 내에 FontVariation 내용 마이크로소프트에서 정리한 opentype font의 포맷을 따른다고 되어있다. 이에 따르면 4글자 axis와 해당 axi의 value가 짝을 이룬다.
class FontVariation {
/// `axis` is the four-character tag that identifies the design axis.
/// These tags are specified by font formats such as OpenType.
/// See <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg>
///
/// `value` is the value that the axis will be set to. The behavior
/// depends on how the font implements the axis.
const FontVariation(
this.axis,
this.value,
) : assert(axis.length == 4,
OpenType Design-Variation Axis Tag Registry (OpenType 1.9) - Typography
마이크로소프트 공식 문서에 따르면 각 태그들의 권장 value는 다음과 같다.
- wght - 폰트에서 지원하는 영역
- wdth : 1 ~ 1000
- sint : -90 ~ +90
- ital : 0~1 value
- opsz : 0보다 큰 수 1(0~16이 regular사이즈에서 권장되는 값이다)
적용한 코드
Variable폰트를 적용한 코드는 다음과 같다.
TextStyle을 선언해주고, fontVariations 프로퍼티 안에서 FontVariation 리스트 아이템을 추가하는 형식이다.
import 'dart:ui';
import 'package:flutter/material.dart';
const textStyle = TextStyle(
fontFamily : 'Pretendard'
fontVariations: <FontVariation>[
const FontVariation('wght', 700),
const FontVariation('opsz', 17),
],
);
'Software > Flutter' 카테고리의 다른 글
[Flutter]GoRouter Redirection (0) | 2024.04.02 |
---|---|
[Flutter] JsonSerializable & Freezed (0) | 2023.08.18 |
Flutter 2.8 업데이트 내용 (2) | 2021.12.24 |
Flutter web Tutorial 디자인 - turorial_coach_mark 플러그인 (0) | 2021.08.31 |
flutter - 일정관리 어플 만들기(2) (2) | 2021.07.17 |