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 8dd8bf1 commit 6d8b3af
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Plugins/Freetype/rubber_unicode_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "hashmap.hpp"
#include "lolly/data/numeral.hpp"
#include "observer.hpp"
#include "resource.hpp"
#include "string.hpp"
#include "translator.hpp"
#include "unicode_font.hpp"
Expand Down Expand Up @@ -46,7 +47,7 @@ struct rubber_unicode_font_rep : font_rep {
rubber_unicode_font_rep (string name, font base, tt_face face= nullptr);
font get_font (int nr);
int search_font_sub (string s, string& rew);
bool search_font_sub_bis (string s, string& rew, int& nr);
int search_font_sub_opentype (string s, string& rew);
int search_font_cached (string s, string& rew);
font search_font (string& s);

Expand Down Expand Up @@ -88,11 +89,16 @@ rubber_unicode_font_rep::rubber_unicode_font_rep (string name, font base2,
//<< ((double) (ex->y2-ex->y1)) / base->yx << LF;
if ((((double) (ex->y2 - ex->y1)) / base->yx) >= 1.55) big_sums= true;
}

for (int i= 0; i < 5; i++) {
initialized << false;
subfn << base;
}

// when opentype rubber failed
initialized << true;
subfn << font_rep::make_rubber_font (base);

if (base->math_type == MATH_TYPE_OPENTYPE) {
cout << "rubber for unicode font with opentype: " << base->res_name << LF;
big_flag= true;
Expand Down Expand Up @@ -146,14 +152,12 @@ parse_variant (string s, string& r) {
return var;
}

bool
rubber_unicode_font_rep::search_font_sub_bis (string s, string& rew, int& nr) {
// look up opentype math table
int
rubber_unicode_font_rep::search_font_sub_opentype (string s, string& rew) {
string r;
int var= 0;
bool ver= true; // verizontal or vertical, default is vertical
rew = s;
nr = 0;

// large,big,wide
// left,right,mid?
Expand Down Expand Up @@ -186,7 +190,7 @@ rubber_unicode_font_rep::search_font_sub_bis (string s, string& rew, int& nr) {

unsigned int glyphID= ft_get_char_index (math_face->ft_face, u);

cout << "search_font_sub_bis for " << u << " -> " << glyphID << LF;
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;
Expand All @@ -198,13 +202,13 @@ rubber_unicode_font_rep::search_font_sub_bis (string s, string& rew, int& nr) {
auto res= v[var];
// use <@XXXX> for native glyph id
rew= "<@" * as_hexadecimal (res, 4) * ">";
nr = 0;
cout << "Variant for " << uu << " -> " << glyphID << " -> " << rew << LF;
return true;
return 0;
}
}
cout << "No variant for " << uu << " -> " << glyphID << LF;
return false;
int nr = search_font_sub (s, rew);
return nr == 0 ? 5 : nr;
}

int
Expand Down Expand Up @@ -280,9 +284,8 @@ rubber_unicode_font_rep::search_font_cached (string s, string& rew) {
return mapper[s];
}
int nr= 0;
if (!is_nil (math_face) && !is_nil (math_face->math_table) &&
search_font_sub_bis (s, rew, nr)) {
// we found it in opentype math table
if (!is_nil (math_face) && !is_nil (math_face->math_table)) {
nr = search_font_sub_opentype (s, rew);
}
else {
nr= search_font_sub (s, rew);
Expand Down
18 changes: 18 additions & 0 deletions test.tmu
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<TMU|<tuple|1.0.5|1.2.9.5>>

<style|<tuple|generic|chinese>>

<\body>
<\equation*>
<big|oiint><big|oint><big|idotsint>
</equation*>
</body>

<\initial>
<\collection>
<associate|font|Asana Math>
<associate|font-family|rm>
<associate|page-medium|paper>
<associate|page-screen-margin|false>
</collection>
</initial>

0 comments on commit 6d8b3af

Please sign in to comment.