|
ファイル構成を下記に示します。今回は、日本語 Font を確かめるために、examples と同列に fonts を構成しました。
|
+- fonts
| |
| +- NotoSansJP-Black.otf
| +- NotoSansJP-Bold.otf
| +- NotoSansJP-Light.otf
| +- NotoSansJP-Medium.otf
| +- NotoSansJP-Regular.otf
| +- NotoSansJP-Thin.otf
| +- icons.ttf
|
+- examples
| |
| +- qr_code
| |
| +- src
| | |
| | +- main.rs
| |
| +- Cargo.toml
| +- README.md
|
|
Cargo.toml
[package]
name = "qr_code"
version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
publish = false
[dependencies]
iced = { path = "../..", features = ["qr_code"] }
src/main.rs
日本語 Font のため、青色部のコードを追加します。その他のコードは、各自にて研鑽願います。
use iced::qr_code::{self, QRCode};
use iced::text_input::{self, TextInput};
use iced::{
Align, Column, Container, Element, Length, Sandbox, Settings, Text,
};
pub fn main() -> iced::Result {
// QRGenerator::run(Settings::default())
QRGenerator::run(Settings {
default_font: Some(include_bytes!("../../fonts/NotoSansJP-Regular.otf")),
..Settings::default()
})
}
#[derive(Default)]
struct QRGenerator {
data: String,
input: text_input::State,
qr_code: Option<qr_code::State>,
}
< 省略 >
旧 src/main.rs 新 src/main.rs 変更点
Alignment 関連の変更内容の diff リストです。
4c4,5
< Align, Column, Container, Element, Length, Sandbox, Settings, Text,
---
> // Align, Column, Container, Element, Length, Sandbox, Settings, Text,
> Alignment, Column, Container, Element, Length, Sandbox, Settings, Text,
70c71,72
< .align_items(Align::Center)
---
> // .align_items(Align::Center)
> .align_items(Alignment::Center)
Top
|