Skip to content

Commit

Permalink
Merge pull request #98 from LaurenzV/4.1
Browse files Browse the repository at this point in the history
Sync with 4.1
  • Loading branch information
RazrFalcon authored Feb 16, 2024
2 parents 26fec9c + 550139c commit 26baa9a
Show file tree
Hide file tree
Showing 12 changed files with 375 additions and 256 deletions.
21 changes: 10 additions & 11 deletions scripts/gen-universal-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,7 @@ def is_CONS_WITH_STACKER(U, UISC, UDI, UGC, AJT):


def is_HALANT(U, UISC, UDI, UGC, AJT):
return (UISC in [Virama, Invisible_Stacker]
and not is_HALANT_OR_VOWEL_MODIFIER(U, UISC, UDI, UGC, AJT)
and not is_SAKOT(U, UISC, UDI, UGC, AJT))


def is_HALANT_OR_VOWEL_MODIFIER(U, UISC, UDI, UGC, AJT):
# Split off of HALANT
# https://github.com/harfbuzz/harfbuzz/issues/1379
return U == 0x1134D
return UISC == Virama


def is_HALANT_NUM(U, UISC, UDI, UGC, AJT):
Expand All @@ -273,6 +265,13 @@ def is_HIEROGLYPH_SEGMENT_END(U, UISC, UDI, UGC, AJT):
return UISC == Hieroglyph_Segment_End


def is_INVISIBLE_STACKER(U, UISC, UDI, UGC, AJT):
# Split off of HALANT
return (UISC == Invisible_Stacker
and not is_SAKOT(U, UISC, UDI, UGC, AJT)
)


def is_ZWNJ(U, UISC, UDI, UGC, AJT):
return UISC == Non_Joiner

Expand Down Expand Up @@ -329,8 +328,8 @@ def is_Word_Joiner(U, UISC, UDI, UGC, AJT):
'SUB': is_CONS_SUB,
'CS': is_CONS_WITH_STACKER,
'H': is_HALANT,
'HVM': is_HALANT_OR_VOWEL_MODIFIER,
'HN': is_HALANT_NUM,
'IS': is_INVISIBLE_STACKER,
'G': is_HIEROGLYPH,
'J': is_HIEROGLYPH_JOINER,
'SB': is_HIEROGLYPH_SEGMENT_BEGIN,
Expand Down Expand Up @@ -378,7 +377,7 @@ def is_Word_Joiner(U, UISC, UDI, UGC, AJT):
'BLW': [Bottom],
},
'H': None,
'HVM': None,
'IS': None,
'B': None,
'FM': {
'ABV': [Top],
Expand Down
12 changes: 10 additions & 2 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::cmp::min;
use ttf_parser::GlyphId;

use crate::buffer::glyph_flag::{UNSAFE_TO_BREAK, UNSAFE_TO_CONCAT};
use crate::face::GlyphExtents;
use crate::unicode::{CharExt, GeneralCategory, GeneralCategoryExt, Space};
use crate::{script, Direction, Face, Language, Mask, Script};

Expand Down Expand Up @@ -1630,7 +1631,13 @@ impl Buffer {

#[inline]
pub fn allocate_lig_id(&mut self) -> u8 {
self.next_serial() & 0x07
let mut lig_id = self.next_serial() & 0x07;

if lig_id == 0 {
lig_id = self.allocate_lig_id();
}

lig_id
}
}

Expand Down Expand Up @@ -2012,7 +2019,8 @@ impl GlyphBuffer {
}

if flags.contains(SerializeFlags::GLYPH_EXTENTS) {
let extents = face.glyph_extents(info.as_glyph()).unwrap_or_default();
let mut extents = GlyphExtents::default();
face.glyph_extents(info.as_glyph(), &mut extents);
write!(
&mut s,
"<{},{},{},{}>",
Expand Down
7 changes: 3 additions & 4 deletions src/complex/indic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,13 @@ fn collect_features(planner: &mut ShapePlanner) {
}

planner.ot_map.add_gsub_pause(Some(final_reordering));
planner
.ot_map
.add_gsub_pause(Some(crate::ot::clear_syllables));

for feature in INDIC_FEATURES.iter().skip(10) {
planner.ot_map.add_feature(feature.0, feature.1, 1);
}

planner
.ot_map
.add_gsub_pause(Some(crate::ot::clear_syllables));
}

fn override_features(planner: &mut ShapePlanner) {
Expand Down
4 changes: 2 additions & 2 deletions src/complex/universal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub mod category {
pub const CS: u8 = 43; // CONS_WITH_STACKER

// https://github.com/harfbuzz/harfbuzz/issues/1102
pub const HVM: u8 = 44; // HALANT_OR_VOWEL_MODIFIER
pub const IS: u8 = 44; // HALANT_OR_VOWEL_MODIFIER

pub const SK: u8 = 48; // SAKOT

Expand Down Expand Up @@ -141,7 +141,7 @@ impl GlyphInfo {
}

fn is_halant_use(&self) -> bool {
matches!(self.use_category(), category::H | category::HVM) && !self.is_ligated()
matches!(self.use_category(), category::H | category::IS) && !self.is_ligated()
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/complex/universal_machine.rl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ZWNJ = 14; # Zero width non-joiner
WJ = 16; # Word joiner
R = 18; # REPHA
CS = 43; # CONS_WITH_STACKER
HVM = 44; # HALANT_OR_VOWEL_MODIFIER
IS = 44; # HALANT_OR_VOWEL_MODIFIER
Sk = 48; # SAKOT
G = 49; # HIEROGLYPH
J = 50; # HIEROGLYPH_JOINER
Expand Down Expand Up @@ -74,12 +74,12 @@ FMAbv = 45; # CONS_FINAL_MOD UIPC = Top
FMBlw = 46; # CONS_FINAL_MOD UIPC = Bottom
FMPst = 47; # CONS_FINAL_MOD UIPC = Not_Applicable

h = H | HVM | Sk;
h = H | IS | Sk;

consonant_modifiers = CMAbv* CMBlw* ((h B | SUB) CMAbv? CMBlw*)*;
medial_consonants = MPre? MAbv? MBlw? MPst?;
dependent_vowels = VPre* VAbv* VBlw* VPst*;
vowel_modifiers = HVM? VMPre* VMAbv* VMBlw* VMPst*;
dependent_vowels = VPre* VAbv* VBlw* VPst* | H;
vowel_modifiers = VMPre* VMAbv* VMBlw* VMPst*;
final_consonants = FAbv* FBlw* FPst*;
final_modifiers = FMAbv* FMBlw* | FMPst?;

Expand All @@ -102,7 +102,7 @@ symbol_cluster_tail = SMAbv+ SMBlw* | SMBlw+;

virama_terminated_cluster_tail =
consonant_modifiers
h
IS
;
virama_terminated_cluster =
complex_syllable_start
Expand Down Expand Up @@ -168,6 +168,7 @@ pub fn find_syllables(buffer: &mut Buffer) {
let mut p = p0;
let mut ts = p0;
let mut te = p0;
let mut act = p0;
let pe = p.end();
let eof = p.end();
let mut syllable_serial = 1u8;
Expand Down
Loading

0 comments on commit 26baa9a

Please sign in to comment.