Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
KeShih committed Oct 20, 2024
1 parent 9a48526 commit c4222fb
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions src/Plugins/Freetype/rubber_unicode_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ rubber_unicode_font_rep::rubber_unicode_font_rep (string name, font base2,
}

if (base->math_type == MATH_TYPE_OPENTYPE) {
cout << "rubber for unicode font with opentype: " << base->res_name << LF;
big_flag= true;
big_sums= true;
}
Expand Down Expand Up @@ -159,28 +158,17 @@ rubber_unicode_font_rep::search_font_sub_opentype (string s, string& rew) {
bool ver= true; // verizontal or vertical, default is vertical
rew = s;

// large,big,wide
// left,right,mid?
var= parse_variant (s, r);

// there is no <big-xxx-0>
if (starts (s, "<big-")) {
var= parse_variant (s, r);
var= max (0, var - 1);
ver= true;
}
else if (starts (s, "<mid-") || starts (s, "<right-") ||
starts (s, "<left-")) {
var= parse_variant (s, r);
ver= true;
}
else if (starts (s, "<wide-")) {
var= parse_variant (s, r);
ver= false;
}
else if (starts (s, "<large-")) {
var= parse_variant (s, r);
ver= true;
}

if (r == "") return false;
if (r == "") return search_font_sub (s, rew);

string uu= N (r) > 1 ? strict_cork_to_utf8 ("<" * r * ">") : r;

Expand All @@ -192,22 +180,27 @@ rubber_unicode_font_rep::search_font_sub_opentype (string s, string& rew) {

cout << "search_font_sub_opentype for " << u << " -> " << glyphID << LF;

auto variant= ver ? math_face->math_table->ver_glyph_variants
: math_face->math_table->hor_glyph_variants;
auto glyph_variants= ver ? math_face->math_table->ver_glyph_variants
: math_face->math_table->hor_glyph_variants;

if (variant->contains (glyphID)) {
if (glyph_variants->contains (glyphID)) {
cout << "Variant for " << uu << " -> " << glyphID << LF;
auto& v= variant (glyphID);
if (var < N (v)) {
auto res= v[var];
auto& gv= glyph_variants (glyphID);
if (var < N (gv)) {
int res= gv[var];
// use <@XXXX> for native glyph id
rew= "<@" * as_hexadecimal (res, 4) * ">";
cout << "Variant for " << uu << " -> " << glyphID << " -> " << rew << LF;
// cout << "OpenType variant for " << uu << " -> " << glyphID << " -> " <<
// rew << LF;
return 0;
}
}
cout << "No variant for " << uu << " -> " << glyphID << LF;
// cout << "No opentype variant for " << uu << " -> " << glyphID << LF;

// try to use subfont
int nr= search_font_sub (s, rew);
// if nr == 0, failed to find the sub font from subfn[1:4]
// use default rubber font subfn[5]
return nr == 0 ? 5 : nr;
}

Expand Down

0 comments on commit c4222fb

Please sign in to comment.