Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/gsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ use crate::layout::{
};
use crate::scripts::{self, ScriptType};
use crate::tables::variable_fonts::Tuple;
use crate::tag;
use crate::unicode::VariationSelector;
use crate::{tag, GlyphId};

const SUBST_RECURSION_LIMIT: usize = 2;
const MAX_GLYPHS: usize = 10_000;

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct FeatureInfo {
Expand Down Expand Up @@ -123,7 +124,7 @@ impl Ligature {
#[derive(Clone, Debug)]
pub struct RawGlyph<T> {
pub unicodes: TinyVec<[char; 1]>,
pub glyph_index: u16,
pub glyph_index: GlyphId,
pub liga_component_pos: u16,
pub glyph_origin: GlyphOrigin,
pub flags: RawGlyphFlags,
Expand Down Expand Up @@ -462,6 +463,10 @@ fn multiplesubst<T: GlyphData>(
) -> Result<Option<usize>, ParseError> {
match multiplesubst_would_apply(subtables, i, glyphs)? {
Some(sequence_table) => {
if sequence_table.substitute_glyphs.len() + glyphs.len() >= MAX_GLYPHS {
return Err(ParseError::LimitExceeded);
}

if !sequence_table.substitute_glyphs.is_empty() {
let first_glyph_index = sequence_table.substitute_glyphs[0];
glyphs[i].glyph_index = first_glyph_index;
Expand Down
2 changes: 1 addition & 1 deletion src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ pub struct MultipleSubst {
}

pub struct SequenceTable {
pub substitute_glyphs: Vec<u16>,
pub substitute_glyphs: Vec<GlyphId>,
}

impl ReadBinaryDep for MultipleSubst {
Expand Down
Loading