Fontdue는 간단한 no_std (휴대 성을 위해 표준 라이브러리를 사용하지 않음), Pure Rust, Truetype ( .ttf/.ttc ) 및 OpenType ( .otf ) 글꼴 라이저 라이저 및 레이아웃 도구입니다. 그것은 가능한 한 빠르게 글꼴과 상호 작용하기 위해 노력하고 있으며 현재 글꼴 래스터 라이저의 최저치에서 끝 대기 시간이 가장 낮습니다.
fontdue 는 rusttype (Link), ab_glyph (LINK), glyph_brush (LINK) 및 glyph_brush_layout (Link)의 일부를 대체하도록 설계되었습니다. 이것은 형성을 해결하지 않는 글꼴 라이브러리 클래스입니다.
모양 도서관과 통합 할 시간이 없을 것입니다. 보다 완전한 글꼴 엔진이 필요한 경우 매우 완전한 순수 Rust Text 라이브러리 인 멋진 Cosmic Text Project를 확인해야합니다.
이 라이브러리의 목표는 할당되지 않으며 빠른 "제로 비용"초기 부하가 있어야합니다. 이 라이브러리는 할당을 만들고 alloc Crate에 따라 다릅니다. 글꼴은 생성에 대해 완전히 구문 분석되며 관련 정보는 액세스 형식에보다 편리하게 저장됩니다. 다른 글꼴 라이브러리와 달리 글꼴 구조는 자체 공간을 할당하기 때문에 수명 의존성이 없습니다.
라이브 데모. 이 데모는 브라우저 캔버스에 fontdue Rasterizing의 웹 어셈블리 빌드입니다. fontdue 와 동일한 매개 변수와 함께 제공되는 브라우저의 캔버스 텍스트 API 사이에서 레이스터 화 된 문자의 나란히 제공합니다.
다른 예제는 ./dev/examples 아래에서 찾을 수 있습니다.
Rasterization API는 가까운 시일 내에 큰 변화를 보지 않아야합니다.
// Read the font data.
let font = include_bytes ! ( "../resources/Roboto-Regular.ttf" ) as & [ u8 ] ;
// Parse it into the font type.
let font = fontdue :: Font :: from_bytes ( font , fontdue :: FontSettings :: default ( ) ) . unwrap ( ) ;
// Rasterize and get the layout metrics for the letter 'g' at 17px.
let ( metrics , bitmap ) = font . rasterize ( 'g' , 17.0 ) ; 레이아웃 API는 미숙하며 변화가 발생할 수 있습니다. fontdue 제공하는 레이아웃은 순진하며 glyph_brush 와 같은 기존 라이브러리와 동등하게 설계되었습니다.
// Read the font data.
let font = include_bytes ! ( "../resources/fonts/Roboto-Regular.ttf" ) as & [ u8 ] ;
// Parse it into the font type.
let roboto_regular = Font :: from_bytes ( font , fontdue :: FontSettings :: default ( ) ) . unwrap ( ) ;
// The list of fonts that will be used during layout.
let fonts = & [ roboto_regular ] ;
// Create a layout context. Laying out text needs some heap allocations; reusing this context
// reduces the need to reallocate space. We inform layout of which way the Y axis points here.
let mut layout = Layout :: new ( CoordinateSystem :: PositiveYUp ) ;
// By default, layout is initialized with the default layout settings. This call is redundant, but
// demonstrates setting the value with your custom settings.
layout . reset ( & LayoutSettings {
.. LayoutSettings :: default ( )
} ) ;
// The text that will be laid out, its size, and the index of the font in the font list to use for
// that section of text.
layout . append ( fonts , & TextStyle :: new ( "Hello " , 35.0 , 0 ) ) ;
layout . append ( fonts , & TextStyle :: new ( "world!" , 40.0 , 0 ) ) ;
// Prints the layout for "Hello world!"
println ! ( "{:?}" , layout . glyphs ( ) ) ;
// If you wanted to attached metadata based on the TextStyle to the glyphs returned in the
// glyphs() function, you can use the TextStyle::with_metadata function. In this example, the
// Layout type is now parameterized with u8 (Layout<u8>). All styles need to share the same
// metadata type.
let mut layout = Layout :: new ( CoordinateSystem :: PositiveYUp ) ;
layout . append ( fonts , & TextStyle :: with_user_data ( "Hello " , 35.0 , 0 , 10u8 ) ) ;
layout . append ( fonts , & TextStyle :: with_user_data ( "world!" , 40.0 , 0 , 20u8 ) ) ;
println ! ( "{:?}" , layout . glyphs ( ) ) ; 이 벤치 마크는 "블랙 쿼츠의 스핑크스, 내 맹세를 판단하는"텍스트의 글리프 메트릭과 비트 맵을 생성하는 데 걸리는 시간을 측정합니다. 다양한 크기에 걸쳐. 그래프의 선이 낮을수록 좋습니다.


이 벤치 마크는 단어 경계를 포장하여 샘플 텍스트의 라틴 문자를 레이아웃하는 데 걸리는 시간을 측정합니다.

중 하나에 따라 라이센스가 부여됩니다
귀하의 선택에.
귀하가 명시 적으로 명시 적으로 명시하지 않는 한, Apache-2.0 라이센스에 정의 된대로 귀하의 작업에 포함되도록 의도적으로 제출 된 기부금은 추가 이용 약관이나 조건없이 위와 같이 여러 라이센스를받습니다.
당신이 찾은 새로운 기능이나 단점에 대해 저와 함께하십시오. 버그가 우선하지만 Fontdue에서 작업하고 싶은 시간이 많지 않으므로 인내심을 가지십시오. 솔로 프로젝트입니다.
Fontdue는 다양한 트루 타입 및 OpenType 기능을 지원하는 글꼴을 구문 분석 용 ttf-parser (Link)에 따라 다릅니다.
Fontdue Rasterization을 얼마나 빨리 만들었는지, rusttype (Link) 상자가 글꼴 구문 분석을 얼마나 간단하게 만들었는지 font-rs (Link)의 모호한 생산 준비 포크 (링크)로 시작했습니다. 그 이후로, 나는 많은 글꼴 사양과 현대식 래스터 화 기술을 읽었으며, 그 과정에서 fontdue 고유 한 짐승으로 다시 쓰는 글을 다시 작성했습니다.