Skip to content

Commit

Permalink
add experiemental svg font support
Browse files Browse the repository at this point in the history
The vertical alignment is wonky, and some glyphs have the wrong
aspect and are missig colors. eg: the watermelon glyph in Noto Color
Emoji (U+1f349).

Turn this off by default, and skip loading fonts that have svg by
default.
  • Loading branch information
wez committed Aug 15, 2023
1 parent 8c77ea1 commit edbf4ac
Show file tree
Hide file tree
Showing 12 changed files with 478 additions and 11 deletions.
163 changes: 160 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,9 @@ pub struct Config {
#[dynamic(default)]
pub experimental_pixel_positioning: bool,

#[dynamic(default)]
pub experimental_svg_fonts: bool,

#[dynamic(default)]
pub bidi_enabled: bool,

Expand Down
10 changes: 10 additions & 0 deletions config/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ bitflags! {
const MONOCHROME = 4096;
/// Disable auto-hinter.
const NO_AUTOHINT = 32768;
const NO_SVG = 16777216;
const SVG_ONLY = 8388608;
}
}

Expand Down Expand Up @@ -293,6 +295,12 @@ impl ToString for FreeTypeLoadFlags {
if self.contains(Self::NO_BITMAP) {
s.push("NO_BITMAP");
}
if self.contains(Self::NO_SVG) {
s.push("NO_SVG");
}
if self.contains(Self::SVG_ONLY) {
s.push("SVG_ONLY");
}
if self.contains(Self::FORCE_AUTOHINT) {
s.push("FORCE_AUTOHINT");
}
Expand All @@ -317,6 +325,8 @@ impl TryFrom<String> for FreeTypeLoadFlags {
"DEFAULT" => flags |= Self::DEFAULT,
"NO_HINTING" => flags |= Self::NO_HINTING,
"NO_BITMAP" => flags |= Self::NO_BITMAP,
"NO_SVG" => flags |= Self::NO_SVG,
"SVG_ONLY" => flags |= Self::SVG_ONLY,
"FORCE_AUTOHINT" => flags |= Self::FORCE_AUTOHINT,
"MONOCHROME" => flags |= Self::MONOCHROME,
"NO_AUTOHINT" => flags |= Self::NO_AUTOHINT,
Expand Down
1 change: 1 addition & 0 deletions deps/freetype/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
#include <freetype/ftsynth.h>
#include <freetype/ftglyph.h>
#include <freetype/ftsnames.h>
#include <freetype/otsvg.h>
#include <freetype/ttnameid.h>
2 changes: 1 addition & 1 deletion deps/freetype/freetype2
Submodule freetype2 updated 168 files
6 changes: 3 additions & 3 deletions deps/freetype/regenerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bindgen bindings.h -o src/lib.rs \
--raw-line "pub type FT_UInt64 = u64;" \
--default-enum-style rust \
--generate=functions,types,vars \
--allowlist-function="FT_.*" \
--allowlist-type="[FT]T_.*" \
--allowlist-var="[FT]T_.*" \
--allowlist-function="(SVG|FT)_.*" \
--allowlist-type="(SVG|[FT]T)_.*" \
--allowlist-var="(SVG|[FT]T)_.*" \
-- -Ifreetype2/include
Loading

0 comments on commit edbf4ac

Please sign in to comment.